linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file
@ 2020-03-13 23:27 Bernardo Perez Priego
  2020-03-17  7:09 ` Enric Balletbo i Serra
  2020-04-02 22:33 ` [PATCH v2] " Bernardo Perez Priego
  0 siblings, 2 replies; 7+ messages in thread
From: Bernardo Perez Priego @ 2020-03-13 23:27 UTC (permalink / raw)
  To: Benson Leung, Enric Balletbo i Serra, Nick Crews,
	Alexandre Belloni, Daniel Campello, linux-kernel

Function 'h1_gpio_get' is receiving 'val' parameter of type u64,
this is being passed to 'send_ec_cmd' as type u8, thus, result
is stored in least significant byte. Due to output format,
the whole 'val' value was being displayed when any of the most
significant bytes are different than zero.

This fix will make sure only least significant byte is displayed
regardless of remaining bytes value.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
---
 drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
index df5a5f6c3ec6..c775b7d58c6d 100644
--- a/drivers/platform/chrome/wilco_ec/debugfs.c
+++ b/drivers/platform/chrome/wilco_ec/debugfs.c
@@ -211,7 +211,7 @@ static int h1_gpio_get(void *arg, u64 *val)
 	return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
 }
 
-DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02hhx\n");
 
 /**
  * test_event_set() - Sends command to EC to cause an EC test event.
-- 
2.17.1


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

* Re: [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file
  2020-03-13 23:27 [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file Bernardo Perez Priego
@ 2020-03-17  7:09 ` Enric Balletbo i Serra
  2020-03-23 20:06   ` Daniel Campello
  2020-04-02 22:33 ` [PATCH v2] " Bernardo Perez Priego
  1 sibling, 1 reply; 7+ messages in thread
From: Enric Balletbo i Serra @ 2020-03-17  7:09 UTC (permalink / raw)
  To: Bernardo Perez Priego, Benson Leung, Nick Crews,
	Alexandre Belloni, Daniel Campello, linux-kernel

Hi,

On 14/3/20 0:27, Bernardo Perez Priego wrote:
> Function 'h1_gpio_get' is receiving 'val' parameter of type u64,
> this is being passed to 'send_ec_cmd' as type u8, thus, result
> is stored in least significant byte. Due to output format,
> the whole 'val' value was being displayed when any of the most
> significant bytes are different than zero.
> 
> This fix will make sure only least significant byte is displayed
> regardless of remaining bytes value.
> 
> Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>

Daniel, could you give a try and give you Tested-by tag if you're fine with it?

Thanks,
 Enric

> ---
>  drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
> index df5a5f6c3ec6..c775b7d58c6d 100644
> --- a/drivers/platform/chrome/wilco_ec/debugfs.c
> +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
> @@ -211,7 +211,7 @@ static int h1_gpio_get(void *arg, u64 *val)
>  	return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
>  }
>  
> -DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02hhx\n");
>  
>  /**
>   * test_event_set() - Sends command to EC to cause an EC test event.
> 

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

* Re: [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file
  2020-03-17  7:09 ` Enric Balletbo i Serra
@ 2020-03-23 20:06   ` Daniel Campello
  2020-03-24 13:54     ` Enric Balletbo i Serra
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Campello @ 2020-03-23 20:06 UTC (permalink / raw)
  To: Enric Balletbo i Serra
  Cc: Bernardo Perez Priego, Benson Leung, Nick Crews,
	Alexandre Belloni, linux-kernel

Hello,

On Tue, Mar 17, 2020 at 1:09 AM Enric Balletbo i Serra
<enric.balletbo@collabora.com> wrote:
>
> Hi,
>
> On 14/3/20 0:27, Bernardo Perez Priego wrote:
> > Function 'h1_gpio_get' is receiving 'val' parameter of type u64,
> > this is being passed to 'send_ec_cmd' as type u8, thus, result
> > is stored in least significant byte. Due to output format,
> > the whole 'val' value was being displayed when any of the most
> > significant bytes are different than zero.
> >
> > This fix will make sure only least significant byte is displayed
> > regardless of remaining bytes value.
> >
> > Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
>
> Daniel, could you give a try and give you Tested-by tag if you're fine with it?
>
> Thanks,
>  Enric
>
> > ---
> >  drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
> > index df5a5f6c3ec6..c775b7d58c6d 100644
> > --- a/drivers/platform/chrome/wilco_ec/debugfs.c
> > +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
> > @@ -211,7 +211,7 @@ static int h1_gpio_get(void *arg, u64 *val)
> >       return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
> >  }
> >
> > -DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
> > +DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02hhx\n");
> >
> >  /**
> >   * test_event_set() - Sends command to EC to cause an EC test event.
> >

Done. I also found the chromium review for this on crrev.com/c/2090128

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

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

* Re: [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file
  2020-03-23 20:06   ` Daniel Campello
@ 2020-03-24 13:54     ` Enric Balletbo i Serra
  2020-03-27 17:24       ` Enric Balletbo i Serra
  0 siblings, 1 reply; 7+ messages in thread
From: Enric Balletbo i Serra @ 2020-03-24 13:54 UTC (permalink / raw)
  To: Daniel Campello
  Cc: Bernardo Perez Priego, Benson Leung, Nick Crews,
	Alexandre Belloni, linux-kernel

Hi,

On 23/3/20 21:06, Daniel Campello wrote:
> Hello,
> 
> On Tue, Mar 17, 2020 at 1:09 AM Enric Balletbo i Serra
> <enric.balletbo@collabora.com> wrote:
>>
>> Hi,
>>
>> On 14/3/20 0:27, Bernardo Perez Priego wrote:
>>> Function 'h1_gpio_get' is receiving 'val' parameter of type u64,
>>> this is being passed to 'send_ec_cmd' as type u8, thus, result
>>> is stored in least significant byte. Due to output format,
>>> the whole 'val' value was being displayed when any of the most
>>> significant bytes are different than zero.
>>>
>>> This fix will make sure only least significant byte is displayed
>>> regardless of remaining bytes value.
>>>
>>> Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
>>
>> Daniel, could you give a try and give you Tested-by tag if you're fine with it?
>>
>> Thanks,
>>  Enric
>>
>>> ---
>>>  drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
>>> index df5a5f6c3ec6..c775b7d58c6d 100644
>>> --- a/drivers/platform/chrome/wilco_ec/debugfs.c
>>> +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
>>> @@ -211,7 +211,7 @@ static int h1_gpio_get(void *arg, u64 *val)
>>>       return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
>>>  }
>>>
>>> -DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02hhx\n");
>>>
>>>  /**
>>>   * test_event_set() - Sends command to EC to cause an EC test event.
>>>
> 
> Done. I also found the chromium review for this on crrev.com/c/2090128
> 
> Tested-by: Daniel Campello <campello@chromium.org>
> 

Queued for 5.7. Thanks.

~ Enric

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

* Re: [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file
  2020-03-24 13:54     ` Enric Balletbo i Serra
@ 2020-03-27 17:24       ` Enric Balletbo i Serra
  0 siblings, 0 replies; 7+ messages in thread
From: Enric Balletbo i Serra @ 2020-03-27 17:24 UTC (permalink / raw)
  To: Daniel Campello
  Cc: Bernardo Perez Priego, Benson Leung, Nick Crews,
	Alexandre Belloni, linux-kernel

Hi Bernardo,

On 24/3/20 14:54, Enric Balletbo i Serra wrote:
> Hi,
> 
> On 23/3/20 21:06, Daniel Campello wrote:
>> Hello,
>>
>> On Tue, Mar 17, 2020 at 1:09 AM Enric Balletbo i Serra
>> <enric.balletbo@collabora.com> wrote:
>>>
>>> Hi,
>>>
>>> On 14/3/20 0:27, Bernardo Perez Priego wrote:
>>>> Function 'h1_gpio_get' is receiving 'val' parameter of type u64,
>>>> this is being passed to 'send_ec_cmd' as type u8, thus, result
>>>> is stored in least significant byte. Due to output format,
>>>> the whole 'val' value was being displayed when any of the most
>>>> significant bytes are different than zero.
>>>>
>>>> This fix will make sure only least significant byte is displayed
>>>> regardless of remaining bytes value.
>>>>
>>>> Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
>>>
>>> Daniel, could you give a try and give you Tested-by tag if you're fine with it?
>>>
>>> Thanks,
>>>  Enric
>>>
>>>> ---
>>>>  drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
>>>> index df5a5f6c3ec6..c775b7d58c6d 100644
>>>> --- a/drivers/platform/chrome/wilco_ec/debugfs.c
>>>> +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
>>>> @@ -211,7 +211,7 @@ static int h1_gpio_get(void *arg, u64 *val)
>>>>       return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
>>>>  }
>>>>
>>>> -DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
>>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02hhx\n");
>>>>
>>>>  /**
>>>>   * test_event_set() - Sends command to EC to cause an EC test event.
>>>>
>>
>> Done. I also found the chromium review for this on crrev.com/c/2090128
>>
>> Tested-by: Daniel Campello <campello@chromium.org>
>>
> 
> Queued for 5.7. Thanks.
> 


I removed the patch from the queue as it triggers the following build warning:

drivers/platform/chrome/wilco_ec/debugfs.c:214:59: warning: format ‘%hhx’
expects argument of type ‘int’, but argument 2 has type ‘long long unsigned int’
[-Wformat=]

Thanks,
Enric

> ~ Enric
> 

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

* [PATCH v2] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file
  2020-03-13 23:27 [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file Bernardo Perez Priego
  2020-03-17  7:09 ` Enric Balletbo i Serra
@ 2020-04-02 22:33 ` Bernardo Perez Priego
  2020-04-14 13:14   ` Enric Balletbo i Serra
  1 sibling, 1 reply; 7+ messages in thread
From: Bernardo Perez Priego @ 2020-04-02 22:33 UTC (permalink / raw)
  To: Benson Leung, Enric Balletbo i Serra, Nick Crews,
	Alexandre Belloni, Daniel Campello, linux-kernel

Function 'h1_gpio_get' is receiving 'val' parameter of type u64,
this is being passed to 'send_ec_cmd' as type u8, thus, result
is stored in least significant byte. Due to output format,
the whole 'val' value was being displayed when any of the most
significant bytes are different than zero.

This fix will make sure only least significant byte is displayed
regardless of remaining bytes value.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
---
Changes in v2:
- Keep original format and apply mask instead to resolve warning

 drivers/platform/chrome/wilco_ec/debugfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
index df5a5f6c3ec6..a812788a0bdc 100644
--- a/drivers/platform/chrome/wilco_ec/debugfs.c
+++ b/drivers/platform/chrome/wilco_ec/debugfs.c
@@ -208,7 +208,12 @@ static int send_ec_cmd(struct wilco_ec_device *ec, u8 sub_cmd, u8 *out_val)
  */
 static int h1_gpio_get(void *arg, u64 *val)
 {
-	return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
+	int ret;
+
+	ret = send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
+	if (ret == 0)
+		*val &= 0xFF;
+	return ret;
 }
 
 DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
