Subject: Re: [PATCH net-next 1/6] net: mdio: add mdio_device_get() and mdio_device_put()

From: [email-masked]
Date: Fri, 26 May 2023 21:20:17 +0300

Fri, May 26, 2023 at 11:14:24AM +0100, Russell King (Oracle) kirjoitti:
> Add two new operations for a mdio device to manage the refcount on the
> underlying struct device. This will be used by mdio PCS drivers to
> simplify the creation and destruction handling, making it easier for
> users to get it correct.

...

> +static inline void mdio_device_get(struct mdio_device *mdiodev)
> +{
> +	get_device(&mdiodev->dev);

Dunno what is the practice in net, but it makes sense to have the pattern as

	if (mdiodev)
		return to_mdiodev(get_device(&mdiodev->dev));

which might be helpful in some cases. This approach is used in many cases in
the kernel.

> +}

P.S. Just my 2c, you may ignore the above comment.

-- 
With Best Regards,
Andy Shevchenko