提交 ca5b74d2 编写于 作者: R Rafael J. Wysocki

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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 ce793486
...@@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) ...@@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
unsigned int node_id; unsigned int node_id;
int retval = -EINVAL; int retval = -EINVAL;
if (ACPI_COMPANION(dev)) { if (has_acpi_companion(dev)) {
if (acpi_dev) { if (acpi_dev) {
dev_warn(dev, "ACPI companion already set\n"); dev_warn(dev, "ACPI companion already set\n");
return -EINVAL; return -EINVAL;
...@@ -220,7 +220,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) ...@@ -220,7 +220,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
list_add(&physical_node->node, physnode_list); list_add(&physical_node->node, physnode_list);
acpi_dev->physical_node_count++; acpi_dev->physical_node_count++;
if (!ACPI_COMPANION(dev)) if (!has_acpi_companion(dev))
ACPI_COMPANION_SET(dev, acpi_dev); ACPI_COMPANION_SET(dev, acpi_dev);
acpi_physnode_link_name(physical_node_name, node_id); acpi_physnode_link_name(physical_node_name, node_id);
......
...@@ -166,7 +166,7 @@ static int dw_i2c_probe(struct platform_device *pdev) ...@@ -166,7 +166,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
/* fast mode by default because of legacy reasons */ /* fast mode by default because of legacy reasons */
clk_freq = 400000; clk_freq = 400000;
if (ACPI_COMPANION(&pdev->dev)) { if (has_acpi_companion(&pdev->dev)) {
dw_i2c_acpi_configure(pdev); dw_i2c_acpi_configure(pdev);
} else if (pdev->dev.of_node) { } else if (pdev->dev.of_node) {
of_property_read_u32(pdev->dev.of_node, of_property_read_u32(pdev->dev.of_node,
...@@ -286,7 +286,7 @@ static int dw_i2c_remove(struct platform_device *pdev) ...@@ -286,7 +286,7 @@ static int dw_i2c_remove(struct platform_device *pdev)
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
if (ACPI_COMPANION(&pdev->dev)) if (has_acpi_companion(&pdev->dev))
dw_i2c_acpi_unconfigure(pdev); dw_i2c_acpi_unconfigure(pdev);
return 0; return 0;
......
...@@ -684,7 +684,7 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf ...@@ -684,7 +684,7 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
if (dev_is_pci(dev)) { if (dev_is_pci(dev)) {
pdev = to_pci_dev(dev); pdev = to_pci_dev(dev);
segment = pci_domain_nr(pdev->bus); segment = pci_domain_nr(pdev->bus);
} else if (ACPI_COMPANION(dev)) } else if (has_acpi_companion(dev))
dev = &ACPI_COMPANION(dev)->dev; dev = &ACPI_COMPANION(dev)->dev;
rcu_read_lock(); rcu_read_lock();
......
...@@ -58,6 +58,11 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) ...@@ -58,6 +58,11 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
acpi_fwnode_handle(adev) : NULL acpi_fwnode_handle(adev) : NULL
#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
static inline bool has_acpi_companion(struct device *dev)
{
return is_acpi_node(dev->fwnode);
}
static inline void acpi_preset_companion(struct device *dev, static inline void acpi_preset_companion(struct device *dev,
struct acpi_device *parent, u64 addr) struct acpi_device *parent, u64 addr)
{ {
...@@ -472,6 +477,11 @@ static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev) ...@@ -472,6 +477,11 @@ static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
return NULL; return NULL;
} }
static inline bool has_acpi_companion(struct device *dev)
{
return false;
}
static inline const char *acpi_dev_name(struct acpi_device *adev) static inline const char *acpi_dev_name(struct acpi_device *adev)
{ {
return NULL; return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册