* ACPI device model
  */
 
-static void __init ibm_handle_init(char *name,
-                                  acpi_handle * handle, acpi_handle parent,
-                                  char **paths, int num_paths, char **path)
+static void ibm_handle_init(char *name,
+                          acpi_handle *handle, acpi_handle parent,
+                          char **paths, int num_paths, char **path)
 {
        int i;
        acpi_status status;
 
        ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
        if (!ibm->driver) {
-               printk(IBM_ERR "kmalloc(ibm->driver) failed\n");
-               return -1;
+               printk(IBM_ERR "kzalloc(ibm->driver) failed\n");
+               return -ENOMEM;
        }
 
        sprintf(ibm->driver->name, "%s_%s", IBM_NAME, ibm->name);
                printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
                       ibm->hid, ret);
                kfree(ibm->driver);
-       }
+               ibm->driver = NULL;
+       } else if (!ret)
+               ibm->driver_registered = 1;
 
        return ret;
 }
 
 static int hotkey_init(void)
 {
+       IBM_HANDLE_INIT(hkey);
+
        /* hotkey not supported on 570 */
        hotkey_supported = hkey_handle != NULL;
 
                        return -ENODEV;
        }
 
-       return 0;
+       return (hotkey_supported)? 0 : 1;
 }
 
 static void hotkey_exit(void)
 {
-       if (hotkey_supported)
+       if (hotkey_supported) {
                hotkey_set(hotkey_orig_status, hotkey_orig_mask);
+       }
 }
 
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 
 static int bluetooth_init(void)
 {
+       IBM_HANDLE_INIT(hkey);
+
        /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
           G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
        bluetooth_supported = hkey_handle &&
            acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
 
-       return 0;
+       return (bluetooth_supported)? 0 : 1;
 }
 
 static int bluetooth_status(void)
 
 static int wan_init(void)
 {
+       IBM_HANDLE_INIT(hkey);
+
        wan_supported = hkey_handle &&
            acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
 
-       return 0;
+       return (wan_supported)? 0 : 1;
 }
 
 static int wan_status(void)
 {
        int ivga;
 
+       IBM_HANDLE_INIT(vid);
+       IBM_HANDLE_INIT(vid2);
+
        if (vid2_handle && acpi_evalf(NULL, &ivga, "\\IVGA", "d") && ivga)
                /* G41, assume IVGA doesn't change */
                vid_handle = vid2_handle;
                /* all others */
                video_supported = TPACPI_VIDEO_NEW;
 
-       return 0;
+       return (video_supported != TPACPI_VIDEO_NONE)? 0 : 1;
 }
 
 static void video_exit(void)
 
 static int light_init(void)
 {
+       IBM_HANDLE_INIT(ledb);
+       IBM_HANDLE_INIT(lght);
+       IBM_HANDLE_INIT(cmos);
+
        /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
        light_supported = (cmos_handle || lght_handle) && !ledb_handle;
 
                light_status_supported = acpi_evalf(ec_handle, NULL,
                                                    "KBLT", "qv");
 
-       return 0;
+       return (light_supported)? 0 : 1;
 }
 
 static int light_read(char *p)
  * Dock subdriver
  */
 
-/* don't list other alternatives as we install a notify handler on the 570 */
-IBM_HANDLE(pci, root, "\\_SB.PCI");    /* 570 */
-
 #ifdef CONFIG_THINKPAD_ACPI_DOCK
 
 IBM_HANDLE(dock, root, "\\_SB.GDCK",   /* X30, X31, X40 */
           "\\_SB.PCI.ISA.SLCE",        /* 570 */
     );                         /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
 
+/* don't list other alternatives as we install a notify handler on the 570 */
+IBM_HANDLE(pci, root, "\\_SB.PCI");    /* 570 */
+
 #define dock_docked() (_sta(dock_handle) & 1)
 
