summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-08-10 18:16:33 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-08-23 18:19:27 +0200
commit5c5e1237032aaa39107e2d0bb8e6cb84b3c41161 (patch)
treec6c4145d53fba861928336a7e17e152547781ed6 /drivers/acpi/scan.c
parentACPI: scan: Rename acpi_bus_get_parent() and rearrange it (diff)
downloadlinux-5c5e1237032aaa39107e2d0bb8e6cb84b3c41161.tar.xz
linux-5c5e1237032aaa39107e2d0bb8e6cb84b3c41161.zip
ACPI: scan: Rearrange initialization of ACPI device objects
The initialization of ACPI device objects is split between acpi_init_device_object() and __acpi_device_add() that initializes the dev field in struct acpi_device. The "release" function pointer is passed to __acpi_device_add() for this reason. However, that split is artificial and all of the initialization can be carried out by acpi_init_device_object(), so rearrange the code to that end. In particular, make acpi_init_device_object() take the "release" pointer as an argument, along with the "type" which is related to it, instead of __acpi_device_add(). No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Punit Agrawal <punit.agrawal@bytedance.com>
Diffstat (limited to '')
-rw-r--r--drivers/acpi/scan.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 25a104d0b743..75a32f2d0f33 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -673,8 +673,7 @@ static void acpi_store_pld_crc(struct acpi_device *adev)
ACPI_FREE(pld);
}
-static int __acpi_device_add(struct acpi_device *device,
- void (*release)(struct device *))
+static int __acpi_device_add(struct acpi_device *device)
{
struct acpi_device_bus_id *acpi_device_bus_id;
int result;
@@ -730,11 +729,6 @@ static int __acpi_device_add(struct acpi_device *device,
mutex_unlock(&acpi_device_lock);
- if (device->parent)
- device->dev.parent = &device->parent->dev;
-
- device->dev.bus = &acpi_bus_type;
- device->dev.release = release;
result = device_add(&device->dev);
if (result) {
dev_err(&device->dev, "Error registering device\n");
@@ -761,7 +755,7 @@ err_unlock:
return result;
}
-int acpi_device_add(struct acpi_device *adev, void (*release)(struct device *))
+int acpi_device_add(struct acpi_device *adev)
{
int ret;
@@ -769,7 +763,7 @@ int acpi_device_add(struct acpi_device *adev, void (*release)(struct device *))
if (ret)
return ret;
- return __acpi_device_add(adev, release);
+ return __acpi_device_add(adev);
}
/* --------------------------------------------------------------------------
@@ -1777,12 +1771,19 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
}
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
- int type)
+ int type, void (*release)(struct device *))
{
+ struct acpi_device *parent = acpi_find_parent_acpi_dev(handle);
+
INIT_LIST_HEAD(&device->pnp.ids);
device->device_type = type;
device->handle = handle;
- device->parent = acpi_find_parent_acpi_dev(handle);
+ if (parent) {
+ device->parent = parent;
+ device->dev.parent = &parent->dev;
+ }
+ device->dev.release = release;
+ device->dev.bus = &acpi_bus_type;
fwnode_init(&device->fwnode, &acpi_device_fwnode_ops);
acpi_set_device_status(device, ACPI_STA_DEFAULT);
acpi_device_get_busid(device);
@@ -1836,7 +1837,7 @@ static int acpi_add_single_object(struct acpi_device **child,
if (!device)
return -ENOMEM;
- acpi_init_device_object(device, handle, type);
+ acpi_init_device_object(device, handle, type, acpi_device_release);
/*
* Getting the status is delayed till here so that we can call
* acpi_bus_get_status() and use its quirk handling. Note that
@@ -1866,7 +1867,7 @@ static int acpi_add_single_object(struct acpi_device **child,
mutex_unlock(&acpi_dep_list_lock);
if (!result)
- result = __acpi_device_add(device, acpi_device_release);
+ result = __acpi_device_add(device);
if (result) {
acpi_device_release(&device->dev);