aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-03-16 18:49:08 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-03-16 18:49:08 -0400
commitca5b74d2675a44f54aacb919c1cf022463e2f738 (patch)
tree08081e436bfed580e7f5a059faa1c77da3dbd58e
parentce793486e23e0162a732c605189c8028e0910e86 (diff)
ACPI: Introduce has_acpi_companion()
Now that the ACPI companions of devices are represented by pointers to struct fwnode_handle, it is not quite efficient to check whether or not an ACPI companion of a device is present by evaluating the ACPI_COMPANION() macro. For this reason, introduce a special static inline routine for that, has_acpi_companion(), and update the code to use it where applicable. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/glue.c4
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c4
-rw-r--r--drivers/iommu/intel-iommu.c2
-rw-r--r--include/linux/acpi.h10
4 files changed, 15 insertions, 5 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f774c65ecb8b..39c485b0c25c 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
168 unsigned int node_id; 168 unsigned int node_id;
169 int retval = -EINVAL; 169 int retval = -EINVAL;
170 170
171 if (ACPI_COMPANION(dev)) { 171 if (has_acpi_companion(dev)) {
172 if (acpi_dev) { 172 if (acpi_dev) {
173 dev_warn(dev, "ACPI companion already set\n"); 173 dev_warn(dev, "ACPI companion already set\n");
174 return -EINVAL; 174 return -EINVAL;
@@ -220,7 +220,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
220 list_add(&physical_node->node, physnode_list); 220 list_add(&physical_node->node, physnode_list);
221 acpi_dev->physical_node_count++; 221 acpi_dev->physical_node_count++;
222 222
223 if (!ACPI_COMPANION(dev)) 223 if (!has_acpi_companion(dev))
224 ACPI_COMPANION_SET(dev, acpi_dev); 224 ACPI_COMPANION_SET(dev, acpi_dev);
225 225
226 acpi_physnode_link_name(physical_node_name, node_id); 226 acpi_physnode_link_name(physical_node_name, node_id);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index c270f5f9a8f9..538d6910b550 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -166,7 +166,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
166 /* fast mode by default because of legacy reasons */ 166 /* fast mode by default because of legacy reasons */
167 clk_freq = 400000; 167 clk_freq = 400000;
168 168
169 if (ACPI_COMPANION(&pdev->dev)) { 169 if (has_acpi_companion(&pdev->dev)) {
170 dw_i2c_acpi_configure(pdev); 170 dw_i2c_acpi_configure(pdev);
171 } else if (pdev->dev.of_node) { 171 } else if (pdev->dev.of_node) {
172 of_property_read_u32(pdev->dev.of_node, 172 of_property_read_u32(pdev->dev.of_node,
@@ -286,7 +286,7 @@ static int dw_i2c_remove(struct platform_device *pdev)
286 pm_runtime_put(&pdev->dev); 286 pm_runtime_put(&pdev->dev);
287 pm_runtime_disable(&pdev->dev); 287 pm_runtime_disable(&pdev->dev);
288 288
289 if (ACPI_COMPANION(&pdev->dev)) 289 if (has_acpi_companion(&pdev->dev))
290 dw_i2c_acpi_unconfigure(pdev); 290 dw_i2c_acpi_unconfigure(pdev);
291 291
292 return 0; 292 return 0;
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index ae4c1a854e57..591b84331315 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -684,7 +684,7 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
684 if (dev_is_pci(dev)) { 684 if (dev_is_pci(dev)) {
685 pdev = to_pci_dev(dev); 685 pdev = to_pci_dev(dev);
686 segment = pci_domain_nr(pdev->bus); 686 segment = pci_domain_nr(pdev->bus);
687 } else if (ACPI_COMPANION(dev)) 687 } else if (has_acpi_companion(dev))
688 dev = &ACPI_COMPANION(dev)->dev; 688 dev = &ACPI_COMPANION(dev)->dev;
689 689
690 rcu_read_lock(); 690 rcu_read_lock();
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 402ddbdc2da1..ec488d03b518 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -58,6 +58,11 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
58 acpi_fwnode_handle(adev) : NULL 58 acpi_fwnode_handle(adev) : NULL
59#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 59#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
60 60
61static inline bool has_acpi_companion(struct device *dev)
62{
63 return is_acpi_node(dev->fwnode);
64}
65
61static inline void acpi_preset_companion(struct device *dev, 66static inline void acpi_preset_companion(struct device *dev,
62 struct acpi_device *parent, u64 addr) 67 struct acpi_device *parent, u64 addr)
63{ 68{
@@ -472,6 +477,11 @@ static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
472 return NULL; 477 return NULL;
473} 478}
474 479
480static inline bool has_acpi_companion(struct device *dev)
481{
482 return false;
483}
484
475static inline const char *acpi_dev_name(struct acpi_device *adev) 485static inline const char *acpi_dev_name(struct acpi_device *adev)
476{ 486{
477 return NULL; 487 return NULL;