Commit e49df67d authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f0bc99c8
...@@ -576,14 +576,14 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) ...@@ -576,14 +576,14 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
} }
EXPORT_SYMBOL(rfkill_set_states); EXPORT_SYMBOL(rfkill_set_states);
static ssize_t rfkill_name_show(struct device *dev, static ssize_t name_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
char *buf) char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%s\n", rfkill->name); return sprintf(buf, "%s\n", rfkill->name);
} }
static DEVICE_ATTR_RO(name);
static const char *rfkill_get_type_str(enum rfkill_type type) static const char *rfkill_get_type_str(enum rfkill_type type)
{ {
...@@ -611,44 +611,43 @@ static const char *rfkill_get_type_str(enum rfkill_type type) ...@@ -611,44 +611,43 @@ static const char *rfkill_get_type_str(enum rfkill_type type)
} }
} }
static ssize_t rfkill_type_show(struct device *dev, static ssize_t type_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
char *buf) char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type)); return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type));
} }
static DEVICE_ATTR_RO(type);
static ssize_t rfkill_idx_show(struct device *dev, static ssize_t index_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
char *buf) char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", rfkill->idx); return sprintf(buf, "%d\n", rfkill->idx);
} }
static DEVICE_ATTR_RO(index);
static ssize_t rfkill_persistent_show(struct device *dev, static ssize_t persistent_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr, char *buf)
char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", rfkill->persistent); return sprintf(buf, "%d\n", rfkill->persistent);
} }
static DEVICE_ATTR_RO(persistent);
static ssize_t rfkill_hard_show(struct device *dev, static ssize_t hard_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
char *buf) char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 ); return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 );
} }
static DEVICE_ATTR_RO(hard);
static ssize_t rfkill_soft_show(struct device *dev, static ssize_t soft_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
char *buf) char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
...@@ -656,8 +655,7 @@ static ssize_t rfkill_soft_show(struct device *dev, ...@@ -656,8 +655,7 @@ static ssize_t rfkill_soft_show(struct device *dev,
return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 ); return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 );
} }
static ssize_t rfkill_soft_store(struct device *dev, static ssize_t soft_store(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
...@@ -680,6 +678,7 @@ static ssize_t rfkill_soft_store(struct device *dev, ...@@ -680,6 +678,7 @@ static ssize_t rfkill_soft_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR_RW(soft);
static u8 user_state_from_blocked(unsigned long state) static u8 user_state_from_blocked(unsigned long state)
{ {
...@@ -691,8 +690,7 @@ static u8 user_state_from_blocked(unsigned long state) ...@@ -691,8 +690,7 @@ static u8 user_state_from_blocked(unsigned long state)
return RFKILL_USER_STATE_UNBLOCKED; return RFKILL_USER_STATE_UNBLOCKED;
} }
static ssize_t rfkill_state_show(struct device *dev, static ssize_t state_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
char *buf) char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
...@@ -700,8 +698,7 @@ static ssize_t rfkill_state_show(struct device *dev, ...@@ -700,8 +698,7 @@ static ssize_t rfkill_state_show(struct device *dev,
return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state)); return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state));
} }
static ssize_t rfkill_state_store(struct device *dev, static ssize_t state_store(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
...@@ -725,32 +722,27 @@ static ssize_t rfkill_state_store(struct device *dev, ...@@ -725,32 +722,27 @@ static ssize_t rfkill_state_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR_RW(state);
static ssize_t rfkill_claim_show(struct device *dev, static ssize_t claim_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%d\n", 0); return sprintf(buf, "%d\n", 0);
} }
static DEVICE_ATTR_RO(claim);
static ssize_t rfkill_claim_store(struct device *dev,
struct device_attribute *attr, static struct attribute *rfkill_dev_attrs[] = {
const char *buf, size_t count) &dev_attr_name.attr,
{ &dev_attr_type.attr,
return -EOPNOTSUPP; &dev_attr_index.attr,
} &dev_attr_persistent.attr,
&dev_attr_state.attr,
static struct device_attribute rfkill_dev_attrs[] = { &dev_attr_claim.attr,
__ATTR(name, S_IRUGO, rfkill_name_show, NULL), &dev_attr_soft.attr,
__ATTR(type, S_IRUGO, rfkill_type_show, NULL), &dev_attr_hard.attr,
__ATTR(index, S_IRUGO, rfkill_idx_show, NULL), NULL,
__ATTR(persistent, S_IRUGO, rfkill_persistent_show, NULL),
__ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store),
__ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store),
__ATTR(soft, S_IRUGO|S_IWUSR, rfkill_soft_show, rfkill_soft_store),
__ATTR(hard, S_IRUGO, rfkill_hard_show, NULL),
__ATTR_NULL
}; };
ATTRIBUTE_GROUPS(rfkill_dev);
static void rfkill_release(struct device *dev) static void rfkill_release(struct device *dev)
{ {
...@@ -830,7 +822,7 @@ static int rfkill_resume(struct device *dev) ...@@ -830,7 +822,7 @@ static int rfkill_resume(struct device *dev)
static struct class rfkill_class = { static struct class rfkill_class = {
.name = "rfkill", .name = "rfkill",
.dev_release = rfkill_release, .dev_release = rfkill_release,
.dev_attrs = rfkill_dev_attrs, .dev_groups = rfkill_dev_groups,
.dev_uevent = rfkill_dev_uevent, .dev_uevent = rfkill_dev_uevent,
.suspend = rfkill_suspend, .suspend = rfkill_suspend,
.resume = rfkill_resume, .resume = rfkill_resume,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment