From: Dan Williams <dan.j.williams@intel.com> To: Logan Gunthorpe <logang@deltatee.com> Cc: Jan Kara <jack@suse.cz>, Arnd Bergmann <arnd@arndb.de>, "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Sajjan Vikas C <vikas.cha.sajjan@hpe.com>, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Subject: Re: [PATCH] device-dax: don't set kobj parent during cdev init Date: Mon, 13 Feb 2017 12:47:30 -0800 [thread overview] Message-ID: <CAPcyv4h-zw5iGQHErbU9py1LLdPhXbxE3H5i7-KxwEqMNTXGUg@mail.gmail.com> (raw) In-Reply-To: <fc011745-b12d-7008-8638-8b0e50f6d8f9@deltatee.com> On Sat, Feb 11, 2017 at 9:42 PM, Logan Gunthorpe <logang@deltatee.com> wrote: > On 11/02/17 11:58 AM, Dan Williams wrote: >> Also when using an embedded cdev how would you recommend avoiding this problem? > > I don't know. Hopefully, Greg has a good idea. But it sounds like a > general problem that a lot of cdev's actually suffer from without > realizing. Perhaps we need a more general solution. Some way for the > cdev to reference its containing structure in a way that it's designed > for such that anyone writing a driver will do the right thing without > needing to dive into the kobjects. > How about something like the below? I.e. hide the details with a new helper api so that all driver writers need to worry about is the parent device and cdev_del(). This is similar to the device_add_disk() and del_gendisk() pairing that we have for block-device drivers. diff --git a/fs/char_dev.c b/fs/char_dev.c index 3bc97002c86f..4c5d51cdd353 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -471,6 +471,12 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count) return 0; } +int device_add_cdev(struct device *dev, struct cdev *p) +{ + p->kobj.parent = &dev->kobj; + return cdev_add(p, dev->devt, 1); +} + static void cdev_unmap(dev_t dev, unsigned count) { kobj_unmap(cdev_map, dev, count); diff --git a/include/linux/cdev.h b/include/linux/cdev.h index f8763615a5f2..043168df1d8f 100644 --- a/include/linux/cdev.h +++ b/include/linux/cdev.h @@ -25,6 +25,7 @@ struct cdev *cdev_alloc(void); void cdev_put(struct cdev *p); int cdev_add(struct cdev *, dev_t, unsigned); +int device_add_cdev(struct device *dev, struct cdev *); void cdev_del(struct cdev *); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: Logan Gunthorpe <logang@deltatee.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Johannes Thumshirn <jthumshirn@suse.de>, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>, Sajjan Vikas C <vikas.cha.sajjan@hpe.com>, Arnd Bergmann <arnd@arndb.de>, Jan Kara <jack@suse.cz>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-nvdimm@lists.01.org" <linux-nvdimm@ml01.01.org> Subject: Re: [PATCH] device-dax: don't set kobj parent during cdev init Date: Mon, 13 Feb 2017 12:47:30 -0800 [thread overview] Message-ID: <CAPcyv4h-zw5iGQHErbU9py1LLdPhXbxE3H5i7-KxwEqMNTXGUg@mail.gmail.com> (raw) In-Reply-To: <fc011745-b12d-7008-8638-8b0e50f6d8f9@deltatee.com> On Sat, Feb 11, 2017 at 9:42 PM, Logan Gunthorpe <logang@deltatee.com> wrote: > On 11/02/17 11:58 AM, Dan Williams wrote: >> Also when using an embedded cdev how would you recommend avoiding this problem? > > I don't know. Hopefully, Greg has a good idea. But it sounds like a > general problem that a lot of cdev's actually suffer from without > realizing. Perhaps we need a more general solution. Some way for the > cdev to reference its containing structure in a way that it's designed > for such that anyone writing a driver will do the right thing without > needing to dive into the kobjects. > How about something like the below? I.e. hide the details with a new helper api so that all driver writers need to worry about is the parent device and cdev_del(). This is similar to the device_add_disk() and del_gendisk() pairing that we have for block-device drivers. diff --git a/fs/char_dev.c b/fs/char_dev.c index 3bc97002c86f..4c5d51cdd353 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -471,6 +471,12 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count) return 0; } +int device_add_cdev(struct device *dev, struct cdev *p) +{ + p->kobj.parent = &dev->kobj; + return cdev_add(p, dev->devt, 1); +} + static void cdev_unmap(dev_t dev, unsigned count) { kobj_unmap(cdev_map, dev, count); diff --git a/include/linux/cdev.h b/include/linux/cdev.h index f8763615a5f2..043168df1d8f 100644 --- a/include/linux/cdev.h +++ b/include/linux/cdev.h @@ -25,6 +25,7 @@ struct cdev *cdev_alloc(void); void cdev_put(struct cdev *p); int cdev_add(struct cdev *, dev_t, unsigned); +int device_add_cdev(struct device *dev, struct cdev *); void cdev_del(struct cdev *);
next prev parent reply other threads:[~2017-02-13 20:47 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-02-10 19:19 [PATCH] device-dax: don't set kobj parent during cdev init Logan Gunthorpe 2017-02-10 19:19 ` Logan Gunthorpe 2017-02-10 19:22 ` Logan Gunthorpe 2017-02-10 19:22 ` Logan Gunthorpe 2017-02-10 19:41 ` Dan Williams 2017-02-10 19:41 ` Dan Williams 2017-02-10 20:17 ` Greg Kroah-Hartman 2017-02-10 20:17 ` Greg Kroah-Hartman 2017-02-10 22:25 ` Dan Williams 2017-02-10 22:25 ` Dan Williams 2017-02-11 7:16 ` Greg Kroah-Hartman 2017-02-11 7:16 ` Greg Kroah-Hartman 2017-02-11 8:56 ` Dan Williams 2017-02-11 8:56 ` Dan Williams 2017-02-11 17:59 ` Logan Gunthorpe 2017-02-11 17:59 ` Logan Gunthorpe 2017-02-11 18:27 ` Dan Williams 2017-02-11 18:27 ` Dan Williams 2017-02-11 18:43 ` Logan Gunthorpe 2017-02-11 18:43 ` Logan Gunthorpe 2017-02-11 18:55 ` Dan Williams 2017-02-11 18:55 ` Dan Williams 2017-02-11 18:58 ` Dan Williams 2017-02-11 18:58 ` Dan Williams 2017-02-12 5:42 ` Logan Gunthorpe 2017-02-12 5:42 ` Logan Gunthorpe 2017-02-13 20:47 ` Dan Williams [this message] 2017-02-13 20:47 ` Dan Williams 2017-02-13 22:38 ` Logan Gunthorpe 2017-02-13 22:38 ` Logan Gunthorpe 2017-02-10 19:46 ` Greg Kroah-Hartman 2017-02-10 19:46 ` Greg Kroah-Hartman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CAPcyv4h-zw5iGQHErbU9py1LLdPhXbxE3H5i7-KxwEqMNTXGUg@mail.gmail.com \ --to=dan.j.williams@intel.com \ --cc=arnd@arndb.de \ --cc=gregkh@linuxfoundation.org \ --cc=jack@suse.cz \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvdimm@lists.01.org \ --cc=logang@deltatee.com \ --cc=paulmck@linux.vnet.ibm.com \ --cc=vikas.cha.sajjan@hpe.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.