Skip to contentSkip to conversation

ACPI: bus: Introduce acpi_bus_for_each_dev()

PATCH In review Rafael J. Wysocki 3 participants 3 messages Feb 22, 2022 – Mar 2, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: bus: Introduce acpi_bus_for_each_dev()

From: Rafael J. Wysocki <[email protected]>

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.

---
 drivers/acpi/bus.c              |    7 ++++++-
 drivers/usb/typec/port-mapper.c |    2 +-
 include/acpi/acpi_bus.h         |    2 ++
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/acpi/bus.c +6 -1
Index: linux-pm/drivers/acpi/bus.c
===================================================================
@@ -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
include/acpi/acpi_bus.h +2 -0
Index: linux-pm/include/acpi/acpi_bus.h
===================================================================
@@ -480,6 +480,8 @@ void acpi_initialize_hp_context(struct a
 /* 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
  * ------
drivers/usb/typec/port-mapper.c +1 -1
Index: linux-pm/drivers/usb/typec/port-mapper.c
===================================================================
@@ -59,7 +59,7 @@ int typec_link_ports(struct typec_port *
 	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;
 
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

Quoted 5 lines

Having done that, drop the acpi_bus_type export.

No intentional functional impact.

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

Quoted 5 lines

Having done that, drop the acpi_bus_type export.

No intentional functional impact.

FWIW:

Quoted 52 lines
---
 drivers/acpi/bus.c              |    7 ++++++-
 drivers/usb/typec/port-mapper.c |    2 +-
 include/acpi/acpi_bus.h         |    2 ++
 3 files changed, 9 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/acpi/bus.c
===================================================================

drivers/acpi/bus.c +6 -1
@@ -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: linux-pm/include/acpi/acpi_bus.h
===================================================================

include/acpi/acpi_bus.h +2 -0
@@ -480,6 +480,8 @@ void acpi_initialize_hp_context(struct a
 /* 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
  * ------

Index: linux-pm/drivers/usb/typec/port-mapper.c
===================================================================

drivers/usb/typec/port-mapper.c +1 -1
@@ -59,7 +59,7 @@ int typec_link_ports(struct typec_port *
 	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;
 
Signature · 1 line
heikki