lkml.org 
[lkml]   [2016]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 1/2] usb: USB Type-C connector class
On Wed, Aug 17, 2016 at 3:53 PM, Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
> 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".
>

Ah, makes sense.

Thanks,
Frans

\
 
 \ /
  Last update: 2016-09-17 09:57    [W:0.057 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site