Subject: Re: [PATCH net-next 1/5] net: phy: marvell: refactor HWMON OOP style

From: Andrew Lunn <[email-masked]>
Date: Tue, 13 Apr 2021 16:36:35 +0200

> +static int marvell_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> +			      u32 attr, int channel, long *temp)
>  {
>  	struct phy_device *phydev = dev_get_drvdata(dev);
> -	int err;
> +	const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev);
> +	int err = -EOPNOTSUPP;
>  
>  	switch (attr) {
>  	case hwmon_temp_input:
> -		err = m88e6390_get_temp(phydev, temp);
> +		if (ops->get_temp)
> +			err = ops->get_temp(phydev, temp);
> +		break;
> +	case hwmon_temp_crit:
> +		if (ops->get_temp_critical)
> +			err = ops->get_temp_critical(phydev, temp);
> +		break;
> +	case hwmon_temp_max_alarm:
> +		if (ops->get_temp_alarm)
> +			err = ops->get_temp_alarm(phydev, temp);
>  		break;
>  	default:
> -		return -EOPNOTSUPP;
> +		fallthrough;
> +	}

Does the default clause actually service any purpose?

And it is not falling through, it is falling out :-)

    Andrew