/* * The USB Monitor, inspired by Dave Harding's USBMon. * * This is the 's' or 'stat' reader which debugs usbmon itself. * Note that this code blows through locks, so make sure that * /dbg/usbmon/0s is well protected from non-root users. * */ #include #include #include #include #include #include #include "usb_mon.h" #define STAT_BUF_SIZE 80 struct snap { int slen; char str[STAT_BUF_SIZE]; }; static int mon_stat_open(struct inode *inode, struct file *file) { struct mon_bus *mbus; struct snap *sp; sp = kmalloc(sizeof(struct snap), GFP_KERNEL); if (sp == NULL) return -ENOMEM; mbus = inode->i_private; sp->slen = snprintf(sp->str, STAT_BUF_SIZE, "nreaders %d events %u text_lost %u\n", mbus->nreaders, mbus->cnt_events, mbus->cnt_text_lost); file->private_data = sp; return 0; } static ssize_t mon_stat_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) { struct snap *sp = file->private_data; return simple_read_from_buffer(buf, nbytes, ppos, sp->str, sp->slen); } static int mon_stat_release(struct inode *inode, struct file *file) { struct snap *sp = file->private_data; file->private_data = NULL; kfree(sp); return 0; } const struct file_operations mon_fops_stat = { .owner = THIS_MODULE, .open = mon_stat_open, .llseek = no_llseek, .read = mon_stat_read, /* .write = mon_stat_write, */ /* .poll = mon_stat_poll, */ /* .unlocked_ioctl = mon_stat_ioctl, */ .release = mon_stat_release, }; td>
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeng <fgao@ikuai8.com>2017-01-20 21:40:43 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2017-02-02 14:30:19 +0100
commit10435c1192d06bdb0bac7666452d8219d7e7c477 (patch)
tree93b76419142fe17b1d162d062c663297a3e8a965 /include/dt-bindings/iio/adc/fsl-imx25-gcq.h
parent1a28ad74ebd8f9d3c7eae0d781f72a6d30545e17 (diff)
netfilter: nf_tables: Eliminate duplicated code in nf_tables_table_enable()
If something fails in nf_tables_table_enable(), it unregisters the chains. But the rollback code is the same as nf_tables_table_disable() almostly, except there is one counter check. Now create one wrapper function to eliminate the duplicated codes. Signed-off-by: Feng <fgao@ikuai8.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/dt-bindings/iio/adc/fsl-imx25-gcq.h')