lkml.org 
[lkml]   [2020]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 3/3] usb: typec: Expose Product Type VDOs via sysfs
On Wed, Nov 18, 2020 at 06:00:59PM +0300, Heikki Krogerus wrote:
> From: Prashant Malani <pmalani@chromium.org>
>
> Interim. ABI doc missing.
>
> 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 sysfs attribute to expose these to userspace.
>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> [ heikki: Only one instead of three attribute files ]
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>'
> ---
> drivers/usb/typec/class.c | 41 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 303f054181ff7..5e135678f5952 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -165,15 +165,55 @@ 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);
> + size_t len = 0;
> + int i;
> +
> + for (i = 0; i < 3; i++) {
> + if (!id->vdo[i])
> + break;
> + len += sysfs_emit(buf, "%08x ", id->vdo[i]);
> + }
> +
> + buf[len - 1] = '\n';
> +
> + return len;
> +}

I don't understand what you are trying to print out here, documentation
would be helpful :)

> +
> +static struct device_attribute dev_attr_product_type_vdo = {
> + .attr = {
> + .name = "product_type",
> + .mode = 0444,
> + },
> + .show = product_type_vdo_show,
> +};

DEVICE_ATTR_RO(product_type_vdo)?

Why are you calling it "product_type" and not with the "vdo"?

And you have to name it this, there's always __ATTR_RO(), never put a
mode in "raw" numbers for a sysfs file if at all possible.

thanks,

greg k-h

\
 
 \ /
  Last update: 2020-11-18 16:59    [W:0.111 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site