aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorStefan Achatz <erazor_de@users.sourceforge.net>2010-11-26 14:57:29 -0500
committerJiri Kosina <jkosina@suse.cz>2011-01-07 19:09:21 -0500
commitc97415a72521071c235e0879f9a600014afd87b1 (patch)
tree4b71de5a0074f93daf4ddea07888c70c3bcc0eaf /drivers/base
parenta7153258b70ccbe3922fcee9ca4271d4f4c2bc55 (diff)
sysfs: Introducing binary attributes for struct class
Added dev_bin_attrs to struct class similar to existing dev_attrs. Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6ed645411c40..761359261589 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -338,6 +338,35 @@ static void device_remove_attributes(struct device *dev,
338 device_remove_file(dev, &attrs[i]); 338 device_remove_file(dev, &attrs[i]);
339} 339}
340 340
341static int device_add_bin_attributes(struct device *dev,
342 struct bin_attribute *attrs)
343{
344 int error = 0;
345 int i;
346
347 if (attrs) {
348 for (i = 0; attr_name(attrs[i]); i++) {
349 error = device_create_bin_file(dev, &attrs[i]);
350 if (error)
351 break;
352 }
353 if (error)
354 while (--i >= 0)
355 device_remove_bin_file(dev, &attrs[i]);
356 }
357 return error;
358}
359
360static void device_remove_bin_attributes(struct device *dev,
361 struct bin_attribute *attrs)
362{
363 int i;
364
365 if (attrs)
366 for (i = 0; attr_name(attrs[i]); i++)
367 device_remove_bin_file(dev, &attrs[i]);
368}
369
341static int device_add_groups(struct device *dev, 370static int device_add_groups(struct device *dev,
342 const struct attribute_group **groups) 371 const struct attribute_group **groups)
343{ 372{
@@ -378,12 +407,15 @@ static int device_add_attrs(struct device *dev)
378 error = device_add_attributes(dev, class->dev_attrs); 407 error = device_add_attributes(dev, class->dev_attrs);
379 if (error) 408 if (error)
380 return error; 409 return error;
410 error = device_add_bin_attributes(dev, class->dev_bin_attrs);
411 if (error)
412 goto err_remove_class_attrs;
381 } 413 }
382 414
383 if (type) { 415 if (type) {
384 error = device_add_groups(dev, type->groups); 416 error = device_add_groups(dev, type->groups);
385 if (error) 417 if (error)
386 goto err_remove_class_attrs; 418 goto err_remove_class_bin_attrs;
387 } 419 }
388 420
389 error = device_add_groups(dev, dev->groups); 421 error = device_add_groups(dev, dev->groups);
@@ -395,6 +427,9 @@ static int device_add_attrs(struct device *dev)
395 err_remove_type_groups: 427 err_remove_type_groups:
396 if (type) 428 if (type)
397 device_remove_groups(dev, type->groups); 429 device_remove_groups(dev, type->groups);
430 err_remove_class_bin_attrs:
431 if (class)
432 device_remove_bin_attributes(dev, class->dev_bin_attrs);
398 err_remove_class_attrs: 433 err_remove_class_attrs:
399 if (class) 434 if (class)
400 device_remove_attributes(dev, class->dev_attrs); 435 device_remove_attributes(dev, class->dev_attrs);
@@ -412,8 +447,10 @@ static void device_remove_attrs(struct device *dev)
412 if (type) 447 if (type)
413 device_remove_groups(dev, type->groups); 448 device_remove_groups(dev, type->groups);
414 449
415 if (class) 450 if (class) {
416 device_remove_attributes(dev, class->dev_attrs); 451 device_remove_attributes(dev, class->dev_attrs);
452 device_remove_bin_attributes(dev, class->dev_bin_attrs);
453 }
417} 454}
418 455
419 456