lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <24a9c917-facd-31b5-1d52-a9bbe95763dc@denx.de>
Date:   Sun, 23 Dec 2018 11:49:01 +0100
From:   Marek Vasut <marex@...x.de>
To:     Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>
Cc:     netdev@...r.kernel.org, Florian Fainelli <f.fainelli@...il.com>
Subject: Re: [PATCH V3] net: phy: tja11xx: Add TJA11xx PHY driver

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