platform/x86: lenovo-yogabook: Add YB_KBD_BL_MAX define
authorHans de Goede <hdegoede@redhat.com>
Sun, 30 Apr 2023 16:58:04 +0000 (18:58 +0200)
committerHans de Goede <hdegoede@redhat.com>
Tue, 9 May 2023 10:33:37 +0000 (12:33 +0200)
Add a define for the max brightness level instead of hardcoding
this to 255 in multiple places.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230430165807.472798-17-hdegoede@redhat.com
drivers/platform/x86/lenovo-yogabook-wmi.c

index d04603c..fcc1863 100644 (file)
@@ -12,7 +12,8 @@
 
 #define YB_MBTN_EVENT_GUID     "243FEC1D-1963-41C1-8100-06A9D82A94B4"
 
-#define YB_KBD_BL_DEFAULT 128
+#define YB_KBD_BL_DEFAULT      128
+#define YB_KBD_BL_MAX          255
 
 /* flags */
 enum {
@@ -139,7 +140,7 @@ static int kbd_brightness_set(struct led_classdev *cdev,
 {
        struct yogabook_data *data = kbd_led_to_yogabook(cdev);
 
-       if ((value < 0) || (value > 255))
+       if ((value < 0) || (value > YB_KBD_BL_MAX))
                return -EINVAL;
 
        data->brightness = value;
@@ -210,7 +211,7 @@ static int yogabook_probe(struct device *dev, struct yogabook_data *data,
        data->kbd_bl_led.name = kbd_bl_led_name;
        data->kbd_bl_led.brightness_set_blocking = kbd_brightness_set;
        data->kbd_bl_led.brightness_get = kbd_brightness_get;
-       data->kbd_bl_led.max_brightness = 255;
+       data->kbd_bl_led.max_brightness = YB_KBD_BL_MAX;
 
        r = devm_led_classdev_register(dev, &data->kbd_bl_led);
        if (r < 0) {
@@ -292,7 +293,7 @@ static int yogabook_wmi_set_kbd_backlight(struct yogabook_data *data,
        input.pointer = &param;
 
        param.type = ACPI_TYPE_INTEGER;
-       param.integer.value = 255 - level;
+       param.integer.value = YB_KBD_BL_MAX - level;
 
        status = acpi_evaluate_object(acpi_device_handle(data->kbd_adev), "KBLC",
                                      &input, &output);