summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-logitech-hidpp.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2023-03-02 13:55:50 +0300
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>2023-04-03 14:30:08 +0300
commite0138763be2d8bcc181c2f6110ef0f66979f1ce4 (patch)
tree58efa8f7e7bfb3b98acde9418a3796fbdb555813 /drivers/hid/hid-logitech-hidpp.c
parent5b3691d15e04b6d5a32c915577b8dbc5cfb56382 (diff)
downloadlinux-e0138763be2d8bcc181c2f6110ef0f66979f1ce4.tar.xz
HID: logitech-hidpp: Simplify array length check
Use the compiler to force a 100-length array, rather than check the length after the fact. Signed-off-by: Bastien Nocera <hadess@hadess.net> Link: https://lore.kernel.org/r/20230302105555.51417-1-hadess@hadess.net Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Diffstat (limited to 'drivers/hid/hid-logitech-hidpp.c')
-rw-r--r--drivers/hid/hid-logitech-hidpp.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index da89e84c9cbe..6f4d31d20832 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -1404,7 +1404,7 @@ static int hidpp20_map_battery_capacity(struct hid_device *hid_dev, int voltage)
* there are a few devices that use different battery technology.
*/
- static const int voltages[] = {
+ static const int voltages[100] = {
4186, 4156, 4143, 4133, 4122, 4113, 4103, 4094, 4086, 4075,
4067, 4059, 4051, 4043, 4035, 4027, 4019, 4011, 4003, 3997,
3989, 3983, 3976, 3969, 3961, 3955, 3949, 3942, 3935, 3929,
@@ -1419,8 +1419,6 @@ static int hidpp20_map_battery_capacity(struct hid_device *hid_dev, int voltage)
int i;
- BUILD_BUG_ON(ARRAY_SIZE(voltages) != 100);
-
if (unlikely(voltage < 3500 || voltage >= 5000))
hid_warn_once(hid_dev,
"%s: possibly using the wrong voltage curve\n",