+static int dock_init(void)
+{
+       IBM_HANDLE_INIT(dock);
+       IBM_HANDLE_INIT(pci);
+
+       return (dock_handle)? 0 : 1;
+}
+
 static void dock_notify(struct ibm_struct *ibm, u32 event)
 {
        int docked = dock_docked();
 
 static int bay_init(void)
 {
+       IBM_HANDLE_INIT(bay);
+       if (bay_handle)
+               IBM_HANDLE_INIT(bay_ej);
+       IBM_HANDLE_INIT(bay2);
+       if (bay2_handle)
+               IBM_HANDLE_INIT(bay2_ej);
+
        bay_status_supported = bay_handle &&
            acpi_evalf(bay_handle, NULL, "_STA", "qv");
        bay_status2_supported = bay2_handle &&
        bay_eject2_supported = bay2_handle && bay2_ej_handle &&
            (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental);
 
-       return 0;
+       return (bay_status_supported || bay_eject_supported ||
+               bay_status2_supported || bay_eject2_supported)? 0 : 1;
 }
 
 static void bay_notify(struct ibm_struct *ibm, u32 event)
  * CMOS subdriver
  */
 
+static int cmos_init(void)
+{
+       IBM_HANDLE_INIT(cmos);
+
+       return (cmos_handle)? 0 : 1;
+}
+
 static int cmos_eval(int cmos_cmd)
 {
        if (cmos_handle)
 
 static int led_init(void)
 {
+       IBM_HANDLE_INIT(led);
+
        if (!led_handle)
                /* led not supported on R30, R31 */
                led_supported = TPACPI_LED_NONE;
                /* all others */
                led_supported = TPACPI_LED_NEW;
 
-       return 0;
+       return (led_supported != TPACPI_LED_NONE)? 0 : 1;
 }
 
 #define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking"))
 
 IBM_HANDLE(beep, ec, "BEEP");  /* all except R30, R31 */
 
+static int beep_init(void)
+{
+       IBM_HANDLE_INIT(beep);
+
+       return (beep_handle)? 0 : 1;
+}
+
 static int beep_read(char *p)
 {
        int len = 0;
 {
        u8 t, ta1, ta2;
        int i;
-       int acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
+       int acpi_tmp7;
+
+       acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
 
        if (ibm_thinkpad_ec_found && experimental) {
                /*
                thermal_read_mode = TPACPI_THERMAL_NONE;
        }
 
-       return 0;
+       return (thermal_read_mode != TPACPI_THERMAL_NONE)? 0 : 1;
 }
 
 static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s)
        fan_control_status_known = 1;
        fan_watchdog_maxinterval = 0;
 
+       IBM_HANDLE_INIT(fans);
+       IBM_HANDLE_INIT(gfan);
+       IBM_HANDLE_INIT(sfan);
+
        if (gfan_handle) {
                /* 570, 600e/x, 770e, 770x */
                fan_status_access_mode = TPACPI_FAN_RD_ACPI_GFAN;
                        printk(IBM_ERR
                               "ThinkPad ACPI EC access misbehaving, "
                               "fan status and control unavailable\n");
-                       return 0;
+                       return 1;
                }
        }
 
                }
        }
 
-       return 0;
+       return (fan_status_access_mode != TPACPI_FAN_NONE ||
+               fan_control_access_mode != TPACPI_FAN_WR_NONE)?
+                       0 : 1;
 }
 
 static int fan_get_status(u8 *status)
 #ifdef CONFIG_THINKPAD_ACPI_DOCK
        {
         .name = "dock",
+        .init = dock_init,
         .read = dock_read,
         .write = dock_write,
         .notify = dock_notify,
 #endif /* CONFIG_THINKPAD_ACPI_BAY */
        {
         .name = "cmos",
+        .init = cmos_init,
         .read = cmos_read,
         .write = cmos_write,
         },
         },
        {
         .name = "beep",
+        .init = beep_init,
         .read = beep_read,
         .write = beep_write,
         },
        if (ibm->experimental && !experimental)
                return 0;
 
-       if (ibm->hid) {
-               ret = register_tpacpi_subdriver(ibm);
-               if (ret < 0)
-                       return ret;
-               ibm->driver_registered = 1;
-       }
-
        if (ibm->init) {
                ret = ibm->init();
-               if (ret != 0)
+               if (ret > 0)
+                       return 0;       /* probe failed */
+               if (ret)
                        return ret;
                ibm->init_called = 1;
        }
 
+       if (ibm->hid) {
+               ret = register_tpacpi_subdriver(ibm);
+               if (ret)
+                       goto err_out;
+       }
+
+       if (ibm->notify) {
+               ret = setup_notify(ibm);
+               if (ret == -ENODEV) {
+                       printk(IBM_NOTICE "disabling subdriver %s\n",
+                               ibm->name);
+                       ret = 0;
+                       goto err_out;
+               }
+               if (ret < 0)
+                       goto err_out;
+       }
+
        if (ibm->read) {
                entry = create_proc_entry(ibm->name,
                                          S_IFREG | S_IRUGO | S_IWUSR,
                if (!entry) {
                        printk(IBM_ERR "unable to create proc entry %s\n",
                               ibm->name);
-                       return -ENODEV;
+                       ret = -ENODEV;
+                       goto err_out;
                }
                entry->owner = THIS_MODULE;
                entry->data = ibm;
                ibm->proc_created = 1;
        }
 
-       if (ibm->notify) {
-               ret = setup_notify(ibm);
-               if (ret == -ENODEV) {
-                       printk(IBM_NOTICE "disabling subdriver %s\n",
-                               ibm->name);
-                       ibm_exit(ibm);
-                       return 0;
-               }
-               if (ret < 0)
-                       return ret;
-       }
-
        return 0;
+
+err_out:
+       ibm_exit(ibm);
+       return (ret < 0)? ret : 0;
 }
 
 static void ibm_exit(struct ibm_struct *ibm)
 {
-       if (ibm->notify_installed)
+       if (ibm->notify_installed) {
                acpi_remove_notify_handler(*ibm->handle, ibm->type,
                                           dispatch_notify);
+               ibm->notify_installed = 0;
+       }
 
-       if (ibm->proc_created)
+       if (ibm->proc_created) {
                remove_proc_entry(ibm->name, proc_dir);
-
-       if (ibm->init_called && ibm->exit)
-               ibm->exit();
+               ibm->proc_created = 0;
+       }
 
        if (ibm->driver_registered) {
                acpi_bus_unregister_driver(ibm->driver);
                kfree(ibm->driver);
+               ibm->driver = NULL;
+               ibm->driver_registered = 0;
+       }
+
+       if (ibm->init_called && ibm->exit) {
+               ibm->exit();
+               ibm->init_called = 0;
        }
 }
 
        return NULL;
 }
 
+static int __init probe_for_thinkpad(void)
+{
+       int is_thinkpad;
+
+       if (acpi_disabled)
+               return -ENODEV;
+
+       /*
+        * Non-ancient models have better DMI tagging, but very old models
+        * don't.
+        */
+       is_thinkpad = dmi_name_in_vendors("ThinkPad");
+
+       /* ec is required because many other handles are relative to it */
+       IBM_HANDLE_INIT(ec);
+       if (!ec_handle) {
+               if (is_thinkpad)
+                       printk(IBM_ERR
+                               "Not yet supported ThinkPad detected!\n");
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+
 /* Module init, exit, parameters */
 
 static int __init set_ibm_param(const char *val, struct kernel_param *kp)
 {
        int ret, i;
 
-       if (acpi_disabled)
-               return -ENODEV;
+       ret = probe_for_thinkpad();
+       if (ret)
+               return ret;
 
-       /* ec is required because many other handles are relative to it */
-       IBM_HANDLE_INIT(ec);
-       if (!ec_handle) {
-               printk(IBM_ERR "ec object not found\n");
-               return -ENODEV;
-       }
-
-       /* Models with newer firmware report the EC in DMI */
        ibm_thinkpad_ec_found = check_dmi_for_ec();
-
-       /* these handles are not required */
-       IBM_HANDLE_INIT(vid);
-       IBM_HANDLE_INIT(vid2);
-       IBM_HANDLE_INIT(ledb);
-       IBM_HANDLE_INIT(led);
-       IBM_HANDLE_INIT(hkey);
-       IBM_HANDLE_INIT(lght);
-       IBM_HANDLE_INIT(cmos);
-#ifdef CONFIG_THINKPAD_ACPI_DOCK
-       IBM_HANDLE_INIT(dock);
-#endif
-       IBM_HANDLE_INIT(pci);
-#ifdef CONFIG_THINKPAD_ACPI_BAY
-       IBM_HANDLE_INIT(bay);
-       if (bay_handle)
-               IBM_HANDLE_INIT(bay_ej);
-       IBM_HANDLE_INIT(bay2);
-       if (bay2_handle)
-               IBM_HANDLE_INIT(bay2_ej);
-#endif /* CONFIG_THINKPAD_ACPI_BAY */
-       IBM_HANDLE_INIT(beep);
        IBM_HANDLE_INIT(ecrd);
        IBM_HANDLE_INIT(ecwr);
-       IBM_HANDLE_INIT(fans);
-       IBM_HANDLE_INIT(gfan);
-       IBM_HANDLE_INIT(sfan);
 
        proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
        if (!proc_dir) {