public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: userspace: use sysfs_create_group
@ 2009-08-09 18:01 Felipe Balbi
  2009-08-09 18:24 ` Mark Brown
  2009-08-10  5:20 ` Mike Rapoport
  0 siblings, 2 replies; 6+ messages in thread
From: Felipe Balbi @ 2009-08-09 18:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood, Mike Rapoport, Felipe Balbi

Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
 drivers/regulator/userspace-consumer.c |   44 ++++++++++++++++----------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
index 06d2fa9..a7e8e0b 100644
--- a/drivers/regulator/userspace-consumer.c
+++ b/drivers/regulator/userspace-consumer.c
@@ -93,16 +93,20 @@ static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR(name, 0444, reg_show_name, NULL);
 static DEVICE_ATTR(state, 0644, reg_show_state, reg_set_state);
 
-static struct device_attribute *attributes[] = {
-	&dev_attr_name,
-	&dev_attr_state,
+static struct attribute *attributes[] = {
+	&dev_attr_name.attr,
+	&dev_attr_state.attr,
+};
+
+static const struct attribute_group attr_group = {
+	.attrs	= attributes,
 };
 
 static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 {
 	struct regulator_userspace_consumer_data *pdata;
 	struct userspace_consumer_data *drvdata;
-	int ret, i;
+	int ret;
 
 	pdata = pdev->dev.platform_data;
 	if (!pdata)
@@ -125,31 +129,29 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 		goto err_alloc_supplies;
 	}
 
-	for (i = 0; i < ARRAY_SIZE(attributes); i++) {
-		ret = device_create_file(&pdev->dev, attributes[i]);
-		if (ret != 0)
-			goto err_create_attrs;
-	}
+	ret = sysfs_create_group(&pdev->dev.kobj, &attr_group);
+	if (ret != 0)
+		goto err_create_attrs;
 
-	if (pdata->init_on)
+	if (pdata->init_on) {
 		ret = regulator_bulk_enable(drvdata->num_supplies,
 					    drvdata->supplies);
-
-	drvdata->enabled = pdata->init_on;
-
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to set initial state: %d\n", ret);
-		goto err_create_attrs;
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Failed to set initial state: %d\n", ret);
+			goto err_enable;
+		}
 	}
 
+	drvdata->enabled = pdata->init_on;
 	platform_set_drvdata(pdev, drvdata);
 
 	return 0;
 
-err_create_attrs:
-	for (i = 0; i < ARRAY_SIZE(attributes); i++)
-		device_remove_file(&pdev->dev, attributes[i]);
+err_enable:
+	sysfs_remove_group(&pdev->dev.kobj, &attr_group);
 
+err_create_attrs:
 	regulator_bulk_free(drvdata->num_supplies, drvdata->supplies);
 
 err_alloc_supplies:
