diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-03 14:37:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-03 14:37:15 -0400 |
commit | 542a086ac72fb193cbc1b996963a572269e57743 (patch) | |
tree | b137c08037cca4ffc8a156a891a01113b3b8edce /net/rfkill/core.c | |
parent | 1d1fdd95df681f0c065d90ffaafa215a0e8825e2 (diff) | |
parent | 1eeeef153c02f5856ec109fa532eb5f31c39f85c (diff) |
Merge tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core patches from Greg KH:
"Here's the big driver core pull request for 3.12-rc1.
Lots of tiny changes here fixing up the way sysfs attributes are
created, to try to make drivers simpler, and fix a whole class race
conditions with creations of device attributes after the device was
announced to userspace.
All the various pieces are acked by the different subsystem
maintainers"
* tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (119 commits)
firmware loader: fix pending_fw_head list corruption
drivers/base/memory.c: introduce help macro to_memory_block
dynamic debug: line queries failing due to uninitialized local variable
sysfs: sysfs_create_groups returns a value.
debugfs: provide debugfs_create_x64() when disabled
rbd: convert bus code to use bus_groups
firmware: dcdbas: use binary attribute groups
sysfs: add sysfs_create/remove_groups for when SYSFS is not enabled
driver core: add #include <linux/sysfs.h> to core files.
HID: convert bus code to use dev_groups
Input: serio: convert bus code to use drv_groups
Input: gameport: convert bus code to use drv_groups
driver core: firmware: use __ATTR_RW()
driver core: core: use DEVICE_ATTR_RO
driver core: bus: use DRIVER_ATTR_WO()
driver core: create write-only attribute macros for devices and drivers
sysfs: create __ATTR_WO()
driver-core: platform: convert bus code to use dev_groups
workqueue: convert bus code to use dev_groups
MEI: convert bus code to use dev_groups
...
Diffstat (limited to 'net/rfkill/core.c')
-rw-r--r-- | net/rfkill/core.c | 90 |
1 files changed, 41 insertions, 49 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 1cec5e4f3a5e..1bacc1079942 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
@@ -576,14 +576,14 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) | |||
576 | } | 576 | } |
577 | EXPORT_SYMBOL(rfkill_set_states); | 577 | EXPORT_SYMBOL(rfkill_set_states); |
578 | 578 | ||
579 | static ssize_t rfkill_name_show(struct device *dev, | 579 | static ssize_t name_show(struct device *dev, struct device_attribute *attr, |
580 | struct device_attribute *attr, | 580 | char *buf) |
581 | char *buf) | ||
582 | { | 581 | { |
583 | struct rfkill *rfkill = to_rfkill(dev); | 582 | struct rfkill *rfkill = to_rfkill(dev); |
584 | 583 | ||
585 | return sprintf(buf, "%s\n", rfkill->name); | 584 | return sprintf(buf, "%s\n", rfkill->name); |
586 | } | 585 | } |
586 | static DEVICE_ATTR_RO(name); | ||
587 | 587 | ||
588 | static const char *rfkill_get_type_str(enum rfkill_type type) | 588 | static const char *rfkill_get_type_str(enum rfkill_type type) |
589 | { | 589 | { |
@@ -611,54 +611,52 @@ static const char *rfkill_get_type_str(enum rfkill_type type) | |||
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | static ssize_t rfkill_type_show(struct device *dev, | 614 | static ssize_t type_show(struct device *dev, struct device_attribute *attr, |
615 | struct device_attribute *attr, | 615 | char *buf) |
616 | char *buf) | ||
617 | { | 616 | { |
618 | struct rfkill *rfkill = to_rfkill(dev); | 617 | struct rfkill *rfkill = to_rfkill(dev); |
619 | 618 | ||
620 | return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type)); | 619 | return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type)); |
621 | } | 620 | } |
621 | static DEVICE_ATTR_RO(type); | ||
622 | 622 | ||
623 | static ssize_t rfkill_idx_show(struct device *dev, | 623 | static ssize_t index_show(struct device *dev, struct device_attribute *attr, |
624 | struct device_attribute *attr, | 624 | char *buf) |
625 | char *buf) | ||
626 | { | 625 | { |
627 | struct rfkill *rfkill = to_rfkill(dev); | 626 | struct rfkill *rfkill = to_rfkill(dev); |
628 | 627 | ||
629 | return sprintf(buf, "%d\n", rfkill->idx); | 628 | return sprintf(buf, "%d\n", rfkill->idx); |
630 | } | 629 | } |
630 | static DEVICE_ATTR_RO(index); | ||
631 | 631 | ||
632 | static ssize_t rfkill_persistent_show(struct device *dev, | 632 | static ssize_t persistent_show(struct device *dev, |
633 | struct device_attribute *attr, | 633 | struct device_attribute *attr, char *buf) |
634 | char *buf) | ||
635 | { | 634 | { |
636 | struct rfkill *rfkill = to_rfkill(dev); | 635 | struct rfkill *rfkill = to_rfkill(dev); |
637 | 636 | ||
638 | return sprintf(buf, "%d\n", rfkill->persistent); | 637 | return sprintf(buf, "%d\n", rfkill->persistent); |
639 | } | 638 | } |
639 | static DEVICE_ATTR_RO(persistent); | ||
640 | 640 | ||
641 | static ssize_t rfkill_hard_show(struct device *dev, | 641 | static ssize_t hard_show(struct device *dev, struct device_attribute *attr, |
642 | struct device_attribute *attr, | 642 | char *buf) |
643 | char *buf) | ||
644 | { | 643 | { |
645 | struct rfkill *rfkill = to_rfkill(dev); | 644 | struct rfkill *rfkill = to_rfkill(dev); |
646 | 645 | ||
647 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 ); | 646 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 ); |
648 | } | 647 | } |
648 | static DEVICE_ATTR_RO(hard); | ||
649 | 649 | ||
650 | static ssize_t rfkill_soft_show(struct device *dev, | 650 | static ssize_t soft_show(struct device *dev, struct device_attribute *attr, |
651 | struct device_attribute *attr, | 651 | char *buf) |
652 | char *buf) | ||
653 | { | 652 | { |
654 | struct rfkill *rfkill = to_rfkill(dev); | 653 | struct rfkill *rfkill = to_rfkill(dev); |
655 | 654 | ||
656 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 ); | 655 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 ); |
657 | } | 656 | } |
658 | 657 | ||
659 | static ssize_t rfkill_soft_store(struct device *dev, | 658 | static ssize_t soft_store(struct device *dev, struct device_attribute *attr, |
660 | struct device_attribute *attr, | 659 | const char *buf, size_t count) |
661 | const char *buf, size_t count) | ||
662 | { | 660 | { |
663 | struct rfkill *rfkill = to_rfkill(dev); | 661 | struct rfkill *rfkill = to_rfkill(dev); |
664 | unsigned long state; | 662 | unsigned long state; |
@@ -680,6 +678,7 @@ static ssize_t rfkill_soft_store(struct device *dev, | |||
680 | 678 | ||
681 | return count; | 679 | return count; |
682 | } | 680 | } |
681 | static DEVICE_ATTR_RW(soft); | ||
683 | 682 | ||
684 | static u8 user_state_from_blocked(unsigned long state) | 683 | static u8 user_state_from_blocked(unsigned long state) |
685 | { | 684 | { |
@@ -691,18 +690,16 @@ static u8 user_state_from_blocked(unsigned long state) | |||
691 | return RFKILL_USER_STATE_UNBLOCKED; | 690 | return RFKILL_USER_STATE_UNBLOCKED; |
692 | } | 691 | } |
693 | 692 | ||
694 | static ssize_t rfkill_state_show(struct device *dev, | 693 | static ssize_t state_show(struct device *dev, struct device_attribute *attr, |
695 | struct device_attribute *attr, | 694 | char *buf) |
696 | char *buf) | ||
697 | { | 695 | { |
698 | struct rfkill *rfkill = to_rfkill(dev); | 696 | struct rfkill *rfkill = to_rfkill(dev); |
699 | 697 | ||
700 | return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state)); | 698 | return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state)); |
701 | } | 699 | } |
702 | 700 | ||
703 | static ssize_t rfkill_state_store(struct device *dev, | 701 | static ssize_t state_store(struct device *dev, struct device_attribute *attr, |
704 | struct device_attribute *attr, | 702 | const char *buf, size_t count) |
705 | const char *buf, size_t count) | ||
706 | { | 703 | { |
707 | struct rfkill *rfkill = to_rfkill(dev); | 704 | struct rfkill *rfkill = to_rfkill(dev); |
708 | unsigned long state; | 705 | unsigned long state; |
@@ -725,32 +722,27 @@ static ssize_t rfkill_state_store(struct device *dev, | |||
725 | 722 | ||
726 | return count; | 723 | return count; |
727 | } | 724 | } |
725 | static DEVICE_ATTR_RW(state); | ||
728 | 726 | ||
729 | static ssize_t rfkill_claim_show(struct device *dev, | 727 | static ssize_t claim_show(struct device *dev, struct device_attribute *attr, |
730 | struct device_attribute *attr, | 728 | char *buf) |
731 | char *buf) | ||
732 | { | 729 | { |
733 | return sprintf(buf, "%d\n", 0); | 730 | return sprintf(buf, "%d\n", 0); |
734 | } | 731 | } |
735 | 732 | static DEVICE_ATTR_RO(claim); | |
736 | static ssize_t rfkill_claim_store(struct device *dev, | 733 | |
737 | struct device_attribute *attr, | 734 | static struct attribute *rfkill_dev_attrs[] = { |
738 | const char *buf, size_t count) | 735 | &dev_attr_name.attr, |
739 | { | 736 | &dev_attr_type.attr, |
740 | return -EOPNOTSUPP; | 737 | &dev_attr_index.attr, |
741 | } | 738 | &dev_attr_persistent.attr, |
742 | 739 | &dev_attr_state.attr, | |
743 | static struct device_attribute rfkill_dev_attrs[] = { | 740 | &dev_attr_claim.attr, |
744 | __ATTR(name, S_IRUGO, rfkill_name_show, NULL), | 741 | &dev_attr_soft.attr, |
745 | __ATTR(type, S_IRUGO, rfkill_type_show, NULL), | 742 | &dev_attr_hard.attr, |
746 | __ATTR(index, S_IRUGO, rfkill_idx_show, NULL), | 743 | NULL, |
747 | __ATTR(persistent, S_IRUGO, rfkill_persistent_show, NULL), | ||
748 | __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store), | ||
749 | __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store), | ||
750 | __ATTR(soft, S_IRUGO|S_IWUSR, rfkill_soft_show, rfkill_soft_store), | ||
751 | __ATTR(hard, S_IRUGO, rfkill_hard_show, NULL), | ||
752 | __ATTR_NULL | ||
753 | }; | 744 | }; |
745 | ATTRIBUTE_GROUPS(rfkill_dev); | ||
754 | 746 | ||
755 | static void rfkill_release(struct device *dev) | 747 | static void rfkill_release(struct device *dev) |
756 | { | 748 | { |
@@ -830,7 +822,7 @@ static int rfkill_resume(struct device *dev) | |||
830 | static struct class rfkill_class = { | 822 | static struct class rfkill_class = { |
831 | .name = "rfkill", | 823 | .name = "rfkill", |
832 | .dev_release = rfkill_release, | 824 | .dev_release = rfkill_release, |
833 | .dev_attrs = rfkill_dev_attrs, | 825 | .dev_groups = rfkill_dev_groups, |
834 | .dev_uevent = rfkill_dev_uevent, | 826 | .dev_uevent = rfkill_dev_uevent, |
835 | .suspend = rfkill_suspend, | 827 | .suspend = rfkill_suspend, |
836 | .resume = rfkill_resume, | 828 | .resume = rfkill_resume, |