-- 
2.17.1


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

* Re: [PATCH v2] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file
  2020-04-02 22:33 ` [PATCH v2] " Bernardo Perez Priego
@ 2020-04-14 13:14   ` Enric Balletbo i Serra
  0 siblings, 0 replies; 7+ messages in thread
From: Enric Balletbo i Serra @ 2020-04-14 13:14 UTC (permalink / raw)
  To: Bernardo Perez Priego, Benson Leung, Nick Crews,
	Alexandre Belloni, Daniel Campello, linux-kernel

Hi Bernardo,

Thank you for your patch.

On 3/4/20 0:33, Bernardo Perez Priego wrote:
> Function 'h1_gpio_get' is receiving 'val' parameter of type u64,
> this is being passed to 'send_ec_cmd' as type u8, thus, result
> is stored in least significant byte. Due to output format,
> the whole 'val' value was being displayed when any of the most
> significant bytes are different than zero.
> 
> This fix will make sure only least significant byte is displayed
> regardless of remaining bytes value.
> 
> Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
> ---

Applied for 5.8

> Changes in v2:
> - Keep original format and apply mask instead to resolve warning
> 
>  drivers/platform/chrome/wilco_ec/debugfs.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
> index df5a5f6c3ec6..a812788a0bdc 100644
> --- a/drivers/platform/chrome/wilco_ec/debugfs.c
> +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
> @@ -208,7 +208,12 @@ static int send_ec_cmd(struct wilco_ec_device *ec, u8 sub_cmd, u8 *out_val)
>   */
>  static int h1_gpio_get(void *arg, u64 *val)
>  {
> -	return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
> +	int ret;
> +
> +	ret = send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
> +	if (ret == 0)
> +		*val &= 0xFF;
> +	return ret;
>  }
>  
>  DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
> 

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

end of thread, other threads:[~2020-04-14 13:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 23:27 [PATCH] platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file Bernardo Perez Priego
2020-03-17  7:09 ` Enric Balletbo i Serra
2020-03-23 20:06   ` Daniel Campello
2020-03-24 13:54     ` Enric Balletbo i Serra
2020-03-27 17:24       ` Enric Balletbo i Serra
2020-04-02 22:33 ` [PATCH v2] " Bernardo Perez Priego
2020-04-14 13:14   ` 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).