From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>
Subject: [PATCH v1 5/5] ACPI: bus: Use the matching table, if ACPI driver has it
Date: Thu, 25 Aug 2022 19:41:03 +0300 [thread overview]
Message-ID: <20220825164103.27694-5-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20220825164103.27694-1-andriy.shevchenko@linux.intel.com>
In case we have an ACPI driver, check its ID table for matching,
This allows to use some generic device property APIs in such
drivers.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/acpi/bus.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 3c0f2d050d47..17c98e826bde 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1049,14 +1049,30 @@ static const void *acpi_of_device_get_match_data(const struct device *dev)
return match->data;
}
+static const struct acpi_device_id *acpi_device_get_ids(const struct device *dev)
+{
+ if (dev->driver->acpi_match_table)
+ return dev->driver->acpi_match_table;
+
+ if (dev_is_acpi(dev)) {
+ struct acpi_driver *drv = to_acpi_driver(dev->driver);
+
+ if (drv->ids)
+ return drv->ids;
+ }
+
+ return NULL;
+}
+
const void *acpi_device_get_match_data(const struct device *dev)
{
+ const struct acpi_device_id *ids = acpi_device_get_ids(dev);
const struct acpi_device_id *match;
- if (!dev->driver->acpi_match_table)
+ if (!ids)
return acpi_of_device_get_match_data(dev);
- match = acpi_match_device(dev->driver->acpi_match_table, dev);
+ match = acpi_match_device(ids, dev);
if (!match)
return NULL;
--
2.35.1
next prev parent reply other threads:[~2022-08-25 16:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 16:40 [PATCH v1 1/5] ACPI: bus: Drop kernel doc annotation from acpi_bus_notify() Andy Shevchenko
2022-08-25 16:41 ` [PATCH v1 2/5] ACPI: bus: Refactor acpi_driver_match_device() for better readability Andy Shevchenko
2022-08-25 16:41 ` [PATCH v1 3/5] ACPI: bus: Refactor acpi_bus_register_driver() to get rid of 'ret' Andy Shevchenko
2022-08-25 16:41 ` [PATCH v1 4/5] ACPI: bus: Move bus type operations upper in the code Andy Shevchenko
2022-08-25 16:41 ` Andy Shevchenko [this message]
2022-08-25 17:04 ` [PATCH v1 5/5] ACPI: bus: Use the matching table, if ACPI driver has it Rafael J. Wysocki
2022-08-25 17:17 ` Andy Shevchenko
2022-08-26 17:12 ` Andy Shevchenko
2022-08-27 11:45 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220825164103.27694-5-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.