summaryrefslogtreecommitdiff
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-06-16 16:24:30 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-06-17 15:56:03 +0200
commitc6a493a1b603ed216ce69d1faac3f0ddc6a2f8eb (patch)
tree7d5fed3c596c7ba3e97966849c28360c9a472b72 /drivers/acpi/scan.c
parentdc612486c91983a113adefedac030575ea7a4c4a (diff)
ACPI: scan: Reorganize acpi_device_add()
Move the invocation of acpi_attach_data() in acpi_device_add() into a separate function. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index b0bdd9b90e44..c62ce287fdb9 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -633,23 +633,32 @@ static int acpi_device_set_name(struct acpi_device *device,
return 0;
}
+static int acpi_tie_acpi_dev(struct acpi_device *adev)
+{
+ acpi_handle handle = adev->handle;
+ acpi_status status;
+
+ if (!handle)
+ return 0;
+
+ status = acpi_attach_data(handle, acpi_scan_drop_device, adev);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_err(handle, "Unable to attach device data\n");
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
int acpi_device_add(struct acpi_device *device,
void (*release)(struct device *))
{
struct acpi_device_bus_id *acpi_device_bus_id;
int result;
- if (device->handle) {
- acpi_status status;
-
- status = acpi_attach_data(device->handle, acpi_scan_drop_device,
- device);
- if (ACPI_FAILURE(status)) {
- acpi_handle_err(device->handle,
- "Unable to attach device data\n");
- return -ENODEV;
- }
- }
+ result = acpi_tie_acpi_dev(device);
+ if (result)
+ return result;
/*
* Linkage