From patchwork Thu Nov 23 10:06:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 168845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp338273vqx; Thu, 23 Nov 2023 02:08:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHW1EYt+EqDWPY2xfcvOBy4VqppwHUe5432nVgLGPvkO7F59HmlrFuhzGDM2foBd4vpqfBy X-Received: by 2002:a05:6e02:1053:b0:35b:b31:6a4b with SMTP id p19-20020a056e02105300b0035b0b316a4bmr3895977ilj.30.1700734090901; Thu, 23 Nov 2023 02:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700734090; cv=none; d=google.com; s=arc-20160816; b=PM7ytb1uYiByfjHdBWoAyZYpJ0NQgVviJ/dNajjlhKi6gSploj+mY2f2yAQ17j59ZN K8xp82KbMheC2gcLp/1lQFUXt5yBhzxDS33z+Ffo5aa8s0y5wxsa48W3tESKGlrKf5Gs XCutKDfGlbGcTIyi+n0ejQAahdRUSzrbsu9y70jM88iCdPHf2rJ4d33UxL2X7bryGLpn NXl5ESawx2GB75e2X6zqS7z0E3o8SCalLmrLwPcdbRAx9dcYgLyfe2uNrQBJFX7XBDp8 cJvn1bhVPJkh3x4LlBUTsksqUoVJtGnZydZtDqX4YsXCmAG25HpmkcUx7LSutM5PqshX Cxkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=NfYTsuDcqc/kQmopngjjrLxDTSlEDr2/B59Sa6Ol6xA=; fh=LrjGCQr9k+7CYyd6XEdJgJkCFIUW/cPwqK3zW8PbdHI=; b=0vwC/ac5JwFG4jWjjArNIHQvXOjGM9EAnWxyIB5zUGKMsjWYlwySH7fjNhSrPlGYU3 pD4QoOuZz9/hRtV3odnQnb7Sknr1gZ9mj9nbQZp/RXEg9K215C61aBbMVg4qICTcpBVx p0TB2l30uK4C9DLR/DzK1A44cDRd2fnVbmENQCi3bt4Ie4lrffwe5s8Vm+1x7SYTIHce Ti8/jQrB7I4befL9+zuNooaB20Fo68G97CmYMF/LPvMlxclUME39Y3vd8x7iyTtAhy1a fxea1m6pBDlXh5bbX5T/ohqT+kgISgtkadyXA3lP5HhdsA/HWyezBwcXV1WWE5cLRiUY rNHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="g0/9uDb4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id q6-20020a635046000000b005c20241fd89si968476pgl.822.2023.11.23.02.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 02:08:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="g0/9uDb4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0259780834A6; Thu, 23 Nov 2023 02:08:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344740AbjKWKHw (ORCPT + 99 others); Thu, 23 Nov 2023 05:07:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235257AbjKWKHV (ORCPT ); Thu, 23 Nov 2023 05:07:21 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40114D5C; Thu, 23 Nov 2023 02:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700734047; x=1732270047; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=M17rtlGu3x0u3QSxZOF2OqZZLdquFjrEe7DlHL2uUIM=; b=g0/9uDb4clB/q4HySwqyj4+a4xz+4oYB5oN4f81TZUrctuBwnBJmfnYS 3r5GAq732atzqh4QbLPiKo6Ez2NKAmtawuastxOtWrwsTJ8u5Vmd5KnYh sFopdsJe4lO2/ugOo3Q0yhobwh/SHsIVhemVWOe9oXF+ug+qFLTrfzGXS Lcc+qE33t9ysfgANmoPU/LaGlpqd/3RKoq1FyEeqr2quCJyNyfusQ4jDV 2CI17tcgWlE35z5/0iQsgwU2clQ1+Bqs1FlaDeCX3cAgiwRgulumCTiSY lxdjC8qiOUXvfj0l0hb0D0ekdXaYRquIb7znNWhcZPv/Bbt/FGg/SWcaT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="456576407" X-IronPort-AV: E=Sophos;i="6.04,221,1695711600"; d="scan'208";a="456576407" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2023 02:07:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="767160473" X-IronPort-AV: E=Sophos;i="6.04,221,1695711600"; d="scan'208";a="767160473" Received: from inlubt0316.iind.intel.com ([10.191.20.213]) by orsmga002.jf.intel.com with ESMTP; 23 Nov 2023 02:07:12 -0800 From: Raag Jadav To: mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, rafael@kernel.org, lenb@kernel.org, robert.moore@intel.com, ardb@kernel.org, will@kernel.org, mark.rutland@arm.com Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linuxfoundation.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mallikarjunappa.sangannavar@intel.com, bala.senthil@intel.com, Raag Jadav Subject: [PATCH v3 2/5] ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types Date: Thu, 23 Nov 2023 15:36:14 +0530 Message-Id: <20231123100617.28020-3-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231123100617.28020-1-raag.jadav@intel.com> References: <20231123100617.28020-1-raag.jadav@intel.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 23 Nov 2023 02:08:05 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783348950424803413 X-GMAIL-MSGID: 1783348950424803413 Now that we have _UID matching support for both integer and string types, we can support them into acpi_dev_hid_uid_match() helper as well. Signed-off-by: Raag Jadav Reviewed-by: Mika Westerberg --- drivers/acpi/utils.c | 29 ----------------------------- include/acpi/acpi_bus.h | 24 +++++++++++++++++++++++- include/linux/acpi.h | 7 +------ 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index fe7e850c6479..03f6de9a0807 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -824,35 +824,6 @@ 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. Absence of @uid2 - * will be treated as a match. If user wants to validate @uid2, it should be - * done before calling this function. - * - * Returns: - * - %true if matches or @uid2 is NULL. - * - %false otherwise. - */ -bool acpi_dev_hid_uid_match(struct acpi_device *adev, - const char *hid2, const char *uid2) -{ - const char *hid1 = acpi_device_hid(adev); - - if (strcmp(hid1, hid2)) - return false; - - if (!uid2) - return true; - - return acpi_dev_uid_match(adev, uid2); -} -EXPORT_SYMBOL(acpi_dev_hid_uid_match); - /** * acpi_dev_uid_to_integer - treat ACPI device _UID as integer * @adev: ACPI device to get _UID from diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a4622d95a36d..e5b4c3f8d2be 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -857,9 +857,15 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev) adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set); } -bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2); int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer); +static inline bool acpi_dev_hid_match(struct acpi_device *adev, const char *hid2) +{ + const char *hid1 = acpi_device_hid(adev); + + return hid1 && hid2 && !strcmp(hid1, hid2); +} + static inline bool acpi_str_uid_match(struct acpi_device *adev, const char *uid2) { const char *uid1 = acpi_device_uid(adev); @@ -900,6 +906,22 @@ static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2) /* Treat as an integer otherwise */ \ default: acpi_int_uid_match)(adev, uid2) +/** + * 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 0 or NULL to not check _UID. + * + * Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2 + * will be treated as a match. If user wants to validate @uid2, it should be + * done before calling this function. + * + * Returns: %true if matches or @uid2 is 0 or NULL, %false otherwise. + */ +#define acpi_dev_hid_uid_match(adev, hid2, uid2) \ + (acpi_dev_hid_match(adev, hid2) && \ + (!(uid2) || acpi_dev_uid_match(adev, uid2))) + void acpi_dev_clear_dependencies(struct acpi_device *supplier); bool acpi_dev_ready_for_enumeration(const struct acpi_device *device); struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier, diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6f1e9f98fa44..118a18b7ff84 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -765,6 +765,7 @@ const char *acpi_get_subsystem_id(acpi_handle handle); /* Get rid of the -Wunused-variable for adev */ #define acpi_dev_uid_match(adev, uid2) (adev && false) +#define acpi_dev_hid_uid_match(adev, hid2, uid2) (adev && false) #include @@ -782,12 +783,6 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) struct acpi_device; -static inline bool -acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2) -{ - return false; -} - static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) { return -ENODEV;