]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: hid-appletb-bl: use appletb_bl_brightness_map instead of magic numbers to set...
authorAditya Garg <gargaditya08@live.com>
Sun, 9 Feb 2025 07:27:52 +0000 (07:27 +0000)
committerJiri Kosina <jkosina@suse.com>
Mon, 10 Feb 2025 07:24:21 +0000 (08:24 +0100)
This commit makes use of appletb_bl_brightness_map instead of using if
statements and magic numbers to set default brightness, and thus simplifies
the code.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-appletb-bl.c

index 819157686e59d1e1ec125c5ac501d38b9083440c..1a3dcd44bf1ab29b201c1c38daebd5e4a24ae29e 100644 (file)
@@ -141,12 +141,8 @@ static int appletb_bl_probe(struct hid_device *hdev, const struct hid_device_id
        bl->aux1_field = aux1_field;
        bl->brightness_field = brightness_field;
 
-       if (appletb_bl_def_brightness == 0)
-               ret = appletb_bl_set_brightness(bl, APPLETB_BL_OFF);
-       else if (appletb_bl_def_brightness == 1)
-               ret = appletb_bl_set_brightness(bl, APPLETB_BL_DIM);
-       else
-               ret = appletb_bl_set_brightness(bl, APPLETB_BL_ON);
+       ret = appletb_bl_set_brightness(bl,
+               appletb_bl_brightness_map[(appletb_bl_def_brightness > 2) ? 2 : appletb_bl_def_brightness]);
 
        if (ret) {
                dev_err_probe(dev, ret, "Failed to set touch bar brightness to off\n");