Commit 86103cff authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (iio_hwmon) Do not duplicate or sanitize fixed string

Calling devm_kstrdup() on a fixed string is unnecessary, as is validating
its contents. Rearrange the code to avoid both.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 0debe4d0
...@@ -137,14 +137,15 @@ static int iio_hwmon_probe(struct platform_device *pdev) ...@@ -137,14 +137,15 @@ static int iio_hwmon_probe(struct platform_device *pdev)
st->attr_group.attrs = st->attrs; st->attr_group.attrs = st->attrs;
st->groups[0] = &st->attr_group; st->groups[0] = &st->attr_group;
if (dev->of_node) if (dev->of_node) {
sname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node); sname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node);
else if (!sname)
sname = devm_kstrdup(dev, "iio_hwmon", GFP_KERNEL); return -ENOMEM;
if (!sname) strreplace(sname, '-', '_');
return -ENOMEM; } else {
sname = "iio_hwmon";
}
strreplace(sname, '-', '_');
hwmon_dev = devm_hwmon_device_register_with_groups(dev, sname, st, hwmon_dev = devm_hwmon_device_register_with_groups(dev, sname, st,
st->groups); st->groups);
return PTR_ERR_OR_ZERO(hwmon_dev); return PTR_ERR_OR_ZERO(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