diff mbox series

power: supply: remove dead code

Message ID 20221004073652.568681-1-usama.anjum@collabora.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power: supply: remove dead code | expand

Commit Message

Muhammad Usama Anjum Oct. 4, 2022, 7:36 a.m. UTC
tmp is an unsigned variable. It can never be less than zero. Remove the
dead code.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 drivers/power/supply/rk817_charger.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Sebastian Reichel Oct. 29, 2022, 12:04 a.m. UTC | #1
Hi,

On Tue, Oct 04, 2022 at 12:36:51PM +0500, Muhammad Usama Anjum wrote:
> tmp is an unsigned variable. It can never be less than zero. Remove the
> dead code.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---

Right, but the return value of regmap_bulk_read() should be checked
instead.

-- Sebastian

>  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 aa4b33f1bb83..ba3f5ccaeacd 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.30.2
>
diff mbox series

Patch

diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
index aa4b33f1bb83..ba3f5ccaeacd 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);