diff options
author | Alexandru Gagniuc <mr.nuke.me@gmail.com> | 2022-09-06 20:54:05 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2022-09-19 06:17:06 -0700 |
commit | 856361b397439157f7f60fd21efb522bb11f537a (patch) | |
tree | 40bbcd19f431c54cc15270c46ffe31f66cf5f907 /drivers/hwmon/tps23861.c | |
parent | 0fed840c7562d9dcc5bf8a91744b079e952683d1 (diff) |
hwmon: (tps23861) create unique debugfs directory per device
On systems with more than one tps23861, creating the debugfs directory
for additional devices fails with
debugfs: Directory 'tps23861' with parent '/' already present!
To resolve this, include the hwmon device name in the directory name.
Since the name is unique, this guarantees that the debugfs directory
is unique.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220907015405.16547-2-mr.nuke.me@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/tps23861.c')
-rw-r--r-- | drivers/hwmon/tps23861.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c index 019009b71a90..a3d7d6b75a26 100644 --- a/drivers/hwmon/tps23861.c +++ b/drivers/hwmon/tps23861.c @@ -503,9 +503,17 @@ static int tps23861_port_status_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(tps23861_port_status); -static void tps23861_init_debugfs(struct tps23861_data *data) +static void tps23861_init_debugfs(struct tps23861_data *data, + struct device *hwmon_dev) { - data->debugfs_dir = debugfs_create_dir(data->client->name, NULL); + const char *debugfs_name; + + debugfs_name = devm_kasprintf(&data->client->dev, GFP_KERNEL, "%s-%s", + data->client->name, dev_name(hwmon_dev)); + if (!debugfs_name) + return; + + data->debugfs_dir = debugfs_create_dir(debugfs_name, NULL); debugfs_create_file("port_status", 0400, @@ -554,7 +562,7 @@ static int tps23861_probe(struct i2c_client *client) if (IS_ERR(hwmon_dev)) return PTR_ERR(hwmon_dev); - tps23861_init_debugfs(data); + tps23861_init_debugfs(data, hwmon_dev); return 0; } |