Re: [PATCH linux] drivers/fsi: Add SBEFIFO FSI client device driver

From: Eddie James
Date: Tue Jun 20 2017 - 12:34:51 EST




On 06/15/2017 5:24 AM, gregkh@xxxxxxxxxxxxxxxxxxx <https://patchwork.kernel.org/project/LKML/list/?submitter=37061> wrote:
On Wed, Jun 14, 2017 at 02:47:27PM -0500, Edward A. James wrote:
+struct sbefifo {
+ struct timer_list poll_timer;
+ struct fsi_device *fsi_dev;
+ struct miscdevice mdev;
+ wait_queue_head_t wait;
+ struct list_head link;
+ struct list_head xfrs;
+ struct kref kref;
+ spinlock_t lock;
+ char name[32];
+ int idx;
+ int rc;
+};

You have a misc device, a pointer to a fsi_device, and a kref in this
structure. Which one actually does the reference counting? It seems
there are 3 different ways it could happen. That's not right at all,
and ripe for lots and lots of confusion. Only use one please.

Thanks for the comments, the problem here is that there is no way to init the miscdevice device kobject with a kobj_type. So we'd have to just do raw kref get/put there so we can get our release function. Does any other linux driver use miscdevice for reference counting? I couldn't find anything. It seems cleaner to me to have our own kref. The fsi_dev is really a parent device, so we shouldn't use that for reference counting.

What do you think? I can add comments to make things clearer?

Thanks,
Eddie


thanks,

greg k-h