Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754665Ab3GJWSP (ORCPT ); Wed, 10 Jul 2013 18:18:15 -0400 Received: from mail-pb0-f53.google.com ([209.85.160.53]:33127 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754110Ab3GJWSO (ORCPT ); Wed, 10 Jul 2013 18:18:14 -0400 Date: Wed, 10 Jul 2013 15:18:12 -0700 From: Guenter Roeck To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, oliver+list@schinagl.nl, khali@linux-fr.org Subject: Re: [PATCH 7/6] driver core: add default groups to struct class Message-ID: <20130710221812.GA22366@roeck-us.net> References: <1373486714-14531-1-git-send-email-gregkh@linuxfoundation.org> <20130710220531.GA4210@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130710220531.GA4210@kroah.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2728 Lines: 77 On Wed, Jul 10, 2013 at 03:05:31PM -0700, Greg Kroah-Hartman wrote: > > We should be using groups, not attribute lists, for classes to allow > subdirectories, and soon, binary files. Groups are just more flexible > overall, so add them. > > The dev_attrs list will go away after all in-kernel users are converted > to use dev_groups. > > Signed-off-by: Greg Kroah-Hartman Nice one ... that solves my problem. Thanks! Guenter > --- > Forgot this one in the series, it adds support to classes for groups, so > that we can handle binary attributes properly for them as well. > > drivers/base/core.c | 8 +++++++- > include/linux/device.h | 4 +++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -528,9 +528,12 @@ static int device_add_attrs(struct devic > int error; > > if (class) { > - error = device_add_attributes(dev, class->dev_attrs); > + error = device_add_groups(dev, class->dev_groups); > if (error) > return error; > + error = device_add_attributes(dev, class->dev_attrs); > + if (error) > + goto err_remove_class_groups; > error = device_add_bin_attributes(dev, class->dev_bin_attrs); > if (error) > goto err_remove_class_attrs; > @@ -563,6 +566,9 @@ static int device_add_attrs(struct devic > err_remove_class_attrs: > if (class) > device_remove_attributes(dev, class->dev_attrs); > + err_remove_class_groups: > + if (class) > + device_remove_groups(dev, class->dev_groups); > > return error; > } > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -313,6 +313,7 @@ int subsys_virtual_register(struct bus_t > * @name: Name of the class. > * @owner: The module owner. > * @class_attrs: Default attributes of this class. > + * @dev_groups: Default attributes of the devices that belong to the class. > * @dev_attrs: Default attributes of the devices belong to the class. > * @dev_bin_attrs: Default binary attributes of the devices belong to the class. > * @dev_kobj: The kobject that represents this class and links it into the hierarchy. > @@ -342,7 +343,8 @@ struct class { > struct module *owner; > > struct class_attribute *class_attrs; > - struct device_attribute *dev_attrs; > + struct device_attribute *dev_attrs; /* use dev_groups instead */ > + const struct attribute_group **dev_groups; > struct bin_attribute *dev_bin_attrs; > struct kobject *dev_kobj; > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/