]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
platform/chrome: wilco_ec: Fix keyboard backlight probing
authorDaniel Campello <campello@chromium.org>
Tue, 7 Jan 2020 18:24:21 +0000 (11:24 -0700)
committerBenson Leung <bleung@chromium.org>
Fri, 10 Jan 2020 22:57:58 +0000 (14:57 -0800)
The EC on the Wilco platform responds with 0xFF to commands related to
the keyboard backlight on the absence of a keyboard backlight module.
This change allows the EC driver to continue loading even if the
backlight module is not present.

Fixes: 119a3cb6d687 ("platform/chrome: wilco_ec: Add keyboard backlight LED support")
Signed-off-by: Daniel Campello <campello@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Benson Leung <bleung@chromium.org>
drivers/platform/chrome/wilco_ec/keyboard_leds.c

index bb0edf51dfda4cf96bd5c7f5496ba213163e5468..5731d1b60e28a4d4e9b8a82b98310ff706a7cccf 100644 (file)
@@ -73,13 +73,6 @@ static int send_kbbl_msg(struct wilco_ec_device *ec,
                return ret;
        }
 
-       if (response->status) {
-               dev_err(ec->dev,
-                       "EC reported failure sending keyboard LEDs command: %d",
-                       response->status);
-               return -EIO;
-       }
-
        return 0;
 }
 
@@ -87,6 +80,7 @@ static int set_kbbl(struct wilco_ec_device *ec, enum led_brightness brightness)
 {
        struct wilco_keyboard_leds_msg request;
        struct wilco_keyboard_leds_msg response;
+       int ret;
 
        memset(&request, 0, sizeof(request));
        request.command = WILCO_EC_COMMAND_KBBL;
@@ -94,7 +88,18 @@ static int set_kbbl(struct wilco_ec_device *ec, enum led_brightness brightness)
        request.mode    = WILCO_KBBL_MODE_FLAG_PWM;
        request.percent = brightness;
 
-       return send_kbbl_msg(ec, &request, &response);
+       ret = send_kbbl_msg(ec, &request, &response);
+       if (ret < 0)
+               return ret;
+
+       if (response.status) {
+               dev_err(ec->dev,
+                       "EC reported failure sending keyboard LEDs command: %d",
+                       response.status);
+               return -EIO;
+       }
+
+       return 0;
 }
 
 static int kbbl_exist(struct wilco_ec_device *ec, bool *exists)
@@ -140,6 +145,13 @@ static int kbbl_init(struct wilco_ec_device *ec)
        if (ret < 0)
                return ret;
 
+       if (response.status) {
+               dev_err(ec->dev,
+                       "EC reported failure sending keyboard LEDs command: %d",
+                       response.status);
+               return -EIO;
+       }
+
        if (response.mode & WILCO_KBBL_MODE_FLAG_PWM)
                return response.percent;