diff mbox series

[v2,2/4] hwmon: pmbus: Use devm_krealloc_array

Message ID 20230309150334.216760-3-james.clark@arm.com (mailing list archive)
State New, archived
Headers show
Series devres: Provide krealloc_array | expand

Commit Message

James Clark March 9, 2023, 3:03 p.m. UTC
Now that it exists, use it instead of doing the multiplication manually.

Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: James Clark <james.clark@arm.com>
---
 drivers/hwmon/pmbus/pmbus_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jonathan Cameron March 11, 2023, 7:06 p.m. UTC | #1
On Thu,  9 Mar 2023 15:03:31 +0000
James Clark <james.clark@arm.com> wrote:

> Now that it exists, use it instead of doing the multiplication manually.
> 
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: James Clark <james.clark@arm.com>
FWIW LGTM
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/hwmon/pmbus/pmbus_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 95e95783972a..e7bee25a3706 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -1190,9 +1190,9 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
>  {
>  	if (data->num_attributes >= data->max_attributes - 1) {
>  		int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE;
> -		void *new_attrs = devm_krealloc(data->dev, data->group.attrs,
> -						new_max_attrs * sizeof(void *),
> -						GFP_KERNEL);
> +		void *new_attrs = devm_krealloc_array(data->dev, data->group.attrs,
> +						      new_max_attrs, sizeof(void *),
> +						      GFP_KERNEL);
>  		if (!new_attrs)
>  			return -ENOMEM;
>  		data->group.attrs = new_attrs;
diff mbox series

Patch

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 95e95783972a..e7bee25a3706 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1190,9 +1190,9 @@  static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
 {
 	if (data->num_attributes >= data->max_attributes - 1) {
 		int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE;
-		void *new_attrs = devm_krealloc(data->dev, data->group.attrs,
-						new_max_attrs * sizeof(void *),
-						GFP_KERNEL);
+		void *new_attrs = devm_krealloc_array(data->dev, data->group.attrs,
+						      new_max_attrs, sizeof(void *),
+						      GFP_KERNEL);
 		if (!new_attrs)
 			return -ENOMEM;
 		data->group.attrs = new_attrs;