[PATCH RFC] hwmon: (pmbus/core) use the new i2c_client debugfs dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
---

@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





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux