aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-04-21 10:08:37 -0400
committerLen Brown <len.brown@intel.com>2007-04-21 23:30:34 -0400
commit8d376cd6543d57ef10799be02ba5f19aa6678032 (patch)
tree0e140fc7d4a6dc0cd78b12e4481f37098b44cecd /drivers
parentd8fd94d9f08237ffda7e44e6825b057bf20a90e3 (diff)
ACPI: thinkpad-acpi: prepare for device model conversion
Prepare the thinkpad-acpi driver for the conversion to the device model, by renaming variables and doing other glue work that shall make the later patches much cleaner. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/thinkpad_acpi.c231
-rw-r--r--drivers/misc/thinkpad_acpi.h40
2 files changed, 153 insertions, 118 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index e2a1b63a812f..809ec8400ec5 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -277,7 +277,7 @@ static int _sta(acpi_handle handle)
277 * ACPI device model 277 * ACPI device model
278 */ 278 */
279 279
280static void ibm_handle_init(char *name, 280static void drv_acpi_handle_init(char *name,
281 acpi_handle *handle, acpi_handle parent, 281 acpi_handle *handle, acpi_handle parent,
282 char **paths, int num_paths, char **path) 282 char **paths, int num_paths, char **path)
283{ 283{
@@ -295,40 +295,42 @@ static void ibm_handle_init(char *name,
295 *handle = NULL; 295 *handle = NULL;
296} 296}
297 297
298static void dispatch_notify(acpi_handle handle, u32 event, void *data) 298static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
299{ 299{
300 struct ibm_struct *ibm = data; 300 struct ibm_struct *ibm = data;
301 301
302 if (!ibm || !ibm->notify) 302 if (!ibm || !ibm->acpi || !ibm->acpi->notify)
303 return; 303 return;
304 304
305 ibm->notify(ibm, event); 305 ibm->acpi->notify(ibm, event);
306} 306}
307 307
308static int __init setup_notify(struct ibm_struct *ibm) 308static int __init setup_acpi_notify(struct ibm_struct *ibm)
309{ 309{
310 acpi_status status; 310 acpi_status status;
311 int ret; 311 int ret;
312 312
313 if (!*ibm->handle) 313 BUG_ON(!ibm->acpi);
314
315 if (!*ibm->acpi->handle)
314 return 0; 316 return 0;
315 317
316 dbg_printk(TPACPI_DBG_INIT, 318 dbg_printk(TPACPI_DBG_INIT,
317 "setting up ACPI notify for %s\n", ibm->name); 319 "setting up ACPI notify for %s\n", ibm->name);
318 320
319 ret = acpi_bus_get_device(*ibm->handle, &ibm->device); 321 ret = acpi_bus_get_device(*ibm->acpi->handle, &ibm->acpi->device);
320 if (ret < 0) { 322 if (ret < 0) {
321 printk(IBM_ERR "%s device not present\n", ibm->name); 323 printk(IBM_ERR "%s device not present\n", ibm->name);
322 return -ENODEV; 324 return -ENODEV;
323 } 325 }
324 326
325 acpi_driver_data(ibm->device) = ibm; 327 acpi_driver_data(ibm->acpi->device) = ibm;
326 sprintf(acpi_device_class(ibm->device), "%s/%s", 328 sprintf(acpi_device_class(ibm->acpi->device), "%s/%s",
327 IBM_ACPI_EVENT_PREFIX, 329 IBM_ACPI_EVENT_PREFIX,
328 ibm->name); 330 ibm->name);
329 331
330 status = acpi_install_notify_handler(*ibm->handle, ibm->type, 332 status = acpi_install_notify_handler(*ibm->acpi->handle,
331 dispatch_notify, ibm); 333 ibm->acpi->type, dispatch_acpi_notify, ibm);
332 if (ACPI_FAILURE(status)) { 334 if (ACPI_FAILURE(status)) {
333 if (status == AE_ALREADY_EXISTS) { 335 if (status == AE_ALREADY_EXISTS) {
334 printk(IBM_NOTICE "another device driver is already handling %s events\n", 336 printk(IBM_NOTICE "another device driver is already handling %s events\n",
@@ -339,11 +341,11 @@ static int __init setup_notify(struct ibm_struct *ibm)
339 } 341 }
340 return -ENODEV; 342 return -ENODEV;
341 } 343 }
342 ibm->flags.notify_installed = 1; 344 ibm->flags.acpi_notify_installed = 1;
343 return 0; 345 return 0;
344} 346}
345 347
346static int __init ibm_device_add(struct acpi_device *device) 348static int __init tpacpi_device_add(struct acpi_device *device)
347{ 349{
348 return 0; 350 return 0;
349} 351}
@@ -355,24 +357,26 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
355 dbg_printk(TPACPI_DBG_INIT, 357 dbg_printk(TPACPI_DBG_INIT,
356 "registering %s as an ACPI driver\n", ibm->name); 358 "registering %s as an ACPI driver\n", ibm->name);
357 359
358 ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); 360 BUG_ON(!ibm->acpi);
359 if (!ibm->driver) { 361
362 ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
363 if (!ibm->acpi->driver) {
360 printk(IBM_ERR "kzalloc(ibm->driver) failed\n"); 364 printk(IBM_ERR "kzalloc(ibm->driver) failed\n");
361 return -ENOMEM; 365 return -ENOMEM;
362 } 366 }
363 367
364 sprintf(ibm->driver->name, "%s_%s", IBM_NAME, ibm->name); 368 sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name);
365 ibm->driver->ids = ibm->hid; 369 ibm->acpi->driver->ids = ibm->acpi->hid;
366 ibm->driver->ops.add = &ibm_device_add; 370 ibm->acpi->driver->ops.add = &tpacpi_device_add;
367 371
368 ret = acpi_bus_register_driver(ibm->driver); 372 ret = acpi_bus_register_driver(ibm->acpi->driver);
369 if (ret < 0) { 373 if (ret < 0) {
370 printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n", 374 printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
371 ibm->hid, ret); 375 ibm->acpi->hid, ret);
372 kfree(ibm->driver); 376 kfree(ibm->acpi->driver);
373 ibm->driver = NULL; 377 ibm->acpi->driver = NULL;
374 } else if (!ret) 378 } else if (!ret)
375 ibm->flags.driver_registered = 1; 379 ibm->flags.acpi_driver_registered = 1;
376 380
377 return ret; 381 return ret;
378} 382}
@@ -386,8 +390,8 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
386 **************************************************************************** 390 ****************************************************************************
387 ****************************************************************************/ 391 ****************************************************************************/
388 392
389static int dispatch_read(char *page, char **start, off_t off, int count, 393static int dispatch_procfs_read(char *page, char **start, off_t off,
390 int *eof, void *data) 394 int count, int *eof, void *data)
391{ 395{
392 struct ibm_struct *ibm = data; 396 struct ibm_struct *ibm = data;
393 int len; 397 int len;
@@ -411,8 +415,9 @@ static int dispatch_read(char *page, char **start, off_t off, int count,
411 return len; 415 return len;
412} 416}
413 417
414static int dispatch_write(struct file *file, const char __user * userbuf, 418static int dispatch_procfs_write(struct file *file,
415 unsigned long count, void *data) 419 const char __user * userbuf,
420 unsigned long count, void *data)
416{ 421{
417 struct ibm_struct *ibm = data; 422 struct ibm_struct *ibm = data;
418 char *kernbuf; 423 char *kernbuf;
@@ -508,7 +513,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
508{ 513{
509 vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n"); 514 vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
510 515
511 IBM_HANDLE_INIT(hkey); 516 IBM_ACPIHANDLE_INIT(hkey);
512 517
513 /* hotkey not supported on 570 */ 518 /* hotkey not supported on 570 */
514 tp_features.hotkey = hkey_handle != NULL; 519 tp_features.hotkey = hkey_handle != NULL;
@@ -545,10 +550,10 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
545 int hkey; 550 int hkey;
546 551
547 if (acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) 552 if (acpi_evalf(hkey_handle, &hkey, "MHKP", "d"))
548 acpi_bus_generate_event(ibm->device, event, hkey); 553 acpi_bus_generate_event(ibm->acpi->device, event, hkey);
549 else { 554 else {
550 printk(IBM_ERR "unknown hotkey event %d\n", event); 555 printk(IBM_ERR "unknown hotkey event %d\n", event);
551 acpi_bus_generate_event(ibm->device, event, 0); 556 acpi_bus_generate_event(ibm->acpi->device, event, 0);
552 } 557 }
553} 558}
554 559
@@ -643,15 +648,19 @@ static int hotkey_write(char *buf)
643 return 0; 648 return 0;
644} 649}
645 650
651static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = {
652 .hid = IBM_HKEY_HID,
653 .notify = hotkey_notify,
654 .handle = &hkey_handle,
655 .type = ACPI_DEVICE_NOTIFY,
656};
657
646static struct ibm_struct hotkey_driver_data = { 658static struct ibm_struct hotkey_driver_data = {
647 .name = "hotkey", 659 .name = "hotkey",
648 .hid = IBM_HKEY_HID,
649 .read = hotkey_read, 660 .read = hotkey_read,
650 .write = hotkey_write, 661 .write = hotkey_write,
651 .exit = hotkey_exit, 662 .exit = hotkey_exit,
652 .notify = hotkey_notify, 663 .acpi = &ibm_hotkey_acpidriver,
653 .handle = &hkey_handle,
654 .type = ACPI_DEVICE_NOTIFY,
655}; 664};
656 665
657/************************************************************************* 666/*************************************************************************
@@ -662,7 +671,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
662{ 671{
663 vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n"); 672 vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
664 673
665 IBM_HANDLE_INIT(hkey); 674 IBM_ACPIHANDLE_INIT(hkey);
666 675
667 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, 676 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
668 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ 677 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
@@ -742,7 +751,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
742{ 751{
743 vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n"); 752 vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
744 753
745 IBM_HANDLE_INIT(hkey); 754 IBM_ACPIHANDLE_INIT(hkey);
746 755
747 tp_features.wan = hkey_handle && 756 tp_features.wan = hkey_handle &&
748 acpi_evalf(hkey_handle, NULL, "GWAN", "qv"); 757 acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
@@ -835,8 +844,8 @@ static int __init video_init(struct ibm_init_struct *iibm)
835 844
836 vdbg_printk(TPACPI_DBG_INIT, "initializing video subdriver\n"); 845 vdbg_printk(TPACPI_DBG_INIT, "initializing video subdriver\n");
837 846
838 IBM_HANDLE_INIT(vid); 847 IBM_ACPIHANDLE_INIT(vid);
839 IBM_HANDLE_INIT(vid2); 848 IBM_ACPIHANDLE_INIT(vid2);
840 849
841 if (vid2_handle && acpi_evalf(NULL, &ivga, "\\IVGA", "d") && ivga) 850 if (vid2_handle && acpi_evalf(NULL, &ivga, "\\IVGA", "d") && ivga)
842 /* G41, assume IVGA doesn't change */ 851 /* G41, assume IVGA doesn't change */
@@ -1053,9 +1062,9 @@ static int __init light_init(struct ibm_init_struct *iibm)
1053{ 1062{
1054 vdbg_printk(TPACPI_DBG_INIT, "initializing light subdriver\n"); 1063 vdbg_printk(TPACPI_DBG_INIT, "initializing light subdriver\n");
1055 1064
1056 IBM_HANDLE_INIT(ledb); 1065 IBM_ACPIHANDLE_INIT(ledb);
1057 IBM_HANDLE_INIT(lght); 1066 IBM_ACPIHANDLE_INIT(lght);
1058 IBM_HANDLE_INIT(cmos); 1067 IBM_ACPIHANDLE_INIT(cmos);
1059 1068
1060 /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */ 1069 /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
1061 tp_features.light = (cmos_handle || lght_handle) && !ledb_handle; 1070 tp_features.light = (cmos_handle || lght_handle) && !ledb_handle;
@@ -1148,8 +1157,8 @@ static int __init dock_init(struct ibm_init_struct *iibm)
1148{ 1157{
1149 vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n"); 1158 vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n");
1150 1159
1151 IBM_HANDLE_INIT(dock); 1160 IBM_ACPIHANDLE_INIT(dock);
1152 IBM_HANDLE_INIT(pci); 1161 IBM_ACPIHANDLE_INIT(pci);
1153 1162
1154 vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n", 1163 vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n",
1155 str_supported(dock_handle != NULL)); 1164 str_supported(dock_handle != NULL));
@@ -1160,22 +1169,22 @@ static int __init dock_init(struct ibm_init_struct *iibm)
1160static void dock_notify(struct ibm_struct *ibm, u32 event) 1169static void dock_notify(struct ibm_struct *ibm, u32 event)
1161{ 1170{
1162 int docked = dock_docked(); 1171 int docked = dock_docked();
1163 int pci = ibm->hid && strstr(ibm->hid, IBM_PCI_HID); 1172 int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID);
1164 1173
1165 if (event == 1 && !pci) /* 570 */ 1174 if (event == 1 && !pci) /* 570 */
1166 acpi_bus_generate_event(ibm->device, event, 1); /* button */ 1175 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */
1167 else if (event == 1 && pci) /* 570 */ 1176 else if (event == 1 && pci) /* 570 */
1168 acpi_bus_generate_event(ibm->device, event, 3); /* dock */ 1177 acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */
1169 else if (event == 3 && docked) 1178 else if (event == 3 && docked)
1170 acpi_bus_generate_event(ibm->device, event, 1); /* button */ 1179 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */
1171 else if (event == 3 && !docked) 1180 else if (event == 3 && !docked)
1172 acpi_bus_generate_event(ibm->device, event, 2); /* undock */ 1181 acpi_bus_generate_event(ibm->acpi->device, event, 2); /* undock */
1173 else if (event == 0 && docked) 1182 else if (event == 0 && docked)
1174 acpi_bus_generate_event(ibm->device, event, 3); /* dock */ 1183 acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */
1175 else { 1184 else {
1176 printk(IBM_ERR "unknown dock event %d, status %d\n", 1185 printk(IBM_ERR "unknown dock event %d, status %d\n",
1177 event, _sta(dock_handle)); 1186 event, _sta(dock_handle));
1178 acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ 1187 acpi_bus_generate_event(ibm->acpi->device, event, 0); /* unknown */
1179 } 1188 }
1180} 1189}
1181 1190
@@ -1218,17 +1227,13 @@ static int dock_write(char *buf)
1218 return 0; 1227 return 0;
1219} 1228}
1220 1229
1221static struct ibm_struct dock_driver_data[2] = { 1230static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
1222 { 1231 {
1223 .name = "dock",
1224 .read = dock_read,
1225 .write = dock_write,
1226 .notify = dock_notify, 1232 .notify = dock_notify,
1227 .handle = &dock_handle, 1233 .handle = &dock_handle,
1228 .type = ACPI_SYSTEM_NOTIFY, 1234 .type = ACPI_SYSTEM_NOTIFY,
1229 }, 1235 },
1230 { 1236 {
1231 .name = "dock",
1232 .hid = IBM_PCI_HID, 1237 .hid = IBM_PCI_HID,
1233 .notify = dock_notify, 1238 .notify = dock_notify,
1234 .handle = &pci_handle, 1239 .handle = &pci_handle,
@@ -1236,6 +1241,19 @@ static struct ibm_struct dock_driver_data[2] = {
1236 }, 1241 },
1237}; 1242};
1238 1243
1244static struct ibm_struct dock_driver_data[2] = {
1245 {
1246 .name = "dock",
1247 .read = dock_read,
1248 .write = dock_write,
1249 .acpi = &ibm_dock_acpidriver[0],
1250 },
1251 {
1252 .name = "dock",
1253 .acpi = &ibm_dock_acpidriver[1],
1254 },
1255};
1256
1239#endif /* CONFIG_THINKPAD_ACPI_DOCK */ 1257#endif /* CONFIG_THINKPAD_ACPI_DOCK */
1240 1258
1241/************************************************************************* 1259/*************************************************************************
@@ -1262,12 +1280,12 @@ static int __init bay_init(struct ibm_init_struct *iibm)
1262{ 1280{
1263 vdbg_printk(TPACPI_DBG_INIT, "initializing bay subdriver\n"); 1281 vdbg_printk(TPACPI_DBG_INIT, "initializing bay subdriver\n");
1264 1282
1265 IBM_HANDLE_INIT(bay); 1283 IBM_ACPIHANDLE_INIT(bay);
1266 if (bay_handle) 1284 if (bay_handle)
1267 IBM_HANDLE_INIT(bay_ej); 1285 IBM_ACPIHANDLE_INIT(bay_ej);
1268 IBM_HANDLE_INIT(bay2); 1286 IBM_ACPIHANDLE_INIT(bay2);
1269 if (bay2_handle) 1287 if (bay2_handle)
1270 IBM_HANDLE_INIT(bay2_ej); 1288 IBM_ACPIHANDLE_INIT(bay2_ej);
1271 1289
1272 tp_features.bay_status = bay_handle && 1290 tp_features.bay_status = bay_handle &&
1273 acpi_evalf(bay_handle, NULL, "_STA", "qv"); 1291 acpi_evalf(bay_handle, NULL, "_STA", "qv");
@@ -1292,7 +1310,7 @@ static int __init bay_init(struct ibm_init_struct *iibm)
1292 1310
1293static void bay_notify(struct ibm_struct *ibm, u32 event) 1311static void bay_notify(struct ibm_struct *ibm, u32 event)
1294{ 1312{
1295 acpi_bus_generate_event(ibm->device, event, 0); 1313 acpi_bus_generate_event(ibm->acpi->device, event, 0);
1296} 1314}
1297 1315
1298#define bay_occupied(b) (_sta(b##_handle) & 1) 1316#define bay_occupied(b) (_sta(b##_handle) & 1)
@@ -1347,13 +1365,17 @@ static int bay_write(char *buf)
1347 return 0; 1365 return 0;
1348} 1366}
1349 1367
1368static struct tp_acpi_drv_struct ibm_bay_acpidriver = {
1369 .notify = bay_notify,
1370 .handle = &bay_handle,
1371 .type = ACPI_SYSTEM_NOTIFY,
1372};
1373
1350static struct ibm_struct bay_driver_data = { 1374static struct ibm_struct bay_driver_data = {
1351 .name = "bay", 1375 .name = "bay",
1352 .read = bay_read, 1376 .read = bay_read,
1353 .write = bay_write, 1377 .write = bay_write,
1354 .notify = bay_notify, 1378 .acpi = &ibm_bay_acpidriver,
1355 .handle = &bay_handle,
1356 .type = ACPI_SYSTEM_NOTIFY,
1357}; 1379};
1358 1380
1359#endif /* CONFIG_THINKPAD_ACPI_BAY */ 1381#endif /* CONFIG_THINKPAD_ACPI_BAY */
@@ -1367,7 +1389,7 @@ static int __init cmos_init(struct ibm_init_struct *iibm)
1367 vdbg_printk(TPACPI_DBG_INIT, 1389 vdbg_printk(TPACPI_DBG_INIT,
1368 "initializing cmos commands subdriver\n"); 1390 "initializing cmos commands subdriver\n");
1369 1391
1370 IBM_HANDLE_INIT(cmos); 1392 IBM_ACPIHANDLE_INIT(cmos);
1371 1393
1372 vdbg_printk(TPACPI_DBG_INIT, "cmos commands are %s\n", 1394 vdbg_printk(TPACPI_DBG_INIT, "cmos commands are %s\n",
1373 str_supported(cmos_handle != NULL)); 1395 str_supported(cmos_handle != NULL));
@@ -1441,7 +1463,7 @@ static int __init led_init(struct ibm_init_struct *iibm)
1441{ 1463{
1442 vdbg_printk(TPACPI_DBG_INIT, "initializing LED subdriver\n"); 1464 vdbg_printk(TPACPI_DBG_INIT, "initializing LED subdriver\n");
1443 1465
1444 IBM_HANDLE_INIT(led); 1466 IBM_ACPIHANDLE_INIT(led);
1445 1467
1446 if (!led_handle) 1468 if (!led_handle)
1447 /* led not supported on R30, R31 */ 1469 /* led not supported on R30, R31 */
@@ -1566,7 +1588,7 @@ static int __init beep_init(struct ibm_init_struct *iibm)
1566{ 1588{
1567 vdbg_printk(TPACPI_DBG_INIT, "initializing beep subdriver\n"); 1589 vdbg_printk(TPACPI_DBG_INIT, "initializing beep subdriver\n");
1568 1590
1569 IBM_HANDLE_INIT(beep); 1591 IBM_ACPIHANDLE_INIT(beep);
1570 1592
1571 vdbg_printk(TPACPI_DBG_INIT, "beep is %s\n", 1593 vdbg_printk(TPACPI_DBG_INIT, "beep is %s\n",
1572 str_supported(beep_handle != NULL)); 1594 str_supported(beep_handle != NULL));
@@ -2200,9 +2222,9 @@ static int __init fan_init(struct ibm_init_struct *iibm)
2200 fan_watchdog_maxinterval = 0; 2222 fan_watchdog_maxinterval = 0;
2201 tp_features.fan_ctrl_status_undef = 0; 2223 tp_features.fan_ctrl_status_undef = 0;
2202 2224
2203 IBM_HANDLE_INIT(fans); 2225 IBM_ACPIHANDLE_INIT(fans);
2204 IBM_HANDLE_INIT(gfan); 2226 IBM_ACPIHANDLE_INIT(gfan);
2205 IBM_HANDLE_INIT(sfan); 2227 IBM_ACPIHANDLE_INIT(sfan);
2206 2228
2207 if (gfan_handle) { 2229 if (gfan_handle) {
2208 /* 570, 600e/x, 770e, 770x */ 2230 /* 570, 600e/x, 770e, 770x */
@@ -2728,22 +2750,24 @@ static int __init ibm_init(struct ibm_init_struct *iibm)
2728 ibm->flags.init_called = 1; 2750 ibm->flags.init_called = 1;
2729 } 2751 }
2730 2752
2731 if (ibm->hid) { 2753 if (ibm->acpi) {
2732 ret = register_tpacpi_subdriver(ibm); 2754 if (ibm->acpi->hid) {
2733 if (ret) 2755 ret = register_tpacpi_subdriver(ibm);
2734 goto err_out; 2756 if (ret)
2735 } 2757 goto err_out;
2758 }
2736 2759
2737 if (ibm->notify) { 2760 if (ibm->acpi->notify) {
2738 ret = setup_notify(ibm); 2761 ret = setup_acpi_notify(ibm);
2739 if (ret == -ENODEV) { 2762 if (ret == -ENODEV) {
2740 printk(IBM_NOTICE "disabling subdriver %s\n", 2763 printk(IBM_NOTICE "disabling subdriver %s\n",
2741 ibm->name); 2764 ibm->name);
2742 ret = 0; 2765 ret = 0;
2743 goto err_out; 2766 goto err_out;
2767 }
2768 if (ret < 0)
2769 goto err_out;
2744 } 2770 }
2745 if (ret < 0)
2746 goto err_out;
2747 } 2771 }
2748 2772
2749 dbg_printk(TPACPI_DBG_INIT, 2773 dbg_printk(TPACPI_DBG_INIT,
@@ -2761,9 +2785,9 @@ static int __init ibm_init(struct ibm_init_struct *iibm)
2761 } 2785 }
2762 entry->owner = THIS_MODULE; 2786 entry->owner = THIS_MODULE;
2763 entry->data = ibm; 2787 entry->data = ibm;
2764 entry->read_proc = &dispatch_read; 2788 entry->read_proc = &dispatch_procfs_read;
2765 if (ibm->write) 2789 if (ibm->write)
2766 entry->write_proc = &dispatch_write; 2790 entry->write_proc = &dispatch_procfs_write;
2767 ibm->flags.proc_created = 1; 2791 ibm->flags.proc_created = 1;
2768 } 2792 }
2769 2793
@@ -2786,12 +2810,15 @@ static void ibm_exit(struct ibm_struct *ibm)
2786 2810
2787 list_del_init(&ibm->all_drivers); 2811 list_del_init(&ibm->all_drivers);
2788 2812
2789 if (ibm->flags.notify_installed) { 2813 if (ibm->flags.acpi_notify_installed) {
2790 dbg_printk(TPACPI_DBG_EXIT, 2814 dbg_printk(TPACPI_DBG_EXIT,
2791 "%s: acpi_remove_notify_handler\n", ibm->name); 2815 "%s: acpi_remove_notify_handler\n", ibm->name);
2792 acpi_remove_notify_handler(*ibm->handle, ibm->type, 2816 BUG_ON(!ibm->acpi);
2793 dispatch_notify); 2817 acpi_remove_notify_handler(*ibm->acpi->handle,
2794 ibm->flags.notify_installed = 0; 2818 ibm->acpi->type,
2819 dispatch_acpi_notify);
2820 ibm->flags.acpi_notify_installed = 0;
2821 ibm->flags.acpi_notify_installed = 0;
2795 } 2822 }
2796 2823
2797 if (ibm->flags.proc_created) { 2824 if (ibm->flags.proc_created) {
@@ -2801,13 +2828,14 @@ static void ibm_exit(struct ibm_struct *ibm)
2801 ibm->flags.proc_created = 0; 2828 ibm->flags.proc_created = 0;
2802 } 2829 }
2803 2830
2804 if (ibm->flags.driver_registered) { 2831 if (ibm->flags.acpi_driver_registered) {
2805 dbg_printk(TPACPI_DBG_EXIT, 2832 dbg_printk(TPACPI_DBG_EXIT,
2806 "%s: acpi_bus_unregister_driver\n", ibm->name); 2833 "%s: acpi_bus_unregister_driver\n", ibm->name);
2807 acpi_bus_unregister_driver(ibm->driver); 2834 BUG_ON(!ibm->acpi);
2808 kfree(ibm->driver); 2835 acpi_bus_unregister_driver(ibm->acpi->driver);
2809 ibm->driver = NULL; 2836 kfree(ibm->acpi->driver);
2810 ibm->flags.driver_registered = 0; 2837 ibm->acpi->driver = NULL;
2838 ibm->flags.acpi_driver_registered = 0;
2811 } 2839 }
2812 2840
2813 if (ibm->flags.init_called && ibm->exit) { 2841 if (ibm->flags.init_called && ibm->exit) {
@@ -2860,7 +2888,7 @@ static int __init probe_for_thinkpad(void)
2860 is_thinkpad = dmi_name_in_vendors("ThinkPad"); 2888 is_thinkpad = dmi_name_in_vendors("ThinkPad");
2861 2889
2862 /* ec is required because many other handles are relative to it */ 2890 /* ec is required because many other handles are relative to it */
2863 IBM_HANDLE_INIT(ec); 2891 IBM_ACPIHANDLE_INIT(ec);
2864 if (!ec_handle) { 2892 if (!ec_handle) {
2865 if (is_thinkpad) 2893 if (is_thinkpad)
2866 printk(IBM_ERR 2894 printk(IBM_ERR
@@ -3016,12 +3044,12 @@ static int __init thinkpad_acpi_module_init(void)
3016 return ret; 3044 return ret;
3017 3045
3018 ibm_thinkpad_ec_found = check_dmi_for_ec(); 3046 ibm_thinkpad_ec_found = check_dmi_for_ec();
3019 IBM_HANDLE_INIT(ecrd); 3047 IBM_ACPIHANDLE_INIT(ecrd);
3020 IBM_HANDLE_INIT(ecwr); 3048 IBM_ACPIHANDLE_INIT(ecwr);
3021 3049
3022 proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); 3050 proc_dir = proc_mkdir(IBM_PROC_DIR, acpi_root_dir);
3023 if (!proc_dir) { 3051 if (!proc_dir) {
3024 printk(IBM_ERR "unable to create proc dir %s", IBM_DIR); 3052 printk(IBM_ERR "unable to create proc dir " IBM_PROC_DIR);
3025 thinkpad_acpi_module_exit(); 3053 thinkpad_acpi_module_exit();
3026 return -ENODEV; 3054 return -ENODEV;
3027 } 3055 }
@@ -3053,10 +3081,9 @@ static void thinkpad_acpi_module_exit(void)
3053 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n"); 3081 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
3054 3082
3055 if (proc_dir) 3083 if (proc_dir)
3056 remove_proc_entry(IBM_DIR, acpi_root_dir); 3084 remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
3057 3085
3058 if (ibm_thinkpad_ec_found) 3086 kfree(ibm_thinkpad_ec_found);
3059 kfree(ibm_thinkpad_ec_found);
3060} 3087}
3061 3088
3062module_init(thinkpad_acpi_module_init); 3089module_init(thinkpad_acpi_module_init);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 4d3ab4015ff2..529528c2fb5d 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -52,8 +52,9 @@
52#define IBM_DESC "ThinkPad ACPI Extras" 52#define IBM_DESC "ThinkPad ACPI Extras"
53#define IBM_FILE "thinkpad_acpi" 53#define IBM_FILE "thinkpad_acpi"
54#define IBM_URL "http://ibm-acpi.sf.net/" 54#define IBM_URL "http://ibm-acpi.sf.net/"
55#define IBM_MAIL "ibm-acpi-devel@lists.sourceforge.net"
55 56
56#define IBM_DIR "ibm" 57#define IBM_PROC_DIR "ibm"
57#define IBM_ACPI_EVENT_PREFIX "ibm" 58#define IBM_ACPI_EVENT_PREFIX "ibm"
58 59
59#define IBM_LOG IBM_FILE ": " 60#define IBM_LOG IBM_FILE ": "
@@ -108,20 +109,21 @@ static acpi_handle ec_handle; /* EC */
108static acpi_handle ecrd_handle, ecwr_handle; /* 570 EC access */ 109static acpi_handle ecrd_handle, ecwr_handle; /* 570 EC access */
109static acpi_handle cmos_handle, hkey_handle; /* basic thinkpad handles */ 110static acpi_handle cmos_handle, hkey_handle; /* basic thinkpad handles */
110 111
111static void ibm_handle_init(char *name, 112static void drv_acpi_handle_init(char *name,
112 acpi_handle *handle, acpi_handle parent, 113 acpi_handle *handle, acpi_handle parent,
113 char **paths, int num_paths, char **path); 114 char **paths, int num_paths, char **path);
114#define IBM_HANDLE_INIT(object) \ 115#define IBM_ACPIHANDLE_INIT(object) \
115 ibm_handle_init(#object, &object##_handle, *object##_parent, \ 116 drv_acpi_handle_init(#object, &object##_handle, *object##_parent, \
116 object##_paths, ARRAY_SIZE(object##_paths), &object##_path) 117 object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
117 118
118/* procfs support */ 119/* procfs support */
119static struct proc_dir_entry *proc_dir; 120static struct proc_dir_entry *proc_dir;
120 121
121/* procfs helpers */ 122/* procfs helpers */
122static int dispatch_read(char *page, char **start, off_t off, int count, 123static int dispatch_procfs_read(char *page, char **start, off_t off,
123 int *eof, void *data); 124 int count, int *eof, void *data);
124static int dispatch_write(struct file *file, const char __user * userbuf, 125static int dispatch_procfs_write(struct file *file,
126 const char __user * userbuf,
125 unsigned long count, void *data); 127 unsigned long count, void *data);
126static char *next_cmd(char **cmds); 128static char *next_cmd(char **cmds);
127 129
@@ -140,28 +142,34 @@ static void thinkpad_acpi_module_exit(void);
140 * Subdrivers 142 * Subdrivers
141 */ 143 */
142 144
143struct ibm_struct { 145struct ibm_struct;
144 char *name;
145 146
147struct tp_acpi_drv_struct {
146 char *hid; 148 char *hid;
147 struct acpi_driver *driver; 149 struct acpi_driver *driver;
148 150
149 int (*read) (char *);
150 int (*write) (char *);
151 void (*exit) (void);
152
153 void (*notify) (struct ibm_struct *, u32); 151 void (*notify) (struct ibm_struct *, u32);
154 acpi_handle *handle; 152 acpi_handle *handle;
155 int type; 153 u32 type;
156 struct acpi_device *device; 154 struct acpi_device *device;
155};
156
157struct ibm_struct {
158 char *name;
159
160 int (*read) (char *);
161 int (*write) (char *);
162 void (*exit) (void);
157 163
158 struct list_head all_drivers; 164 struct list_head all_drivers;
159 165
166 struct tp_acpi_drv_struct *acpi;
167
160 struct { 168 struct {
161 u8 driver_registered:1; 169 u8 acpi_driver_registered:1;
170 u8 acpi_notify_installed:1;
162 u8 proc_created:1; 171 u8 proc_created:1;
163 u8 init_called:1; 172 u8 init_called:1;
164 u8 notify_installed:1;
165 u8 experimental:1; 173 u8 experimental:1;
166 } flags; 174 } flags;
167}; 175};