[PATCH linux-next] nvme:Use the function kobj_to_dev()

Christoph Hellwig hch at lst.de
Wed Aug 10 22:59:51 PDT 2022


On Wed, Aug 10, 2022 at 07:32:40PM -0600, Jens Axboe wrote:
> > Use kobj_to_dev() instead of open-coding it.
> 
> This:
> 
> > -	struct device *dev = container_of(kobj, struct device, kobj);
> > +	struct device *dev = kobj_to_dev(kobj);
> 
> just makes the code harder to read, imho. The original line, I can tell
> what it does. The new line, I have to go look it up.

Exactly.

> Is some tool suggesting these transformations? Because they look like a
> bad idea to me, and we should fix that rather than make the code worse.

I keeps coming up again and again and one of the maintainers always
answers something like you just did.  Which suggests like someone or
something is unfortunately suggesting it.



More information about the Linux-nvme mailing list