* [PATCH v2] power: supply: rk817: Fix unsigned comparison with less than zero
@ 2022-12-14 3:23 Jiapeng Chong
2022-12-15 19:04 ` Chris Morgan
0 siblings, 1 reply; 3+ messages in thread
From: Jiapeng Chong @ 2022-12-14 3:23 UTC (permalink / raw)
To: sre; +Cc: linux-pm, linux-kernel, Jiapeng Chong, Abaci Robot
The tmp is defined as u32 type, which results in invalid processing of
tmp<0 in function rk817_read_or_set_full_charge_on_boot(). Therefore,
drop the comparison.
drivers/power/supply/rk817_charger.c:828 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
drivers/power/supply/rk817_charger.c:788 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3444
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
Changes in v2:
-Drop the comparison 'tmp<0'.
drivers/power/supply/rk817_charger.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
index 4f9c1c417916..36f807b5ec44 100644
--- a/drivers/power/supply/rk817_charger.c
+++ b/drivers/power/supply/rk817_charger.c
@@ -785,8 +785,6 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
bulk_reg, 4);
tmp = get_unaligned_be32(bulk_reg);
- if (tmp < 0)
- tmp = 0;
boot_charge_mah = ADC_TO_CHARGE_UAH(tmp,
charger->res_div) / 1000;
/*
@@ -825,8 +823,6 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
bulk_reg, 4);
tmp = get_unaligned_be32(bulk_reg);
- if (tmp < 0)
- tmp = 0;
boot_charge_mah = ADC_TO_CHARGE_UAH(tmp, charger->res_div) / 1000;
regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_OCV_VOL_H,
bulk_reg, 2);
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] power: supply: rk817: Fix unsigned comparison with less than zero
2022-12-14 3:23 [PATCH v2] power: supply: rk817: Fix unsigned comparison with less than zero Jiapeng Chong
@ 2022-12-15 19:04 ` Chris Morgan
2023-01-02 22:18 ` Sebastian Reichel
0 siblings, 1 reply; 3+ messages in thread
From: Chris Morgan @ 2022-12-15 19:04 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: sre, linux-pm, linux-kernel, Abaci Robot
On Wed, Dec 14, 2022 at 11:23:16AM +0800, Jiapeng Chong wrote:
> The tmp is defined as u32 type, which results in invalid processing of
> tmp<0 in function rk817_read_or_set_full_charge_on_boot(). Therefore,
> drop the comparison.
>
> drivers/power/supply/rk817_charger.c:828 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
> drivers/power/supply/rk817_charger.c:788 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3444
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Looks good to me, thank you.
Tested-by: Chris Morgan <macromorgan@hotmail.com>
> ---
> Changes in v2:
> -Drop the comparison 'tmp<0'.
>
> drivers/power/supply/rk817_charger.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
> index 4f9c1c417916..36f807b5ec44 100644
> --- a/drivers/power/supply/rk817_charger.c
> +++ b/drivers/power/supply/rk817_charger.c
> @@ -785,8 +785,6 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
> regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
> bulk_reg, 4);
> tmp = get_unaligned_be32(bulk_reg);
> - if (tmp < 0)
> - tmp = 0;
> boot_charge_mah = ADC_TO_CHARGE_UAH(tmp,
> charger->res_div) / 1000;
> /*
> @@ -825,8 +823,6 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
> regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
> bulk_reg, 4);
> tmp = get_unaligned_be32(bulk_reg);
> - if (tmp < 0)
> - tmp = 0;
> boot_charge_mah = ADC_TO_CHARGE_UAH(tmp, charger->res_div) / 1000;
> regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_OCV_VOL_H,
> bulk_reg, 2);
> --
> 2.20.1.7.g153144c
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] power: supply: rk817: Fix unsigned comparison with less than zero
2022-12-15 19:04 ` Chris Morgan
@ 2023-01-02 22:18 ` Sebastian Reichel
0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2023-01-02 22:18 UTC (permalink / raw)
To: Chris Morgan; +Cc: Jiapeng Chong, linux-pm, linux-kernel, Abaci Robot
[-- Attachment #1: Type: text/plain, Size: 2176 bytes --]
Hi,
On Thu, Dec 15, 2022 at 01:04:14PM -0600, Chris Morgan wrote:
> On Wed, Dec 14, 2022 at 11:23:16AM +0800, Jiapeng Chong wrote:
> > The tmp is defined as u32 type, which results in invalid processing of
> > tmp<0 in function rk817_read_or_set_full_charge_on_boot(). Therefore,
> > drop the comparison.
> >
> > drivers/power/supply/rk817_charger.c:828 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
> > drivers/power/supply/rk817_charger.c:788 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
> >
> > Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3444
> > Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> > Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
>
> Looks good to me, thank you.
>
> Tested-by: Chris Morgan <macromorgan@hotmail.com>
Thanks, queued to power-supply's fixes branch.
-- Sebastian
> > ---
> > Changes in v2:
> > -Drop the comparison 'tmp<0'.
> >
> > drivers/power/supply/rk817_charger.c | 4 ----
> > 1 file changed, 4 deletions(-)
> >
> > diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
> > index 4f9c1c417916..36f807b5ec44 100644
> > --- a/drivers/power/supply/rk817_charger.c
> > +++ b/drivers/power/supply/rk817_charger.c
> > @@ -785,8 +785,6 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
> > regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
> > bulk_reg, 4);
> > tmp = get_unaligned_be32(bulk_reg);
> > - if (tmp < 0)
> > - tmp = 0;
> > boot_charge_mah = ADC_TO_CHARGE_UAH(tmp,
> > charger->res_div) / 1000;
> > /*
> > @@ -825,8 +823,6 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
> > regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
> > bulk_reg, 4);
> > tmp = get_unaligned_be32(bulk_reg);
> > - if (tmp < 0)
> > - tmp = 0;
> > boot_charge_mah = ADC_TO_CHARGE_UAH(tmp, charger->res_div) / 1000;
> > regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_OCV_VOL_H,
> > bulk_reg, 2);
> > --
> > 2.20.1.7.g153144c
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-02 22:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-14 3:23 [PATCH v2] power: supply: rk817: Fix unsigned comparison with less than zero Jiapeng Chong
2022-12-15 19:04 ` Chris Morgan
2023-01-02 22:18 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox