Skip to contentSkip to conversation

nvme: hwmon: Do not create min and max values when not supported.

PATCH New Zephaniah E. Loss-Cutler-Hull 1 participant 1 message Oct 5, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: hwmon: Do not create min and max values when not supported.

The Mushkin Enhanced Pilot-E 2TB (MKNSSDPE2TB-D8) provides a composite temperature, as well as the over temperature threshold and under temperature threshold settings for the composite temperature.

However for the 5 individual sensors, no over or under temperature thresholds appear to be available, any attempt to access them results in an error.

At the moment, that means that reading from or writing to the _min or _max files in sys (as lmsensors does) results in an error.

That isn't horribly user friendly, and we can detect this situation at initialization time.

So in nvme_hwmon_is_visible, for the hwmon_temp_max/hwmon_temp_min case, we now attempt to actually get the threshold data, and if that fails we return 0 to indicate that the data should not be made visible.

---
 drivers/nvme/host/hwmon.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/nvme/host/hwmon.c +4 -0
index 0a586d712920..063f8aaddcd5 100644
@@ -164,6 +164,10 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
 	case hwmon_temp_min:
 		if ((!channel && data->ctrl->wctemp) ||
 		    (channel && data->log.temp_sensor[channel - 1])) {
+			long val;
+
+			if (nvme_get_temp_thresh(data->ctrl, channel, (attr == hwmon_temp_min), &val) < 0)
+				return 0;
 			if (data->ctrl->quirks &
 			    NVME_QUIRK_NO_TEMP_THRESH_CHANGE)
 				return 0444;
Signature · 1 line
2.33.0