linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvme: hwmon: Do not create min and max values when not supported.
@ 2021-10-05  4:53 Zephaniah E. Loss-Cutler-Hull
  0 siblings, 0 replies; only message in thread
From: Zephaniah E. Loss-Cutler-Hull @ 2021-10-05  4:53 UTC (permalink / raw)
  To: linux-nvme; +Cc: linux-kernel, Zephaniah E. Loss-Cutler-Hull

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.

Signed-off-by: Zephaniah E. Loss-Cutler-Hull <zephaniah@gmail.com>
---
 drivers/nvme/host/hwmon.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c
index 0a586d712920..063f8aaddcd5 100644
--- a/drivers/nvme/host/hwmon.c
+++ b/drivers/nvme/host/hwmon.c
@@ -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;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-05  4:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05  4:53 [PATCH] nvme: hwmon: Do not create min and max values when not supported Zephaniah E. Loss-Cutler-Hull

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).