rfkill: add read-write rfkill switch support
[safe/jmp/linux-2.6] / include / linux / rfkill.h
index d76397c..844e961 100644 (file)
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
+#include <linux/leds.h>
 
 /**
  * enum rfkill_type - type of rfkill switch.
  * RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device.
  * RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
  * RFKILL_TYPE_UWB: switch is on a ultra wideband device.
+ * RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
  */
 enum rfkill_type {
        RFKILL_TYPE_WLAN ,
        RFKILL_TYPE_BLUETOOTH,
        RFKILL_TYPE_UWB,
+       RFKILL_TYPE_WIMAX,
        RFKILL_TYPE_MAX,
 };
 
 enum rfkill_state {
-       RFKILL_STATE_OFF        = 0,
-       RFKILL_STATE_ON         = 1,
+       RFKILL_STATE_OFF        = 0,    /* Radio output blocked */
+       RFKILL_STATE_ON         = 1,    /* Radio output active */
 };
 
 /**
@@ -50,12 +53,17 @@ enum rfkill_state {
  * @name: Name of the switch.
  * @type: Radio type which the button controls, the value stored
  *     here should be a value from enum rfkill_type.
- * @state: State of the switch (on/off).
+ * @state: State of the switch, "ON" means radio can operate.
+ * @user_claim_unsupported: Whether the hardware supports exclusive
+ *     RF-kill control by userspace. Set this before registering.
  * @user_claim: Set when the switch is controlled exlusively by userspace.
  * @mutex: Guards switch state transitions
  * @data: Pointer to the RF button drivers private data which will be
  *     passed along when toggling radio state.
  * @toggle_radio(): Mandatory handler to control state of the radio.
+ * @get_state(): handler to read current radio state from hardware,
+ *      may be called from atomic context, should return 0 on success.
+ * @led_trigger: A LED trigger for this button's LED.
  * @dev: Device structure integrating the switch into device tree.
  * @node: Used to place switch into list of all switches known to the
  *     the system.
@@ -67,12 +75,18 @@ struct rfkill {
        enum rfkill_type type;
 
        enum rfkill_state state;
+       bool user_claim_unsupported;
        bool user_claim;
 
        struct mutex mutex;
 
        void *data;
        int (*toggle_radio)(void *data, enum rfkill_state state);
+       int (*get_state)(void *data, enum rfkill_state *state);
+
+#ifdef CONFIG_RFKILL_LEDS
+       struct led_trigger led_trigger;
+#endif
 
        struct device dev;
        struct list_head node;
@@ -84,4 +98,21 @@ void rfkill_free(struct rfkill *rfkill);
 int rfkill_register(struct rfkill *rfkill);
 void rfkill_unregister(struct rfkill *rfkill);
 
+int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state);
+
+/**
+ * rfkill_get_led_name - Get the LED trigger name for the button's LED.
+ * This function might return a NULL pointer if registering of the
+ * LED trigger failed.
+ * Use this as "default_trigger" for the LED.
+ */
+static inline char *rfkill_get_led_name(struct rfkill *rfkill)
+{
+#ifdef CONFIG_RFKILL_LEDS
+       return (char *)(rfkill->led_trigger.name);
+#else
+       return NULL;
+#endif
+}
+
 #endif /* RFKILL_H */