From 1ed8459d8f1060c87c7d66fe2d3cbbe4bc9cdd24 Mon Sep 17 00:00:00 2001 From: Benson Leung Date: Thu, 28 Jan 2021 22:14:01 -0800 Subject: usb: typec: Standardize PD Revision format with Type-C Revision The Type-C Revision was in a specific BCD format "0120H" for 1.2. USB PD revision numbers follow a similar pattern with "0300H" for 3.0. Standardizes the sysfs format for usb_power_delivery_revision to align with the BCD format used for usb_typec_revision. Example values: - "2.0": USB Power Delivery Release 2.0 - "3.0": USB Power Delivery Release 3.0 - "3.1": USB Power Delivery Release 3.1 Reviewed-by: Heikki Krogerus Signed-off-by: Benson Leung Link: https://lore.kernel.org/r/20210129061406.2680146-2-bleung@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/class.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 8f77669f9cf4..4f60ee7ba76a 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1500,8 +1500,9 @@ static ssize_t usb_power_delivery_revision_show(struct device *dev, char *buf) { struct typec_port *p = to_typec_port(dev); + u16 rev = p->cap->pd_revision; - return sprintf(buf, "%d\n", (p->cap->pd_revision >> 8) & 0xff); + return sprintf(buf, "%d.%d\n", (rev >> 8) & 0xff, (rev >> 4) & 0xf); } static DEVICE_ATTR_RO(usb_power_delivery_revision); -- cgit v1.2.3