Skip to content

Commit cef03d7

Browse files
sudeep-hollagroeck
authored andcommitted
hwmon: (scpi) skip unsupported sensors properly
Currently it's assumed that firmware exports only the class of sensors supported by the driver. However with newer firmware or SCPI protocol revision, support for newer classes of sensors can be present. The driver fails to probe with the following warning if an unsupported class of sensor is encountered in the firmware. sysfs: cannot create duplicate filename '/devices/platform/scpi/scpi:sensors/hwmon/hwmon0/' ------------[ cut here ]------------ WARNING: at fs/sysfs/dir.c:31 Modules linked in: CPU: 0 PID: 6 Comm: kworker/u12:0 Not tainted 4.3.0-rc7 #137 Hardware name: ARM Juno development board (r0) (DT) Workqueue: deferwq deferred_probe_work_func PC is at sysfs_warn_dup+0x54/0x78 LR is at sysfs_warn_dup+0x54/0x78 This patch fixes the above issue by skipping through the unsupported class of SCPI sensors. Fixes: 68acc77 ("hwmon: Support thermal zones registration for SCP temperature sensors") Fixes: ea98b29 ("hwmon: Support sensors exported via ARM SCP interface") Cc: Guenter Roeck <[email protected]> Reviewed-by: Punit Agrawal <[email protected]> Signed-off-by: Sudeep Holla <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
1 parent d42d5b6 commit cef03d7

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

drivers/hwmon/scpi-hwmon.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
117117
struct scpi_ops *scpi_ops;
118118
struct device *hwdev, *dev = &pdev->dev;
119119
struct scpi_sensors *scpi_sensors;
120-
int ret;
120+
int ret, idx;
121121

122122
scpi_ops = get_scpi_ops();
123123
if (!scpi_ops)
@@ -146,8 +146,8 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
146146

147147
scpi_sensors->scpi_ops = scpi_ops;
148148

149-
for (i = 0; i < nr_sensors; i++) {
150-
struct sensor_data *sensor = &scpi_sensors->data[i];
149+
for (i = 0, idx = 0; i < nr_sensors; i++) {
150+
struct sensor_data *sensor = &scpi_sensors->data[idx];
151151

152152
ret = scpi_ops->sensor_get_info(i, &sensor->info);
153153
if (ret)
@@ -183,7 +183,7 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
183183
num_power++;
184184
break;
185185
default:
186-
break;
186+
continue;
187187
}
188188

189189
sensor->dev_attr_input.attr.mode = S_IRUGO;
@@ -194,11 +194,12 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
194194
sensor->dev_attr_label.show = scpi_show_label;
195195
sensor->dev_attr_label.attr.name = sensor->label;
196196

197-
scpi_sensors->attrs[i << 1] = &sensor->dev_attr_input.attr;
198-
scpi_sensors->attrs[(i << 1) + 1] = &sensor->dev_attr_label.attr;
197+
scpi_sensors->attrs[idx << 1] = &sensor->dev_attr_input.attr;
198+
scpi_sensors->attrs[(idx << 1) + 1] = &sensor->dev_attr_label.attr;
199199

200-
sysfs_attr_init(scpi_sensors->attrs[i << 1]);
201-
sysfs_attr_init(scpi_sensors->attrs[(i << 1) + 1]);
200+
sysfs_attr_init(scpi_sensors->attrs[idx << 1]);
201+
sysfs_attr_init(scpi_sensors->attrs[(idx << 1) + 1]);
202+
idx++;
202203
}
203204

204205
scpi_sensors->group.attrs = scpi_sensors->attrs;
@@ -236,8 +237,8 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
236237

237238
zone->sensor_id = i;
238239
zone->scpi_sensors = scpi_sensors;
239-
zone->tzd = thermal_zone_of_sensor_register(dev, i, zone,
240-
&scpi_sensor_ops);
240+
zone->tzd = thermal_zone_of_sensor_register(dev,
241+
sensor->info.sensor_id, zone, &scpi_sensor_ops);
241242
/*
242243
* The call to thermal_zone_of_sensor_register returns
243244
* an error for sensors that are not associated with

0 commit comments

Comments
 (0)