return sprintf(buf, "%s\n", rfkill->name);
 }
 
-static ssize_t rfkill_type_show(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
+static const char *rfkill_get_type_str(enum rfkill_type type)
 {
-       struct rfkill *rfkill = to_rfkill(dev);
-       const char *type;
-
-       switch (rfkill->type) {
+       switch (type) {
        case RFKILL_TYPE_WLAN:
-               type = "wlan";
-               break;
+               return "wlan";
        case RFKILL_TYPE_BLUETOOTH:
-               type = "bluetooth";
-               break;
+               return "bluetooth";
        case RFKILL_TYPE_UWB:
-               type = "ultrawideband";
-               break;
+               return "ultrawideband";
        case RFKILL_TYPE_WIMAX:
-               type = "wimax";
-               break;
+               return "wimax";
        case RFKILL_TYPE_WWAN:
-               type = "wwan";
-               break;
+               return "wwan";
        default:
                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,