diff mbox series

[v5,06/18] ACPI: scan: Add parameter to allow defering some actions in acpi_scan_check_and_detach.

Message ID 20240412143719.11398-7-Jonathan.Cameron@huawei.com
State New
Headers show
Series ACPI/arm64: add support for virtual cpu hotplug | expand

Commit Message

Jonathan Cameron April 12, 2024, 2:37 p.m. UTC
Precursor patch adds the ability to pass a flag (not yet used) into
acpi_scan_check_and detach().  Done in a separate patch with no
functional changes to reduce complexity of the actual deferal which
follows.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

---
v5: New patch resulting from rebase.
    - Internal review suggested we could also do this with flags
      so I'm looking for feedback on which option people find
      more readable.
---
 drivers/acpi/scan.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 7c157bf92695..79b1f4d2b6bd 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -244,13 +244,19 @@  static int acpi_scan_try_to_offline(struct acpi_device *device)
 	return 0;
 }
 
-static int acpi_scan_check_and_detach(struct acpi_device *adev, void *check)
+struct acpi_scan_c_and_d_param {
+	bool check_status;
+	bool eject;
+};
+
+static int acpi_scan_check_and_detach(struct acpi_device *adev, void *p)
 {
 	struct acpi_scan_handler *handler = adev->handler;
+	struct acpi_scan_c_and_d_param *param = p;
 
-	acpi_dev_for_each_child_reverse(adev, acpi_scan_check_and_detach, check);
+	acpi_dev_for_each_child_reverse(adev, acpi_scan_check_and_detach, p);
 
-	if (check) {
+	if (param->check_status) {
 		acpi_bus_get_status(adev);
 		/*
 		 * Skip devices that are still there and take the enabled
@@ -288,7 +294,11 @@  static int acpi_scan_check_and_detach(struct acpi_device *adev, void *check)
 
 static void acpi_scan_check_subtree(struct acpi_device *adev)
 {
-	acpi_scan_check_and_detach(adev, (void *)true);
+	struct acpi_scan_c_and_d_param p = {
+		.check_status = true, /* Not update until after ej0 */
+		.eject = false,
+	};
+	acpi_scan_check_and_detach(adev, &p);
 }
 
 static int acpi_scan_hot_remove(struct acpi_device *device)
@@ -2600,7 +2610,12 @@  EXPORT_SYMBOL(acpi_bus_scan);
  */
 void acpi_bus_trim(struct acpi_device *adev)
 {
-	acpi_scan_check_and_detach(adev, NULL);
+	struct acpi_scan_c_and_d_param p = {
+		.check_status = false,
+		.eject = false,
+	};
+
+	acpi_scan_check_and_detach(adev, &p);
 }
 EXPORT_SYMBOL_GPL(acpi_bus_trim);