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

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: thinkpad_acpi: Drop ACPI driver registration

There is no point in registering an ACPI driver that only has an empty
.add() callback, which is done by the thinkpad_acpi driver, since
after binding to an ACPI device it only sits there and does nothing.

That binding only effectively causes the ACPI device's reference count
to increase, but that can be achieved by using acpi_get_acpi_dev()
instead of acpi_fetch_acpi_dev() in setup_acpi_notify(), and doing
the corresponding cleanup in ibm_exit().

Update the code accordingly and get rid of the non-functional ACPI
driver.

No intentional functional impact beyond altering sysfs content.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://patch.msgid.link/3949487.kQq0lBPeGt@rafael.j.wysocki
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Rafael J. Wysocki and committed by
Ilpo Järvinen
955165c3 e85c8a18

+4 -58
+4 -58
drivers/platform/x86/lenovo/thinkpad_acpi.c
··· 299 299 300 300 struct tp_acpi_drv_struct { 301 301 const struct acpi_device_id *hid; 302 - struct acpi_driver *driver; 303 302 304 303 void (*notify) (struct ibm_struct *, u32); 305 304 acpi_handle *handle; ··· 321 322 struct tp_acpi_drv_struct *acpi; 322 323 323 324 struct { 324 - u8 acpi_driver_registered:1; 325 325 u8 acpi_notify_installed:1; 326 326 u8 proc_created:1; 327 327 u8 init_called:1; ··· 830 832 vdbg_printk(TPACPI_DBG_INIT, 831 833 "setting up ACPI notify for %s\n", ibm->name); 832 834 833 - ibm->acpi->device = acpi_fetch_acpi_dev(*ibm->acpi->handle); 835 + ibm->acpi->device = acpi_get_acpi_dev(*ibm->acpi->handle); 834 836 if (!ibm->acpi->device) { 835 - pr_err("acpi_fetch_acpi_dev(%s) failed\n", ibm->name); 837 + pr_err("acpi_get_acpi_dev(%s) failed\n", ibm->name); 836 838 return -ENODEV; 837 839 } 838 840 ··· 856 858 ibm->flags.acpi_notify_installed = 1; 857 859 return 0; 858 860 } 859 - 860 - static int __init tpacpi_device_add(struct acpi_device *device) 861 - { 862 - return 0; 863 - } 864 - 865 - static int __init register_tpacpi_subdriver(struct ibm_struct *ibm) 866 - { 867 - int rc; 868 - 869 - dbg_printk(TPACPI_DBG_INIT, 870 - "registering %s as an ACPI driver\n", ibm->name); 871 - 872 - BUG_ON(!ibm->acpi); 873 - 874 - ibm->acpi->driver = kzalloc_obj(struct acpi_driver); 875 - if (!ibm->acpi->driver) { 876 - pr_err("failed to allocate memory for ibm->acpi->driver\n"); 877 - return -ENOMEM; 878 - } 879 - 880 - sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); 881 - ibm->acpi->driver->ids = ibm->acpi->hid; 882 - 883 - ibm->acpi->driver->ops.add = &tpacpi_device_add; 884 - 885 - rc = acpi_bus_register_driver(ibm->acpi->driver); 886 - if (rc < 0) { 887 - pr_err("acpi_bus_register_driver(%s) failed: %d\n", 888 - ibm->name, rc); 889 - kfree(ibm->acpi->driver); 890 - ibm->acpi->driver = NULL; 891 - } else if (!rc) 892 - ibm->flags.acpi_driver_registered = 1; 893 - 894 - return rc; 895 - } 896 - 897 861 898 862 /**************************************************************************** 899 863 **************************************************************************** ··· 11520 11560 acpi_remove_notify_handler(*ibm->acpi->handle, 11521 11561 ibm->acpi->type, 11522 11562 dispatch_acpi_notify); 11563 + ibm->acpi->device->driver_data = NULL; 11564 + acpi_dev_put(ibm->acpi->device); 11523 11565 ibm->flags.acpi_notify_installed = 0; 11524 11566 } 11525 11567 ··· 11530 11568 "%s: remove_proc_entry\n", ibm->name); 11531 11569 remove_proc_entry(ibm->name, proc_dir); 11532 11570 ibm->flags.proc_created = 0; 11533 - } 11534 - 11535 - if (ibm->flags.acpi_driver_registered) { 11536 - dbg_printk(TPACPI_DBG_EXIT, 11537 - "%s: acpi_bus_unregister_driver\n", ibm->name); 11538 - BUG_ON(!ibm->acpi); 11539 - acpi_bus_unregister_driver(ibm->acpi->driver); 11540 - kfree(ibm->acpi->driver); 11541 - ibm->acpi->driver = NULL; 11542 - ibm->flags.acpi_driver_registered = 0; 11543 11571 } 11544 11572 11545 11573 if (ibm->flags.init_called && ibm->exit) { ··· 11567 11615 } 11568 11616 11569 11617 if (ibm->acpi) { 11570 - if (ibm->acpi->hid) { 11571 - ret = register_tpacpi_subdriver(ibm); 11572 - if (ret) 11573 - goto err_out; 11574 - } 11575 - 11576 11618 if (ibm->acpi->notify) { 11577 11619 ret = setup_acpi_notify(ibm); 11578 11620 if (ret == -ENODEV) {