Commit a33710bd authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: phy: sfp: Handle unimplemented hwmon limits and alarms

Not all SFPs implement the registers containing sensor limits and
alarms. Luckily, there is a bit indicating if they are implemented or
not. Add checking for this bit, when deciding if the hwmon attributes
should be visible.

Fixes: 1323061a ("net: phy: sfp: Add HWMON support for module sensors")
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 84cb8eb2
...@@ -398,7 +398,6 @@ static umode_t sfp_hwmon_is_visible(const void *data, ...@@ -398,7 +398,6 @@ static umode_t sfp_hwmon_is_visible(const void *data,
switch (type) { switch (type) {
case hwmon_temp: case hwmon_temp:
switch (attr) { switch (attr) {
case hwmon_temp_input:
case hwmon_temp_min_alarm: case hwmon_temp_min_alarm:
case hwmon_temp_max_alarm: case hwmon_temp_max_alarm:
case hwmon_temp_lcrit_alarm: case hwmon_temp_lcrit_alarm:
...@@ -407,13 +406,16 @@ static umode_t sfp_hwmon_is_visible(const void *data, ...@@ -407,13 +406,16 @@ static umode_t sfp_hwmon_is_visible(const void *data,
case hwmon_temp_max: case hwmon_temp_max:
case hwmon_temp_lcrit: case hwmon_temp_lcrit:
case hwmon_temp_crit: case hwmon_temp_crit:
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
return 0;
/* fall through */
case hwmon_temp_input:
return 0444; return 0444;
default: default:
return 0; return 0;
} }
case hwmon_in: case hwmon_in:
switch (attr) { switch (attr) {
case hwmon_in_input:
case hwmon_in_min_alarm: case hwmon_in_min_alarm:
case hwmon_in_max_alarm: case hwmon_in_max_alarm:
case hwmon_in_lcrit_alarm: case hwmon_in_lcrit_alarm:
...@@ -422,13 +424,16 @@ static umode_t sfp_hwmon_is_visible(const void *data, ...@@ -422,13 +424,16 @@ static umode_t sfp_hwmon_is_visible(const void *data,
case hwmon_in_max: case hwmon_in_max:
case hwmon_in_lcrit: case hwmon_in_lcrit:
case hwmon_in_crit: case hwmon_in_crit:
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
return 0;
/* fall through */
case hwmon_in_input:
return 0444; return 0444;
default: default:
return 0; return 0;
} }
case hwmon_curr: case hwmon_curr:
switch (attr) { switch (attr) {
case hwmon_curr_input:
case hwmon_curr_min_alarm: case hwmon_curr_min_alarm:
case hwmon_curr_max_alarm: case hwmon_curr_max_alarm:
case hwmon_curr_lcrit_alarm: case hwmon_curr_lcrit_alarm:
...@@ -437,6 +442,10 @@ static umode_t sfp_hwmon_is_visible(const void *data, ...@@ -437,6 +442,10 @@ static umode_t sfp_hwmon_is_visible(const void *data,
case hwmon_curr_max: case hwmon_curr_max:
case hwmon_curr_lcrit: case hwmon_curr_lcrit:
case hwmon_curr_crit: case hwmon_curr_crit:
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
return 0;
/* fall through */
case hwmon_curr_input:
return 0444; return 0444;
default: default:
return 0; return 0;
...@@ -452,7 +461,6 @@ static umode_t sfp_hwmon_is_visible(const void *data, ...@@ -452,7 +461,6 @@ static umode_t sfp_hwmon_is_visible(const void *data,
channel == 1) channel == 1)
return 0; return 0;
switch (attr) { switch (attr) {
case hwmon_power_input:
case hwmon_power_min_alarm: case hwmon_power_min_alarm:
case hwmon_power_max_alarm: case hwmon_power_max_alarm:
case hwmon_power_lcrit_alarm: case hwmon_power_lcrit_alarm:
...@@ -461,6 +469,10 @@ static umode_t sfp_hwmon_is_visible(const void *data, ...@@ -461,6 +469,10 @@ static umode_t sfp_hwmon_is_visible(const void *data,
case hwmon_power_max: case hwmon_power_max:
case hwmon_power_lcrit: case hwmon_power_lcrit:
case hwmon_power_crit: case hwmon_power_crit:
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
return 0;
/* fall through */
case hwmon_power_input:
return 0444; return 0444;
default: default:
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment