diff options
| author | Guenter Roeck <linux@roeck-us.net> | 2026-03-20 07:18:37 -0700 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2026-03-30 19:45:06 -0700 |
| commit | 1814f4d3ff358277a5b6957e7f133c2812dc80ec (patch) | |
| tree | 3a496b577b3b06818ddf5da076a6f770fe6e1fc5 /drivers | |
| parent | 7c760db74c9f30da7281c7f450d0676ec78ec3e6 (diff) | |
hwmon: (pmbus) Add support for guarded PMBus lock
Add support for guard(pmbus_lock)() and scoped_guard(pmbus_lock)()
to be able to simplify the PMBus code.
Also introduce pmbus_lock() as pre-requisite for supporting
guard().
Reviewed-by: Sanman Pradhan <psanman@juniper.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/hwmon/pmbus/pmbus.h | 5 | ||||
| -rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index deb556971a72..23e3eda58870 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -10,6 +10,7 @@ #define PMBUS_H #include <linux/bitops.h> +#include <linux/cleanup.h> #include <linux/regulator/driver.h> /* @@ -569,7 +570,11 @@ int pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id, int pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id, enum pmbus_fan_mode mode); int pmbus_lock_interruptible(struct i2c_client *client); +void pmbus_lock(struct i2c_client *client); void pmbus_unlock(struct i2c_client *client); + +DEFINE_GUARD(pmbus_lock, struct i2c_client *, pmbus_lock(_T), pmbus_unlock(_T)) + int pmbus_update_fan(struct i2c_client *client, int page, int id, u8 config, u8 mask, u16 command); struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client); diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index d82162b3c3b4..0500e92d7732 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3876,6 +3876,14 @@ struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client) } EXPORT_SYMBOL_NS_GPL(pmbus_get_debugfs_dir, "PMBUS"); +void pmbus_lock(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); +} +EXPORT_SYMBOL_NS_GPL(pmbus_lock, "PMBUS"); + int pmbus_lock_interruptible(struct i2c_client *client) { struct pmbus_data *data = i2c_get_clientdata(client); |
