[PATCH 2/4] HID: sony: Use min() macro to simplify code
Chen Changcheng <[email protected]>
| Newsgroups | org.kernel.vger.linux-input,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Replace open-coded min() logic with the standard min() macro in hid-sony.c for battery capacity index calculation. Detected by Coccinelle: ./hid-sony.c:970:21-23: WARNING opportunity for min() Signed-off-by: Chen Changcheng <[email protected]> --- drivers/hid/hid-sony.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index e75246d29e16..cbc916989646 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -967,7 +967,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, u8 *rd, int size) battery_capacity = 100; battery_status = (rd[offset] & 0x01) ? POWER_SUPPLY_STATUS_FULL : POWER_SUPPLY_STATUS_CHARGING; } else { - index = rd[offset] <= 5 ? rd[offset] : 5; + index = min(rd[offset], 5); battery_capacity = sixaxis_battery_capacity[index]; battery_status = POWER_SUPPLY_STATUS_DISCHARGING; } -- 2.25.1