Skip to content

Commit

Permalink
hwmon: (scpi) skip unsupported sensors properly
Browse files Browse the repository at this point in the history
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 torvalds#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 <linux@roeck-us.net>
Reviewed-by: Punit Agrawal <punit.agrawal@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
  • Loading branch information
sudeep-holla authored and 0day robot committed Oct 28, 2015
1 parent 6dcf94f commit 1639b3e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions drivers/hwmon/scpi-hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
struct scpi_ops *scpi_ops;
struct device *hwdev, *dev = &pdev->dev;
struct scpi_sensors *scpi_sensors;
int ret;
int ret, idx;

scpi_ops = get_scpi_ops();
if (!scpi_ops)
Expand Down Expand Up @@ -146,8 +146,8 @@ static int scpi_hwmon_probe(struct platform_device *pdev)

scpi_sensors->scpi_ops = scpi_ops;

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

ret = scpi_ops->sensor_get_info(i, &sensor->info);
if (ret)
Expand Down Expand Up @@ -183,7 +183,7 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
num_power++;
break;
default:
break;
continue;
}

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

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

sysfs_attr_init(scpi_sensors->attrs[i << 1]);
sysfs_attr_init(scpi_sensors->attrs[(i << 1) + 1]);
sysfs_attr_init(scpi_sensors->attrs[idx << 1]);
sysfs_attr_init(scpi_sensors->attrs[(idx << 1) + 1]);
idx++;
}

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

zone->sensor_id = i;
zone->scpi_sensors = scpi_sensors;
zone->tzd = thermal_zone_of_sensor_register(dev, i, zone,
&scpi_sensor_ops);
zone->tzd = thermal_zone_of_sensor_register(dev,
sensor->info.sensor_id, zone, &scpi_sensor_ops);
/*
* The call to thermal_zone_of_sensor_register returns
* an error for sensors that are not associated with
Expand Down

0 comments on commit 1639b3e

Please sign in to comment.