Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Henrique de Moraes Holschuh and committed by
Len Brown
d94a7f16 5ae930e6

+50 -28
+50 -28
drivers/misc/thinkpad_acpi.c
··· 1519 1519 /* don't list other alternatives as we install a notify handler on the 570 */ 1520 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 1549 #define dock_docked() (_sta(dock_handle) & 1) 1523 1550 1524 1551 static int __init dock_init(struct ibm_init_struct *iibm) ··· 1553 1526 vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n"); 1554 1527 1555 1528 IBM_ACPIHANDLE_INIT(dock); 1556 - IBM_ACPIHANDLE_INIT(pci); 1557 1529 1558 1530 vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n", 1559 1531 str_supported(dock_handle != NULL)); 1560 1532 1561 1533 return (dock_handle)? 0 : 1; 1534 + } 1535 + 1536 + static int __init dock_init2(struct ibm_init_struct *iibm) 1537 + { 1538 + int dock2_needed; 1539 + 1540 + vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver part 2\n"); 1541 + 1542 + if (dock_driver_data[0].flags.acpi_driver_registered && 1543 + dock_driver_data[0].flags.acpi_notify_installed) { 1544 + IBM_ACPIHANDLE_INIT(pci); 1545 + dock2_needed = (pci_handle != NULL); 1546 + vdbg_printk(TPACPI_DBG_INIT, 1547 + "dock PCI handler for the TP 570 is %s\n", 1548 + str_supported(dock2_needed)); 1549 + } else { 1550 + vdbg_printk(TPACPI_DBG_INIT, 1551 + "dock subdriver part 2 not required\n"); 1552 + dock2_needed = 0; 1553 + } 1554 + 1555 + return (dock2_needed)? 0 : 1; 1562 1556 } 1563 1557 1564 1558 static void dock_notify(struct ibm_struct *ibm, u32 event) ··· 1642 1594 1643 1595 return 0; 1644 1596 } 1645 - 1646 - static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = { 1647 - { 1648 - .notify = dock_notify, 1649 - .handle = &dock_handle, 1650 - .type = ACPI_SYSTEM_NOTIFY, 1651 - }, 1652 - { 1653 - .hid = IBM_PCI_HID, 1654 - .notify = dock_notify, 1655 - .handle = &pci_handle, 1656 - .type = ACPI_SYSTEM_NOTIFY, 1657 - }, 1658 - }; 1659 - 1660 - static struct ibm_struct dock_driver_data[2] = { 1661 - { 1662 - .name = "dock", 1663 - .read = dock_read, 1664 - .write = dock_write, 1665 - .acpi = &ibm_dock_acpidriver[0], 1666 - }, 1667 - { 1668 - .name = "dock", 1669 - .acpi = &ibm_dock_acpidriver[1], 1670 - }, 1671 - }; 1672 1597 1673 1598 #endif /* CONFIG_THINKPAD_ACPI_DOCK */ 1674 1599 ··· 3871 3850 .data = &dock_driver_data[0], 3872 3851 }, 3873 3852 { 3853 + .init = dock_init2, 3874 3854 .data = &dock_driver_data[1], 3875 3855 }, 3876 3856 #endif