Subject: [PATCH] [acpi driver model] Add support for drivers' ->d_probe() in matching code. - Call ->d_probe() if we find a match of a device's ID and one of the driver's ID. The dummy ->d_probe() will always return 1, verifying the match. If it's implemented, it will return 0, telling us that it's not really a match. - If the driver doesn't support any IDs, only call ->d_probe() which returns whether or not the device is supported. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/core/bus.c | 59 ++++++++++++++++++++++++++++++++------- 1 files changed, 48 insertions(+), 11 deletions(-) applies-to: 314093f6e8559e4378a3dc31ced4f01c84c3a840 3f9e72e7e3b52169276dadb54ca4b7f97f1dbef4 diff --git a/drivers/acpi/drivers/core/bus.c b/drivers/acpi/drivers/core/bus.c index 6f53c46..a533245 100644 --- a/drivers/acpi/drivers/core/bus.c +++ b/drivers/acpi/drivers/core/bus.c @@ -53,22 +53,59 @@ static int acpi_bus_match(struct device { struct acpi_dev * ad = to_acpi_dev(dev); struct acpi_device_driver * adrv = to_acpi_driver(drv); - - /* - * First, try the HID.. - */ - if (match_id(ad, adrv, acpi_dev_hid(ad))) - return 1; + int found_match = 0; + /* - * If that doesn't work, try to match each _CID of the - * device with each UID that the driver supports. + * Try to match one of the driver's supported IDs with the + * HID or CID of the device. (But, only try this if the driver + * supports devices with IDs (not the case w/ e.g. video devices + * that don't have a HID or CID)). */ + if (adrv->d_num_ids) { - if (match_cid(ad, adrv)) - return 1; + /* + * First, try the HID.. + */ + found_match = match_id(ad, adrv, acpi_dev_hid(ad)); + + /* + * ..but if that doesn't work, try to match each _CID + * of the device with each UID that the driver supports. + */ + if (!found_match) + found_match = match_cid(ad, adrv); + + /* + * If we found a matching ID, call the driver's ->d_probe() method + * in the event that it needs to do a manual check to that it can + * support the device. + * + * Every driver will have at least a dummy ->d_probe() defined + * that always returns 1. + */ + + if (found_match) { + int probe_good = adrv->d_probe(ad); + + /* + * If ->d_probe() returns 0, then revoke the 'matched' + * status. + * + * Otherwise, we're good to go. + */ + if (!probe_good) + found_match = 0; + } + } else { + /* + * If the driver doesn't have any IDs to bind to, then call the + * ->d_probe() method to manually check for a supported device. + */ + found_match = adrv->d_probe(ad); + } - return 0; + return found_match; } --- 0.99.9.GIT