@@ -160,10 +162,8 @@ err_alloc_supplies:
 static int regulator_userspace_consumer_remove(struct platform_device *pdev)
 {
 	struct userspace_consumer_data *data = platform_get_drvdata(pdev);
-	int i;
 
-	for (i = 0; i < ARRAY_SIZE(attributes); i++)
-		device_remove_file(&pdev->dev, attributes[i]);
+	sysfs_remove_group(&pdev->dev.kobj, &attr_group);
 
 	if (data->enabled)
 		regulator_bulk_disable(data->num_supplies, data->supplies);
-- 
1.6.4.rc1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: userspace: use sysfs_create_group
  2009-08-09 18:01 [PATCH] regulator: userspace: use sysfs_create_group Felipe Balbi
@ 2009-08-09 18:24 ` Mark Brown
  2009-08-10  5:20 ` Mike Rapoport
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2009-08-09 18:24 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: linux-kernel, Liam Girdwood, Mike Rapoport

On Sun, Aug 09, 2009 at 09:01:25PM +0300, Felipe Balbi wrote:
> Signed-off-by: Felipe Balbi <me@felipebalbi.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: userspace: use sysfs_create_group
  2009-08-09 18:01 [PATCH] regulator: userspace: use sysfs_create_group Felipe Balbi
  2009-08-09 18:24 ` Mark Brown
@ 2009-08-10  5:20 ` Mike Rapoport
  2009-08-10  6:06   ` Felipe Balbi
  1 sibling, 1 reply; 6+ messages in thread
From: Mike Rapoport @ 2009-08-10  5:20 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: linux-kernel, Mark Brown, Liam Girdwood



Felipe Balbi wrote:
> Signed-off-by: Felipe Balbi <me@felipebalbi.com>
> ---

NAK

>  drivers/regulator/userspace-consumer.c |   44 ++++++++++++++++----------------
>  1 files changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
> index 06d2fa9..a7e8e0b 100644
> --- a/drivers/regulator/userspace-consumer.c
> +++ b/drivers/regulator/userspace-consumer.c
> @@ -93,16 +93,20 @@ static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr,
>  static DEVICE_ATTR(name, 0444, reg_show_name, NULL);
>  static DEVICE_ATTR(state, 0644, reg_show_state, reg_set_state);
>  
> -static struct device_attribute *attributes[] = {
> -	&dev_attr_name,
> -	&dev_attr_state,
> +static struct attribute *attributes[] = {
> +	&dev_attr_name.attr,
> +	&dev_attr_state.attr,

NULL?
Except that patch is Ok.

> +};
> +
> +static const struct attribute_group attr_group = {
> +	.attrs	= attributes,
>  };
>  
>  static int regulator_userspace_consumer_probe(struct platform_device *pdev)
>  {
>  	struct regulator_userspace_consumer_data *pdata;
>  	struct userspace_consumer_data *drvdata;
> -	int ret, i;
> +	int ret;
>  
>  	pdata = pdev->dev.platform_data;
>  	if (!pdata)
> @@ -125,31 +129,29 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
>  		goto err_alloc_supplies;
>  	}
>  
> -	for (i = 0; i < ARRAY_SIZE(attributes); i++) {
> -		ret = device_create_file(&pdev->dev, attributes[i]);
> -		if (ret != 0)
> -			goto err_create_attrs;
> -	}
> +	ret = sysfs_create_group(&pdev->dev.kobj, &attr_group);
> +	if (ret != 0)
> +		goto err_create_attrs;
>  
> -	if (pdata->init_on)
> +	if (pdata->init_on) {
>  		ret = regulator_bulk_enable(drvdata->num_supplies,
>  					    drvdata->supplies);
> -
> -	drvdata->enabled = pdata->init_on;
> -
> -	if (ret) {
> -		dev_err(&pdev->dev, "Failed to set initial state: %d\n", ret);
> -		goto err_create_attrs;
> +		if (ret) {
> +			dev_err(&pdev->dev,
> +				"Failed to set initial state: %d\n", ret);
> +			goto err_enable;
> +		}
>  	}
>  
> +	drvdata->enabled = pdata->init_on;
>  	platform_set_drvdata(pdev, drvdata);
>  
>  	return 0;
>  
> -err_create_attrs:
> -	for (i = 0; i < ARRAY_SIZE(attributes); i++)
> -		device_remove_file(&pdev->dev, attributes[i]);
> +err_enable:
> +	sysfs_remove_group(&pdev->dev.kobj, &attr_group);
>  
> +err_create_attrs:
>  	regulator_bulk_free(drvdata->num_supplies, drvdata->supplies);
>  
>  err_alloc_supplies:
> @@ -160,10 +162,8 @@ err_alloc_supplies:
>  static int regulator_userspace_consumer_remove(struct platform_device *pdev)
>  {
>  	struct userspace_consumer_data *data = platform_get_drvdata(pdev);
> -	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(attributes); i++)
> -		device_remove_file(&pdev->dev, attributes[i]);
> +	sysfs_remove_group(&pdev->dev.kobj, &attr_group);
>  
>  	if (data->enabled)
>  		regulator_bulk_disable(data->num_supplies, data->supplies);

-- 
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: userspace: use sysfs_create_group
  2009-08-10  5:20 ` Mike Rapoport
@ 2009-08-10  6:06   ` Felipe Balbi
  2009-08-10  6:30     ` Mike Rapoport
  2009-08-10 17:33     ` Liam Girdwood
  0 siblings, 2 replies; 6+ messages in thread
From: Felipe Balbi @ 2009-08-10  6:06 UTC (permalink / raw)
  To: ext Mike Rapoport
  Cc: Felipe Balbi, linux-kernel@vger.kernel.org, Mark Brown,
	Liam Girdwood

On Mon, Aug 10, 2009 at 07:20:34AM +0200, ext Mike Rapoport wrote:
> 
> 
> Felipe Balbi wrote:
> > Signed-off-by: Felipe Balbi <me@felipebalbi.com>
> > ---
> 
> NAK
> 
> >  drivers/regulator/userspace-consumer.c |   44 ++++++++++++++++----------------
> >  1 files changed, 22 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
> > index 06d2fa9..a7e8e0b 100644
> > --- a/drivers/regulator/userspace-consumer.c
> > +++ b/drivers/regulator/userspace-consumer.c
> > @@ -93,16 +93,20 @@ static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr,
> >  static DEVICE_ATTR(name, 0444, reg_show_name, NULL);
> >  static DEVICE_ATTR(state, 0644, reg_show_state, reg_set_state);
> >  
> > -static struct device_attribute *attributes[] = {
> > -	&dev_attr_name,
> > -	&dev_attr_state,
> > +static struct attribute *attributes[] = {
> > +	&dev_attr_name.attr,
> > +	&dev_attr_state.attr,
> 
> NULL?
> Except that patch is Ok.

oops, sorry for that, here's updated version

================================ CUT HERE =====================================

>From 5e3502b30b2cbd30946e1240d62905db33716dbd Mon Sep 17 00:00:00 2001
From: Felipe Balbi <felipe.balbi@nokia.com>
Date: Mon, 10 Aug 2009 09:05:13 +0300
Subject: [PATCH] regulator: userspace: use sysfs_create_group

and avoid introducing our own loops for creating
several sysfs entries.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/regulator/userspace-consumer.c |   45 ++++++++++++++++---------------
 1 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
index 06d2fa9..44917da 100644
--- a/drivers/regulator/userspace-consumer.c
+++ b/drivers/regulator/userspace-consumer.c
@@ -93,16 +93,21 @@ static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR(name, 0444, reg_show_name, NULL);
 static DEVICE_ATTR(state, 0644, reg_show_state, reg_set_state);
 
-static struct device_attribute *attributes[] = {
-	&dev_attr_name,
-	&dev_attr_state,
+static struct attribute *attributes[] = {
+	&dev_attr_name.attr,
+	&dev_attr_state.attr,
+	NULL,
+};
+
+static const struct attribute_group attr_group = {
+	.attrs	= attributes,
 };
 
 static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 {
 	struct regulator_userspace_consumer_data *pdata;
 	struct userspace_consumer_data *drvdata;
-	int ret, i;
+	int ret;
 
 	pdata = pdev->dev.platform_data;
 	if (!pdata)
@@ -125,31 +130,29 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 		goto err_alloc_supplies;
 	}
 
-	for (i = 0; i < ARRAY_SIZE(attributes); i++) {
-		ret = device_create_file(&pdev->dev, attributes[i]);
-		if (ret != 0)
-			goto err_create_attrs;
-	}
+	ret = sysfs_create_group(&pdev->dev.kobj, &attr_group);
+	if (ret != 0)
+		goto err_create_attrs;
 
-	if (pdata->init_on)
+	if (pdata->init_on) {
 		ret = regulator_bulk_enable(drvdata->num_supplies,
 					    drvdata->supplies);
-
-	drvdata->enabled = pdata->init_on;
-
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to set initial state: %d\n", ret);
-		goto err_create_attrs;
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Failed to set initial state: %d\n", ret);
+			goto err_enable;
+		}
 	}
 
+	drvdata->enabled = pdata->init_on;
 	platform_set_drvdata(pdev, drvdata);
 
 	return 0;
 
-err_create_attrs:
-	for (i = 0; i < ARRAY_SIZE(attributes); i++)
-		device_remove_file(&pdev->dev, attributes[i]);
+err_enable:
+	sysfs_remove_group(&pdev->dev.kobj, &attr_group);
 
+err_create_attrs:
 	regulator_bulk_free(drvdata->num_supplies, drvdata->supplies);
 
 err_alloc_supplies:
@@ -160,10 +163,8 @@ err_alloc_supplies:
 static int regulator_userspace_consumer_remove(struct platform_device *pdev)
 {
 	struct userspace_consumer_data *data = platform_get_drvdata(pdev);
-	int i;
 
-	for (i = 0; i < ARRAY_SIZE(attributes); i++)
-		device_remove_file(&pdev->dev, attributes[i]);
+	sysfs_remove_group(&pdev->dev.kobj, &attr_group);
 
 	if (data->enabled)
 		regulator_bulk_disable(data->num_supplies, data->supplies);
-- 
1.6.3.3.385.g60647

-- 
balbi

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: userspace: use sysfs_create_group
  2009-08-10  6:06   ` Felipe Balbi
@ 2009-08-10  6:30     ` Mike Rapoport
  2009-08-10 17:33     ` Liam Girdwood
  1 sibling, 0 replies; 6+ messages in thread
From: Mike Rapoport @ 2009-08-10  6:30 UTC (permalink / raw)
  To: felipe.balbi
  Cc: Felipe Balbi, linux-kernel@vger.kernel.org, Mark Brown,
	Liam Girdwood



Felipe Balbi wrote:
> 
> ================================ CUT HERE =====================================
> 
>>From 5e3502b30b2cbd30946e1240d62905db33716dbd Mon Sep 17 00:00:00 2001
> From: Felipe Balbi <felipe.balbi@nokia.com>
> Date: Mon, 10 Aug 2009 09:05:13 +0300
> Subject: [PATCH] regulator: userspace: use sysfs_create_group
> 
> and avoid introducing our own loops for creating
> several sysfs entries.
> 
> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
> ---

Acked-by: Mike Rapoport <mike@compulab.co.il>

-- 
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: userspace: use sysfs_create_group
  2009-08-10  6:06   ` Felipe Balbi
  2009-08-10  6:30     ` Mike Rapoport
@ 2009-08-10 17:33     ` Liam Girdwood
  1 sibling, 0 replies; 6+ messages in thread
From: Liam Girdwood @ 2009-08-10 17:33 UTC (permalink / raw)
  To: felipe.balbi
  Cc: ext Mike Rapoport, Felipe Balbi, linux-kernel@vger.kernel.org,
	Mark Brown

On Mon, 2009-08-10 at 09:06 +0300, Felipe Balbi wrote:
> On Mon, Aug 10, 2009 at 07:20:34AM +0200, ext Mike Rapoport wrote:
> > 
> > 
> > Felipe Balbi wrote:
> > > Signed-off-by: Felipe Balbi <me@felipebalbi.com>
> > > ---
> > 
> > NAK
> > 
> > >  drivers/regulator/userspace-consumer.c |   44 ++++++++++++++++----------------
> > >  1 files changed, 22 insertions(+), 22 deletions(-)
> > > 
> > > diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
> > > index 06d2fa9..a7e8e0b 100644
> > > --- a/drivers/regulator/userspace-consumer.c
> > > +++ b/drivers/regulator/userspace-consumer.c
> > > @@ -93,16 +93,20 @@ static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr,
> > >  static DEVICE_ATTR(name, 0444, reg_show_name, NULL);
> > >  static DEVICE_ATTR(state, 0644, reg_show_state, reg_set_state);
> > >  
> > > -static struct device_attribute *attributes[] = {
> > > -	&dev_attr_name,
> > > -	&dev_attr_state,
> > > +static struct attribute *attributes[] = {
> > > +	&dev_attr_name.attr,
> > > +	&dev_attr_state.attr,
> > 
> > NULL?
> > Except that patch is Ok.
> 
> oops, sorry for that, here's updated version
> 
> ================================ CUT HERE =====================================
> 
> >From 5e3502b30b2cbd30946e1240d62905db33716dbd Mon Sep 17 00:00:00 2001
> From: Felipe Balbi <felipe.balbi@nokia.com>
> Date: Mon, 10 Aug 2009 09:05:13 +0300
> Subject: [PATCH] regulator: userspace: use sysfs_create_group
> 
> and avoid introducing our own loops for creating
> several sysfs entries.
> 
> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
> ---
>  drivers/regulator/userspace-consumer.c |   45 ++++++++++++++++---------------
>  1 files changed, 23 insertions(+), 22 deletions(-)
> 

New version applied.

Thanks

Liam


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-10 17:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-09 18:01 [PATCH] regulator: userspace: use sysfs_create_group Felipe Balbi
2009-08-09 18:24 ` Mark Brown
2009-08-10  5:20 ` Mike Rapoport
2009-08-10  6:06   ` Felipe Balbi
2009-08-10  6:30     ` Mike Rapoport
2009-08-10 17:33     ` Liam Girdwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox