Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2166615rdb; Mon, 20 Nov 2023 04:09:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHO5/OlZUw8/VRya0l2TPydx0MK1Ya9uqKc2jGGm+Nt0KdTR0P6nMC2xddPpJUbSuYOjgUj X-Received: by 2002:a05:6a20:3cab:b0:18a:5593:3ca3 with SMTP id b43-20020a056a203cab00b0018a55933ca3mr2197416pzj.26.1700482167027; Mon, 20 Nov 2023 04:09:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700482167; cv=none; d=google.com; s=arc-20160816; b=SpFxGkUrpfdxq5Vh+g7rCX5zkNZ9XYiz+qPgJqrO/ZY1ZxYjic8/7l9j9b84XxXJh8 x7JaSBNWZvi8mWiPitqk60M+omZwbziMmqlvGvTXI7NuOVcT4zsyo9637lkZFiSenzIt v7ZznGS43wkNOnalFhDGTyYPBE0UsND1DZ1soRoGf3Qb1MOeNB5K4us3SfT2DJF/3Wyj xangS8gyY16zutGzKj4uvJ1tEy9ZRLbC7pJ5au0aJBDGi4NLzUu9M8AgLb2/d4F4aDCn mceLSgUHY+XIxUiPOvUqrtZoxB43Kj2WmtiPT0/sfDMj56SGLW/FqvEo1JcpOfNydzks c7jw== 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=u7eJx6RQ4MPtSk3h0KjCAw+3sSHLhVS71xpDh/PMLlo=; fh=LrjGCQr9k+7CYyd6XEdJgJkCFIUW/cPwqK3zW8PbdHI=; b=lriFK+NzwlafxOLWdxgaxLyebotSyWw6Fi3YzzPaT3hyxKbFXRMVuKv4Y5zZon3d40 knJY0auBg7XtHBpImDNqO3FIKzzAcWTxTETqLP+s75thgjc9hm9VccN/faB6y6BZOrJj EgWd8P4yp5/ko+Enu93k4qrhCcso5Aua9tLjOMbLh1199OW/Z+vyipbb/KWnLxzpWMrL kTCRJaSCqgjDF7ORMKeb+7ObIVgDqrQ3/qaUsaC6frS4dkHUcKLNEGBbGO8cHNV2wNz/ faVtAeyg65V/yLQhS+ffjKs4qALvK4K3HBhl5ymPxO5Wk6kQJ+AMH9QZ3TspqvtZqUA9 jMrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="EaIybLj/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d12-20020a170903230c00b001ce6733e3f6si6103985plh.365.2023.11.20.04.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 04:09:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="EaIybLj/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id BF2A580236F9; Mon, 20 Nov 2023 04:09:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233454AbjKTMJO (ORCPT + 99 others); Mon, 20 Nov 2023 07:09:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbjKTMJL (ORCPT ); Mon, 20 Nov 2023 07:09:11 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EEACA7; Mon, 20 Nov 2023 04:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700482147; x=1732018147; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=grRMXiEtkBznUlyfaZprJCk2FG73YbohNhePpa+Muco=; b=EaIybLj/aiCSulSNKaFIbB7+ZfTqfcgNXghcIsac20cPcnj2jvKl/HDi Ldo7wr+Mnvs6x/FOjVJ+JGB+uk7g6TsWnTbavtDXCVjVdBBAOsnOQLcxX q1g2DR1zauy65j2ot9mTSvVWcyQt08rpHBpD2cOeOTZKHnxCNrwSw9eo7 JcJQfuoLOYd+VgucCCc20IZ75jzVH3TbtiEMmt7xyBiofvpyz6XsTcZw8 q7bK+kQMZLboPqthM7MOvUIeapKwuK5zh3Xnv9FKm5jdxHEcP2VWP6ZW3 /HcuL1AkiLfSa5AiLZWUDOwEavkW0r/EhJHhUs+9W7I0A291BWIrl29M4 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="394455706" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="394455706" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 04:09:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="769878637" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="769878637" Received: from inlubt0316.iind.intel.com ([10.191.20.213]) by fmsmga007.fm.intel.com with ESMTP; 20 Nov 2023 04:09:00 -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 v1 3/6] ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types Date: Mon, 20 Nov 2023 17:38:34 +0530 Message-Id: <20231120120837.3002-4-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231120120837.3002-1-raag.jadav@intel.com> References: <20231120120837.3002-1-raag.jadav@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 04:09:25 -0800 (PST) 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 --- drivers/acpi/utils.c | 29 ----------------------------- include/acpi/acpi_bus.h | 23 ++++++++++++++++++++++- include/linux/acpi.h | 7 +------ 3 files changed, 23 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 25b9fabf350f..979a60a512e5 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); @@ -893,6 +899,21 @@ static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2) const char *: acpi_str_uid_match, \ u64: 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 3d7ee8c0b86a..c43ae3bd238d 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -758,6 +758,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, uid2) (adev && false) #include @@ -775,12 +776,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; -- 2.17.1