From: Qianfeng Rong Date: Thu, 14 Aug 2025 14:36:53 +0000 (+0800) Subject: power: supply: use max() to improve code X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d48d4e4f141b38944da3b0a9c21ce6828ec31d83;p=users%2Fhch%2Fmisc.git power: supply: use max() to improve code Use max() to reduce the code in cw_battery_get_property() and improve its readability. Signed-off-by: Qianfeng Rong Signed-off-by: Sebastian Reichel --- diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c index f63c3c410451..afc607fee5c9 100644 --- a/drivers/power/supply/cw2015_battery.c +++ b/drivers/power/supply/cw2015_battery.c @@ -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: