power: supply: rk817: Fix unsigned comparison with less than zero
PATCH v2 1/1 power: supply: rk817: Fix unsigned comparison with less than zero
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.
---
Changes in v2:
-Drop the comparison 'tmp<0'.
drivers/power/supply/rk817_charger.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/power/supply/rk817_charger.c +0 -4
@@ -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 );
Signature · 1 line
2.20.1.7.g153144c
Quoted 10 lines · Jiapeng Chong
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:828rk817_read_or_set_full_charge_on_boot()warn: unsigned 'tmp' is never less than zero.drivers/power/supply/rk817_charger.c:788rk817_read_or_set_full_charge_on_boot()warn: unsigned 'tmp' is never less than zero.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>
Looks good to me, thank you.
Quoted 32 lines
---
Changes in v2:
-Drop the comparison 'tmp<0'.drivers/power/supply/rk817_charger.c | 4 ---- 1 file changed, 4 deletions(-)drivers/power/supply/rk817_charger.c +0
-4@@ -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 );Signature · 1 line
2.20.1.7.g153144c
Hi,
Quoted 8 lines · Chris Morgan
Quoted 7 lines · Jiapeng Chong
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:828rk817_read_or_set_full_charge_on_boot()warn: unsigned 'tmp' is never less than zero.drivers/power/supply/rk817_charger.c:788rk817_read_or_set_full_charge_on_boot()warn: unsigned 'tmp' is never less than zero.
Quoted 7 lines
Quoted 3 lines
Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>Looks good to me, thank you.
Tested-by Chris Morgan <[email protected]>
Thanks, queued to power-supply's fixes branch.
-- Sebastian
Quoted 32 lines
Quoted 32 lines
---
Changes in v2:
-Drop the comparison 'tmp<0'.drivers/power/supply/rk817_charger.c | 4 ---- 1 file changed, 4 deletions(-)drivers/power/supply/rk817_charger.c +0
-4@@ -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 );Signature · 1 line
2.20.1.7.g153144c