Skip to content

Commit e49df67

Browse files
committed
net: rfkill: convert class code to use dev_groups
The dev_attrs field of struct class is going away soon, dev_groups should be used instead. This converts the rfkill class code to use the correct field. Cc: John W. Linville <linville@tuxdriver.com> Reviewed-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f0bc99c commit e49df67

1 file changed

Lines changed: 41 additions & 49 deletions

File tree

‎net/rfkill/core.c‎

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,14 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
576576
}
577577
EXPORT_SYMBOL(rfkill_set_states);
578578

579-
static ssize_t rfkill_name_show(struct device *dev,
580-
struct device_attribute *attr,
581-
char *buf)
579+
static ssize_t name_show(struct device *dev, struct device_attribute *attr,
580+
char *buf)
582581
{
583582
struct rfkill *rfkill = to_rfkill(dev);
584583

585584
return sprintf(buf, "%s\n", rfkill->name);
586585
}
586+
static DEVICE_ATTR_RO(name);
587587

588588
static const char *rfkill_get_type_str(enum rfkill_type type)
589589
{
@@ -611,54 +611,52 @@ static const char *rfkill_get_type_str(enum rfkill_type type)
611611
}
612612
}
613613

614-
static ssize_t rfkill_type_show(struct device *dev,
615-
struct device_attribute *attr,
616-
char *buf)
614+
static ssize_t type_show(struct device *dev, struct device_attribute *attr,
615+
char *buf)
617616
{
618617
struct rfkill *rfkill = to_rfkill(dev);
619618

620619
return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type));
621620
}
621+
static DEVICE_ATTR_RO(type);
622622

623-
static ssize_t rfkill_idx_show(struct device *dev,
624-
struct device_attribute *attr,
625-
char *buf)
623+
static ssize_t index_show(struct device *dev, struct device_attribute *attr,
624+
char *buf)
626625
{
627626
struct rfkill *rfkill = to_rfkill(dev);
628627

629628
return sprintf(buf, "%d\n", rfkill->idx);
630629
}
630+
static DEVICE_ATTR_RO(index);
631631

632-
static ssize_t rfkill_persistent_show(struct device *dev,
633-
struct device_attribute *attr,
634-
char *buf)
632+
static ssize_t persistent_show(struct device *dev,
633+
struct device_attribute *attr, char *buf)
635634
{
636635
struct rfkill *rfkill = to_rfkill(dev);
637636

638637
return sprintf(buf, "%d\n", rfkill->persistent);
639638
}
639+
static DEVICE_ATTR_RO(persistent);
640640

641-
static ssize_t rfkill_hard_show(struct device *dev,
642-
struct device_attribute *attr,
643-
char *buf)
641+
static ssize_t hard_show(struct device *dev, struct device_attribute *attr,
642+
char *buf)
644643
{
645644
struct rfkill *rfkill = to_rfkill(dev);
646645

647646
return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 );
648647
}
648+
static DEVICE_ATTR_RO(hard);
649649

650-
static ssize_t rfkill_soft_show(struct device *dev,
651-
struct device_attribute *attr,
652-
char *buf)
650+
static ssize_t soft_show(struct device *dev, struct device_attribute *attr,
651+
char *buf)
653652
{
654653
struct rfkill *rfkill = to_rfkill(dev);
655654

656655
return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 );
657656
}
658657

659-
static ssize_t rfkill_soft_store(struct device *dev,
660-
struct device_attribute *attr,
661-
const char *buf, size_t count)
658+
static ssize_t soft_store(struct device *dev, struct device_attribute *attr,
659+
const char *buf, size_t count)
662660
{
663661
struct rfkill *rfkill = to_rfkill(dev);
664662
unsigned long state;
@@ -680,6 +678,7 @@ static ssize_t rfkill_soft_store(struct device *dev,
680678

681679
return count;
682680
}
681+
static DEVICE_ATTR_RW(soft);
683682

684683
static u8 user_state_from_blocked(unsigned long state)
685684
{
@@ -691,18 +690,16 @@ static u8 user_state_from_blocked(unsigned long state)
691690
return RFKILL_USER_STATE_UNBLOCKED;
692691
}
693692

694-
static ssize_t rfkill_state_show(struct device *dev,
695-
struct device_attribute *attr,
696-
char *buf)
693+
static ssize_t state_show(struct device *dev, struct device_attribute *attr,
694+
char *buf)
697695
{
698696
struct rfkill *rfkill = to_rfkill(dev);
699697

700698
return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state));
701699
}
702700

703-
static ssize_t rfkill_state_store(struct device *dev,
704-
struct device_attribute *attr,
705-
const char *buf, size_t count)
701+
static ssize_t state_store(struct device *dev, struct device_attribute *attr,
702+
const char *buf, size_t count)
706703
{
707704
struct rfkill *rfkill = to_rfkill(dev);
708705
unsigned long state;
@@ -725,32 +722,27 @@ static ssize_t rfkill_state_store(struct device *dev,
725722

726723
return count;
727724
}
725+
static DEVICE_ATTR_RW(state);
728726

729-
static ssize_t rfkill_claim_show(struct device *dev,
730-
struct device_attribute *attr,
731-
char *buf)
727+
static ssize_t claim_show(struct device *dev, struct device_attribute *attr,
728+
char *buf)
732729
{
733730
return sprintf(buf, "%d\n", 0);
734731
}
735-
736-
static ssize_t rfkill_claim_store(struct device *dev,
737-
struct device_attribute *attr,
738-
const char *buf, size_t count)
739-
{
740-
return -EOPNOTSUPP;
741-
}
742-
743-
static struct device_attribute rfkill_dev_attrs[] = {
744-
__ATTR(name, S_IRUGO, rfkill_name_show, NULL),
745-
__ATTR(type, S_IRUGO, rfkill_type_show, NULL),
746-
__ATTR(index, S_IRUGO, rfkill_idx_show, 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
732+
static DEVICE_ATTR_RO(claim);
733+
734+
static struct attribute *rfkill_dev_attrs[] = {
735+
&dev_attr_name.attr,
736+
&dev_attr_type.attr,
737+
&dev_attr_index.attr,
738+
&dev_attr_persistent.attr,
739+
&dev_attr_state.attr,
740+
&dev_attr_claim.attr,
741+
&dev_attr_soft.attr,
742+
&dev_attr_hard.attr,
743+
NULL,
753744
};
745+
ATTRIBUTE_GROUPS(rfkill_dev);
754746

755747
static void rfkill_release(struct device *dev)
756748
{
@@ -830,7 +822,7 @@ static int rfkill_resume(struct device *dev)
830822
static struct class rfkill_class = {
831823
.name = "rfkill",
832824
.dev_release = rfkill_release,
833-
.dev_attrs = rfkill_dev_attrs,
825+
.dev_groups = rfkill_dev_groups,
834826
.dev_uevent = rfkill_dev_uevent,
835827
.suspend = rfkill_suspend,
836828
.resume = rfkill_resume,

0 commit comments

Comments
 (0)