Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 4/8] hwmon: (pmbus/core) Make debugfs code unconditional
Date: Sat,  8 Feb 2025 17:26:13 -0800	[thread overview]
Message-ID: <20250209012617.944499-5-linux@roeck-us.net> (raw)
In-Reply-To: <20250209012617.944499-1-linux@roeck-us.net>

Drop contitionals around debugfs code to compile it unconditionally.
In practice it will be optimized away by the compiler if CONFIG_DEBUG_FS
is not enabled, so the code size is not affected by this change.

Also silently ignore errors if debugfs initialization fails.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/pmbus/pmbus_core.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index be794ba993b8..39cdcbb96215 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -3421,7 +3421,6 @@ static int pmbus_irq_setup(struct i2c_client *client, struct pmbus_data *data)
 
 static struct dentry *pmbus_debugfs_dir;	/* pmbus debugfs directory */
 
-#if IS_ENABLED(CONFIG_DEBUG_FS)
 static int pmbus_debugfs_get(void *data, u64 *val)
 {
 	int rc;
@@ -3502,8 +3501,8 @@ static void pmbus_remove_symlink(void *symlink)
 	debugfs_remove(symlink);
 }
 
-static int pmbus_init_debugfs(struct i2c_client *client,
-			      struct pmbus_data *data)
+static void pmbus_init_debugfs(struct i2c_client *client,
+			       struct pmbus_data *data)
 {
 	struct dentry *symlink_d, *debugfs = client->debugfs;
 	struct pmbus_debugfs_entry *entries;
@@ -3517,7 +3516,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
 	 * client->debugfs before using it.
 	 */
 	if (!pmbus_debugfs_dir || IS_ERR_OR_NULL(debugfs))
-		return -ENODEV;
+		return;
 
 	/*
 	 * Backwards compatibility: Create symlink from /pmbus/<hwmon_device>
@@ -3525,7 +3524,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
 	 */
 	pathname = dentry_path_raw(debugfs, name, sizeof(name));
 	if (IS_ERR(pathname))
-		return PTR_ERR(pathname);
+		return;
 
 	/*
 	 * The path returned by dentry_path_raw() starts with '/'. Prepend it
@@ -3533,7 +3532,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
 	 */
 	symlink = kasprintf(GFP_KERNEL, "..%s", pathname);
 	if (!symlink)
-		return -ENOMEM;
+		return;
 
 	symlink_d = debugfs_create_symlink(dev_name(data->hwmon_dev),
 					   pmbus_debugfs_dir, symlink);
@@ -3550,7 +3549,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
 			       7 + data->info->pages * 10, sizeof(*entries),
 			       GFP_KERNEL);
 	if (!entries)
-		return -ENOMEM;
+		return;
 
 	/*
 	 * Add device-specific entries.
@@ -3727,15 +3726,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
 					    &pmbus_debugfs_ops);
 		}
 	}
-	return 0;
 }
-#else
-static int pmbus_init_debugfs(struct i2c_client *client,
-			      struct pmbus_data *data)
-{
-	return 0;
-}
-#endif	/* IS_ENABLED(CONFIG_DEBUG_FS) */
 
 int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
 {
@@ -3822,9 +3813,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
 	if (ret)
 		return ret;
 
-	ret = pmbus_init_debugfs(client, data);
-	if (ret)
-		dev_warn(dev, "Failed to register debugfs\n");
+	pmbus_init_debugfs(client, data);
 
 	return 0;
 }
-- 
2.45.2


  parent reply	other threads:[~2025-02-09  1:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-09  1:26 [PATCH 0/8] hwmon: (pmbus/core) Various fixes and improvements Guenter Roeck
2025-02-09  1:26 ` [PATCH 1/8] hwmon: (pmbus/core) Fix various coding style issues Guenter Roeck
2025-02-10  2:21   ` Tzung-Bi Shih
2025-02-09  1:26 ` [PATCH 2/8] hwmon: (pmbus/core) Use local debugfs variable in debugfs initialization Guenter Roeck
2025-02-10  2:21   ` Tzung-Bi Shih
2025-02-09  1:26 ` [PATCH 3/8] hwmon: (pmbus/core) Use the new i2c_client debugfs directory Guenter Roeck
2025-02-10  2:21   ` Tzung-Bi Shih
2025-02-09  1:26 ` Guenter Roeck [this message]
2025-02-10  2:22   ` [PATCH 4/8] hwmon: (pmbus/core) Make debugfs code unconditional Tzung-Bi Shih
2025-02-09  1:26 ` [PATCH 5/8] hwmon: (pmbus/core) Declare regulator notification function as void Guenter Roeck
2025-02-10  2:22   ` Tzung-Bi Shih
2025-02-09  1:26 ` [PATCH 6/8] hwmon: (pmbus/core) Optimize debugfs block data attribute initialization Guenter Roeck
2025-02-10  2:22   ` Tzung-Bi Shih
2025-02-10  2:21 ` [PATCH 0/8] hwmon: (pmbus/core) Various fixes and improvements Tzung-Bi Shih
2025-02-10  4:00   ` 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=20250209012617.944499-5-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /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