2020-07-02 08:59:42

by Peng Fan

[permalink] [raw]
Subject: [PATCH] power: supply: rt5033_battery: Fix error code in rt5033_battery_probe()

In the function rt5033_battery_probe(), it should return -ENOMEM
instead of -EINVAL when call function devm_kzalloc() failed.

Signed-off-by: Peng Fan <[email protected]>
---
drivers/power/supply/rt5033_battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c
index d8667a9..f330452 100644
--- a/drivers/power/supply/rt5033_battery.c
+++ b/drivers/power/supply/rt5033_battery.c
@@ -125,7 +125,7 @@ static int rt5033_battery_probe(struct i2c_client *client,

battery = devm_kzalloc(&client->dev, sizeof(*battery), GFP_KERNEL);
if (!battery)
- return -EINVAL;
+ return -ENOMEM;

battery->client = client;
battery->regmap = devm_regmap_init_i2c(client,
--
2.1.0


2020-07-28 00:22:22

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH] power: supply: rt5033_battery: Fix error code in rt5033_battery_probe()

Hi,

On Thu, Jul 02, 2020 at 04:58:52PM +0800, Peng Fan wrote:
> In the function rt5033_battery_probe(), it should return -ENOMEM
> instead of -EINVAL when call function devm_kzalloc() failed.
>
> Signed-off-by: Peng Fan <[email protected]>
> ---

Thanks, queued.

-- Sebastian

> drivers/power/supply/rt5033_battery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c
> index d8667a9..f330452 100644
> --- a/drivers/power/supply/rt5033_battery.c
> +++ b/drivers/power/supply/rt5033_battery.c
> @@ -125,7 +125,7 @@ static int rt5033_battery_probe(struct i2c_client *client,
>
> battery = devm_kzalloc(&client->dev, sizeof(*battery), GFP_KERNEL);
> if (!battery)
> - return -EINVAL;
> + return -ENOMEM;
>
> battery->client = client;
> battery->regmap = devm_regmap_init_i2c(client,
> --
> 2.1.0
>


Attachments:
(No filename) (950.00 B)
signature.asc (849.00 B)
Download all attachments