diff mbox series

power: supply: bq27xxx: fix __be16 warnings

Message ID 20220721210735.451138-1-ben-linux@fluff.org
State Accepted
Commit 569581a21ff57f43dbe900b2f578c0ec3b0018ba
Headers show
Series power: supply: bq27xxx: fix __be16 warnings | expand

Commit Message

Ben Dooks July 21, 2022, 9:07 p.m. UTC
The bq27xxx_dm_reg_ptr() should return a __be16 as the result
is being passed to be16_to_cpup() to convert to the proper
cpu endian value. Move to using __be16 as appropriate to fix
the following sparse warnings:

drivers/power/supply/bq27xxx_battery.c:1293:26: warning: incorrect type in argument 1 (different base types)
drivers/power/supply/bq27xxx_battery.c:1293:26:    expected restricted __be16 const [usertype] *p
drivers/power/supply/bq27xxx_battery.c:1293:26:    got unsigned short [usertype] *prev
drivers/power/supply/bq27xxx_battery.c:1304:17: warning: incorrect type in argument 1 (different base types)
drivers/power/supply/bq27xxx_battery.c:1304:17:    expected restricted __be16 const [usertype] *p
drivers/power/supply/bq27xxx_battery.c:1304:17:    got unsigned short [usertype] *prev
drivers/power/supply/bq27xxx_battery.c:1316:15: warning: incorrect type in assignment (different base types)
drivers/power/supply/bq27xxx_battery.c:1316:15:    expected unsigned short [usertype]
drivers/power/supply/bq27xxx_battery.c:1316:15:    got restricted __be16 [usertype]

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 drivers/power/supply/bq27xxx_battery.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Sebastian Reichel Sept. 11, 2022, 1:04 p.m. UTC | #1
Hi,

On Thu, Jul 21, 2022 at 10:07:35PM +0100, Ben Dooks wrote:
> The bq27xxx_dm_reg_ptr() should return a __be16 as the result
> is being passed to be16_to_cpup() to convert to the proper
> cpu endian value. Move to using __be16 as appropriate to fix
> the following sparse warnings:
> 
> drivers/power/supply/bq27xxx_battery.c:1293:26: warning: incorrect type in argument 1 (different base types)
> drivers/power/supply/bq27xxx_battery.c:1293:26:    expected restricted __be16 const [usertype] *p
> drivers/power/supply/bq27xxx_battery.c:1293:26:    got unsigned short [usertype] *prev
> drivers/power/supply/bq27xxx_battery.c:1304:17: warning: incorrect type in argument 1 (different base types)
> drivers/power/supply/bq27xxx_battery.c:1304:17:    expected restricted __be16 const [usertype] *p
> drivers/power/supply/bq27xxx_battery.c:1304:17:    got unsigned short [usertype] *prev
> drivers/power/supply/bq27xxx_battery.c:1316:15: warning: incorrect type in assignment (different base types)
> drivers/power/supply/bq27xxx_battery.c:1316:15:    expected unsigned short [usertype]
> drivers/power/supply/bq27xxx_battery.c:1316:15:    got restricted __be16 [usertype]
> 
> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/bq27xxx_battery.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index dccc2683455a..8bf048fbd36a 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -1044,12 +1044,12 @@ struct bq27xxx_dm_buf {
>  	.block = (di)->dm_regs[i].offset / BQ27XXX_DM_SZ, \
>  }
>  
> -static inline u16 *bq27xxx_dm_reg_ptr(struct bq27xxx_dm_buf *buf,
> +static inline __be16 *bq27xxx_dm_reg_ptr(struct bq27xxx_dm_buf *buf,
>  				      struct bq27xxx_dm_reg *reg)
>  {
>  	if (buf->class == reg->subclass_id &&
>  	    buf->block == reg->offset / BQ27XXX_DM_SZ)
> -		return (u16 *) (buf->data + reg->offset % BQ27XXX_DM_SZ);
> +		return (__be16 *) (buf->data + reg->offset % BQ27XXX_DM_SZ);
>  
>  	return NULL;
>  }
> @@ -1275,7 +1275,7 @@ static void bq27xxx_battery_update_dm_block(struct bq27xxx_device_info *di,
>  {
>  	struct bq27xxx_dm_reg *reg = &di->dm_regs[reg_id];
>  	const char *str = bq27xxx_dm_reg_name[reg_id];
> -	u16 *prev = bq27xxx_dm_reg_ptr(buf, reg);
> +	__be16 *prev = bq27xxx_dm_reg_ptr(buf, reg);
>  
>  	if (prev == NULL) {
>  		dev_warn(di->dev, "buffer does not match %s dm spec\n", str);
> -- 
> 2.35.1
>
diff mbox series

Patch

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index dccc2683455a..8bf048fbd36a 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1044,12 +1044,12 @@  struct bq27xxx_dm_buf {
 	.block = (di)->dm_regs[i].offset / BQ27XXX_DM_SZ, \
 }
 
-static inline u16 *bq27xxx_dm_reg_ptr(struct bq27xxx_dm_buf *buf,
+static inline __be16 *bq27xxx_dm_reg_ptr(struct bq27xxx_dm_buf *buf,
 				      struct bq27xxx_dm_reg *reg)
 {
 	if (buf->class == reg->subclass_id &&
 	    buf->block == reg->offset / BQ27XXX_DM_SZ)
-		return (u16 *) (buf->data + reg->offset % BQ27XXX_DM_SZ);
+		return (__be16 *) (buf->data + reg->offset % BQ27XXX_DM_SZ);
 
 	return NULL;
 }
@@ -1275,7 +1275,7 @@  static void bq27xxx_battery_update_dm_block(struct bq27xxx_device_info *di,
 {
 	struct bq27xxx_dm_reg *reg = &di->dm_regs[reg_id];
 	const char *str = bq27xxx_dm_reg_name[reg_id];
-	u16 *prev = bq27xxx_dm_reg_ptr(buf, reg);
+	__be16 *prev = bq27xxx_dm_reg_ptr(buf, reg);
 
 	if (prev == NULL) {
 		dev_warn(di->dev, "buffer does not match %s dm spec\n", str);