From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Prashant Malani <pmalani@chromium.org>,
Benson Leung <bleung@chromium.org>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [RFC PATCH 3/3] usb: typec: Expose Product Type VDOs via sysfs
Date: Thu, 19 Nov 2020 14:11:07 +0200 [thread overview]
Message-ID: <20201119121107.GD3774817@kuha.fi.intel.com> (raw)
In-Reply-To: <X7VESebL4CnS45hv@kroah.com>
On Wed, Nov 18, 2020 at 04:56:57PM +0100, Greg Kroah-Hartman wrote:
> 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.
Sorry Greg. This is still work-in-progress.
I didn't use the _vdo ending in the file name because the other files
exposing the other parts (VDOs) of the response to the discover
identity don't have it either.
thanks,
--
heikki
next prev parent reply other threads:[~2020-11-19 12:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 15:00 [RFC PATCH 0/3] usb: typec: Product Type time Heikki Krogerus
2020-11-18 15:00 ` [RFC PATCH 1/3] usb: pd: DFP product types Heikki Krogerus
2020-11-18 15:00 ` [RFC PATCH 2/3] usb: typec: Add product_type sysfs attribute file for partners and cables Heikki Krogerus
2020-11-18 15:57 ` Greg Kroah-Hartman
2020-11-18 17:48 ` Benson Leung
2020-11-19 11:11 ` Heikki Krogerus
2020-11-18 18:53 ` Prashant Malani
2020-11-19 11:05 ` Heikki Krogerus
2020-11-19 11:11 ` Prashant Malani
2020-11-19 14:12 ` Heikki Krogerus
2020-11-18 15:00 ` [RFC PATCH 3/3] usb: typec: Expose Product Type VDOs via sysfs Heikki Krogerus
2020-11-18 15:56 ` Greg Kroah-Hartman
2020-11-19 12:11 ` Heikki Krogerus [this message]
2020-11-18 18:39 ` [RFC PATCH 0/3] usb: typec: Product Type time Prashant Malani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201119121107.GD3774817@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=bleung@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pmalani@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).