ACPI: Rename acpi_bus_get/put_acpi_device()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 10 Aug 2022 16:14:22 +0000 (18:14 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 23 Aug 2022 16:19:27 +0000 (18:19 +0200)
Because acpi_bus_get_acpi_device() is completely analogous to
acpi_fetch_acpi_dev(), rename it to acpi_get_acpi_dev() and
add a kerneldoc comment to it.

Accordingly, rename acpi_bus_put_acpi_device() to acpi_put_acpi_dev()
and update all of the users of these two functions.

While at it, move the acpi_fetch_acpi_dev() header next to the
acpi_get_acpi_dev() header in the header file holding them.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Punit Agrawal <punit.agrawal@bytedance.com>
drivers/acpi/bus.c
drivers/acpi/device_pm.c
drivers/acpi/irq.c
drivers/acpi/scan.c
drivers/hwmon/acpi_power_meter.c
include/acpi/acpi_bus.h

index c0d20d997891c34d69c6397f3f1fcfcc96ab0220..f43c6a4b08273a5cf051b7c695ecc8f493560ce4 100644 (file)
@@ -511,7 +511,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
                break;
        }
 
-       adev = acpi_bus_get_acpi_device(handle);
+       adev = acpi_get_acpi_dev(handle);
        if (!adev)
                goto err;
 
@@ -524,14 +524,14 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
        }
 
        if (!hotplug_event) {
-               acpi_bus_put_acpi_device(adev);
+               acpi_put_acpi_dev(adev);
                return;
        }
 
        if (ACPI_SUCCESS(acpi_hotplug_schedule(adev, type)))
                return;
 
-       acpi_bus_put_acpi_device(adev);
+       acpi_put_acpi_dev(adev);
 
  err:
        acpi_evaluate_ost(handle, type, ost_code, NULL);
index 9dce1245689ca2512240b20c6e544ce09b19621c..2b7e08d54c3f0f55deb4ccf78b8069ffc553470e 100644 (file)
@@ -497,7 +497,7 @@ static void acpi_pm_notify_handler(acpi_handle handle, u32 val, void *not_used)
 
        acpi_handle_debug(handle, "Wake notify\n");
 
-       adev = acpi_bus_get_acpi_device(handle);
+       adev = acpi_get_acpi_dev(handle);
        if (!adev)
                return;
 
@@ -515,7 +515,7 @@ static void acpi_pm_notify_handler(acpi_handle handle, u32 val, void *not_used)
 
        mutex_unlock(&acpi_pm_notifier_lock);
 
-       acpi_bus_put_acpi_device(adev);
+       acpi_put_acpi_dev(adev);
 }
 
 /**
index dabe45eba055d1f28721138e832ad422650bcf81..4db5bb587599891418799c2a90a0ac90bdb96b3e 100644 (file)
@@ -118,12 +118,12 @@ acpi_get_irq_source_fwhandle(const struct acpi_resource_source *source,
        if (WARN_ON(ACPI_FAILURE(status)))
                return NULL;
 
-       device = acpi_bus_get_acpi_device(handle);
+       device = acpi_get_acpi_dev(handle);
        if (WARN_ON(!device))
                return NULL;
 
        result = &device->fwnode;
-       acpi_bus_put_acpi_device(device);
+       acpi_put_acpi_dev(device);
        return result;
 }
 
index 42cec8120f18e513d60bed04c3d1b1a389f26864..b3ee0823f73517a6880cb5e74713b67e06ff20e2 100644 (file)
@@ -429,7 +429,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src)
        acpi_evaluate_ost(adev->handle, src, ost_code, NULL);
 
  out:
-       acpi_bus_put_acpi_device(adev);
+       acpi_put_acpi_dev(adev);
        mutex_unlock(&acpi_scan_lock);
        unlock_device_hotplug();
 }
@@ -599,11 +599,22 @@ static void get_acpi_device(void *dev)
        acpi_dev_get(dev);
 }
 
-struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle)
+/**
+ * acpi_get_acpi_dev - Retrieve ACPI device object and reference count it.
+ * @handle: ACPI handle associated with the requested ACPI device object.
+ *
+ * Return a pointer to the ACPI device object associated with @handle and bump
+ * up that object's reference counter (under the ACPI Namespace lock), if
+ * present, or return NULL otherwise.
+ *
+ * The ACPI device object reference acquired by this function needs to be
+ * dropped via acpi_dev_put().
+ */
+struct acpi_device *acpi_get_acpi_dev(acpi_handle handle)
 {
        return handle_to_device(handle, get_acpi_device);
 }
-EXPORT_SYMBOL_GPL(acpi_bus_get_acpi_device);
+EXPORT_SYMBOL_GPL(acpi_get_acpi_dev);
 
 static struct acpi_device_bus_id *acpi_device_bus_id_match(const char *dev_id)
 {
@@ -2239,7 +2250,7 @@ static int acpi_dev_get_first_consumer_dev_cb(struct acpi_dep_data *dep, void *d
 {
        struct acpi_device *adev;
 
-       adev = acpi_bus_get_acpi_device(dep->consumer);
+       adev = acpi_get_acpi_dev(dep->consumer);
        if (adev) {
                *(struct acpi_device **)data = adev;
                return 1;
@@ -2292,7 +2303,7 @@ static bool acpi_scan_clear_dep_queue(struct acpi_device *adev)
 
 static int acpi_scan_clear_dep(struct acpi_dep_data *dep, void *data)
 {
-       struct acpi_device *adev = acpi_bus_get_acpi_device(dep->consumer);
+       struct acpi_device *adev = acpi_get_acpi_dev(dep->consumer);
 
        if (adev) {
                adev->dep_unmet--;
index d2545a1be9fc079145ecf39b2ed4f0fd0031d29a..44e04c75d0d33a59fae32cc82b66613753712775 100644 (file)
@@ -598,7 +598,7 @@ static int read_domain_devices(struct acpi_power_meter_resource *resource)
                        continue;
 
                /* Create a symlink to domain objects */
-               obj = acpi_bus_get_acpi_device(element->reference.handle);
+               obj = acpi_get_acpi_dev(element->reference.handle);
                resource->domain_devices[i] = obj;
                if (!obj)
                        continue;
index e7d27373ff71ff9dc508585eacc118405029fa97..7ff067a5a3bd310741f78d657ef7b56cdba4323c 100644 (file)
@@ -512,7 +512,6 @@ extern int unregister_acpi_notifier(struct notifier_block *);
  * External Functions
  */
 
-struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle);
 acpi_status acpi_bus_get_status_handle(acpi_handle handle,
                                       unsigned long long *sta);
 int acpi_bus_get_status(struct acpi_device *device);
@@ -767,9 +766,10 @@ static inline void acpi_dev_put(struct acpi_device *adev)
                put_device(&adev->dev);
 }
 
-struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);
+struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle);
+struct acpi_device *acpi_get_acpi_dev(acpi_handle handle);
 
-static inline void acpi_bus_put_acpi_device(struct acpi_device *adev)
+static inline void acpi_put_acpi_dev(struct acpi_device *adev)
 {
        acpi_dev_put(adev);
 }