Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1115443rdb; Fri, 20 Oct 2023 08:50:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeS7dzG8gWsjz/+Wtx7/FHLXnflinHUJhMOMp8fPNY2Uo62Unj2GVGGkNfMA9X+ZGOeozC X-Received: by 2002:a17:902:e746:b0:1ca:9507:52 with SMTP id p6-20020a170902e74600b001ca95070052mr2317485plf.67.1697816999841; Fri, 20 Oct 2023 08:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697816999; cv=none; d=google.com; s=arc-20160816; b=xsGhRdGpiMl9nrKATHImJouUoBn5S2FfTIaiOVgyJyYbkdjglyuDLMYzarEkOkRDni BLMc2DigSspVPiuSDF/NNeQkAgWnAZu84jTK3XjaO504cRGOk9erASAD17jjRUTzDfz0 t3VhsijAC0ZItWz4RaQ+qQI2LJ5l4175KVLIg6bZ/8WZC1AuZ0tSg9Y4M7gW8XzMZ7aQ fp3yr4+sUN1/zasj17EsBXU3xCzsbAstyJYbDNraV4ke4x9MXZJP2Ja0DBIyfbykTDhH 17h+HrORl9QxL11Azn/MKLau65DrVykeEEppRQX5omY3HXVFcTzEz8EkHr8ElBsPRtaJ JHFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=wuMRR3CD3V9Zw56kNneM//+npa8SLSfOpLSdixygqUc=; fh=+6F5NQ8vAOj5L0o56GzBibOw7r/w1ldwx2Qmt19nZTU=; b=kuASFiFXYzdqcuoAwiJuSNa+PwvTNhEU1mGe4T1cuH4x41YldKrWi/9pfOi13pOQTR Q391TOeirlSpby0TK2zjkdKSXFkFDva8QDrFfeRx4kZ5oQQ8WqUKfA5ERhD+ajIRRKe3 zq4qu3lleZQlVlcCekFWeUfQAyoeXeNJta+52vsBuKOt4Oj9Oo1ftX3puv2r2JSygZg2 EaVDIC1KTM/+6zGjtHbpHoHvwiZinl/HnuOg0lHSzO5e4s5LHqKE1DGXfEwpTtru8Jzv StrjL6erpwfCTgguJbzSdNOcFI+vBKLNep7hsLPgYQR5MZe69G3dYjHCPkhcpUK9Dwdc PRWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k8-20020a170902c40800b001c1f1394bf9si2292468plk.357.2023.10.20.08.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 08:49:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A974381DF0C2; Fri, 20 Oct 2023 08:49:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377773AbjJTPtl (ORCPT + 99 others); Fri, 20 Oct 2023 11:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377663AbjJTPtk (ORCPT ); Fri, 20 Oct 2023 11:49:40 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E2B51A3; Fri, 20 Oct 2023 08:49:37 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4SBpsm1khlz67M1H; Fri, 20 Oct 2023 23:49:00 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 20 Oct 2023 16:49:34 +0100 Date: Fri, 20 Oct 2023 16:49:33 +0100 From: Jonathan Cameron To: Raag Jadav CC: , , , , , , , , , , , , , , , Subject: Re: [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID Message-ID: <20231020164933.00002f53@Huawei.com> In-Reply-To: <20231020084732.17130-2-raag.jadav@intel.com> References: <20231020084732.17130-1-raag.jadav@intel.com> <20231020084732.17130-2-raag.jadav@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100006.china.huawei.com (7.191.160.224) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 08:49:54 -0700 (PDT) On Fri, 20 Oct 2023 14:17:25 +0530 Raag Jadav wrote: > Introduce acpi_dev_uid_match() helper that matches the device with > supplied _UID string. > > Suggested-by: Andy Shevchenko > Signed-off-by: Raag Jadav > Reviewed-by: Andy Shevchenko > /** > * 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. > + * 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. This behaviour is as needed by most of > + * its current users. If there are other other users that need different behavior are they buggy? Also what behavior is this referring to? I'd just drop the at last sentence as confusing and not adding much. > + * > + * 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); > - const char *uid1 = acpi_device_uid(adev); > > if (strcmp(hid1, hid2)) > return false; > > - if (!uid2) > - return true; > - > - return uid1 && !strcmp(uid1, uid2); > + return acpi_dev_uid_match(adev, uid2); > } > EXPORT_SYMBOL(acpi_dev_hid_uid_match); > > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h > index 254685085c82..d1fe6446ffe0 100644 > --- a/include/acpi/acpi_bus.h > +++ b/include/acpi/acpi_bus.h > @@ -760,6 +760,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev) > adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set); > } > > +bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2); > 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); > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index afd94c9b8b8a..db3a33e19c97 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -787,6 +787,11 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) > > struct acpi_device; > > +static inline bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2) > +{ > + return false; > +} > + > static inline bool > acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2) > {