From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752975AbcHQOAp (ORCPT ); Wed, 17 Aug 2016 10:00:45 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36452 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751495AbcHQOAn (ORCPT ); Wed, 17 Aug 2016 10:00:43 -0400 MIME-Version: 1.0 In-Reply-To: <20160817135318.GT9927@kuha.fi.intel.com> References: <1471430081-12860-1-git-send-email-heikki.krogerus@linux.intel.com> <1471430081-12860-2-git-send-email-heikki.krogerus@linux.intel.com> <20160817135318.GT9927@kuha.fi.intel.com> From: Frans Klaver Date: Wed, 17 Aug 2016 16:00:41 +0200 Message-ID: Subject: Re: [PATCH v5 1/2] usb: USB Type-C connector class To: Heikki Krogerus Cc: Greg KH , Guenter Roeck , Oliver Neukum , Felipe Balbi , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 17, 2016 at 3:53 PM, Heikki Krogerus 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