thermal/drivers/qcom/spmi-adc-tm5: Register thermal zones as hwmon sensors
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 19 Jul 2022 05:49:40 +0000 (08:49 +0300)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Thu, 28 Jul 2022 15:29:51 +0000 (17:29 +0200)
Register thermal zones as hwmon sensors to let userspace read
temperatures using standard hwmon interface.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
Link: https://lore.kernel.org/r/20220719054940.755907-2-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/qcom/qcom-spmi-adc-tm5.c

index d9c9c975f931ca12d315da3090866cef8526b33f..073943cbcc2bea777b5e7665fc91c984d40968f0 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/thermal.h>
 #include <asm-generic/unaligned.h>
 
+#include "../thermal_hwmon.h"
+
 /*
  * Thermal monitoring block consists of 8 (ADC_TM5_NUM_CHANNELS) channels. Each
  * channel is programmed to use one of ADC channels for voltage comparison.
@@ -687,6 +689,9 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)
                        return PTR_ERR(tzd);
                }
                adc_tm->channels[i].tzd = tzd;
+               if (devm_thermal_add_hwmon_sysfs(tzd))
+                       dev_warn(adc_tm->dev,
+                                "Failed to add hwmon sysfs attributes\n");
        }
 
        return 0;