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

From: Jonathan Cameron
Date: Fri Apr 12 2024 - 10:40:36 EST


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@xxxxxxxxxx>

---
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 --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);

--
2.39.2