Skip to contentSkip to conversation

platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file

PATCH Applied Bernardo Perez Priego 3 participants 7 messages Mar 13, 2020 – Apr 14, 2020 Chrome hardware platform support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file

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.

---
 drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/wilco_ec/debugfs.c +1 -1
index df5a5f6c3ec6..c775b7d58c6d 100644
@@ -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.
Signature · 1 line
2.17.1
#1 lore raw

Hi,

Quoted 10 lines · Bernardo Perez Priego

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.

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

Thanks,
Enric

Quoted 18 lines
---
 drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/wilco_ec/debugfs.c +1 -1
index df5a5f6c3ec6..c775b7d58c6d 100644
@@ -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.
Tested-by
#2 lore raw

Hello,

Quoted 32 lines · Enric Balletbo i Serra

Hi,

Quoted 10 lines · Bernardo Perez Priego

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.

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

Thanks,
Enric

Quoted 12 lines
---
 drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/wilco_ec/debugfs.c +0 -0
index df5a5f6c3ec6..c775b7d58c6d 100644
@@ -211,7 +211,7 @@ static int h1_gpio_get(void *arg, u64 *val)
      return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
 }
 
Quoted 6 lines

drivers/platform/chrome/wilco_ec/debugfs.c static int h1_gpio_get(void *arg, u64 *val) · line 217

Quoted 6 lines
drivers/platform/chrome/wilco_ec/debugfs.c +1 -1
-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

#3 lore raw

Hi,

Quoted 39 lines · Daniel Campello

Hello,

Quoted 35 lines · Enric Balletbo i Serra

Hi,

Quoted 10 lines · Bernardo Perez Priego

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.

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

Thanks,
Enric

Quoted 15 lines
---
 drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/wilco_ec/debugfs.c +1 -1
index df5a5f6c3ec6..c775b7d58c6d 100644
@@ -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");
 
Quoted 8 lines
Quoted 3 lines

drivers/platform/chrome/wilco_ec/debugfs.c static int h1_gpio_get(void *arg, u64 *val) · line 217

Quoted 3 lines
drivers/platform/chrome/wilco_ec/debugfs.c +0 -0
 /**
  * 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

Queued for 5.7. Thanks.

~ Enric

#4 lore raw

Hi Bernardo,

Quoted 48 lines · Enric Balletbo i Serra

Hi,

Quoted 45 lines · Daniel Campello

Hello,

Quoted 32 lines · Enric Balletbo i Serra

Hi,

Quoted 10 lines · Bernardo Perez Priego

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.

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

Thanks,
Enric

Quoted 12 lines
---
 drivers/platform/chrome/wilco_ec/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/wilco_ec/debugfs.c +0 -0
index df5a5f6c3ec6..c775b7d58c6d 100644
@@ -211,7 +211,7 @@ static int h1_gpio_get(void *arg, u64 *val)
      return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
 }
 
Quoted 6 lines

drivers/platform/chrome/wilco_ec/debugfs.c static int h1_gpio_get(void *arg, u64 *val) · line 217

Quoted 6 lines
drivers/platform/chrome/wilco_ec/debugfs.c +1 -1
-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

Quoted 5 lines
Quoted 2 lines

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

Quoted 2 lines

~ Enric

#5 lore raw

PATCH v2 1/1 platform/chrome: wilco_ec: Provide correct output format to 'h1_gpio' file

In reply to Bernardo Perez Priego

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.

---
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(-)
drivers/platform/chrome/wilco_ec/debugfs.c +6 -1
index df5a5f6c3ec6..a812788a0bdc 100644
@@ -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");
Signature · 1 line
2.17.1
#6 lore raw

Hi Bernardo,

Thank you for your patch.

Quoted 11 lines · Bernardo Perez Priego

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.

---

Applied for 5.8

Quoted 25 lines

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(-)
drivers/platform/chrome/wilco_ec/debugfs.c +6 -1
index df5a5f6c3ec6..a812788a0bdc 100644
@@ -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");