Skip to content

Commit a33710b

Browse files
lunndavem330
authored andcommitted
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: 1323061 ("net: phy: sfp: Add HWMON support for module sensors") Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 84cb8eb commit a33710b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/net/phy/sfp.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ static umode_t sfp_hwmon_is_visible(const void *data,
398398
switch (type) {
399399
case hwmon_temp:
400400
switch (attr) {
401-
case hwmon_temp_input:
402401
case hwmon_temp_min_alarm:
403402
case hwmon_temp_max_alarm:
404403
case hwmon_temp_lcrit_alarm:
@@ -407,13 +406,16 @@ static umode_t sfp_hwmon_is_visible(const void *data,
407406
case hwmon_temp_max:
408407
case hwmon_temp_lcrit:
409408
case hwmon_temp_crit:
409+
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
410+
return 0;
411+
/* fall through */
412+
case hwmon_temp_input:
410413
return 0444;
411414
default:
412415
return 0;
413416
}
414417
case hwmon_in:
415418
switch (attr) {
416-
case hwmon_in_input:
417419
case hwmon_in_min_alarm:
418420
case hwmon_in_max_alarm:
419421
case hwmon_in_lcrit_alarm:
@@ -422,13 +424,16 @@ static umode_t sfp_hwmon_is_visible(const void *data,
422424
case hwmon_in_max:
423425
case hwmon_in_lcrit:
424426
case hwmon_in_crit:
427+
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
428+
return 0;
429+
/* fall through */
430+
case hwmon_in_input:
425431
return 0444;
426432
default:
427433
return 0;
428434
}
429435
case hwmon_curr:
430436
switch (attr) {
431-
case hwmon_curr_input:
432437
case hwmon_curr_min_alarm:
433438
case hwmon_curr_max_alarm:
434439
case hwmon_curr_lcrit_alarm:
@@ -437,6 +442,10 @@ static umode_t sfp_hwmon_is_visible(const void *data,
437442
case hwmon_curr_max:
438443
case hwmon_curr_lcrit:
439444
case hwmon_curr_crit:
445+
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
446+
return 0;
447+
/* fall through */
448+
case hwmon_curr_input:
440449
return 0444;
441450
default:
442451
return 0;
@@ -452,7 +461,6 @@ static umode_t sfp_hwmon_is_visible(const void *data,
452461
channel == 1)
453462
return 0;
454463
switch (attr) {
455-
case hwmon_power_input:
456464
case hwmon_power_min_alarm:
457465
case hwmon_power_max_alarm:
458466
case hwmon_power_lcrit_alarm:
@@ -461,6 +469,10 @@ static umode_t sfp_hwmon_is_visible(const void *data,
461469
case hwmon_power_max:
462470
case hwmon_power_lcrit:
463471
case hwmon_power_crit:
472+
if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
473+
return 0;
474+
/* fall through */
475+
case hwmon_power_input:
464476
return 0444;
465477
default:
466478
return 0;

0 commit comments

Comments
 (0)