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

Jens Axboe axboe at kernel.dk
Wed Aug 10 18:32:40 PDT 2022


On 8/10/22 7:29 PM, cgel.zte at gmail.com wrote:
> From: ye xingchen <ye.xingchen at zte.com.cn>
> 
> 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.

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.

-- 
Jens Axboe




More information about the Linux-nvme mailing list