summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-04-10 16:07:30 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-04-10 16:07:30 +0200
commit54fe9ce385d499fe5a2bb0c68f092c97dad9365c (patch)
tree3068d2382c54d1f3fb7d40c55e3e6863891a2a7b /drivers/acpi/scan.c
parentACPI / scan: fix fixed event handler return value (diff)
downloadlinux-54fe9ce385d499fe5a2bb0c68f092c97dad9365c.tar.xz
linux-54fe9ce385d499fe5a2bb0c68f092c97dad9365c.zip
ACPI / scan: Generalize of_compatible matching
Redefine the function used for matching the device's "compatible" property against a given list of "compatible" strings to take a pointer to that list instead of a driver object pointer to make it more general. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 3e5a2768c3b4..99f97ac64aa4 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -949,9 +949,17 @@ int acpi_match_device_ids(struct acpi_device *device,
}
EXPORT_SYMBOL(acpi_match_device_ids);
-/* Performs match against special "PRP0001" shoehorn ACPI ID */
-static bool acpi_of_driver_match_device(struct device *dev,
- const struct device_driver *drv)
+/**
+ * acpi_of_match_device - Match device using the "compatible" property.
+ * @dev: Device to match.
+ * @of_match_table: List of device IDs to match against.
+ *
+ * If @dev has an ACPI companion which has the special PRP0001 device ID in its
+ * list of identifiers and a _DSD object with the "compatible" property, use
+ * that property to match against the given list of identifiers.
+ */
+static bool acpi_of_match_device(struct device *dev,
+ const struct of_device_id *of_match_table)
{
const union acpi_object *of_compatible, *obj;
struct acpi_device *adev;
@@ -962,7 +970,7 @@ static bool acpi_of_driver_match_device(struct device *dev,
return false;
of_compatible = adev->data.of_compatible;
- if (!drv->of_match_table || !of_compatible)
+ if (!of_match_table || !of_compatible)
return false;
if (of_compatible->type == ACPI_TYPE_PACKAGE) {
@@ -976,7 +984,7 @@ static bool acpi_of_driver_match_device(struct device *dev,
for (i = 0; i < nval; i++, obj++) {
const struct of_device_id *id;
- for (id = drv->of_match_table; id->compatible[0]; id++)
+ for (id = of_match_table; id->compatible[0]; id++)
if (!strcasecmp(obj->string.pointer, id->compatible))
return true;
}
@@ -988,7 +996,7 @@ bool acpi_driver_match_device(struct device *dev,
const struct device_driver *drv)
{
if (!drv->acpi_match_table)
- return acpi_of_driver_match_device(dev, drv);
+ return acpi_of_match_device(dev, drv->of_match_table);
return !!acpi_match_device(drv->acpi_match_table, dev);
}