[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221201200419.GA2110128@roeck-us.net>
Date: Thu, 1 Dec 2022 12:04:19 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Naresh Solanki <naresh.solanki@...ements.com>
Cc: devicetree@...r.kernel.org, Jean Delvare <jdelvare@...e.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, linux-kernel@...r.kernel.org,
linux-hwmon@...r.kernel.org,
Patrick Rudolph <patrick.rudolph@...ements.com>
Subject: Re: [PATCH v5 1/5] hwmon: (pmbus/core): Add rdev in pmbus_data struct
On Thu, Dec 01, 2022 at 08:30:20PM +0100, Naresh Solanki wrote:
> Add regulator device in pmbus_data & initialize the same during PMBus
> regulator register.
>
This needs an explanation why this change is needed.
Guenter
> Signed-off-by: Naresh Solanki <Naresh.Solanki@...ements.com>
>
> ---
> Change in V5:
> - Fix error check for rdev
> ---
> drivers/hwmon/pmbus/pmbus_core.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 95e95783972a..a95f998ca247 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 */
>
> @@ -3050,9 +3051,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 = { };
>
> @@ -3062,10 +3067,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],
> + data->rdevs[i] = devm_regulator_register(dev, &info->reg_desc[i],
> &config);
> - if (IS_ERR(rdev))
> - return dev_err_probe(dev, PTR_ERR(rdev),
> + 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);
> }
>
> base-commit: 9494c53e1389b120ba461899207ac8a3aab2632c
> --
> 2.37.3
>
Powered by blists - more mailing lists