linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: wilco_ec: Fix keyboard backlight probing
@ 2020-01-07 18:24 Daniel Campello
  2020-01-08 10:38 ` Enric Balletbo i Serra
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Campello @ 2020-01-07 18:24 UTC (permalink / raw)
  To: LKML; +Cc: Daniel Campello, Nick Crews, Enric Balletbo i Serra, Benson Leung

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.

Signed-off-by: Daniel Campello <campello@chromium.org>
---

 .../platform/chrome/wilco_ec/keyboard_leds.c  | 28 +++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/chrome/wilco_ec/keyboard_leds.c b/drivers/platform/chrome/wilco_ec/keyboard_leds.c
index bb0edf51dfda..5731d1b60e28 100644
--- a/drivers/platform/chrome/wilco_ec/keyboard_leds.c
+++ b/drivers/platform/chrome/wilco_ec/keyboard_leds.c
@@ -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;

--
2.24.1.735.g03f4e72817-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] platform/chrome: wilco_ec: Fix keyboard backlight probing
  2020-01-07 18:24 [PATCH] platform/chrome: wilco_ec: Fix keyboard backlight probing Daniel Campello
@ 2020-01-08 10:38 ` Enric Balletbo i Serra
  2020-01-08 15:59   ` Daniel Campello
  0 siblings, 1 reply; 4+ messages in thread
From: Enric Balletbo i Serra @ 2020-01-08 10:38 UTC (permalink / raw)
  To: Daniel Campello, LKML; +Cc: Nick Crews, Benson Leung

Hi Daniel,

Many thanks for sending the patch upstream.

On 7/1/20 19:24, Daniel Campello wrote:
> 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.
> 

Could you explain a bit more which is the problem you're trying to solve? I am
not sure I understand it, isn't the kbbl_exist call for that purpose? (in
absence of the keyboard backligh module just don't init the device?)

Thanks,
 Enric


> Signed-off-by: Daniel Campello <campello@chromium.org>
> ---
> 
>  .../platform/chrome/wilco_ec/keyboard_leds.c  | 28 +++++++++++++------
>  1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/chrome/wilco_ec/keyboard_leds.c b/drivers/platform/chrome/wilco_ec/keyboard_leds.c
> index bb0edf51dfda..5731d1b60e28 100644
> --- a/drivers/platform/chrome/wilco_ec/keyboard_leds.c
> +++ b/drivers/platform/chrome/wilco_ec/keyboard_leds.c
> @@ -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;
> 
> --
> 2.24.1.735.g03f4e72817-goog
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] platform/chrome: wilco_ec: Fix keyboard backlight probing
  2020-01-08 10:38 ` Enric Balletbo i Serra
@ 2020-01-08 15:59   ` Daniel Campello
  2020-01-10 10:46     ` Enric Balletbo i Serra
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Campello @ 2020-01-08 15:59 UTC (permalink / raw)
  To: Enric Balletbo i Serra; +Cc: LKML, Nick Crews, Benson Leung

Hi Enric,

On Wed, Jan 08, 2020 at 11:38:58AM +0100, Enric Balletbo i Serra wrote:
> Hi Daniel,
>
> Many thanks for sending the patch upstream.
>
> On 7/1/20 19:24, Daniel Campello wrote:
> > 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.
> >
>
> Could you explain a bit more which is the problem you're trying to solve? I am
> not sure I understand it, isn't the kbbl_exist call for that purpose? (in
> absence of the keyboard backligh module just don't init the device?)

kbbl_exists is intended to return a bool based on response.status !=
0xFF. Without this patch kbbl_exists will fail and return an -EIO
error on any value of response.status

>
> Thanks,
>  Enric
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] platform/chrome: wilco_ec: Fix keyboard backlight probing
  2020-01-08 15:59   ` Daniel Campello
@ 2020-01-10 10:46     ` Enric Balletbo i Serra
  0 siblings, 0 replies; 4+ messages in thread
From: Enric Balletbo i Serra @ 2020-01-10 10:46 UTC (permalink / raw)
  To: Daniel Campello; +Cc: LKML, Nick Crews, Benson Leung

Hi Daniel,
On 8/1/20 16:59, Daniel Campello wrote:
> Hi Enric,
> 
> On Wed, Jan 08, 2020 at 11:38:58AM +0100, Enric Balletbo i Serra wrote:
>> Hi Daniel,
>>
>> Many thanks for sending the patch upstream.
>>
>> On 7/1/20 19:24, Daniel Campello wrote:
>>> 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.
>>>
>>
>> Could you explain a bit more which is the problem you're trying to solve? I am
>> not sure I understand it, isn't the kbbl_exist call for that purpose? (in
>> absence of the keyboard backligh module just don't init the device?)
> 
> kbbl_exists is intended to return a bool based on response.status !=
> 0xFF. Without this patch kbbl_exists will fail and return an -EIO
> error on any value of response.status
> 

Thanks for the explanation I understand now what is happening. I added the Fixed
tag and queued as a fix for chrome-platform-5.5

Thanks,
 Enric

>>
>> Thanks,
>>  Enric
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-10 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 18:24 [PATCH] platform/chrome: wilco_ec: Fix keyboard backlight probing Daniel Campello
2020-01-08 10:38 ` Enric Balletbo i Serra
2020-01-08 15:59   ` Daniel Campello
2020-01-10 10:46     ` Enric Balletbo i Serra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).