ACPI: glue: Rework ACPI companion lookup related to device type
Subsystems (6)
Rafael J. Wysocki
maintainercover ACPI: glue: Rework ACPI companion lookup related to device type
Hi All,
The ACPI "glue" code is responsible for binding Linux devices (like platform devices for one example) to their ACPI companions (represented by struct acpi_device objects). This is done by acpi_device_notify() when the given device is registered.
If the device's ACPI companion is set already at that point, the binding simply adds the device to the list of "physical nodes" associated with its ACPI companion. That's the case for PCI devices and platform devices, for example. However, there are cases in which the ACPI companion is not set upfront and it needs to be looked up via "lookup helpers" registered by the subsystems the devices in question belong to. This series changes the "lookup helpers" representation and handling.
Before the changes, the "lookup helpers" are represented by struct acpi_bus_type objects which is doubly confusing because they have nothing to do with bus types and because the "acpi_bus_type" name is also used elsewhere. Patch [1/3] renames struct acpi_bus_type to struct acpi_dev_type because all of the existing "lookup helpers" operate on device types.
Next, the registration and unregistration functions for "lookup helpers" are defined to return an int, but all of their existing users effectively discard their return values (they are discarded right away or passed up the call chain and then discarded). Patch [2/3] changes the return type of those functions to void.
Finally, since all of the existing "lookup helpers" match dev->type to a certain device type, they can be rearranged to point to the device types in question and provide a .find_companion() callback, and an additional .setup() callback in one case. This is done by patch [3/3] and allows all of the affected code to be simplified quite a bit.
Thanks!
Rafael J. Wysocki
maintainerPATCH 1/3 ACPI: glue: Rename struct acpi_bus_type to acpi_dev_type
From: "Rafael J. Wysocki" <[email protected]>
The name of struct acpi_bus_type is misleading because that data type is only used for ACPI companion lookup for specific types of devices and it has nothing to do with buses in principle. Moreover, it clashes with the name of the acpi_bus_type variable (that is a const struct bus_type) which increases the overall confusion.
For this reason, rename struct acpi_bus_type to struct acpi_dev_type and rename the related functions and variables accordingly in all of the code using it.
No intentional functional impact beyond messaging.
--- drivers/acpi/glue.c | 32 ++++++++++++++++---------------- drivers/gpu/drm/drm_sysfs.c | 10 +++++----- drivers/thunderbolt/acpi.c | 10 +++++----- drivers/usb/core/usb-acpi.c | 10 +++++----- include/acpi/acpi_bus.h | 10 +++++----- 5 files changed, 36 insertions(+), 36 deletions(-)
drivers/acpi/glue.c +16 -16
@@ -23,52 +23,52 @@#include "internal.h" -static LIST_HEAD (bus_type_list); -static DECLARE_RWSEM (bus_type_sem); +static LIST_HEAD (dev_type_list); +static DECLARE_RWSEM (dev_type_sem);#define PHYSICAL_NODE_STRING "physical_node"#define PHYSICAL_NODE_NAME_SIZE (sizeof(PHYSICAL_NODE_STRING) + 10) -int register_acpi_bus_type (struct acpi_bus_type *type) +int register_acpi_dev_type (struct acpi_dev_type *type) {if (acpi_disabled)return -ENODEV ;if (type && type->match && type->find_companion) { -down_write (&bus_type_sem); -list_add_tail (&type->list, &bus_type_list); -up_write (&bus_type_sem); -pr_info ("bus type %s registered\n" , type->name); +down_write (&dev_type_sem); +list_add_tail (&type->list, &dev_type_list); +up_write (&dev_type_sem); +pr_info ("device type %s registered\n" , type->name);return 0 ; }return -ENODEV ; } -EXPORT_SYMBOL_GPL (register_acpi_bus_type); +EXPORT_SYMBOL_GPL (register_acpi_dev_type); -int unregister_acpi_bus_type (struct acpi_bus_type *type) +int unregister_acpi_dev_type (struct acpi_dev_type *type) {if (acpi_disabled)return 0 ;if (type) { -down_write (&bus_type_sem); +down_write (&dev_type_sem);list_del_init (&type->list); -up_write (&bus_type_sem); -pr_info ("bus type %s unregistered\n" , type->name); +up_write (&dev_type_sem); +pr_info ("device type %s unregistered\n" , type->name);return 0 ; }return -ENODEV ; } -EXPORT_SYMBOL_GPL (unregister_acpi_bus_type); +EXPORT_SYMBOL_GPL (unregister_acpi_dev_type);static struct acpi_device *acpi_companion_lookup (struct device *dev) { -struct acpi_bus_type *type; +struct acpi_dev_type *type;if (!dev->type)return NULL ; -guard (rwsem_read)(&bus_type_sem); +guard (rwsem_read)(&dev_type_sem); -list_for_each_entry (type, &bus_type_list, list) { +list_for_each_entry (type, &dev_type_list, list) {struct acpi_device *adev;if (!type->match (dev))
drivers/gpu/drm/drm_sysfs.c +5 -5
@@ -64,7 +64,7 @@ static struct device_type drm_sysfs_device_connector = {struct class *drm_class;#ifdef CONFIG_ACPI -static bool drm_connector_acpi_bus_match (struct device *dev) +static bool drm_connector_acpi_dev_type_match (struct device *dev) {return dev->type == &drm_sysfs_device_connector; }
@@ -76,20 +76,20 @@ static struct acpi_device *drm_connector_acpi_find_companion(struct device *dev) return to_acpi_device_node(connector->fwnode); } -static struct acpi_bus_type drm_connector_acpi_bus = { +static struct acpi_dev_type drm_connector_acpi_dev_type = { .name ="drm_connector" , - .match = drm_connector_acpi_bus_match, + .match = drm_connector_acpi_dev_type_match, .find_companion = drm_connector_acpi_find_companion, };static void drm_sysfs_acpi_register (void ) { -register_acpi_bus_type (&drm_connector_acpi_bus); +register_acpi_dev_type (&drm_connector_acpi_dev_type); }static void drm_sysfs_acpi_unregister (void ) { -unregister_acpi_bus_type (&drm_connector_acpi_bus); +unregister_acpi_dev_type (&drm_connector_acpi_dev_type); }#else static void drm_sysfs_acpi_register (void ) { }
drivers/thunderbolt/acpi.c +5 -5
@@ -280,7 +280,7 @@ int tb_acpi_power_off_retimers(struct tb_port *port)return tb_acpi_retimer_set_power (port, false); } -static bool tb_acpi_bus_match (struct device *dev) +static bool tb_acpi_dev_type_match (struct device *dev) {return tb_is_switch (dev) ||tb_is_usb4_port_device (dev); }
@@ -351,19 +351,19 @@ static void tb_acpi_setup(struct device *dev) usb4->can_offline = true; } -static struct acpi_bus_type tb_acpi_bus = { +static struct acpi_dev_type tb_acpi_dev_type = { .name ="thunderbolt" , - .match = tb_acpi_bus_match, + .match = tb_acpi_dev_type_match, .find_companion = tb_acpi_find_companion, .setup = tb_acpi_setup, };int tb_acpi_init (void ) { -return register_acpi_bus_type (&tb_acpi_bus); +return register_acpi_dev_type (&tb_acpi_dev_type); }void tb_acpi_exit (void ) { -unregister_acpi_bus_type (&tb_acpi_bus); +unregister_acpi_dev_type (&tb_acpi_dev_type); }
drivers/usb/core/usb-acpi.c +5 -5
@@ -364,23 +364,23 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev)return NULL ; } -static bool usb_acpi_bus_match (struct device *dev) +static bool usb_acpi_dev_type_match (struct device *dev) {return is_usb_device (dev) ||is_usb_port (dev); } -static struct acpi_bus_type usb_acpi_bus = { +static struct acpi_dev_type usb_acpi_dev_type = { .name ="USB" , - .match = usb_acpi_bus_match, + .match = usb_acpi_dev_type_match, .find_companion = usb_acpi_find_companion, };int usb_acpi_register (void ) { -return register_acpi_bus_type (&usb_acpi_bus); +return register_acpi_dev_type (&usb_acpi_dev_type); }void usb_acpi_unregister (void ) { -unregister_acpi_bus_type (&usb_acpi_bus); +unregister_acpi_dev_type (&usb_acpi_dev_type); }
include/acpi/acpi_bus.h +5 -5
@@ -659,15 +659,15 @@ static inline bool acpi_device_enumerated(struct acpi_device *adev)/* * Bind physical devices with ACPI devices */ -struct acpi_bus_type { +struct acpi_dev_type {struct list_head list;const char *name;bool (*match)(struct device *dev);struct acpi_device * (*find_companion)(struct device *);void (*setup)(struct device *); }; -int register_acpi_bus_type (struct acpi_bus_type *); -int unregister_acpi_bus_type (struct acpi_bus_type *); +int register_acpi_dev_type (struct acpi_dev_type *type); +int unregister_acpi_dev_type (struct acpi_dev_type *type);int acpi_bind_one (struct device *dev,struct acpi_device *adev);void acpi_unbind_one (struct device *dev);
@@ -978,8 +978,8 @@ static inline struct device *acpi_bus_get_primary_device(struct acpi_device *adereturn NULL ; } -static inline int register_acpi_bus_type (void *bus) {return 0 ; } -static inline int unregister_acpi_bus_type (void *bus) {return 0 ; } +static inline int register_acpi_dev_type (void *type) {return 0 ; } +static inline int unregister_acpi_dev_type (void *type) {return 0 ; }static inline int acpi_wait_for_acpi_ipmi (void ) {return 0 ; }
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH v1 1/3] ACPI: glue: Rename struct acpi_bus_type to acpi_dev_type
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
From: "Rafael J. Wysocki" <[email protected]>
The name of struct
acpi_bus_typeis misleading because that data type is only used for ACPI companion lookup for specific types of devices and it has nothing to do with buses in principle. Moreover, it clashes with the name of theacpi_bus_typevariable (that is a const structbus_type) which increases the overall confusion.
Quoted 7 lines
For this reason, rename struct
acpi_bus_typeto structacpi_dev_typeand rename the related functions and variables accordingly in all of the code using it.No intentional functional impact beyond messaging.
Signed-off-by Rafael J. Wysocki <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Rafael J. Wysocki
maintainerPATCH 2/3 ACPI: glue: Change (un)register_acpi_dev_type() to void functions
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
The register_acpi_dev_type() and unregister_acpi_dev_type() return values are effectively ignored in all cases (either directly or up in the call chain), so make them both void and adjust two callers of register_acpi_dev_type() accordingly.
No intentional functional impact.
--- drivers/acpi/glue.c | 14 ++++++-------- drivers/thunderbolt/acpi.c | 4 ++-- drivers/thunderbolt/tb.h | 4 ++-- drivers/usb/core/usb-acpi.c | 4 ++-- drivers/usb/core/usb.h | 4 ++-- include/acpi/acpi_bus.h | 8 ++++---- 6 files changed, 18 insertions(+), 20 deletions(-)
drivers/acpi/glue.c +6 -8
@@ -29,33 +29,31 @@ static DECLARE_RWSEM(dev_type_sem);#define PHYSICAL_NODE_STRING "physical_node"#define PHYSICAL_NODE_NAME_SIZE (sizeof(PHYSICAL_NODE_STRING) + 10) -int register_acpi_dev_type (struct acpi_dev_type *type) +void register_acpi_dev_type (struct acpi_dev_type *type) {if (acpi_disabled) -return -ENODEV ; +return ; +if (type && type->match && type->find_companion) {down_write (&dev_type_sem);list_add_tail (&type->list, &dev_type_list);up_write (&dev_type_sem);pr_info ("device type %s registered\n" , type->name); -return 0 ; } -return -ENODEV ; }EXPORT_SYMBOL_GPL (register_acpi_dev_type); -int unregister_acpi_dev_type (struct acpi_dev_type *type) +void unregister_acpi_dev_type (struct acpi_dev_type *type) {if (acpi_disabled) -return 0 ; +return ; +if (type) {down_write (&dev_type_sem);list_del_init (&type->list);up_write (&dev_type_sem);pr_info ("device type %s unregistered\n" , type->name); -return 0 ; } -return -ENODEV ; }EXPORT_SYMBOL_GPL (unregister_acpi_dev_type);
drivers/thunderbolt/acpi.c +2 -2
@@ -358,9 +358,9 @@ static struct acpi_dev_type tb_acpi_dev_type = { .setup = tb_acpi_setup, }; -int tb_acpi_init (void ) +void tb_acpi_init (void ) { -return register_acpi_dev_type (&tb_acpi_dev_type); +register_acpi_dev_type (&tb_acpi_dev_type); }void tb_acpi_exit (void )
drivers/thunderbolt/tb.h +2 -2
@@ -1520,7 +1520,7 @@ bool tb_acpi_may_tunnel_dp(void);bool tb_acpi_may_tunnel_pcie (void );bool tb_acpi_is_xdomain_allowed (void ); -int tb_acpi_init (void ); +void tb_acpi_init (void );void tb_acpi_exit (void );int tb_acpi_power_on_retimers (struct tb_port *port);int tb_acpi_power_off_retimers (struct tb_port *port);
@@ -1533,7 +1533,7 @@ static inline bool tb_acpi_may_tunnel_dp(void) { return true; }static inline bool tb_acpi_may_tunnel_pcie (void ) {return true; }static inline bool tb_acpi_is_xdomain_allowed (void ) {return true; } -static inline int tb_acpi_init (void ) {return 0 ; } +static inline void tb_acpi_init (void ) { }static inline void tb_acpi_exit (void ) { }static inline int tb_acpi_power_on_retimers (struct tb_port *port) {return 0 ; }static inline int tb_acpi_power_off_retimers (struct tb_port *port) {return 0 ; }
drivers/usb/core/usb-acpi.c +2 -2
@@ -375,9 +375,9 @@ static struct acpi_dev_type usb_acpi_dev_type = { .find_companion = usb_acpi_find_companion, }; -int usb_acpi_register (void ) +void usb_acpi_register (void ) { -return register_acpi_dev_type (&usb_acpi_dev_type); +register_acpi_dev_type (&usb_acpi_dev_type); }void usb_acpi_unregister (void )
drivers/usb/core/usb.h +2 -2
@@ -207,11 +207,11 @@ extern void usb_hub_adjust_deviceremovable(struct usb_device *hdev, struct usb_hub_descriptor *desc);#ifdef CONFIG_ACPI -extern int usb_acpi_register (void ); +extern void usb_acpi_register (void );extern void usb_acpi_unregister (void );extern acpi_handle usb_get_hub_port_acpi_handle (struct usb_device *hdev,int port1);#else -static inline int usb_acpi_register (void ) {return 0 ; }; +static inline void usb_acpi_register (void ) { }static inline void usb_acpi_unregister (void ) { };#endif
include/acpi/acpi_bus.h +4 -4
@@ -666,8 +666,8 @@ struct acpi_dev_type {struct acpi_device * (*find_companion)(struct device *);void (*setup)(struct device *); }; -int register_acpi_dev_type (struct acpi_dev_type *type); -int unregister_acpi_dev_type (struct acpi_dev_type *type); +void register_acpi_dev_type (struct acpi_dev_type *type); +void unregister_acpi_dev_type (struct acpi_dev_type *type);int acpi_bind_one (struct device *dev,struct acpi_device *adev);void acpi_unbind_one (struct device *dev);
@@ -978,8 +978,8 @@ static inline struct device *acpi_bus_get_primary_device(struct acpi_device *adereturn NULL ; } -static inline int register_acpi_dev_type (void *type) {return 0 ; } -static inline int unregister_acpi_dev_type (void *type) {return 0 ; } +static inline void register_acpi_dev_type (void *type) { } +static inline void unregister_acpi_dev_type (void *type) { }static inline int acpi_wait_for_acpi_ipmi (void ) {return 0 ; }
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH v1 2/3] ACPI: glue: Change (un)register_acpi_dev_type() to void functions
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
From: "Rafael J. Wysocki" <[email protected]>
The
register_acpi_dev_type()andunregister_acpi_dev_type()return values are effectively ignored in all cases (either directly or up in the call chain), so make them both void and adjust two callers ofregister_acpi_dev_type()accordingly.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Rafael J. Wysocki
maintainerPATCH 3/3 ACPI: glue: Simplify struct acpi_dev_type and its usage
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
All of the current users of struct acpi_dev_type match the device type in their .match() callbacks and all of them use const device type pointers for that which means that the structure can be simplified and used in a more straightforward way.
Namely, modify struct acpi_dev_type to contain a const device type pointer instead of the .match() callback and remove the name field from it. Next, update the users of struct acpi_dev_type to register a separate object of that type for each device type that requires an ACPI companion lookup.
Since the register_acpi_dev_type() and unregister_acpi_dev_type() function bodies are rewiritten entirely anyway, make them use guard(rwsem_write) instead of down_write()/up_write() pairs and print the messages under the semaphore to ensure that the struct acpi_dev_type objects they refer to will not be freed prematurely.
No intentional functional impact beyond messaging.
--- drivers/acpi/glue.c | 33 ++++++++++-------- drivers/gpu/drm/drm_sysfs.c | 8 +---- drivers/thunderbolt/acpi.c | 69 +++++++++++++++++-------------------- drivers/usb/core/usb-acpi.c | 47 ++++++++++--------------- include/acpi/acpi_bus.h | 4 +-- 5 files changed, 72 insertions(+), 89 deletions(-)
drivers/acpi/glue.c +18 -15
@@ -31,29 +31,32 @@ static DECLARE_RWSEM(dev_type_sem);void register_acpi_dev_type (struct acpi_dev_type *type) { -if (acpi_disabled) +if (acpi_disabled || !type)return ; -if (type && type->match && type->find_companion) { -down_write (&dev_type_sem); -list_add_tail (&type->list, &dev_type_list); -up_write (&dev_type_sem); -pr_info ("device type %s registered\n" , type->name); - } +INIT_LIST_HEAD (&type->list); + +if (!type->dev_type || !type->find_companion) +return ; + +guard (rwsem_write)(&dev_type_sem); + +list_add_tail (&type->list, &dev_type_list); + +pr_info ("Device type %s added to lookup list\n" , type->dev_type->name); }EXPORT_SYMBOL_GPL (register_acpi_dev_type);void unregister_acpi_dev_type (struct acpi_dev_type *type) { -if (acpi_disabled) +if (acpi_disabled || !type || !type->dev_type || !type->find_companion)return ; -if (type) { -down_write (&dev_type_sem); -list_del_init (&type->list); -up_write (&dev_type_sem); -pr_info ("device type %s unregistered\n" , type->name); - } +guard (rwsem_write)(&dev_type_sem); + +list_del (&type->list); + +pr_info ("Device type %s removed from lookup list\n" , type->dev_type->name); }EXPORT_SYMBOL_GPL (unregister_acpi_dev_type);
@@ -69,7 +72,7 @@ static struct acpi_device *acpi_companion_lookup(struct device *dev)list_for_each_entry (type, &dev_type_list, list) {struct acpi_device *adev; -if (!type->match (dev)) +if (type->dev_type != dev->type)continue ; adev = type->find_companion (dev);
drivers/gpu/drm/drm_sysfs.c +1 -7
@@ -64,11 +64,6 @@ static struct device_type drm_sysfs_device_connector = {struct class *drm_class;#ifdef CONFIG_ACPI -static bool drm_connector_acpi_dev_type_match (struct device *dev) -{ -return dev->type == &drm_sysfs_device_connector; -} -static struct acpi_device *drm_connector_acpi_find_companion (struct device *dev) {struct drm_connector *connector =to_drm_connector (dev);
@@ -77,8 +72,7 @@ static struct acpi_device *drm_connector_acpi_find_companion(struct device *dev) }static struct acpi_dev_type drm_connector_acpi_dev_type = { - .name ="drm_connector" , - .match = drm_connector_acpi_dev_type_match, + .dev_type = &drm_sysfs_device_connector, .find_companion = drm_connector_acpi_find_companion, };
drivers/thunderbolt/acpi.c +32 -37
101 lines not on this page · raw message
drivers/usb/core/usb-acpi.c +19 -28
75 lines not on this page · raw message
include/acpi/acpi_bus.h +2 -2
@@ -661,11 +661,11 @@ static inline bool acpi_device_enumerated(struct acpi_device *adev)*/ struct acpi_dev_type {struct list_head list; -const char *name; -bool (*match)(struct device *dev); +const struct device_type *dev_type;struct acpi_device * (*find_companion)(struct device *);void (*setup)(struct device *); }; +void register_acpi_dev_type (struct acpi_dev_type *type);void unregister_acpi_dev_type (struct acpi_dev_type *type);int acpi_bind_one (struct device *dev,struct acpi_device *adev);
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH v1 3/3] ACPI: glue: Simplify struct acpi_dev_type and its usage
Sashiko has reviewed this patch and found no issues.
Quoted 19 lines
From: "Rafael J. Wysocki" <[email protected]>
All of the current users of struct
acpi_dev_typematch the device type in their .match() callbacks and all of them use const device type pointers for that which means that the structure can be simplified and used in a more straightforward way.Namely, modify struct
acpi_dev_typeto contain a const device type pointer instead of the .match() callback and remove the name field from it. Next, update the users of structacpi_dev_typeto register a separate object of that type for each device type that requires an ACPI companion lookup.Since the
register_acpi_dev_type()andunregister_acpi_dev_type()function bodies are rewiritten entirely anyway, make them useguard(rwsem_write)instead of down_write()/up_write() pairs and print the messages under the semaphore to ensure that the structacpi_dev_typeobjects they refer to will not be freed prematurely.
Quoted 3 lines
No intentional functional impact beyond messaging.
Signed-off-by Rafael J. Wysocki <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Rafael J. Wysocki (Intel)
maintainerQuoted 28 lines · Rafael J. Wysocki
Hi All,
The ACPI "glue" code is responsible for binding Linux devices (like platform devices for one example) to their ACPI companions (represented by struct
acpi_deviceobjects). This is done byacpi_device_notify()when the given device is registered.If the device's ACPI companion is set already at that point, the binding simply adds the device to the list of "physical nodes" associated with its ACPI companion. That's the case for PCI devices and platform devices, for example. However, there are cases in which the ACPI companion is not set upfront and it needs to be looked up via "lookup helpers" registered by the subsystems the devices in question belong to. This series changes the "lookup helpers" representation and handling.
Before the changes, the "lookup helpers" are represented by struct
acpi_bus_typeobjects which is doubly confusing because they have nothing to do with bus types and because the "acpi_bus_type" name is also used elsewhere. Patch [1/3] renames structacpi_bus_typeto structacpi_dev_typebecause all of the existing "lookup helpers" operate on device types.Next, the registration and unregistration functions for "lookup helpers" are defined to return an int, but all of their existing users effectively discard their return values (they are discarded right away or passed up the call chain and then discarded). Patch [2/3] changes the return type of those functions to void.
Quoted 5 lines
Finally, since all of the existing "lookup helpers" match
dev->typeto a certain device type, they can be rearranged to point to the device types in question and provide a .find_companion() callback, and an additional .setup() callback in one case. This is done by patch [3/3] and allows all of the affected code to be simplified quite a bit.
In the absence of any feedback I will assume no objections or concerns and I'll queue up this lot for 7.5.
Thanks!
Rafael J. Wysocki (Intel)
maintainerQuoted 30 lines · Rafael J. Wysocki (Intel)
Quoted 28 lines · Rafael J. Wysocki
Hi All,
The ACPI "glue" code is responsible for binding Linux devices (like platform devices for one example) to their ACPI companions (represented by struct
acpi_deviceobjects). This is done byacpi_device_notify()when the given device is registered.If the device's ACPI companion is set already at that point, the binding simply adds the device to the list of "physical nodes" associated with its ACPI companion. That's the case for PCI devices and platform devices, for example. However, there are cases in which the ACPI companion is not set upfront and it needs to be looked up via "lookup helpers" registered by the subsystems the devices in question belong to. This series changes the "lookup helpers" representation and handling.
Before the changes, the "lookup helpers" are represented by struct
acpi_bus_typeobjects which is doubly confusing because they have nothing to do with bus types and because the "acpi_bus_type" name is also used elsewhere. Patch [1/3] renames structacpi_bus_typeto structacpi_dev_typebecause all of the existing "lookup helpers" operate on device types.Next, the registration and unregistration functions for "lookup helpers" are defined to return an int, but all of their existing users effectively discard their return values (they are discarded right away or passed up the call chain and then discarded). Patch [2/3] changes the return type of those functions to void.
Quoted 8 lines
Quoted 5 lines
Finally, since all of the existing "lookup helpers" match
dev->typeto a certain device type, they can be rearranged to point to the device types in question and provide a .find_companion() callback, and an additional .setup() callback in one case. This is done by patch [3/3] and allows all of the affected code to be simplified quite a bit.In the absence of any feedback I will assume no objections or concerns and I'll queue up this lot for 7.5.
And so applied.
Thanks!