Commit f807e8be authored by Chris Packham's avatar Chris Packham Committed by Guenter Roeck

hwmon: (pmbus) Replace - with _ in device names before registration

The hwmon sysfs ABI requires that the `name` property doesn't include
any dashes. But when the pmbus code picks the name up from the device
tree it quite often does. Replace '-' with '_' before registering the
device.
Signed-off-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210317040231.21490-2-chris.packham@alliedtelesis.co.nzSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 82e3430d
...@@ -2568,6 +2568,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info) ...@@ -2568,6 +2568,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
struct pmbus_data *data; struct pmbus_data *data;
size_t groups_num = 0; size_t groups_num = 0;
int ret; int ret;
char *name;
if (!info) if (!info)
return -ENODEV; return -ENODEV;
...@@ -2617,10 +2618,15 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info) ...@@ -2617,10 +2618,15 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
return -ENODEV; return -ENODEV;
} }
name = devm_kstrdup(dev, client->name, GFP_KERNEL);
if (!name)
return -ENOMEM;
strreplace(name, '-', '_');
data->groups[0] = &data->group; data->groups[0] = &data->group;
memcpy(data->groups + 1, info->groups, sizeof(void *) * groups_num); memcpy(data->groups + 1, info->groups, sizeof(void *) * groups_num);
data->hwmon_dev = devm_hwmon_device_register_with_groups(dev, data->hwmon_dev = devm_hwmon_device_register_with_groups(dev,
client->name, data, data->groups); name, data, data->groups);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
dev_err(dev, "Failed to register hwmon device\n"); dev_err(dev, "Failed to register hwmon device\n");
return PTR_ERR(data->hwmon_dev); return PTR_ERR(data->hwmon_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment