From nobody Mon Oct 6 01:28:22 2025 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99C5725CC5E for ; Mon, 28 Jul 2025 09:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753695798; cv=none; b=ZxjRtqwI9c7B3u/CHP0TJJtDYthLdMiiuSGEKR6xu8jU4Ecc/9AwSBuQ4me5lCR9vcPnuL01kZ08A9A/dNlXnLtodGudVQBwcrV62lLWBPn0aO50CPQBzz1Dm0tp2KpHdbE0R/hcY8RnmJELRY4Tn2lIFxKqsC2ggwzFOeSLCRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753695798; c=relaxed/simple; bh=AzDnkvkLdRyeS7VDWrPZhFEpyPeN7AYdoKFUiRxG/uY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u5kZxq5Yvx/P3kSpJ8TDbQHft4Qm2IFcISgV+icMtE2us4+mdmib6wGUTYmuRd3ZAqUnPAmD5Z9TnaceySFNQxLGsDWHrXnOaEeLqPIVaUxw+8oOMFXgewOXAf614bvc9jfb+KYS3IK4O9qPZzNH1KQtQ8D0FH7lD1qQ1evm8+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=TBHlR5tw; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="TBHlR5tw" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-31ca042d3b8so3422732a91.0 for ; Mon, 28 Jul 2025 02:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1753695796; x=1754300596; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=psS8/HGvEcGOGsMgWWXg1B2q2pSduh9TsFVsTLXCZt8=; b=TBHlR5tw76+MK5suLBWY7bwblTkjtVgCJq8UhERGZT4qrofiI93ua/58rdFJWkedgY rVBaNiXRN8iP1yt2E88Yd843IMDB7fsr6Ptkyuyq8yehyBk93mSLR8mbXXXur5yfl70h xZcGIrzALP/w3sbJOUiMlExBxpg6HetcMBoZMm8DhhW4eVHceHxaWcebeUkmLhNAZT8Z rkRVr+CIdusxP0aH7iT6pmK/mN7ZjSMObY7AoNK+0WCbtSjmRCrfGNGltHGLcsCl5iMu mSTs48tUfFtW0rBdj3TBCEOeCroZh4uXRHSOPEtpDlTU8I0G4F7W53J+9jeiQAdXsXF7 KMeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753695796; x=1754300596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=psS8/HGvEcGOGsMgWWXg1B2q2pSduh9TsFVsTLXCZt8=; b=neCDxMD3LV8UzMyY5NTcgEW9kn2arUWMuIIyQUtO/vaLsz4Z8MWRZBlxv3YaRVblcy /oMs7GvUaYihmVizCzm+M37vCV/gaMAxg7qTlSB6AidwtWfCg1m9c5ltB3O+o4i/+s7T JBx54TAOYlMJWh8ADjiEUug95ECQCJpdmGB5XpABHfUbCKFNVTeUITc4Uu9ndIft7lZc YcA0yZ4i72/V5ZjSFQIkFb0R2wk0WF4CavZh6GBN6GgaNDhQkAJ/+WxSGHC8ByvPMMlq 9sW4C0bQcXHQZy8rq7J1ZzFQbsWqjCcJqq+PY7C/bJmO36GWl2aIZCIWaGv6EJ3sRu0Q K/3g== X-Forwarded-Encrypted: i=1; AJvYcCVkYOffZXzwH89HjlaMdWJH/vBYeC6R2LS8JE7APRKDEiTsN/cg+Zal3wwPZ2nssoQsFXZYshELsIlhaLk=@vger.kernel.org X-Gm-Message-State: AOJu0YyWvnBBUScctiXmurIIV9I5QsKp8bFRk6FtkVky4KWMQkDfiKIj 3UEvSV++5yIFE1PzCW1JHxyIHTXGe7zC3k4/rIq4soIbodrvRBlloKn6+/Yw2+NfAvY= X-Gm-Gg: ASbGncv8FkTjf6A9CgmvpzEAbFclK/V2Bl48WZ1TJFHHgZWlguhMB8j4P5q0bU0Wx0k dQ5rT5w5e/PNG64HHGJVGqj1j9OlW6dn35R0dzLgwxOUwtf+hv+7Vth4KuJ0V9o/jmNkrv55o+/ VlHbkbfQ9uf1h2RTj5S8rXkwOKH9SIW3Ac6tRewsEPkzXiNpCAyIYaKkn4PAJ1nPw+Z9JyknRv3 dHh2v+sqM5l6xZEq4kvFuc5SjmNcdAcd5ZVUANO0YhC58V9KgqvRPUEPXYbQcYD+heRht1M6ksH hmZkk5VJFatG1SCzohP8p1YRttXvkNJiKTgSxYOdgiH3X0kM75cX4ms91/bPFD6o4t1N2T+A7v5 vd88TgEBmYx0rrCqw5yENJ6uTvoPwKkpvfY1vZUwGdE2OKNIq9VfsHOOAAb9CFmRLBGm3K4o= X-Google-Smtp-Source: AGHT+IHL9arQT5aDqAz1dZ7cvYy38Ns9Xdix/MnurcSEyrOlJ5A4rj3vvzb2xougKwWOpnOXJIDzwQ== X-Received: by 2002:a17:90b:3d46:b0:312:daf3:bac9 with SMTP id 98e67ed59e1d1-31e77a32a3emr13516455a91.34.1753695795553; Mon, 28 Jul 2025 02:43:15 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([122.171.19.28]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31e832fbf99sm5396230a91.1.2025.07.28.02.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jul 2025 02:43:15 -0700 (PDT) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Alexandre Ghiti , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Anup Patel Subject: [PATCH v9 14/24] ACPI: property: Refactor acpi_fwnode_get_reference_args() to support nargs_prop Date: Mon, 28 Jul 2025 15:10:22 +0530 Message-ID: <20250728094032.63545-15-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250728094032.63545-1-apatel@ventanamicro.com> References: <20250728094032.63545-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sunil V L Currently, acpi_fwnode_get_reference_args() delegates to the internal function __acpi_node_get_property_reference() to retrieve property references. However, this function does not handle the nargs_prop (cells property) parameter, and instead expects the number of arguments (nargs) to be known or hardcoded. As a result, when fwnode_property_get_reference_args() is used with a valid nargs_prop, the ACPI backend ignores it, whereas the Device Tree (DT) backend uses the #*-cells property from the reference node to determine the number of arguments dynamically. To support the nargs_prop in ACPI, refactor the code as follows: - Move the implementation from __acpi_node_get_property_reference() into acpi_fwnode_get_reference_args(). - Update __acpi_node_get_property_reference() to call the (now updated) acpi_fwnode_get_reference_args() passing NULL as nargs_prop to keep the behavior of __acpi_node_get_property_reference() intact. Acked-by: Rafael J. Wysocki Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/acpi/property.c | 101 ++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 436019d96027..d4863746fb11 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -882,45 +882,10 @@ static struct fwnode_handle *acpi_parse_string_ref(co= nst struct fwnode_handle *f return &dn->fwnode; } =20 -/** - * __acpi_node_get_property_reference - returns handle to the referenced o= bject - * @fwnode: Firmware node to get the property from - * @propname: Name of the property - * @index: Index of the reference to return - * @num_args: Maximum number of arguments after each reference - * @args: Location to store the returned reference with optional arguments - * (may be NULL) - * - * Find property with @name, verifify that it is a package containing at l= east - * one object reference and if so, store the ACPI device object pointer to= the - * target object in @args->adev. If the reference includes arguments, sto= re - * them in the @args->args[] array. - * - * If there's more than one reference in the property value package, @inde= x is - * used to select the one to return. - * - * It is possible to leave holes in the property value set like in the - * example below: - * - * Package () { - * "cs-gpios", - * Package () { - * ^GPIO, 19, 0, 0, - * ^GPIO, 20, 0, 0, - * 0, - * ^GPIO, 21, 0, 0, - * } - * } - * - * Calling this function with index %2 or index %3 return %-ENOENT. If the - * property does not contain any more values %-ENOENT is returned. The NULL - * entry must be single integer and preferably contain value %0. - * - * Return: %0 on success, negative error code on failure. - */ -int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, - const char *propname, size_t index, size_t num_args, - struct fwnode_reference_args *args) +static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwno= de, + const char *propname, const char *nargs_prop, + unsigned int args_count, unsigned int index, + struct fwnode_reference_args *args) { const union acpi_object *element, *end; const union acpi_object *obj; @@ -999,7 +964,7 @@ int __acpi_node_get_property_reference(const struct fwn= ode_handle *fwnode, =20 ret =3D acpi_get_ref_args(idx =3D=3D index ? args : NULL, acpi_fwnode_handle(device), - &element, end, num_args); + &element, end, args_count); if (ret < 0) return ret; =20 @@ -1017,7 +982,7 @@ int __acpi_node_get_property_reference(const struct fw= node_handle *fwnode, =20 ret =3D acpi_get_ref_args(idx =3D=3D index ? args : NULL, ref_fwnode, &element, end, - num_args); + args_count); if (ret < 0) return ret; =20 @@ -1039,6 +1004,50 @@ int __acpi_node_get_property_reference(const struct = fwnode_handle *fwnode, =20 return -ENOENT; } + +/** + * __acpi_node_get_property_reference - returns handle to the referenced o= bject + * @fwnode: Firmware node to get the property from + * @propname: Name of the property + * @index: Index of the reference to return + * @num_args: Maximum number of arguments after each reference + * @args: Location to store the returned reference with optional arguments + * (may be NULL) + * + * Find property with @name, verifify that it is a package containing at l= east + * one object reference and if so, store the ACPI device object pointer to= the + * target object in @args->adev. If the reference includes arguments, sto= re + * them in the @args->args[] array. + * + * If there's more than one reference in the property value package, @inde= x is + * used to select the one to return. + * + * It is possible to leave holes in the property value set like in the + * example below: + * + * Package () { + * "cs-gpios", + * Package () { + * ^GPIO, 19, 0, 0, + * ^GPIO, 20, 0, 0, + * 0, + * ^GPIO, 21, 0, 0, + * } + * } + * + * Calling this function with index %2 or index %3 return %-ENOENT. If the + * property does not contain any more values %-ENOENT is returned. The NULL + * entry must be single integer and preferably contain value %0. + * + * Return: %0 on success, negative error code on failure. + */ +int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, + const char *propname, size_t index, + size_t num_args, + struct fwnode_reference_args *args) +{ + return acpi_fwnode_get_reference_args(fwnode, propname, NULL, index, num_= args, args); +} EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference); =20 static int acpi_data_prop_read_single(const struct acpi_device_data *data, @@ -1558,16 +1567,6 @@ acpi_fwnode_property_read_string_array(const struct = fwnode_handle *fwnode, val, nval); } =20 -static int -acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, - const char *prop, const char *nargs_prop, - unsigned int args_count, unsigned int index, - struct fwnode_reference_args *args) -{ - return __acpi_node_get_property_reference(fwnode, prop, index, - args_count, args); -} - static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode) { const struct acpi_device *adev; --=20 2.43.0