]> Pileus Git - ~andy/linux/commitdiff
ACPI / bind: Redefine acpi_preset_companion()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 28 Nov 2013 22:58:28 +0000 (23:58 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 7 Dec 2013 00:05:49 +0000 (01:05 +0100)
Modify acpi_preset_companion() to take a struct acpi_device pointer
instead of an ACPI handle as its second argument and redefine it as
a static inline wrapper around ACPI_COMPANION_SET() passing the
return value of acpi_find_child_device() directly as the second
argument to it.  Update its users to pass struct acpi_device
pointers instead of ACPI handles to it.

This allows some unnecessary acpi_bus_get_device() calls to be
avoided.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Aaron Lu <aaron.lu@intel.com>
Tested-by: Aaron Lu <aaron.lu@intel.com> # for ATA binding
drivers/acpi/glue.c
drivers/ata/libata-acpi.c
drivers/mmc/core/sdio_bus.c
include/acpi/acpi_bus.h
include/linux/acpi.h

index 12b2acbaa1168f8fe015d0002b530e72055a480b..c0d18b2145c1698f1cdc2d58cc6d34bef6209a63 100644 (file)
@@ -149,6 +149,7 @@ struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
        }
        return ret;
 }
+EXPORT_SYMBOL_GPL(acpi_find_child_device);
 
 acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
 {
@@ -298,15 +299,6 @@ int acpi_unbind_one(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(acpi_unbind_one);
 
-void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr)
-{
-       struct acpi_device *adev;
-
-       if (!acpi_bus_get_device(acpi_get_child(parent, addr), &adev))
-               ACPI_COMPANION_SET(dev, adev);
-}
-EXPORT_SYMBOL_GPL(acpi_preset_companion);
-
 static int acpi_platform_notify(struct device *dev)
 {
        struct acpi_bus_type *type = acpi_get_bus_type(dev);
index 8e22d976232835d81ff086083d7b2fd459e2d6d9..9e69a5308693de59abd5c596244033af43f7b3a8 100644 (file)
@@ -178,12 +178,12 @@ static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
 /* bind acpi handle to pata port */
 void ata_acpi_bind_port(struct ata_port *ap)
 {
-       acpi_handle host_handle = ACPI_HANDLE(ap->host->dev);
+       struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
 
-       if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_handle)
+       if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion)
                return;
 
-       acpi_preset_companion(&ap->tdev, host_handle, ap->port_no);
+       acpi_preset_companion(&ap->tdev, host_companion, ap->port_no);
 
        if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
                ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
@@ -196,17 +196,17 @@ void ata_acpi_bind_port(struct ata_port *ap)
 void ata_acpi_bind_dev(struct ata_device *dev)
 {
        struct ata_port *ap = dev->link->ap;
-       acpi_handle port_handle = ACPI_HANDLE(&ap->tdev);
-       acpi_handle host_handle = ACPI_HANDLE(ap->host->dev);
-       acpi_handle parent_handle;
+       struct acpi_device *port_companion = ACPI_COMPANION(&ap->tdev);
+       struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
+       struct acpi_device *parent;
        u64 adr;
 
        /*
-        * For both sata/pata devices, host handle is required.
-        * For pata device, port handle is also required.
+        * For both sata/pata devices, host companion device is required.
+        * For pata device, port companion device is also required.
         */
-       if (libata_noacpi || !host_handle ||
-                       (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_handle))
+       if (libata_noacpi || !host_companion ||
+                       (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_companion))
                return;
 
        if (ap->flags & ATA_FLAG_ACPI_SATA) {
@@ -214,13 +214,13 @@ void ata_acpi_bind_dev(struct ata_device *dev)
                        adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
                else
                        adr = SATA_ADR(ap->port_no, dev->link->pmp);
-               parent_handle = host_handle;
+               parent = host_companion;
        } else {
                adr = dev->devno;
-               parent_handle = port_handle;
+               parent = port_companion;
        }
 
-       acpi_preset_companion(&dev->tdev, parent_handle, adr);
+       acpi_preset_companion(&dev->tdev, parent, adr);
 
        register_hotplug_dock_device(ata_dev_acpi_handle(dev),
                                     &ata_acpi_dev_dock_ops, dev, NULL, NULL);
index 157b570ba343e4648b796e7330e7b75bc052d00a..92d1ba8e8153ab9849ab51037804747cd37df7f1 100644 (file)
@@ -308,7 +308,7 @@ static void sdio_acpi_set_handle(struct sdio_func *func)
        struct mmc_host *host = func->card->host;
        u64 addr = (host->slotno << 16) | func->num;
 
-       acpi_preset_companion(&func->dev, ACPI_HANDLE(host->parent), addr);
+       acpi_preset_companion(&func->dev, ACPI_COMPANION(host->parent), addr);
 }
 #else
 static inline void sdio_acpi_set_handle(struct sdio_func *func) {}
index a1a48f27933a864f2348fc336d5ca1d4d7b90209..918eaab892e1565341bd8e980aa3d5122f412e36 100644 (file)
@@ -435,7 +435,6 @@ struct acpi_pci_root {
 struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
                                           u64 address, bool check_children);
 acpi_handle acpi_get_child(acpi_handle handle, u64 addr);
-void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr);
 int acpi_is_root_bridge(acpi_handle);
 struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
 
index d9099b15b4726404343308a39e5e55d39a16aa05..115c610324d1ec6b9ecc8aa3a67d839636ca35bf 100644 (file)
@@ -53,6 +53,12 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
 #define ACPI_COMPANION_SET(dev, adev)  ACPI_COMPANION(dev) = (adev)
 #define ACPI_HANDLE(dev)               acpi_device_handle(ACPI_COMPANION(dev))
 
+static inline void acpi_preset_companion(struct device *dev,
+                                        struct acpi_device *parent, u64 addr)
+{
+       ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, NULL));
+}
+
 static inline const char *acpi_dev_name(struct acpi_device *adev)
 {
        return dev_name(&adev->dev);