* [PATCH 1/5] sysfs: Introducing binary attributes for struct class
@ 2010-11-26 19:57 Stefan Achatz
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Achatz @ 2010-11-26 19:57 UTC (permalink / raw)
To: Randy Dunlap, Greg Kroah-Hartman, Jiri Kosina, Stefan Achatz,
linux-doc
Added dev_bin_attrs to struct class similar to existing dev_attrs.
Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
---
drivers/base/core.c | 41 +++++++++++++++++++++++++++++++++++++++--
include/linux/device.h | 1 +
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6ed6454..7613592 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -338,6 +338,35 @@ static void device_remove_attributes(struct device *dev,
device_remove_file(dev, &attrs[i]);
}
+static int device_add_bin_attributes(struct device *dev,
+ struct bin_attribute *attrs)
+{
+ int error = 0;
+ int i;
+
+ if (attrs) {
+ for (i = 0; attr_name(attrs[i]); i++) {
+ error = device_create_bin_file(dev, &attrs[i]);
+ if (error)
+ break;
+ }
+ if (error)
+ while (--i >= 0)
+ device_remove_bin_file(dev, &attrs[i]);
+ }
+ return error;
+}
+
+static void device_remove_bin_attributes(struct device *dev,
+ struct bin_attribute *attrs)
+{
+ int i;
+
+ if (attrs)
+ for (i = 0; attr_name(attrs[i]); i++)
+ device_remove_bin_file(dev, &attrs[i]);
+}
+
static int device_add_groups(struct device *dev,
const struct attribute_group **groups)
{
@@ -378,12 +407,15 @@ static int device_add_attrs(struct device *dev)
error = device_add_attributes(dev, class->dev_attrs);
if (error)
return error;
+ error = device_add_bin_attributes(dev, class->dev_bin_attrs);
+ if (error)
+ goto err_remove_class_attrs;
}
if (type) {
error = device_add_groups(dev, type->groups);
if (error)
- goto err_remove_class_attrs;
+ goto err_remove_class_bin_attrs;
}
error = device_add_groups(dev, dev->groups);
@@ -395,6 +427,9 @@ static int device_add_attrs(struct device *dev)
err_remove_type_groups:
if (type)
device_remove_groups(dev, type->groups);
+ err_remove_class_bin_attrs:
+ if (class)
+ device_remove_bin_attributes(dev, class->dev_bin_attrs);
err_remove_class_attrs:
if (class)
device_remove_attributes(dev, class->dev_attrs);
@@ -412,8 +447,10 @@ static void device_remove_attrs(struct device *dev)
if (type)
device_remove_groups(dev, type->groups);
- if (class)
+ if (class) {
device_remove_attributes(dev, class->dev_attrs);
+ device_remove_bin_attributes(dev, class->dev_bin_attrs);
+ }
}
diff --git a/include/linux/device.h b/include/linux/device.h
index dd48953..032bdb5 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -197,6 +197,7 @@ struct class {
struct class_attribute *class_attrs;
struct device_attribute *dev_attrs;
+ struct bin_attribute *dev_bin_attrs;
struct kobject *dev_kobj;
int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/5] sysfs: Introducing binary attributes for struct class
[not found] <1290801449.18750.162.camel@neuromancer>
@ 2010-12-08 13:33 ` Jiri Kosina
2010-12-08 15:06 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2010-12-08 13:33 UTC (permalink / raw)
To: Stefan Achatz
Cc: Randy Dunlap, Greg Kroah-Hartman, linux-doc, linux-kernel,
linux-input, netdev
On Fri, 26 Nov 2010, Stefan Achatz wrote:
> Added dev_bin_attrs to struct class similar to existing dev_attrs.
>
> Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Greg, just to make sure (as you have stated your Ack in a thread belonging
to different thread) -- I can add your Acked-by: to this patch and take it
through my tree with the rest of the roccat patchset, is that correct?
Thanks.
--
Jiri Kosina
SUSE Labs, Novell Inc.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/5] sysfs: Introducing binary attributes for struct class
2010-12-08 13:33 ` [PATCH 1/5] sysfs: Introducing binary attributes for struct class Jiri Kosina
@ 2010-12-08 15:06 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2010-12-08 15:06 UTC (permalink / raw)
To: Jiri Kosina
Cc: Stefan Achatz, Randy Dunlap, linux-doc, linux-kernel, linux-input,
netdev
On Wed, Dec 08, 2010 at 02:33:14PM +0100, Jiri Kosina wrote:
> On Fri, 26 Nov 2010, Stefan Achatz wrote:
>
> > Added dev_bin_attrs to struct class similar to existing dev_attrs.
> >
> > Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
>
> Greg, just to make sure (as you have stated your Ack in a thread belonging
> to different thread) -- I can add your Acked-by: to this patch and take it
> through my tree with the rest of the roccat patchset, is that correct?
Yes you can.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-08 15:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1290801449.18750.162.camel@neuromancer>
2010-12-08 13:33 ` [PATCH 1/5] sysfs: Introducing binary attributes for struct class Jiri Kosina
2010-12-08 15:06 ` Greg KH
2010-11-26 19:57 Stefan Achatz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).