From: Chris Packham <chris.packham@alliedtelesis.co.nz>
To: robh+dt@kernel.org, jdelvare@suse.com, linux@roeck-us.net
Cc: devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org,
Chris Packham <chris.packham@alliedtelesis.co.nz>
Subject: [PATCH v3 2/3] hwmon: (pmbus): Replace - with _ in device names before registration
Date: Wed, 17 Mar 2021 17:02:30 +1300 [thread overview]
Message-ID: <20210317040231.21490-2-chris.packham@alliedtelesis.co.nz> (raw)
In-Reply-To: <20210317040231.21490-1-chris.packham@alliedtelesis.co.nz>
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: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Notes:
Changes in v3:
- None
Changes in v2:
- New
drivers/hwmon/pmbus/pmbus_core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index aadea85fe630..7d2f8f032314 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -2557,6 +2557,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
struct pmbus_data *data;
size_t groups_num = 0;
int ret;
+ char *name;
if (!info)
return -ENODEV;
@@ -2606,10 +2607,15 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
return -ENODEV;
}
+ name = devm_kstrdup(dev, client->name, GFP_KERNEL);
+ if (!name)
+ return -ENOMEM;
+ strreplace(name, '-', '_');
+
data->groups[0] = &data->group;
memcpy(data->groups + 1, info->groups, sizeof(void *) * groups_num);
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)) {
dev_err(dev, "Failed to register hwmon device\n");
return PTR_ERR(data->hwmon_dev);
--
2.30.2
next prev parent reply other threads:[~2021-03-17 4:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 4:02 [PATCH v3 1/3] dt-bindings: Add vendor prefix and trivial device for BluTek BPA-RS600 Chris Packham
2021-03-17 4:02 ` Chris Packham [this message]
2021-03-19 21:30 ` [PATCH v3 2/3] hwmon: (pmbus): Replace - with _ in device names before registration Guenter Roeck
2021-03-17 4:02 ` [PATCH v3 3/3] hwmon: (pmbus): Add driver for BluTek BPA-RS600 Chris Packham
2021-03-19 21:31 ` Guenter Roeck
2021-03-29 22:05 ` Guenter Roeck
2021-03-19 21:31 ` [PATCH v3 1/3] dt-bindings: Add vendor prefix and trivial device " Guenter Roeck
2021-03-26 0:17 ` Rob Herring
2021-03-29 22:03 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210317040231.21490-2-chris.packham@alliedtelesis.co.nz \
--to=chris.packham@alliedtelesis.co.nz \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).