Skip to content

Commit

Permalink
ACPI: bus: Introduce acpi_bus_for_each_dev()
Browse files Browse the repository at this point in the history
In order to avoid exposing acpi_bus_type to modules, introduce an
acpi_bus_for_each_dev() helper for iterating over all ACPI device
objects and make typec_link_ports() use it instead of the raw
bus_for_each_dev() along with acpi_bus_type.

Having done that, drop the acpi_bus_type export.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
  • Loading branch information
Rafael J. Wysocki committed Mar 2, 2022
1 parent 7e57714 commit 3c36fe9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,12 @@ struct bus_type acpi_bus_type = {
.remove = acpi_device_remove,
.uevent = acpi_device_uevent,
};
EXPORT_SYMBOL_GPL(acpi_bus_type);

int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data)
{
return bus_for_each_dev(&acpi_bus_type, NULL, data, fn);
}
EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev);

/* --------------------------------------------------------------------------
Initialization/Cleanup
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/typec/port-mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int typec_link_ports(struct typec_port *con)
if (!has_acpi_companion(&con->dev))
return 0;

bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match);
acpi_bus_for_each_dev(typec_port_match, &arg);
if (!arg.match)
return 0;

Expand Down
2 changes: 2 additions & 0 deletions include/acpi/acpi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ void acpi_initialize_hp_context(struct acpi_device *adev,
/* acpi_device.dev.bus == &acpi_bus_type */
extern struct bus_type acpi_bus_type;

int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data);

/*
* Events
* ------
Expand Down

0 comments on commit 3c36fe9

Please sign in to comment.