diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 11:15:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 11:15:37 -0500 |
commit | facc7a96d443d84060a8679c3fcc51d20d4981c3 (patch) | |
tree | e2d633b07766609aedac0708adcde2bc2e37e68a /drivers/base | |
parent | c8940eca75e6d1ea57f6c491a30bd1023c64c9ad (diff) | |
parent | 4ead36407b41eae942c8c9f70ef963cd369c90e2 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (34 commits)
HID: roccat: Update sysfs attribute doc
HID: roccat: don't use #pragma pack
HID: roccat: Add support for Roccat Kone[+] v2
HID: roccat: reduce number of functions in kone and pyra drivers
HID: roccat: declare meaning of pack pragma usage in driver headers
HID: roccat: use class for char device for sysfs attribute creation
sysfs: Introducing binary attributes for struct class
HID: hidraw: add compatibility ioctl() for 32-bit applications.
HID: hid-picolcd: Fix memory leak in picolcd_debug_out_report()
HID: picolcd: fix misuse of logical operation in place of bitop
HID: usbhid: base runtime PM on modern API
HID: replace offsets values with their corresponding BTN_* defines
HID: hid-mosart: support suspend/resume
HID: hid-mosart: ignore buttons report
HID: hid-picolcd: don't use flush_scheduled_work()
HID: simplify an index check in hid_lookup_collection
HID: Hoist assigns from ifs
HID: Remove superfluous __inline__
HID: Use vzalloc for vmalloc/memset(,0...)
HID: Add and use hid_<level>: dev_<level> equivalents
...
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 41 |
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 | ||
341 | static 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 | |||
360 | static 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 | |||
341 | static int device_add_groups(struct device *dev, | 370 | static 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 | ||