ACPI: bus: Introduce acpi_bus_for_each_dev()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 22 Feb 2022 19:51:42 +0000 (20:51 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 2 Mar 2022 19:55:47 +0000 (20:55 +0100)
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>
drivers/acpi/bus.c
drivers/usb/typec/port-mapper.c
include/acpi/acpi_bus.h

index 07f604832fd6b125a307a52573478ea2f20acb54..647791d34c19ffd43bbbd51e4d3993ef65fc3533 100644 (file)
@@ -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
index a7d507802509f33aead9cffb53a74257d2bcd6c0..a929e000d0e2cf05b7223f21c4321f9686c876d0 100644 (file)
@@ -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;
 
index ca88c4706f2bba984f580874d45189ce817436ef..3f7f01f03869059f1390b91a0d63831060cafb50 100644 (file)
@@ -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
  * ------