public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: add comment to not use kobj_to_dev()
@ 2021-06-21  3:09 Chaitanya Kulkarni
  2021-06-21  5:32 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-21  3:09 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, kbusch, Chaitanya Kulkarni

Add a comment in nvme_ns_id_attrs_are_visible() and
nvme_dev_attrs_are_visible() not to replace container_of() with
kobj_to_dev(). Since use of kobj_to_dev() makes code harder to read.

Suggested-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 14d96ee4d341..559637ebda25 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3191,6 +3191,7 @@ static struct attribute *nvme_ns_id_attrs[] = {
 static umode_t nvme_ns_id_attrs_are_visible(struct kobject *kobj,
 		struct attribute *a, int n)
 {
+	/* Don't use kobj_to_dev(), since it makes code harder to read. */
 	struct device *dev = container_of(kobj, struct device, kobj);
 	struct nvme_ns_ids *ids = &dev_to_ns_head(dev)->ids;
 
@@ -3463,6 +3464,7 @@ static struct attribute *nvme_dev_attrs[] = {
 static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
 		struct attribute *a, int n)
 {
+	/* Don't use kobj_to_dev(), since it makes code harder to read. */
 	struct device *dev = container_of(kobj, struct device, kobj);
 	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
 
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: add comment to not use kobj_to_dev()
  2021-06-21  3:09 [PATCH] nvme: add comment to not use kobj_to_dev() Chaitanya Kulkarni
@ 2021-06-21  5:32 ` Christoph Hellwig
  2021-06-21 16:17   ` Keith Busch
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-06-21  5:32 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: linux-nvme, hch, sagi, kbusch

On Sun, Jun 20, 2021 at 08:09:40PM -0700, Chaitanya Kulkarni wrote:
> Add a comment in nvme_ns_id_attrs_are_visible() and
> nvme_dev_attrs_are_visible() not to replace container_of() with
> kobj_to_dev(). Since use of kobj_to_dev() makes code harder to read.
> 
> Suggested-by: Keith Busch <kbusch@kernel.org>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

Err, no.  This code is completely obvious as is, and if people keep
sending these stupid patches we need to start blacklisting them.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: add comment to not use kobj_to_dev()
  2021-06-21  5:32 ` Christoph Hellwig
@ 2021-06-21 16:17   ` Keith Busch
  2021-06-21 16:19     ` Jens Axboe
  2021-06-21 16:20     ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Keith Busch @ 2021-06-21 16:17 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Chaitanya Kulkarni, linux-nvme, sagi

On Mon, Jun 21, 2021 at 07:32:51AM +0200, Christoph Hellwig wrote:
> On Sun, Jun 20, 2021 at 08:09:40PM -0700, Chaitanya Kulkarni wrote:
> > Add a comment in nvme_ns_id_attrs_are_visible() and
> > nvme_dev_attrs_are_visible() not to replace container_of() with
> > kobj_to_dev(). Since use of kobj_to_dev() makes code harder to read.
> > 
> > Suggested-by: Keith Busch <kbusch@kernel.org>
> > Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> 
> Err, no.  This code is completely obvious as is, and if people keep
> sending these stupid patches we need to start blacklisting them.

People will continue to send these patches as long as
scripts/coccinelle/api/kobj_to_dev.cocci keeps warning about it.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: add comment to not use kobj_to_dev()
  2021-06-21 16:17   ` Keith Busch
@ 2021-06-21 16:19     ` Jens Axboe
  2021-06-21 16:20     ` Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2021-06-21 16:19 UTC (permalink / raw)
  To: Keith Busch, Christoph Hellwig; +Cc: Chaitanya Kulkarni, linux-nvme, sagi

On 6/21/21 10:17 AM, Keith Busch wrote:
> On Mon, Jun 21, 2021 at 07:32:51AM +0200, Christoph Hellwig wrote:
>> On Sun, Jun 20, 2021 at 08:09:40PM -0700, Chaitanya Kulkarni wrote:
>>> Add a comment in nvme_ns_id_attrs_are_visible() and
>>> nvme_dev_attrs_are_visible() not to replace container_of() with
>>> kobj_to_dev(). Since use of kobj_to_dev() makes code harder to read.
>>>
>>> Suggested-by: Keith Busch <kbusch@kernel.org>
>>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>>
>> Err, no.  This code is completely obvious as is, and if people keep
>> sending these stupid patches we need to start blacklisting them.
> 
> People will continue to send these patches as long as
> scripts/coccinelle/api/kobj_to_dev.cocci keeps warning about it.

How about we remove that rule then? FWIW, I totally agree with
conversions like this being harmful, container_of() is perfectly
readable, and the kobj_to_dev() is one of those things you always have
to cscope in to see wtf it is.

-- 
Jens Axboe


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: add comment to not use kobj_to_dev()
  2021-06-21 16:17   ` Keith Busch
  2021-06-21 16:19     ` Jens Axboe
@ 2021-06-21 16:20     ` Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-06-21 16:20 UTC (permalink / raw)
  To: Keith Busch; +Cc: Christoph Hellwig, Chaitanya Kulkarni, linux-nvme, sagi

On Mon, Jun 21, 2021 at 09:17:43AM -0700, Keith Busch wrote:
> On Mon, Jun 21, 2021 at 07:32:51AM +0200, Christoph Hellwig wrote:
> > On Sun, Jun 20, 2021 at 08:09:40PM -0700, Chaitanya Kulkarni wrote:
> > > Add a comment in nvme_ns_id_attrs_are_visible() and
> > > nvme_dev_attrs_are_visible() not to replace container_of() with
> > > kobj_to_dev(). Since use of kobj_to_dev() makes code harder to read.
> > > 
> > > Suggested-by: Keith Busch <kbusch@kernel.org>
> > > Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> > 
> > Err, no.  This code is completely obvious as is, and if people keep
> > sending these stupid patches we need to start blacklisting them.
> 
> People will continue to send these patches as long as
> scripts/coccinelle/api/kobj_to_dev.cocci keeps warning about it.

Maybe we need to fix that instead?

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-21 16:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-21  3:09 [PATCH] nvme: add comment to not use kobj_to_dev() Chaitanya Kulkarni
2021-06-21  5:32 ` Christoph Hellwig
2021-06-21 16:17   ` Keith Busch
2021-06-21 16:19     ` Jens Axboe
2021-06-21 16:20     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox