ACPI: thinkpad-acpi: enable more hotkeys
[powerpc.git] / drivers / misc / thinkpad_acpi.c
index 95c0b96..450b1e5 100644 (file)
@@ -92,6 +92,29 @@ MODULE_LICENSE("GPL");
 /* Please remove this in year 2009 */
 MODULE_ALIAS("ibm_acpi");
 
+/*
+ * DMI matching for module autoloading
+ *
+ * See http://thinkwiki.org/wiki/List_of_DMI_IDs
+ * See http://thinkwiki.org/wiki/BIOS_Upgrade_Downloads
+ *
+ * Only models listed in thinkwiki will be supported, so add yours
+ * if it is not there yet.
+ */
+#define IBM_BIOS_MODULE_ALIAS(__type) \
+       MODULE_ALIAS("dmi:bvnIBM:bvr" __type "ET??WW")
+
+/* Non-ancient thinkpads */
+MODULE_ALIAS("dmi:bvnIBM:*:svnIBM:*:pvrThinkPad*:rvnIBM:*");
+MODULE_ALIAS("dmi:bvnLENOVO:*:svnLENOVO:*:pvrThinkPad*:rvnLENOVO:*");
+
+/* Ancient thinkpad BIOSes have to be identified by
+ * BIOS type or model number, and there are far less
+ * BIOS types than model numbers... */
+IBM_BIOS_MODULE_ALIAS("I[B,D,H,I,M,N,O,T,W,V,Y,Z]");
+IBM_BIOS_MODULE_ALIAS("1[0,3,6,8,A-G,I,K,M-P,S,T]");
+IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
+
 #define __unused __attribute__ ((unused))
 
 /****************************************************************************
@@ -106,7 +129,7 @@ MODULE_ALIAS("ibm_acpi");
  * ACPI basic handles
  */
 
-static acpi_handle root_handle = NULL;
+static acpi_handle root_handle;
 
 #define IBM_HANDLE(object, parent, paths...)                   \
        static acpi_handle  object##_handle;                    \
@@ -492,8 +515,8 @@ static char *next_cmd(char **cmds)
  ****************************************************************************
  ****************************************************************************/
 
-static struct platform_device *tpacpi_pdev = NULL;
-static struct class_device *tpacpi_hwmon = NULL;
+static struct platform_device *tpacpi_pdev;
+static struct class_device *tpacpi_hwmon;
 
 static struct platform_driver tpacpi_pdriver = {
        .driver = {
@@ -704,16 +727,17 @@ static struct ibm_struct thinkpad_acpi_driver_data = {
  */
 
 static int hotkey_orig_status;
-static int hotkey_orig_mask;
+static u32 hotkey_orig_mask;
 
-static struct attribute_set *hotkey_dev_attributes = NULL;
+static struct attribute_set *hotkey_dev_attributes;
 
 /* sysfs hotkey enable ------------------------------------------------- */
 static ssize_t hotkey_enable_show(struct device *dev,
                           struct device_attribute *attr,
                           char *buf)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
        res = hotkey_get(&status, &mask);
        if (res)
@@ -727,7 +751,8 @@ static ssize_t hotkey_enable_store(struct device *dev,
                            const char *buf, size_t count)
 {
        unsigned long t;
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
        if (parse_strtoul(buf, 1, &t))
                return -EINVAL;
@@ -748,13 +773,14 @@ static ssize_t hotkey_mask_show(struct device *dev,
                           struct device_attribute *attr,
                           char *buf)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
        res = hotkey_get(&status, &mask);
        if (res)
                return res;
 
-       return snprintf(buf, PAGE_SIZE, "0x%04x\n", mask);
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n", mask);
 }
 
 static ssize_t hotkey_mask_store(struct device *dev,
@@ -762,9 +788,10 @@ static ssize_t hotkey_mask_store(struct device *dev,
                            const char *buf, size_t count)
 {
        unsigned long t;
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
-       if (parse_strtoul(buf, 0xffff, &t))
+       if (parse_strtoul(buf, 0xffffffffUL, &t))
                return -EINVAL;
 
        res = hotkey_get(&status, &mask);
@@ -794,7 +821,7 @@ static ssize_t hotkey_bios_mask_show(struct device *dev,
                           struct device_attribute *attr,
                           char *buf)
 {
-       return snprintf(buf, PAGE_SIZE, "0x%04x\n", hotkey_orig_mask);
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_orig_mask);
 }
 
 static struct device_attribute dev_attr_hotkey_bios_mask =
@@ -879,10 +906,10 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 {
        int hkey;
 
-       if (acpi_evalf(hkey_handle, &hkey, "MHKP", "d"))
+       if (event == 0x80 && acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
                acpi_bus_generate_event(ibm->acpi->device, event, hkey);
-       else {
-               printk(IBM_ERR "unknown hotkey event %d\n", event);
+       else {
+               printk(IBM_ERR "unknown hotkey notification event %d\n", event);
                acpi_bus_generate_event(ibm->acpi->device, event, 0);
        }
 }
@@ -890,7 +917,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 /*
  * Call with hotkey_mutex held
  */
-static int hotkey_get(int *status, int *mask)
+static int hotkey_get(int *status, u32 *mask)
 {
        if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
                return -EIO;
@@ -905,7 +932,7 @@ static int hotkey_get(int *status, int *mask)
 /*
  * Call with hotkey_mutex held
  */
-static int hotkey_set(int status, int mask)
+static int hotkey_set(int status, u32 mask)
 {
        int i;
 
@@ -926,7 +953,8 @@ static int hotkey_set(int status, int mask)
 /* procfs -------------------------------------------------------------- */
 static int hotkey_read(char *p)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
        int len = 0;
 
        if (!tp_features.hotkey) {
@@ -944,7 +972,7 @@ static int hotkey_read(char *p)
 
        len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
        if (tp_features.hotkey_mask) {
-               len += sprintf(p + len, "mask:\t\t0x%04x\n", mask);
+               len += sprintf(p + len, "mask:\t\t0x%08x\n", mask);
                len += sprintf(p + len,
                               "commands:\tenable, disable, reset, <mask>\n");
        } else {
@@ -957,7 +985,8 @@ static int hotkey_read(char *p)
 
 static int hotkey_write(char *buf)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
        char *cmd;
        int do_cmd = 0;
 
@@ -2671,7 +2700,7 @@ static struct ibm_struct ecdump_driver_data = {
  * Backlight/brightness subdriver
  */
 
-static struct backlight_device *ibm_backlight_device = NULL;
+static struct backlight_device *ibm_backlight_device;
 
 static struct backlight_ops ibm_backlight_data = {
         .get_brightness = brightness_get,
@@ -3474,7 +3503,7 @@ static void fan_watchdog_fire(struct work_struct *ignored)
 
 static void fan_watchdog_reset(void)
 {
-       static int fan_watchdog_active = 0;
+       static int fan_watchdog_active;
 
        if (fan_control_access_mode == TPACPI_FAN_WR_NONE)
                return;
@@ -3877,7 +3906,7 @@ static struct ibm_struct fan_driver_data = {
  ****************************************************************************/
 
 /* /proc support */
-static struct proc_dir_entry *proc_dir = NULL;
+static struct proc_dir_entry *proc_dir;
 
 /* Subdriver registry */
 static LIST_HEAD(tpacpi_all_drivers);
@@ -4020,7 +4049,7 @@ static void ibm_exit(struct ibm_struct *ibm)
 
 /* Probing */
 
-static char *ibm_thinkpad_ec_found = NULL;
+static char *ibm_thinkpad_ec_found;
 
 static char* __init check_dmi_for_ec(void)
 {