develoment workflow: how to avoid duplicate work ?

Valentin Vidic Valentin.Vidic at CARNet.hr
Tue Jun 5 13:47:13 EDT 2018


On Tue, Jun 05, 2018 at 10:33:21AM -0400, valdis.kletnieks at vt.edu wrote:
> It's not duplication, it's increment/decrement of a counter.
> 
> Look for functions  with 'get' and 'put' in their names.

AFAICT counter is f_count in struct file, updated by fget and fput.

> I haven't looked at the code - there's an outside chance that the driver
> isn't doing reference counting correctly.

pi433 driver does not mess with struct file too much so I guess it should
be safe :)

pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos)
        instance = filp->private_data;
pi433_write(struct file *filp, const char __user *buf,
        instance = filp->private_data;
pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        instance = filp->private_data;
pi433_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        return pi433_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
static int pi433_open(struct inode *inode, struct file *filp)
        filp->private_data = instance;
        nonseekable_open(inode, filp);
static int pi433_release(struct inode *inode, struct file *filp)
        instance = filp->private_data;
        filp->private_data = NULL;

-- 
Valentin



More information about the Kernelnewbies mailing list