Subject: Re: [net-next: PATCH v3 8/8] net: dsa: mv88e6xxx: switch to device_/fwnode_ APIs

From: Andy Shevchenko <[email-masked]>
Date: Wed, 27 Jul 2022 16:37:18 +0300

On Wed, Jul 27, 2022 at 08:43:21AM +0200, Marcin Wojtas wrote:
> In order to support both DT and ACPI in future, modify the
> mv88e6xx driver  code to use device_/fwnode_ equivalent routines.
> No functional change is introduced by this patch.

...

>  static int mv88e6xxx_probe(struct mdio_device *mdiodev)
>  {
>  	struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;

> +	struct fwnode_handle *fwnode = dev_fwnode(&mdiodev->dev);

Move this...

>  	const struct mv88e6xxx_info *compat_info = NULL;
>  	struct device *dev = &mdiodev->dev;
> -	struct device_node *np = dev->of_node;

...here as

	struct fwnode_handle *fwnode = dev_fwnode(dev);

>  	struct mv88e6xxx_chip *chip;
>  	int port;
>  	int err;

> +	if (fwnode)

Redundant check.

> +		compat_info = device_get_match_data(dev);
> +	else if (pdata) {
>  		compat_info = pdata_device_get_match_data(dev);

	compat_info - device_get_match_data(dev);
	if (!compat_info && pdata)
		compat_info = pdata_device_get_match_data(dev);

...

> +		if (fwnode)
> +			device_property_read_u32(dev, "eeprom-length",
> +						 &chip->eeprom_len);
>  		else
>  			chip->eeprom_len = pdata->eeprom_len;

Can be done w/o conditional

		chip->eeprom_len = pdata->eeprom_len;
		device_property_read_u32(dev, "eeprom-length", &chip->eeprom_len);

-- 
With Best Regards,
Andy Shevchenko