From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Joerg Roedel <joro@8bytes.org>, iommu@lists.linux-foundation.org, Adrian Hunter <adrian.hunter@intel.com>, Ulf Hansson <ulf.hansson@linaro.org>, linux-mmc@vger.kernel.org, "Rafael J. Wysocki" <rjw@rjwysocki.net>, linux-acpi@vger.kernel.org Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 2/5] ACPI / utils: Introduce acpi_dev_hid_uid_match() helper Date: Tue, 24 Sep 2019 15:01:50 +0300 Message-ID: <20190924120153.8382-2-andriy.shevchenko@linux.intel.com> (raw) In-Reply-To: <20190924120153.8382-1-andriy.shevchenko@linux.intel.com> There are users outside of ACPI realm which reimplementing the comparator function to check if the given device matches to given HID and UID. For better utilization, introduce a helper for everyone to use. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/acpi/utils.c | 25 +++++++++++++++++++++++++ include/acpi/acpi_bus.h | 3 +++ include/linux/acpi.h | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index dbd1c4cfd7d1..804ac0df58ec 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -701,6 +701,31 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs) } EXPORT_SYMBOL(acpi_check_dsm); +/** + * acpi_dev_hid_uid_match - Match device by supplied HID and UID + * @adev: ACPI device to match. + * @hid2: Hardware ID of the device. + * @uid2: Unique ID of the device, pass NULL to not check _UID. + * + * Matches HID and UID in @adev with given @hid2 and @uid2. + * Returns true if matches. + */ +bool acpi_dev_hid_uid_match(struct acpi_device *adev, + const char *hid2, const char *uid2) +{ + const char *hid1 = acpi_device_hid(adev); + const char *uid1 = acpi_device_uid(adev); + + if (strcmp(hid1, hid2)) + return false; + + if (!uid2) + return true; + + return uid1 && !strcmp(uid1, uid2); +} +EXPORT_SYMBOL(acpi_dev_hid_uid_match); + /** * acpi_dev_found - Detect presence of a given ACPI device in the namespace. * @hid: Hardware ID of the device. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 175f7b40c585..d3cc8a786065 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -75,6 +75,9 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev, .package.elements = (eles) \ } +bool acpi_dev_hid_uid_match(struct acpi_device *adev, + const char *hid2, const char *uid2); + bool acpi_dev_found(const char *hid); bool acpi_dev_present(const char *hid, const char *uid, s64 hrv); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 9426b9aaed86..272b51a4f385 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -662,6 +662,12 @@ static inline u64 acpi_arch_get_root_pointer(void) struct fwnode_handle; +static inline bool acpi_dev_hid_uid_match(struct acpi_device *adev, + const char *hid2, const char *uid2) +{ + return false; +} + static inline bool acpi_dev_found(const char *hid) { return false; -- 2.23.0 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply index Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-24 12:01 [PATCH v1 1/5] ACPI / utils: Describe function parameters in kernel-doc Andy Shevchenko 2019-09-24 12:01 ` Andy Shevchenko [this message] 2019-09-24 17:24 ` [PATCH v1 2/5] ACPI / utils: Introduce acpi_dev_hid_uid_match() helper kbuild test robot 2019-09-24 17:24 ` kbuild test robot 2019-09-24 12:01 ` [PATCH v1 3/5] ACPI / LPSS: Switch to use acpi_dev_hid_uid_match() Andy Shevchenko 2019-09-24 16:52 ` kbuild test robot 2019-09-24 12:01 ` [PATCH v1 4/5] mmc: sdhci-acpi: " Andy Shevchenko 2019-09-24 17:34 ` kbuild test robot 2019-09-24 12:01 ` [PATCH v1 5/5] iommu/amd: " Andy Shevchenko 2019-09-24 12:16 ` Andy Shevchenko
Reply instructions: You may reply publically 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=20190924120153.8382-2-andriy.shevchenko@linux.intel.com \ --to=andriy.shevchenko@linux.intel.com \ --cc=adrian.hunter@intel.com \ --cc=iommu@lists.linux-foundation.org \ --cc=joro@8bytes.org \ --cc=linux-acpi@vger.kernel.org \ --cc=linux-mmc@vger.kernel.org \ --cc=rjw@rjwysocki.net \ --cc=ulf.hansson@linaro.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
IOMMU Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-iommu/0 linux-iommu/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-iommu linux-iommu/ https://lore.kernel.org/linux-iommu \ iommu@lists.linux-foundation.org public-inbox-index linux-iommu Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.linux-foundation.lists.iommu AGPL code for this site: git clone https://public-inbox.org/public-inbox.git