Re: [PATCH] power: supply: bq27xxx: fix NULL vs 0 warnings
From: Sebastian Reichel
Date: Mon Sep 12 2022 - 06:29:07 EST
Hi,
On Thu, Jul 21, 2022 at 10:01:20PM +0100, Ben Dooks wrote:
> The driver has a lot of sparse warnings for using 0 as a NULL
> pointer when NULL would be appropriate. Change the 0 values
> to NULL to fix the warnings, some of which are shown here:
>
> drivers/power/supply/bq27xxx_battery.c:984:23: warning: Using plain integer as NULL pointer
> drivers/power/supply/bq27xxx_battery.c:985:23: warning: Using plain integer as NULL pointer
> drivers/power/supply/bq27xxx_battery.c:986:23: warning: Using plain integer as NULL pointer
> drivers/power/supply/bq27xxx_battery.c:987:23: warning: Using plain integer as NULL pointer
> drivers/power/supply/bq27xxx_battery.c:988:23: warning: Using plain integer as NULL pointer
>
> Signed-off-by: Ben Dooks <ben-linux@xxxxxxxxx>
> ---
Thanks, queued.
-- Sebastian
> drivers/power/supply/bq27xxx_battery.c | 54 +++++++++++++-------------
> 1 file changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index 35e6a394c0df..dccc2683455a 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -868,11 +868,11 @@ enum bq27xxx_dm_reg_id {
> BQ27XXX_DM_TERMINATE_VOLTAGE,
> };
>
> -#define bq27000_dm_regs 0
> -#define bq27010_dm_regs 0
> -#define bq2750x_dm_regs 0
> -#define bq2751x_dm_regs 0
> -#define bq2752x_dm_regs 0
> +#define bq27000_dm_regs NULL
> +#define bq27010_dm_regs NULL
> +#define bq2750x_dm_regs NULL
> +#define bq2751x_dm_regs NULL
> +#define bq2752x_dm_regs NULL
>
> #if 0 /* not yet tested */
> static struct bq27xxx_dm_reg bq27500_dm_regs[] = {
> @@ -881,24 +881,24 @@ static struct bq27xxx_dm_reg bq27500_dm_regs[] = {
> [BQ27XXX_DM_TERMINATE_VOLTAGE] = { 80, 48, 2, 1000, 32767 },
> };
> #else
> -#define bq27500_dm_regs 0
> +#define bq27500_dm_regs NULL
> #endif
>
> /* todo create data memory definitions from datasheets and test on chips */
> -#define bq27510g1_dm_regs 0
> -#define bq27510g2_dm_regs 0
> -#define bq27510g3_dm_regs 0
> -#define bq27520g1_dm_regs 0
> -#define bq27520g2_dm_regs 0
> -#define bq27520g3_dm_regs 0
> -#define bq27520g4_dm_regs 0
> -#define bq27521_dm_regs 0
> -#define bq27530_dm_regs 0
> -#define bq27531_dm_regs 0
> -#define bq27541_dm_regs 0
> -#define bq27542_dm_regs 0
> -#define bq27546_dm_regs 0
> -#define bq27742_dm_regs 0
> +#define bq27510g1_dm_regs NULL
> +#define bq27510g2_dm_regs NULL
> +#define bq27510g3_dm_regs NULL
> +#define bq27520g1_dm_regs NULL
> +#define bq27520g2_dm_regs NULL
> +#define bq27520g3_dm_regs NULL
> +#define bq27520g4_dm_regs NULL
> +#define bq27521_dm_regs NULL
> +#define bq27530_dm_regs NULL
> +#define bq27531_dm_regs NULL
> +#define bq27541_dm_regs NULL
> +#define bq27542_dm_regs NULL
> +#define bq27546_dm_regs NULL
> +#define bq27742_dm_regs NULL
>
> #if 0 /* not yet tested */
> static struct bq27xxx_dm_reg bq27545_dm_regs[] = {
> @@ -907,7 +907,7 @@ static struct bq27xxx_dm_reg bq27545_dm_regs[] = {
> [BQ27XXX_DM_TERMINATE_VOLTAGE] = { 80, 67, 2, 2800, 3700 },
> };
> #else
> -#define bq27545_dm_regs 0
> +#define bq27545_dm_regs NULL
> #endif
>
> static struct bq27xxx_dm_reg bq27411_dm_regs[] = {
> @@ -937,7 +937,7 @@ static struct bq27xxx_dm_reg bq27426_dm_regs[] = {
> #if 0 /* not yet tested */
> #define bq27441_dm_regs bq27421_dm_regs
> #else
> -#define bq27441_dm_regs 0
> +#define bq27441_dm_regs NULL
> #endif
>
> #if 0 /* not yet tested */
> @@ -947,13 +947,13 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
> [BQ27XXX_DM_TERMINATE_VOLTAGE] = { 82, 9, 2, 2500, 3700 },
> };
> #else
> -#define bq27621_dm_regs 0
> +#define bq27621_dm_regs NULL
> #endif
>
> -#define bq27z561_dm_regs 0
> -#define bq28z610_dm_regs 0
> -#define bq34z100_dm_regs 0
> -#define bq78z100_dm_regs 0
> +#define bq27z561_dm_regs NULL
> +#define bq28z610_dm_regs NULL
> +#define bq34z100_dm_regs NULL
> +#define bq78z100_dm_regs NULL
>
> #define BQ27XXX_O_ZERO BIT(0)
> #define BQ27XXX_O_OTDC BIT(1) /* has OTC/OTD overtemperature flags */
> --
> 2.35.1
>
Attachment:
signature.asc
Description: PGP signature