@@ -1388,6 +1388,33 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
EXPORT_SYMBOL(input_set_capability);
/**
+ * input_init_switch - prepare device to handle a certain EV_SW event
+ * @dev: device that is capable of issuing the EV_SW event
+ * @code: event code
+ * @state: initial state for the switch
+ *
+ * This function sets the corresponding bits in the capability bitmap,
+ * switch capability bitmap, and switch state bitmap.
+ */
+void input_init_switch(struct input_dev *dev, unsigned int code, bool state)
+{
+ if (code > SW_MAX) {
+ printk(KERN_ERR
+ "input_init_switch: unknown code %u\n",
+ code);
+ dump_stack();
+ return;
+ }
+
+ input_set_capability(dev, EV_SW, code);
+ if (state)
+ __set_bit(code, dev->sw);
+ else
+ __clear_bit(code, dev->sw);
+}
+EXPORT_SYMBOL(input_init_switch);
+
+/**
* input_register_device - register device with input core
* @dev: device to be registered
*
@@ -3365,16 +3365,12 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
}
}
- if (tp_features.hotkey_wlsw) {
- input_set_capability(tpacpi_inputdev, EV_SW, SW_RFKILL_ALL);
- if (radiosw_state)
- __set_bit(SW_RFKILL_ALL, tpacpi_inputdev->sw);
- }
- if (tp_features.hotkey_tablet) {
- input_set_capability(tpacpi_inputdev, EV_SW, SW_TABLET_MODE);
- if (tabletsw_state)
- __set_bit(SW_TABLET_MODE, tpacpi_inputdev->sw);
- }
+ if (tp_features.hotkey_wlsw)
+ input_init_switch(tpacpi_inputdev,
+ SW_RFKILL_ALL, radiosw_state);
+ if (tp_features.hotkey_tablet)
+ input_init_switch(tpacpi_inputdev,
+ SW_TABLET_MODE, tabletsw_state);
/* Do not issue duplicate brightness change events to
* userspace */
@@ -1353,6 +1353,8 @@ static inline void input_set_abs_params(struct input_dev *dev, int axis, int min
int input_get_keycode(struct input_dev *dev, int scancode, int *keycode);
int input_set_keycode(struct input_dev *dev, int scancode, int keycode);
+void input_init_switch(struct input_dev *dev, unsigned int code, bool state);
+
extern struct class input_class;
/**