From mboxrd@z Thu Jan 1 00:00:00 1970 From: Valentin.Vidic@CARNet.hr (Valentin Vidic) Date: Tue, 5 Jun 2018 19:47:13 +0200 Subject: develoment workflow: how to avoid duplicate work ? In-Reply-To: <179873.1528209201@turing-police.cc.vt.edu> References: <22501.1527692619@turing-police.cc.vt.edu> <20180531014432.GA3722@hle-laptop.local> <20180603192336.GV14048@gavran.carpriv.carnet.hr> <20180603222556.GB20060@hle-laptop.local> <20180604033303.GX14048@gavran.carpriv.carnet.hr> <12368.1528128607@turing-police.cc.vt.edu> <20180604223131.GA1981@hle-laptop.local> <68638.1528178148@turing-police.cc.vt.edu> <20180605142016.GA2334@hle-laptop.local> <179873.1528209201@turing-police.cc.vt.edu> Message-ID: <20180605174713.GS14048@gavran.carpriv.carnet.hr> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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