aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorNaresh Solanki2023-03-28 17:03:33 +0200
committerGuenter Roeck2023-04-19 07:08:39 -0700
commitffe36eb557d375ff7667d249aecdf08ed5acf55d (patch)
tree6f3e2b63f120078cc9ac976f691594c46f232b32 /drivers/hwmon
parent7f2958e845d2c8bf1100dc088dbdc31af2a80fd0 (diff)
hwmon: (pmbus/core) Add rdev in pmbus_data struct
Add regulator device in pmbus_data & initialize the same during PMBus regulator register. Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230328150335.90238-1-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 0ddef2c9ba9b..d93405f1a495 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -81,6 +81,7 @@ struct pmbus_label {
struct pmbus_data {
struct device *dev;
struct device *hwmon_dev;
+ struct regulator_dev **rdevs;
u32 flags; /* from platform data */
@@ -3109,9 +3110,13 @@ static int pmbus_regulator_register(struct pmbus_data *data)
struct device *dev = data->dev;
const struct pmbus_driver_info *info = data->info;
const struct pmbus_platform_data *pdata = dev_get_platdata(dev);
- struct regulator_dev *rdev;
int i;
+ data->rdevs = devm_kzalloc(dev, sizeof(struct regulator_dev *) * info->num_regulators,
+ GFP_KERNEL);
+ if (!data->rdevs)
+ return -ENOMEM;
+
for (i = 0; i < info->num_regulators; i++) {
struct regulator_config config = { };
@@ -3121,10 +3126,10 @@ static int pmbus_regulator_register(struct pmbus_data *data)
if (pdata && pdata->reg_init_data)
config.init_data = &pdata->reg_init_data[i];
- rdev = devm_regulator_register(dev, &info->reg_desc[i],
- &config);
- if (IS_ERR(rdev))
- return dev_err_probe(dev, PTR_ERR(rdev),
+ data->rdevs[i] = devm_regulator_register(dev, &info->reg_desc[i],
+ &config);
+ if (IS_ERR(data->rdevs[i]))
+ return dev_err_probe(dev, PTR_ERR(data->rdevs[i]),
"Failed to register %s regulator\n",
info->reg_desc[i].name);
}