linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: typec: Expose Product Type VDOs via sysfs
@ 2020-10-21 21:18 Prashant Malani
  2020-10-22  3:18 ` Benson Leung
  2020-10-22  5:30 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Prashant Malani @ 2020-10-21 21:18 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh
  Cc: Prashant Malani, Benson Leung, Heikki Krogerus

A PD-capable device can return up to 3 Product Type VDOs as part of its
DiscoverIdentity Response (USB PD Spec, Rev 3.0, Version 2.0, Section
6.4.4.3.1). Add a sysfs attribute to expose these to userspace.

Cc: Benson Leung <bleung@chromium.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/usb/typec/class.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 35eec707cb51..e6abb0dee9fa 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -122,10 +122,20 @@ static ssize_t product_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(product);
 
+static ssize_t product_type_vdo_show(struct device *dev, struct device_attribute *attr,
+				     char *buf)
+{
+	struct usb_pd_identity *id = get_pd_identity(dev);
+
+	return sprintf(buf, "0x%08x\n0x%08x\n0x%08x\n", id->vdo[0], id->vdo[1], id->vdo[2]);
+}
+static DEVICE_ATTR_RO(product_type_vdo);
+
 static struct attribute *usb_pd_id_attrs[] = {
 	&dev_attr_id_header.attr,
 	&dev_attr_cert_stat.attr,
 	&dev_attr_product.attr,
+	&dev_attr_product_type_vdo.attr,
 	NULL
 };
 
-- 
2.29.0.rc1.297.gfa9743e501-goog


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

* Re: [PATCH] usb: typec: Expose Product Type VDOs via sysfs
  2020-10-21 21:18 [PATCH] usb: typec: Expose Product Type VDOs via sysfs Prashant Malani
@ 2020-10-22  3:18 ` Benson Leung
  2020-10-22  5:30 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Benson Leung @ 2020-10-22  3:18 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, gregkh, Benson Leung, Heikki Krogerus

[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]

Hi Prashant,

On Wed, Oct 21, 2020 at 02:18:02PM -0700, Prashant Malani wrote:
> A PD-capable device can return up to 3 Product Type VDOs as part of its
> DiscoverIdentity Response (USB PD Spec, Rev 3.0, Version 2.0, Section
> 6.4.4.3.1). Add a sysfs attribute to expose these to userspace.
> 
> Cc: Benson Leung <bleung@chromium.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Benson Leung <bleung@chromium.org>

> ---
>  drivers/usb/typec/class.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 35eec707cb51..e6abb0dee9fa 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -122,10 +122,20 @@ static ssize_t product_show(struct device *dev, struct device_attribute *attr,
>  }
>  static DEVICE_ATTR_RO(product);
>  
> +static ssize_t product_type_vdo_show(struct device *dev, struct device_attribute *attr,
> +				     char *buf)
> +{
> +	struct usb_pd_identity *id = get_pd_identity(dev);
> +
> +	return sprintf(buf, "0x%08x\n0x%08x\n0x%08x\n", id->vdo[0], id->vdo[1], id->vdo[2]);
> +}
> +static DEVICE_ATTR_RO(product_type_vdo);
> +
>  static struct attribute *usb_pd_id_attrs[] = {
>  	&dev_attr_id_header.attr,
>  	&dev_attr_cert_stat.attr,
>  	&dev_attr_product.attr,
> +	&dev_attr_product_type_vdo.attr,
>  	NULL
>  };
>  
> -- 
> 2.29.0.rc1.297.gfa9743e501-goog
> 

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH] usb: typec: Expose Product Type VDOs via sysfs
  2020-10-21 21:18 [PATCH] usb: typec: Expose Product Type VDOs via sysfs Prashant Malani
  2020-10-22  3:18 ` Benson Leung
@ 2020-10-22  5:30 ` Greg KH
  2020-10-22  5:36   ` Prashant Malani
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2020-10-22  5:30 UTC (permalink / raw)
  To: Prashant Malani; +Cc: linux-kernel, linux-usb, Benson Leung, Heikki Krogerus

On Wed, Oct 21, 2020 at 02:18:02PM -0700, Prashant Malani wrote:
> A PD-capable device can return up to 3 Product Type VDOs as part of its
> DiscoverIdentity Response (USB PD Spec, Rev 3.0, Version 2.0, Section
> 6.4.4.3.1). Add a sysfs attribute to expose these to userspace.

You forgot to add the proper Documentation/ABI/ file at the same time,
which makes this patch impossible to review properly and able to be
applied :(

Please fix.

thanks,

greg k-h

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

* Re: [PATCH] usb: typec: Expose Product Type VDOs via sysfs
  2020-10-22  5:30 ` Greg KH
@ 2020-10-22  5:36   ` Prashant Malani
  0 siblings, 0 replies; 4+ messages in thread
From: Prashant Malani @ 2020-10-22  5:36 UTC (permalink / raw)
  To: Greg KH
  Cc: Linux Kernel Mailing List, open list:USB NETWORKING DRIVERS,
	Benson Leung, Heikki Krogerus

Hi Greg,

Thanks for taking a look.

On Wed, Oct 21, 2020 at 10:30 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Oct 21, 2020 at 02:18:02PM -0700, Prashant Malani wrote:
> > A PD-capable device can return up to 3 Product Type VDOs as part of its
> > DiscoverIdentity Response (USB PD Spec, Rev 3.0, Version 2.0, Section
> > 6.4.4.3.1). Add a sysfs attribute to expose these to userspace.
>
> You forgot to add the proper Documentation/ABI/ file at the same time,
> which makes this patch impossible to review properly and able to be
> applied :(
>
Sorry about that, will fix and resend.

Best regards,

-Prashant
> Please fix.
>
> thanks,
>
> greg k-h

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

end of thread, other threads:[~2020-10-22  5:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 21:18 [PATCH] usb: typec: Expose Product Type VDOs via sysfs Prashant Malani
2020-10-22  3:18 ` Benson Leung
2020-10-22  5:30 ` Greg KH
2020-10-22  5:36   ` Prashant Malani

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).