Skip to contentSkip to conversation

usb: typec: Fix fast_role_swap_current show function

PATCH Superseded Pavan Holla 5 participants 8 messages Jun 5, 2023 – Jun 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: Fix fast_role_swap_current show function

The current implementation mistakenly performs a & operation on the output of sysfs_emit. This patch performs the & operation before calling sysfs_emit.

Series-to: LKML <[email protected]>

---
 drivers/usb/typec/pd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/pd.c +1 -1
index 0bcde1ff4d39..8cc66e4467c4 100644
@@ -95,7 +95,7 @@ peak_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 static ssize_t
 fast_role_swap_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	return sysfs_emit(buf, "%u\n", to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3;
+	return sysfs_emit(buf, "%u\n", (to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3);
 }
 static DEVICE_ATTR_RO(fast_role_swap_current);
 
Signature · 1 line
2.41.0.rc0.172.g3f132b7071-goog
Reviewed-by on v1 1/1
#1 lore raw

Hi Pavan,

Quoted 7 lines · Pavan Holla

The current implementation mistakenly performs a & operation on the output of sysfs_emit. This patch performs the & operation before calling sysfs_emit.

Series-to: LKML <[email protected]>

Thanks!
Benson

Quoted 20 lines
---
 drivers/usb/typec/pd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/pd.c +1 -2
index 0bcde1ff4d39..8cc66e4467c4 100644
@@ -95,7 +95,7 @@ peak_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 static ssize_t
 fast_role_swap_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       return sysfs_emit(buf, "%u\n", to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3;
+       return sysfs_emit(buf, "%u\n", (to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3);
 }
 static DEVICE_ATTR_RO(fast_role_swap_current);
 
--

2.41.0.rc0.172.g3f132b7071-goog

Signature · 7 lines
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]
#2 lore raw
In reply to Pavan Holla
Quoted 5 lines · Pavan Holla

The current implementation mistakenly performs a & operation on the output of sysfs_emit. This patch performs the & operation before calling sysfs_emit.

Series-to: LKML <[email protected]>

What is this line for?

What commit id does this fix?

thanks,

greg k-h

#3 lore raw
Quoted 10 lines · Greg Kroah-Hartman
Quoted 5 lines · Pavan Holla

The current implementation mistakenly performs a & operation on the output of sysfs_emit. This patch performs the & operation before calling sysfs_emit.

Series-to: LKML <[email protected]>

What is this line for?

Sorry, this was intended for a tool that simplifies git send-email. I ended up not using the tool, but forgot to delete the tag.

Quoted 2 lines

What commit id does this fix?

Fixes 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")
Quoted 3 lines

thanks,

greg k-h

Please look out for V2 of this patch.

Thanks,
Pavan

#4 lore raw

PATCH v2 1/1 usb: typec: Fix fast_role_swap_current show function

In reply to Greg Kroah-Hartman

The current implementation mistakenly performs a & operation on the output of sysfs_emit. This patch performs the & operation before calling sysfs_emit.

Fixes 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")
---
 drivers/usb/typec/pd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/pd.c +1 -1
index 0bcde1ff4d39..8cc66e4467c4 100644
@@ -95,7 +95,7 @@ peak_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 static ssize_t
 fast_role_swap_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	return sysfs_emit(buf, "%u\n", to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3;
+	return sysfs_emit(buf, "%u\n", (to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3);
 }
 static DEVICE_ATTR_RO(fast_role_swap_current);
 
Signature · 1 line
2.41.0.rc0.172.g3f132b7071-goog
maintainer Reviewed-by on v2 1/1
#5 lore raw
Quoted 7 lines · Pavan Holla

The current implementation mistakenly performs a & operation on the output of sysfs_emit. This patch performs the & operation before calling sysfs_emit.

Fixes 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")
Quoted 19 lines
---
 drivers/usb/typec/pd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/pd.c +1 -1
index 0bcde1ff4d39..8cc66e4467c4 100644
@@ -95,7 +95,7 @@ peak_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 static ssize_t
 fast_role_swap_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	return sysfs_emit(buf, "%u\n", to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3;
+	return sysfs_emit(buf, "%u\n", (to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3);
 }
 static DEVICE_ATTR_RO(fast_role_swap_current);
 
Signature · 1 line
2.41.0.rc0.172.g3f132b7071-goog
Signature · 1 line
heikki
Reviewed-by on v2 1/1
#6 lore raw
In reply to Pavan Holla

Hi Pavan,

Quoted 8 lines · Pavan Holla

The current implementation mistakenly performs a & operation on the output of sysfs_emit. This patch performs the & operation before calling sysfs_emit.

Fixes 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")
Quoted 20 lines
---
 drivers/usb/typec/pd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/pd.c +1 -2
index 0bcde1ff4d39..8cc66e4467c4 100644
@@ -95,7 +95,7 @@ peak_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 static ssize_t
 fast_role_swap_current_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       return sysfs_emit(buf, "%u\n", to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3;
+       return sysfs_emit(buf, "%u\n", (to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3);
 }
 static DEVICE_ATTR_RO(fast_role_swap_current);
 
--

2.41.0.rc0.172.g3f132b7071-goog

Signature · 7 lines
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]