Skip to content

Commit 4f4a335

Browse files
committed
ACPI: scan: Consolidate Device Check and Bus Check notification handling
There is no particular reason why device object subtree rescans in acpi_scan_device_check() and acpi_scan_device_check() should be carried out differently, so move the rescan code into a new function called acpi_scan_rescan_bus() and make both the functions above invoke it. While at it, in the Device Check case, start the device object subtree rescan mentioned above from the target device's parent, as per the specification. [1] Link: https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#device-object-notification-values # [1] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 520c228 commit 4f4a335

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

drivers/acpi/scan.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,25 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
336336
return 0;
337337
}
338338

339+
static int acpi_scan_rescan_bus(struct acpi_device *adev)
340+
{
341+
struct acpi_scan_handler *handler = adev->handler;
342+
int ret;
343+
344+
if (handler && handler->hotplug.scan_dependent)
345+
ret = handler->hotplug.scan_dependent(adev);
346+
else
347+
ret = acpi_bus_scan(adev->handle);
348+
349+
if (ret)
350+
dev_info(&adev->dev, "Namespace scan failure\n");
351+
352+
return ret;
353+
}
354+
339355
static int acpi_scan_device_check(struct acpi_device *adev)
340356
{
341-
int error;
357+
struct acpi_device *parent;
342358

343359
acpi_scan_check_subtree(adev);
344360

@@ -356,36 +372,26 @@ static int acpi_scan_device_check(struct acpi_device *adev)
356372
dev_dbg(&adev->dev, "Already enumerated\n");
357373
return 0;
358374
}
359-
error = acpi_bus_scan(adev->handle);
360-
if (error)
361-
dev_warn(&adev->dev, "Namespace scan failure\n");
362375

363-
return error;
376+
parent = acpi_dev_parent(adev);
377+
if (!parent)
378+
parent = adev;
379+
380+
return acpi_scan_rescan_bus(parent);
364381
}
365382

366-
static int acpi_scan_bus_check(struct acpi_device *adev, void *not_used)
383+
static int acpi_scan_bus_check(struct acpi_device *adev)
367384
{
368-
struct acpi_scan_handler *handler = adev->handler;
369-
int error;
370-
371385
acpi_scan_check_subtree(adev);
372386

373-
if (handler && handler->hotplug.scan_dependent)
374-
return handler->hotplug.scan_dependent(adev);
375-
376-
error = acpi_bus_scan(adev->handle);
377-
if (error) {
378-
dev_warn(&adev->dev, "Namespace scan failure\n");
379-
return error;
380-
}
381-
return acpi_dev_for_each_child(adev, acpi_scan_bus_check, NULL);
387+
return acpi_scan_rescan_bus(adev);
382388
}
383389

384390
static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
385391
{
386392
switch (type) {
387393
case ACPI_NOTIFY_BUS_CHECK:
388-
return acpi_scan_bus_check(adev, NULL);
394+
return acpi_scan_bus_check(adev);
389395
case ACPI_NOTIFY_DEVICE_CHECK:
390396
return acpi_scan_device_check(adev);
391397
case ACPI_NOTIFY_EJECT_REQUEST:

0 commit comments

Comments
 (0)