Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp188486lqh; Wed, 27 Mar 2024 20:56:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4YgDxYBmE07ZxHP9ed40iZJEY2vZ/a/5vkVre4GyCz7qSeiC9pqcxDTf3/eTS/CFr09ziH10TCoRNPhGnLEBotRNThv+FT3T3MDGBSQ== X-Google-Smtp-Source: AGHT+IE9TNjoVBo3Hwmg/n+u1106KREEZT+tuBeCGRFYMgiQzfsefpj3bQFu2n0KzS0OxtY5kb5p X-Received: by 2002:a50:f697:0:b0:56b:a74e:d581 with SMTP id d23-20020a50f697000000b0056ba74ed581mr1636301edn.13.1711598163399; Wed, 27 Mar 2024 20:56:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711598163; cv=pass; d=google.com; s=arc-20160816; b=jjvZ/tp+MJYWSHMwdLevo0GkYoFfuNDY/705Goj8XS6PsY9o7scyrdngMA/yLOAGrY TyeMiYhwwXUTtOG4MguOIyJU09AjoQ9paE+g0mdwRrB936hgF44cOUAhe/tM7HXBgZzP 786tICj4ZjJANj0hUVbI9WCGlpafxoDH9xZYmdvtDtWvP2VXr2TqP1UzpOK2GaQ7zlUx CLUR6gVZjoMs9XeDbm+ldHpZOfQEaIGuHLQTGHiyOaMMhzFrKYbwJSMR2aMJ3BLfHxeb j+xjeUWj69GnXVJoU1NtK9zM3NBdU/Yh/70tx+ewS09Qb3SQh7KhfLBTsPoI2Y1IkGNJ PB4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=FgHVJ/NX7Z5OAJ0fRbA23lPsEHQnFij8aMqZu3DXVDo=; fh=g62rt5fQpmnwubuYwNQWlMF5VtzS9fMO41+/5hNwvBU=; b=MrTgOsBw5H5FQzYrLaeEMDytNmK6fGA4a4nkEwW5qqZ6wtsSV/+1jl3dhvwC+szhaE aIwZG72UOxPQHlsFF3YWbadmDgog7zM5MUay1CRvZ+a+jcE4EmtUgd+FodhgSr2qZDjK c3Ox9TX3liijvQMr2wxbSZl0wpl/n5yJllWSfsxrxceCqTQpP0z1axbd8bjkJFCHsk/n fARNpQZbzbh1e0RlrhLQksYCC75fPbMqcPK2kmIBoV5hdR5mQv3Z2fAib3gGwiNM1fIc A5jFVC9xabmd+PAfFLUAUcx5N21RxTJwRBqmelA3zrLD4/D9CY5+J4SsXyKpZsEldylD Zukg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jSxV0nX2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-122391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122391-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t5-20020a056402524500b00567f5f694basi326179edd.232.2024.03.27.20.56.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 20:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jSxV0nX2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-122391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122391-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 16FCB1F285E5 for ; Thu, 28 Mar 2024 03:56:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EDC6376F4; Thu, 28 Mar 2024 03:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jSxV0nX2" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66A35376E1; Thu, 28 Mar 2024 03:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711598153; cv=none; b=nXH1oVcjksHkeRkPGPMzs5idUK4J4KdE8QBfTaP7u+PGmoAc9vJOUNY/izWWT9VvYUIpfazk3vee7k0BzWUjvLdMz1Z1DfrLK03dJIxsVPR8HVg8yfx7FkYJMqhrLqIMi5rTdfUHtx3AFJqBCmN9q+l7oNaedeCacQDW7q7l1qM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711598153; c=relaxed/simple; bh=8qYAERBQGCHec4afmPtkDK884L7d7FIyHJ2D+fRxMCg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jloizku4le0W+l2iZcFrq8O4F+8HGgGWDc3Co3/ZOmPPfvDkfDAl4q5ZC6wS9EkLKtVSOc+EqoVZmnTaIDrDlnDhn1TsWUw8UzVxUI3y6CyzrljG14pctFaW/4x4o+1bA89gNY3Lv2464KGqSxbzhzODnSD6FW5U6QTP0ftfdfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=none smtp.mailfrom=ecsmtp.iind.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jSxV0nX2; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ecsmtp.iind.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711598153; x=1743134153; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=8qYAERBQGCHec4afmPtkDK884L7d7FIyHJ2D+fRxMCg=; b=jSxV0nX2HMNx/6yn11o6BFKmxyd6V16yvmclBY8N/qqa0B7R2qoGba8V 2at86DC2ZzjAGh+YUfhlO9bSWwypgoGtzPDWemk7KXOx/O5TFLC8espg4 rRR8uS4VJ7asFZjacJqQ14iIFFYL1OLmZf41GqidE3nhU/mpb3xdf8/jR 59IhfrlR6pHhNgwQCeix4u0fYfWRFhJMLqaIX+XOitmzktrQ28lggX8yW I7bP+3lmueiSEaMggKtci89c1QjWHM2hf4nMx5yV81AmgkuRQ2xBro9nv ISMM7V1u87BnQZRPlcDoCDmrto7gxu+jV30HS8Lcu1vLPGrdZ7d4sj5ow A==; X-CSE-ConnectionGUID: Etmf4Zo4Qi622nSkPVldyQ== X-CSE-MsgGUID: OvyYG85kR4ugjpERKpmHFg== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="6588840" X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="6588840" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 20:55:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="16969321" Received: from inesxmail01.iind.intel.com ([10.223.57.40]) by orviesa006.jf.intel.com with ESMTP; 27 Mar 2024 20:55:46 -0700 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 481261B32F; Thu, 28 Mar 2024 09:25:45 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 443C51600102; Thu, 28 Mar 2024 09:25:45 +0530 (IST) From: Raag Jadav To: rafael@kernel.org, lenb@kernel.org, robert.moore@intel.com, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, stanislaw.gruszka@linux.intel.com Cc: linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH v1] ACPI: bus: allow _UID matching for integer zero Date: Thu, 28 Mar 2024 09:25:40 +0530 Message-Id: <20240328035540.13194-1-raag.jadav@intel.com> X-Mailer: git-send-email 2.35.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types") added _UID matching support for both integer and string types, which satisfies NULL @uid2 argument for string types using inversion, but this logic prevents _UID comparision in case the argument is integer 0, which may result in false positives. Fix this using _Generic(), which will allow NULL @uid2 argument for string types as well as _UID matching for all possible integer values. Fixes: b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types") Signed-off-by: Raag Jadav --- include/acpi/acpi_bus.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 5de954e2b18a..683458de5a81 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -911,17 +911,19 @@ static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 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. + * @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 0 or NULL, %false otherwise. + * Returns: %true if matches or @uid2 is 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))) + /* Differentiate integer 0 from NULL @uid2 */ \ + (_Generic(uid2, ACPI_STR_TYPES(!(uid2)), default: 0) || \ + 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); -- 2.35.3