diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2007-04-27 21:00:15 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-04-28 21:41:20 -0400 |
commit | d94a7f16cad7700f8d2b142cc13cfba5387af3db (patch) | |
tree | c05c534bb1ef98a5c45321a107c8cd28894f0e84 /drivers/misc | |
parent | 5ae930e685018e2dc6d4139362213e4b283e5700 (diff) |
ACPI: thinkpad-acpi: improve dock subdriver initialization
The dock sub-driver has split-personality (two subdrivers), and it was
doing some unoptimal things on init because of that. Fix it so that the
second half of it will only init when necessary, and only if the first half
initialized sucessfully in the first place.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 78 |
1 files changed, 50 insertions, 28 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 68f1cc0d7fae..a56526500c18 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -1519,6 +1519,33 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ | |||
1519 | /* don't list other alternatives as we install a notify handler on the 570 */ | 1519 | /* don't list other alternatives as we install a notify handler on the 570 */ |
1520 | IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */ | 1520 | IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */ |
1521 | 1521 | ||
1522 | static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = { | ||
1523 | { | ||
1524 | .notify = dock_notify, | ||
1525 | .handle = &dock_handle, | ||
1526 | .type = ACPI_SYSTEM_NOTIFY, | ||
1527 | }, | ||
1528 | { | ||
1529 | .hid = IBM_PCI_HID, | ||
1530 | .notify = dock_notify, | ||
1531 | .handle = &pci_handle, | ||
1532 | .type = ACPI_SYSTEM_NOTIFY, | ||
1533 | }, | ||
1534 | }; | ||
1535 | |||
1536 | static struct ibm_struct dock_driver_data[2] = { | ||
1537 | { | ||
1538 | .name = "dock", | ||
1539 | .read = dock_read, | ||
1540 | .write = dock_write, | ||
1541 | .acpi = &ibm_dock_acpidriver[0], | ||
1542 | }, | ||
1543 | { | ||
1544 | .name = "dock", | ||
1545 | .acpi = &ibm_dock_acpidriver[1], | ||
1546 | }, | ||
1547 | }; | ||
1548 | |||
1522 | #define dock_docked() (_sta(dock_handle) & 1) | 1549 | #define dock_docked() (_sta(dock_handle) & 1) |
1523 | 1550 | ||
1524 | static int __init dock_init(struct ibm_init_struct *iibm) | 1551 | static int __init dock_init(struct ibm_init_struct *iibm) |
@@ -1526,7 +1553,6 @@ static int __init dock_init(struct ibm_init_struct *iibm) | |||
1526 | vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n"); | 1553 | vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n"); |
1527 | 1554 | ||
1528 | IBM_ACPIHANDLE_INIT(dock); | 1555 | IBM_ACPIHANDLE_INIT(dock); |
1529 | IBM_ACPIHANDLE_INIT(pci); | ||
1530 | 1556 | ||
1531 | vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n", | 1557 | vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n", |
1532 | str_supported(dock_handle != NULL)); | 1558 | str_supported(dock_handle != NULL)); |
@@ -1534,6 +1560,28 @@ static int __init dock_init(struct ibm_init_struct *iibm) | |||
1534 | return (dock_handle)? 0 : 1; | 1560 | return (dock_handle)? 0 : 1; |
1535 | } | 1561 | } |
1536 | 1562 | ||
1563 | static int __init dock_init2(struct ibm_init_struct *iibm) | ||
1564 | { | ||
1565 | int dock2_needed; | ||
1566 | |||
1567 | vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver part 2\n"); | ||
1568 | |||
1569 | if (dock_driver_data[0].flags.acpi_driver_registered && | ||
1570 | dock_driver_data[0].flags.acpi_notify_installed) { | ||
1571 | IBM_ACPIHANDLE_INIT(pci); | ||
1572 | dock2_needed = (pci_handle != NULL); | ||
1573 | vdbg_printk(TPACPI_DBG_INIT, | ||
1574 | "dock PCI handler for the TP 570 is %s\n", | ||
1575 | str_supported(dock2_needed)); | ||
1576 | } else { | ||
1577 | vdbg_printk(TPACPI_DBG_INIT, | ||
1578 | "dock subdriver part 2 not required\n"); | ||
1579 | dock2_needed = 0; | ||
1580 | } | ||
1581 | |||
1582 | return (dock2_needed)? 0 : 1; | ||
1583 | } | ||
1584 | |||
1537 | static void dock_notify(struct ibm_struct *ibm, u32 event) | 1585 | static void dock_notify(struct ibm_struct *ibm, u32 event) |
1538 | { | 1586 | { |
1539 | int docked = dock_docked(); | 1587 | int docked = dock_docked(); |
@@ -1595,33 +1643,6 @@ static int dock_write(char *buf) | |||
1595 | return 0; | 1643 | return 0; |
1596 | } | 1644 | } |
1597 | 1645 | ||
1598 | static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = { | ||
1599 | { | ||
1600 | .notify = dock_notify, | ||
1601 | .handle = &dock_handle, | ||
1602 | .type = ACPI_SYSTEM_NOTIFY, | ||
1603 | }, | ||
1604 | { | ||
1605 | .hid = IBM_PCI_HID, | ||
1606 | .notify = dock_notify, | ||
1607 | .handle = &pci_handle, | ||
1608 | .type = ACPI_SYSTEM_NOTIFY, | ||
1609 | }, | ||
1610 | }; | ||
1611 | |||
1612 | static struct ibm_struct dock_driver_data[2] = { | ||
1613 | { | ||
1614 | .name = "dock", | ||
1615 | .read = dock_read, | ||
1616 | .write = dock_write, | ||
1617 | .acpi = &ibm_dock_acpidriver[0], | ||
1618 | }, | ||
1619 | { | ||
1620 | .name = "dock", | ||
1621 | .acpi = &ibm_dock_acpidriver[1], | ||
1622 | }, | ||
1623 | }; | ||
1624 | |||
1625 | #endif /* CONFIG_THINKPAD_ACPI_DOCK */ | 1646 | #endif /* CONFIG_THINKPAD_ACPI_DOCK */ |
1626 | 1647 | ||
1627 | /************************************************************************* | 1648 | /************************************************************************* |
@@ -3850,6 +3871,7 @@ static struct ibm_init_struct ibms_init[] __initdata = { | |||
3850 | .data = &dock_driver_data[0], | 3871 | .data = &dock_driver_data[0], |
3851 | }, | 3872 | }, |
3852 | { | 3873 | { |
3874 | .init = dock_init2, | ||
3853 | .data = &dock_driver_data[1], | 3875 | .data = &dock_driver_data[1], |
3854 | }, | 3876 | }, |
3855 | #endif | 3877 | #endif |