[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <29b5043db9a51ef7a0cb6e3a8c69c91e36045cd6.1585944770.git.mirq-linux@rere.qmqm.pl>
Date: Fri, 03 Apr 2020 22:20:33 +0200
From: Michał Mirosław <mirq-linux@...e.qmqm.pl>
To: Andrey Smirnov <andrew.smirnov@...il.com>,
Guenter Roeck <linux@...ck-us.net>,
Sebastian Reichel <sebastian.reichel@...labora.com>
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: [PATCH v3 07/11] power: supply: core: tabularize HWMON temperature
labels
Rework power_supply_hwmon_read_string() to check it's parameters.
This allows to extend it later with labels for other types of
measurements.
Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
v2: split from fix temperature labels
v3: remove power_supply_hwmon_read_string() parameter checks
as it is internal API (suggested by Guenter Roeck)
---
drivers/power/supply/power_supply_hwmon.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c
index 67b6ee60085e..5621e72a39f0 100644
--- a/drivers/power/supply/power_supply_hwmon.c
+++ b/drivers/power/supply/power_supply_hwmon.c
@@ -13,6 +13,11 @@ struct power_supply_hwmon {
unsigned long *props;
};
+static const char *const ps_temp_label[] = {
+ "temp",
+ "ambient temp",
+};
+
static int power_supply_hwmon_in_to_property(u32 attr)
{
switch (attr) {
@@ -144,7 +149,14 @@ static int power_supply_hwmon_read_string(struct device *dev,
u32 attr, int channel,
const char **str)
{
- *str = channel ? "temp ambient" : "temp";
+ switch (type) {
+ case hwmon_temp:
+ *str = ps_temp_label[channel];
+ break;
+ default:
+ unreachable();
+ }
+
return 0;
}
--
2.20.1
Powered by blists - more mailing lists