Skip to content

Commit 54fe9ce

Browse files
committed
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>
1 parent fd9caef commit 54fe9ce

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

drivers/acpi/scan.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -949,9 +949,17 @@ int acpi_match_device_ids(struct acpi_device *device,
949949
}
950950
EXPORT_SYMBOL(acpi_match_device_ids);
951951

952-
/* Performs match against special "PRP0001" shoehorn ACPI ID */
953-
static bool acpi_of_driver_match_device(struct device *dev,
954-
const struct device_driver *drv)
952+
/**
953+
* acpi_of_match_device - Match device using the "compatible" property.
954+
* @dev: Device to match.
955+
* @of_match_table: List of device IDs to match against.
956+
*
957+
* If @dev has an ACPI companion which has the special PRP0001 device ID in its
958+
* list of identifiers and a _DSD object with the "compatible" property, use
959+
* that property to match against the given list of identifiers.
960+
*/
961+
static bool acpi_of_match_device(struct device *dev,
962+
const struct of_device_id *of_match_table)
955963
{
956964
const union acpi_object *of_compatible, *obj;
957965
struct acpi_device *adev;
@@ -962,7 +970,7 @@ static bool acpi_of_driver_match_device(struct device *dev,
962970
return false;
963971

964972
of_compatible = adev->data.of_compatible;
965-
if (!drv->of_match_table || !of_compatible)
973+
if (!of_match_table || !of_compatible)
966974
return false;
967975

968976
if (of_compatible->type == ACPI_TYPE_PACKAGE) {
@@ -976,7 +984,7 @@ static bool acpi_of_driver_match_device(struct device *dev,
976984
for (i = 0; i < nval; i++, obj++) {
977985
const struct of_device_id *id;
978986

979-
for (id = drv->of_match_table; id->compatible[0]; id++)
987+
for (id = of_match_table; id->compatible[0]; id++)
980988
if (!strcasecmp(obj->string.pointer, id->compatible))
981989
return true;
982990
}
@@ -988,7 +996,7 @@ bool acpi_driver_match_device(struct device *dev,
988996
const struct device_driver *drv)
989997
{
990998
if (!drv->acpi_match_table)
991-
return acpi_of_driver_match_device(dev, drv);
999+
return acpi_of_match_device(dev, drv->of_match_table);
9921000

9931001
return !!acpi_match_device(drv->acpi_match_table, dev);
9941002
}

0 commit comments

Comments
 (0)