]> www.infradead.org Git - users/hch/misc.git/commitdiff
power: supply: use max() to improve code
authorQianfeng Rong <rongqianfeng@vivo.com>
Thu, 14 Aug 2025 14:36:53 +0000 (22:36 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sat, 6 Sep 2025 21:32:11 +0000 (23:32 +0200)
Use max() to reduce the code in cw_battery_get_property() and improve
its readability.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/cw2015_battery.c

index f63c3c41045155bc2a2f99eed45ca9237d7db362..afc607fee5c96f7b2e6b7e0dc86d4a1c8735a16c 100644 (file)
@@ -506,10 +506,7 @@ static int cw_battery_get_property(struct power_supply *psy,
 
        case POWER_SUPPLY_PROP_CHARGE_FULL:
        case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
-               if (cw_bat->battery->charge_full_design_uah > 0)
-                       val->intval = cw_bat->battery->charge_full_design_uah;
-               else
-                       val->intval = 0;
+               val->intval = max(cw_bat->battery->charge_full_design_uah, 0);
                break;
 
        case POWER_SUPPLY_PROP_CHARGE_NOW: