diff mbox series

[-next] power: supply: bq25890: Fix enum conversion in bq25890_power_supply_set_property()

Message ID 20220912141553.1743568-1-nathan@kernel.org (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series [-next] power: supply: bq25890: Fix enum conversion in bq25890_power_supply_set_property() | expand

Commit Message

Nathan Chancellor Sept. 12, 2022, 2:15 p.m. UTC
Clang warns:

  drivers/power/supply/bq25890_charger.c:625:40: error: implicit conversion from enumeration type 'enum bq25890_fields' to different enumeration type 'enum bq25890_table_ids' [-Werror,-Wenum-conversion]
                  lval = bq25890_find_idx(val->intval, F_IINLIM);
                         ~~~~~~~~~~~~~~~~              ^~~~~~~~
  1 error generated.

Use the proper value from the right enumerated type, TBL_IINLIM, so
there is no more implcit conversion. The numerical values of F_IINLIM
and TBL_IINLIM happen to be the same so there is no change in behavior.

Fixes: 4a4748f28b0b ("power: supply: bq25890: Add support for setting IINLIM")
Link: https://github.com/ClangBuiltLinux/linux/issues/1707
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/power/supply/bq25890_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: f52c4d5f0bb486bc515b5f8a56130aea69fb29db

Comments

Marek Vasut Sept. 12, 2022, 6:11 p.m. UTC | #1
On 9/12/22 16:15, Nathan Chancellor wrote:
> Clang warns:
> 
>    drivers/power/supply/bq25890_charger.c:625:40: error: implicit conversion from enumeration type 'enum bq25890_fields' to different enumeration type 'enum bq25890_table_ids' [-Werror,-Wenum-conversion]
>                    lval = bq25890_find_idx(val->intval, F_IINLIM);
>                           ~~~~~~~~~~~~~~~~              ^~~~~~~~
>    1 error generated.
> 
> Use the proper value from the right enumerated type, TBL_IINLIM, so
> there is no more implcit conversion. The numerical values of F_IINLIM
> and TBL_IINLIM happen to be the same so there is no change in behavior.
> 
> Fixes: 4a4748f28b0b ("power: supply: bq25890: Add support for setting IINLIM")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1707
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Reviewed-by: Marek Vasut <marex@denx.de>

Thanks
Sebastian Reichel Sept. 14, 2022, 10:56 a.m. UTC | #2
Hi,

On Mon, Sep 12, 2022 at 08:11:59PM +0200, Marek Vasut wrote:
> On 9/12/22 16:15, Nathan Chancellor wrote:
> > Clang warns:
> > 
> >    drivers/power/supply/bq25890_charger.c:625:40: error: implicit conversion from enumeration type 'enum bq25890_fields' to different enumeration type 'enum bq25890_table_ids' [-Werror,-Wenum-conversion]
> >                    lval = bq25890_find_idx(val->intval, F_IINLIM);
> >                           ~~~~~~~~~~~~~~~~              ^~~~~~~~
> >    1 error generated.
> > 
> > Use the proper value from the right enumerated type, TBL_IINLIM, so
> > there is no more implcit conversion. The numerical values of F_IINLIM
> > and TBL_IINLIM happen to be the same so there is no change in behavior.
> > 
> > Fixes: 4a4748f28b0b ("power: supply: bq25890: Add support for setting IINLIM")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1707
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> 
> Reviewed-by: Marek Vasut <marex@denx.de>

Thanks, queued.

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index f5368be32843..e6bd60fef0f6 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -622,7 +622,7 @@  static int bq25890_power_supply_set_property(struct power_supply *psy,
 
 	switch (psp) {
 	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
-		lval = bq25890_find_idx(val->intval, F_IINLIM);
+		lval = bq25890_find_idx(val->intval, TBL_IINLIM);
 		return bq25890_field_write(bq, F_IINLIM, lval);
 	default:
 		return -EINVAL;