Commit 99c632e5 authored by Henrique de Moraes Holschuh's avatar Henrique de Moraes Holschuh Committed by John W. Linville

rfkill: add type string helper

We will need access to the rfkill switch type in string format for more
than just sysfs.  Therefore, move it to a generic helper.
Signed-off-by: default avatarHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 79399a8d
...@@ -224,34 +224,31 @@ static ssize_t rfkill_name_show(struct device *dev, ...@@ -224,34 +224,31 @@ static ssize_t rfkill_name_show(struct device *dev,
return sprintf(buf, "%s\n", rfkill->name); return sprintf(buf, "%s\n", rfkill->name);
} }
static ssize_t rfkill_type_show(struct device *dev, static const char *rfkill_get_type_str(enum rfkill_type type)
struct device_attribute *attr,
char *buf)
{ {
struct rfkill *rfkill = to_rfkill(dev); switch (type) {
const char *type;
switch (rfkill->type) {
case RFKILL_TYPE_WLAN: case RFKILL_TYPE_WLAN:
type = "wlan"; return "wlan";
break;
case RFKILL_TYPE_BLUETOOTH: case RFKILL_TYPE_BLUETOOTH:
type = "bluetooth"; return "bluetooth";
break;
case RFKILL_TYPE_UWB: case RFKILL_TYPE_UWB:
type = "ultrawideband"; return "ultrawideband";
break;
case RFKILL_TYPE_WIMAX: case RFKILL_TYPE_WIMAX:
type = "wimax"; return "wimax";
break;
case RFKILL_TYPE_WWAN: case RFKILL_TYPE_WWAN:
type = "wwan"; return "wwan";
break;
default: default:
BUG(); BUG();
} }
}
static ssize_t rfkill_type_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%s\n", type); return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type));
} }
static ssize_t rfkill_state_show(struct device *dev, static ssize_t rfkill_state_show(struct device *dev,
......
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