lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Aug 2016 16:53:18 +0300
From:	Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To:	Frans Klaver <fransklaver@...il.com>
Cc:	Greg KH <gregkh@...uxfoundation.org>,
	Guenter Roeck <linux@...ck-us.net>,
	Oliver Neukum <oneukum@...e.com>,
	Felipe Balbi <felipe.balbi@...ux.intel.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>
Subject: Re: [PATCH v5 1/2] usb: USB Type-C connector class

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