From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D91CC83F0C for ; Fri, 4 Jul 2025 07:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eg5u56TIZ7myZcR7I0I2xUWReQaq1Se4Lit+38LbnhM=; b=kSmlwlsQvU71fy MRLrrdvUuxUf4v5ByJjkKolzrKgsuyGdhewzyfUDTiF+FS4zZfeugIAd4g87Rtqcs7YNQ1QekZbPK dsZNBdy3hzKZnBKbIPWAkx+2F6p/4nlj8C0XRVY68X2JR6nHKuuNcxkLTIj8MI0PTgsHoxWlvNcsp cKzMRmEgNYCDZJYhj6+onfUN3lfzZz84EQmGrVlEacdmaWfoiROqqVhNt9UT/o8xKmxtyjRQ1HdNv mxqSVZppe9q3kGQct8XiPjaZynH18jKluM33zavgXa6HjkwEdTQjYlCXD+bMB5S/JpMDN5DLxK8yR 019C/JbVIWWGWADG8qPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uXaW5-0000000DV3Y-01hm; Fri, 04 Jul 2025 07:07:25 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uXaVe-0000000DUnB-48tJ for linux-riscv@lists.infradead.org; Fri, 04 Jul 2025 07:07:00 +0000 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-b26f5f47ba1so545691a12.1 for ; Fri, 04 Jul 2025 00:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1751612818; x=1752217618; darn=lists.infradead.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=ObbyW0OuMQm4eB8vpRAI3PGtL6LDEvFC+dNo0dBAW4Y=; b=fbvXeOJHgjtq8V4ELqFqUvLGLR1vmgXJWfmL/SeHzzIlZVdemHPLwSyPWR14iLONui Rfsgn7wpeq9ZOTotpVJcSBkPCr/XsnZwPgr4Of0qwqutAcL1KRh2Besy9WKV9RB1PDkz 05nDZ/KDRocci9TC1hYRR3jqbDy5wqIy7OXI60eRwJh0ctX16C7o7FgXj8aJGfRf5G1F ap+XumnbZpFylHG90UR/6pXoOg5y8xSrL9F4he/P+iLQ132mv/WMgUT0o/uag30/wVHk 8S6RrMCmMmBHQS8obAoW+5bM9A35nun+LR7DMbKNMw8Bf2olpnMJoks4ucsbH2D4G9IN pNUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751612818; x=1752217618; 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=ObbyW0OuMQm4eB8vpRAI3PGtL6LDEvFC+dNo0dBAW4Y=; b=vjoOfDpI5qji/mOy8vE7WVFMEvU9RDYZ0vhQNDrMh75ZdOU2BqppLNL7iU8cloBSkG xVBAtX7cnHcWuRrTNROdUW4eoNUPc30hnvwWLuAGXNp8pfEo7igZZ/LjjwL47A+MML4D sdUbLTNRRFKPSxgvO684Ql0ZtVmVydIJhC9q3596cKou7x/LOFY5kK2iuGKoWpArNUeJ j3S6qMe4O1jQ3Mvy3P9hBMyXaw7aFl33o20E0Ym9Yrec6d9HFLymX4ydJCrUpSaduejb 8FOfolOuIHhpguOtVx/QmittcApRe7lv3dAl1w9JtRl+DozPcXDjB8XK7FpTWIdf/oM5 R2og== X-Forwarded-Encrypted: i=1; AJvYcCUPnfoQiQdIw+DWndnMVqokruIeAtdjWzS/RxIrAP8BE9jKN+UqPEaDxOEhjVuynjxbOXui2mliuB6Suw==@lists.infradead.org X-Gm-Message-State: AOJu0Yy89DDgfhiEMkivGZxRJCcHTPrRsTZnrwsbB+OFIeHaBrG7KAr4 dydbKmKPKcUzpvzmVtt9+RyqCFHbb/MDEltQkPTKNISdpY/B00JVR9dn5Cg/fSdD69g= X-Gm-Gg: ASbGnctRdOhl9J4TQSFgC62EJpuCKji1t+2qwZwmERV1sn3zuSE7ulZCG6kOnqpxuL0 R773RZhK5JzU87534OIiF+tszylXrLbeKm4dTadymIjH2VFnmwPzWlEWMbnvO9C9AmgKXcB8zxN I2xqkI7rj9updX/j8mJZ+B78TPvmGT3K0vSpz4g1YGdI5ZHsZTDGxwJ2nzJTkzEwuvWpO2BnJ4k 8BCx1SI0ykVYSzNe+GjVrU4btWzrWdIAq/81bsgJ7A+ee/LQZE6xouHlXlJs/NuoiexjIy+TS9/ xV2w1TH9IQJ+E/9eHPuLmMtpG8uwObPH9PaGzdRxlV2MKs4bdaN6KROaAoaW3FEHjZRhqC+J0XI j5Fz1EOvvpzEMTuAfnXNnBu82yQ== X-Google-Smtp-Source: AGHT+IHBAOQFhJ/Dr0zUTWSqWq0gW8xgB9ku+vJx3I6DITXH2EWKdkHCZXKrN0Vn0sKHROjxmMUN7g== X-Received: by 2002:a17:90b:4fcd:b0:315:9ac2:8700 with SMTP id 98e67ed59e1d1-31aac4dfd02mr2612265a91.24.1751612818031; Fri, 04 Jul 2025 00:06:58 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31aaae59a93sm1358697a91.12.2025.07.04.00.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jul 2025 00:06:57 -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?= Subject: [PATCH v8 14/24] ACPI: property: Refactor acpi_fwnode_get_reference_args() to support nargs_prop Date: Fri, 4 Jul 2025 12:33:46 +0530 Message-ID: <20250704070356.1683992-15-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250704070356.1683992-1-apatel@ventanamicro.com> References: <20250704070356.1683992-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250704_000659_030412_0B53EFF1 X-CRM114-Status: GOOD ( 23.05 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Alexandre Ghiti , Atish Patra , Leyfoon Tan , Anup Patel , linux-kernel@vger.kernel.org, Samuel Holland , linux-acpi@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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. Suggested-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(const struct fwnode_handle *f return &dn->fwnode; } -/** - * __acpi_node_get_property_reference - returns handle to the referenced object - * @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 least - * one object reference and if so, store the ACPI device object pointer to the - * target object in @args->adev. If the reference includes arguments, store - * them in the @args->args[] array. - * - * If there's more than one reference in the property value package, @index 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 *fwnode, + 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 fwnode_handle *fwnode, ret = acpi_get_ref_args(idx == index ? args : NULL, acpi_fwnode_handle(device), - &element, end, num_args); + &element, end, args_count); if (ret < 0) return ret; @@ -1017,7 +982,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ret = acpi_get_ref_args(idx == index ? args : NULL, ref_fwnode, &element, end, - num_args); + args_count); if (ret < 0) return ret; @@ -1039,6 +1004,50 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, return -ENOENT; } + +/** + * __acpi_node_get_property_reference - returns handle to the referenced object + * @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 least + * one object reference and if so, store the ACPI device object pointer to the + * target object in @args->adev. If the reference includes arguments, store + * them in the @args->args[] array. + * + * If there's more than one reference in the property value package, @index 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); 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); } -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; -- 2.43.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv