Skip to content

Commit 05452a3

Browse files
committed
hwmon: (pmbus/core) Make debugfs code unconditional
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. Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent de438ec commit 05452a3

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

drivers/hwmon/pmbus/pmbus_core.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,7 +3420,6 @@ static int pmbus_irq_setup(struct i2c_client *client, struct pmbus_data *data)
34203420

34213421
static struct dentry *pmbus_debugfs_dir; /* pmbus debugfs directory */
34223422

3423-
#if IS_ENABLED(CONFIG_DEBUG_FS)
34243423
static int pmbus_debugfs_get(void *data, u64 *val)
34253424
{
34263425
int rc;
@@ -3501,8 +3500,8 @@ static void pmbus_remove_symlink(void *symlink)
35013500
debugfs_remove(symlink);
35023501
}
35033502

3504-
static int pmbus_init_debugfs(struct i2c_client *client,
3505-
struct pmbus_data *data)
3503+
static void pmbus_init_debugfs(struct i2c_client *client,
3504+
struct pmbus_data *data)
35063505
{
35073506
struct dentry *symlink_d, *debugfs = client->debugfs;
35083507
struct pmbus_debugfs_entry *entries;
@@ -3516,23 +3515,23 @@ static int pmbus_init_debugfs(struct i2c_client *client,
35163515
* client->debugfs before using it.
35173516
*/
35183517
if (!pmbus_debugfs_dir || IS_ERR_OR_NULL(debugfs))
3519-
return -ENODEV;
3518+
return;
35203519

35213520
/*
35223521
* Backwards compatibility: Create symlink from /pmbus/<hwmon_device>
35233522
* to i2c debugfs directory.
35243523
*/
35253524
pathname = dentry_path_raw(debugfs, name, sizeof(name));
35263525
if (IS_ERR(pathname))
3527-
return PTR_ERR(pathname);
3526+
return;
35283527

35293528
/*
35303529
* The path returned by dentry_path_raw() starts with '/'. Prepend it
35313530
* with ".." to get the symlink relative to the pmbus root directory.
35323531
*/
35333532
symlink = kasprintf(GFP_KERNEL, "..%s", pathname);
35343533
if (!symlink)
3535-
return -ENOMEM;
3534+
return;
35363535

35373536
symlink_d = debugfs_create_symlink(dev_name(data->hwmon_dev),
35383537
pmbus_debugfs_dir, symlink);
@@ -3549,7 +3548,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
35493548
7 + data->info->pages * 10, sizeof(*entries),
35503549
GFP_KERNEL);
35513550
if (!entries)
3552-
return -ENOMEM;
3551+
return;
35533552

35543553
/*
35553554
* Add device-specific entries.
@@ -3726,15 +3725,7 @@ static int pmbus_init_debugfs(struct i2c_client *client,
37263725
&pmbus_debugfs_ops);
37273726
}
37283727
}
3729-
return 0;
3730-
}
3731-
#else
3732-
static int pmbus_init_debugfs(struct i2c_client *client,
3733-
struct pmbus_data *data)
3734-
{
3735-
return 0;
37363728
}
3737-
#endif /* IS_ENABLED(CONFIG_DEBUG_FS) */
37383729

37393730
int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
37403731
{
@@ -3821,9 +3812,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
38213812
if (ret)
38223813
return ret;
38233814

3824-
ret = pmbus_init_debugfs(client, data);
3825-
if (ret)
3826-
dev_warn(dev, "Failed to register debugfs\n");
3815+
pmbus_init_debugfs(client, data);
38273816

38283817
return 0;
38293818
}

0 commit comments

Comments
 (0)