Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1464595
| From | Heikki Krogerus <heikki.krogerus@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v5 1/2] usb: USB Type-C connector class |
| Date | 2016-08-17 16:00 +0200 |
| Message-ID | <s79xT-1My-17@gated-at.bofh.it> (permalink) |
| References | <s76ql-8dD-9@gated-at.bofh.it> <s76ql-8dD-7@gated-at.bofh.it> <s78Vc-1vG-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi,
On Wed, Aug 17, 2016 at 03:14:03PM +0200, Frans Klaver wrote:
> On Wed, Aug 17, 2016 at 12:34 PM, Heikki Krogerus
> > +static const char * const typec_partner_types[] = {
> > + [TYPEC_PARTNER_USB] = "USB",
> > + [TYPEC_PARTNER_CHARGER] = "Charger",
> > + [TYPEC_PARTNER_ALTMODE] = "Alternate Mode",
> > + [TYPEC_PARTNER_ACCESSORY] = "Accessory",
> > +};
> > +
> > +static ssize_t partner_type_show(struct device *dev,
> > + struct device_attribute *attr, char *buf)
> > +{
> > + struct typec_partner *partner = container_of(dev, struct typec_partner,
> > + dev);
> > +
> > + return sprintf(buf, "%s\n", typec_partner_types[partner->type]);
> > +}
> > +
> > +static struct device_attribute dev_attr_partner_type = {
> > + .attr = {
> > + .name = "type",
> > + .mode = S_IRUGO,
> > + },
> > + .show = partner_type_show,
> > +};
>
> Why not use DEVICE_ATTR_RO() for this?
Because I don't want to tie the attribute names to the function names
in this case. There are other *type* attributes being created in the
driver, so type_show() is not good, and we can't name the attribute
"partner_type". The attribute will be placed in group named "partner".
> > +
> > +static ssize_t
> > +partner_accessory_mode_show(struct device *dev, struct device_attribute *attr,
> > + char *buf)
> > +{
> > + struct typec_partner *partner = container_of(dev, struct typec_partner,
> > + dev);
> > +
> > + return sprintf(buf, "%s\n", typec_accessory_modes[partner->accessory]);
> > +}
> > +
> > +static struct device_attribute dev_attr_partner_accessory = {
> > + .attr = {
> > + .name = "accessory",
> > + .mode = S_IRUGO,
> > + },
> > + .show = partner_accessory_mode_show,
> > +};
>
> And this
Ditto.
Thanks,
--
heikki
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 0/2] USB Type-C Connector class Heikki Krogerus <heikki.krogerus@linux.intel.com> - 2016-08-17 12:40 +0200
[PATCH v5 2/2] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY Heikki Krogerus <heikki.krogerus@linux.intel.com> - 2016-08-17 12:40 +0200
Re: [PATCH v5 2/2] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY Felipe Balbi <felipe.balbi@linux.intel.com> - 2016-08-17 15:00 +0200
Re: [PATCH v5 2/2] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY Heikki Krogerus <heikki.krogerus@linux.intel.com> - 2016-08-17 15:40 +0200
Re: [PATCH v5 2/2] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY Peter Chen <hzpeterchen@gmail.com> - 2016-08-18 02:20 +0200
Re: [PATCH v5 2/2] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY Felipe Balbi <felipe.balbi@linux.intel.com> - 2016-08-18 08:40 +0200
Re: [PATCH v5 2/2] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY Guenter Roeck <linux@roeck-us.net> - 2016-08-18 15:40 +0200
Re: [PATCH v5 1/2] usb: USB Type-C connector class Frans Klaver <fransklaver@gmail.com> - 2016-08-17 15:20 +0200
Re: [PATCH v5 1/2] usb: USB Type-C connector class Heikki Krogerus <heikki.krogerus@linux.intel.com> - 2016-08-17 16:00 +0200
Re: [PATCH v5 1/2] usb: USB Type-C connector class Frans Klaver <fransklaver@gmail.com> - 2016-08-17 16:10 +0200
Re: [PATCH v5 1/2] usb: USB Type-C connector class Guenter Roeck <linux@roeck-us.net> - 2016-08-17 20:00 +0200
Re: [PATCH v5 1/2] usb: USB Type-C connector class Heikki Krogerus <heikki.krogerus@linux.intel.com> - 2016-08-18 12:50 +0200
Re: [PATCH v5 1/2] usb: USB Type-C connector class Guenter Roeck <linux@roeck-us.net> - 2016-08-17 20:00 +0200
Re: [PATCH v5 1/2] usb: USB Type-C connector class Heikki Krogerus <heikki.krogerus@linux.intel.com> - 2016-08-18 12:50 +0200
csiph-web