Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH RFC] hwmon: (pmbus/core) use the new i2c_client debugfs dir
@ 2025-01-23 16:33 Wolfram Sang
  2025-01-25 18:24 ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2025-01-23 16:33 UTC (permalink / raw)
  To: linux-renesas-soc; +Cc: Wolfram Sang, Jean Delvare, Guenter Roeck, linux-hwmon

The I2C core now manages a debugfs dir per i2c_client. PMBus has its own
debugfs hierarchy. Link the two, so a user will be pointed to the pmbus
domain from the i2c domain.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

@Guenter: I don't have any PMBus device here. Would you be interested to
test this patch? It build tests fine at least.

 drivers/hwmon/pmbus/pmbus_core.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 787683e83db6..510b88aed326 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -3517,6 +3517,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
 	int i, idx = 0;
 	char name[PMBUS_NAME_SIZE];
 	struct pmbus_debugfs_entry *entries;
+	const char *symlink, *hwmon_name = dev_name(data->hwmon_dev);
 
 	if (!pmbus_debugfs_dir)
 		return -ENODEV;
@@ -3525,13 +3526,19 @@ static int pmbus_init_debugfs(struct i2c_client *client,
 	 * Create the debugfs directory for this device. Use the hwmon device
 	 * name to avoid conflicts (hwmon numbers are globally unique).
 	 */
-	data->debugfs = debugfs_create_dir(dev_name(data->hwmon_dev),
-					   pmbus_debugfs_dir);
+	data->debugfs = debugfs_create_dir(hwmon_name, pmbus_debugfs_dir);
 	if (IS_ERR_OR_NULL(data->debugfs)) {
 		data->debugfs = NULL;
 		return -ENODEV;
 	}
 
+	/* The default i2c_client debugfs dir should link to where the data is */
+	symlink = kasprintf(GFP_KERNEL, "../../pmbus/%s", hwmon_name);
+	if (!symlink)
+		return -ENOMEM;
+	debugfs_create_symlink(hwmon_name, client->debugfs, symlink);
+	kfree(symlink);
+
 	/*
 	 * Allocate the max possible entries we need.
 	 * 7 entries device-specific
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-27 14:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-23 16:33 [PATCH RFC] hwmon: (pmbus/core) use the new i2c_client debugfs dir Wolfram Sang
2025-01-25 18:24 ` Guenter Roeck
2025-01-25 23:59   ` Guenter Roeck
2025-01-27  7:05     ` Wolfram Sang
2025-01-27 14:31       ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox