On 12/23/18 11:06 AM, Andrew Lunn wrote: >>> + switch (attr) { >>> + case hwmon_in_lcrit_alarm: >>> + ret = phy_read(phydev, MII_INTSRC); >>> + if (ret < 0) >>> + return ret; >>> + >>> + *value = !!(ret & MII_INTSRC_TEMP_ERR); >>> + return 0; >>> + case hwmon_temp_crit_alarm: >>> + ret = phy_read(phydev, MII_INTSRC); >>> + if (ret < 0) >>> + return ret; >>> + >>> + *value = !!(ret & MII_INTSRC_TEMP_ERR); >>> + return 0; >>> + default: >>> + return -EOPNOTSUPP; >>> + } >>> +} >> This looks like a copy & paste error, in both cases you're doing the same. > > You also should not do it like this. hwmon_temp_crit_alarm is in a > different set of enum's as hwmon_in_lcrit_alarm. hwmon_in_lcrit_alarm > = 14. hwmon_temp_max_alarm also is 14. You should have two different > switch statements to take account of this.
I can also use a simple conditional, since I don't expect the number of HWMON properties to grow, eg. if (type == hwmon_in && attr == hwmon_in_lcrit_alarm) {...} if (type == hwmon_temp && attr == hwmon_temp_crit_alarm) {...} I think that's a bit more readable. -- Best regards, Marek Vasut