From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 92FA72E427C for ; Wed, 18 Jun 2025 12:16:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248977; cv=none; b=EBpXRC5aob6prx7E4M0TaheZAx7U77dkkbidx9BLKSUJWy6scdR0yUlpZUAle9OvPjTxbIG2+qcfxuX8usklCZqBaM3EvzLtXjgjCtV8Mhn1a85iNmo2nygBsvr6mwYZ9APanMXHMh2MWJJkwY/J66ym4Mtr81qogp4qs9hTQ2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248977; c=relaxed/simple; bh=uYspFdcUP7K03KSkIbLSgQUq1PmFh7JvyJFUbmFVifk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LxaaDEDFUBGKBGpL2NJdtHqKJTPTxlryVKDJBXjwLf2Xq1Sdskx8OdKxe4S4fHRb3joWMX9Y64h6EikWozYnbX7U1PbUD1QbW4MINa+1hPYGze1D8JkNx5chsrs8AP7fhzc4UfaXxVbMvp0QvEAEB6butlkiYEtvbPefJ5YUlos= 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=dLpuXr5z; arc=none smtp.client-ip=209.85.210.171 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="dLpuXr5z" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7406c6dd2b1so585985b3a.0 for ; Wed, 18 Jun 2025 05:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1750248975; x=1750853775; 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=iK7PqVF4zZIJUvApimJUz6BsykWi/7ZoxPUCnW7EQA0=; b=dLpuXr5zGl39MjAx66t/TN2gKGOa0ZGnBKy9nzmRGyJSzy1OKRfNHkwmNUeC41K7OT nSrQG6qKPLLLy012IAOKR6krPDp0I4v7LAMtT1yZuzPOPyyQlmh7yDUgGVoEb9Kwnoij RE1Z0s3Ale96uajhW7iG+h1S1lhkI+U2hwQLAitRvbUVb1oGQIO8Zr1vCANzK7O8H1ec qxu4/AoQKxCjPPUSeh2W9GpGYu/9vRfa/KS1g18/MQdsiyluh9TOpVJweNxNG7FZxuZ7 /7TRLTg1noclGozqnvASDQr7DGgb+aqruTH8EQ9RPgvgpfBcocJgJ3o+kLxut9NvtLPY O1dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750248975; x=1750853775; 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=iK7PqVF4zZIJUvApimJUz6BsykWi/7ZoxPUCnW7EQA0=; b=eIX4u5e0UjPGLU16PaRoCT7iDIsMpWse/3jP0094J3KCo188IacaabsVlSw0CTIDFF w1XmkPB1h9xcdn9bUjuW1yK+u2/ccTT6ZG76nsMSMNMgb0A0LlP/nQahtezHanmFuHjQ wgbFEXVL1GhhLU6iiwxaJ3K70plgypwXOOtmeO2DVC6ZuPI39ZbWhvORIf5/uPBzfIav MxjPFVa+UN46G8dZdClU9/gzKqa7nlGiINfu/FWfmtuNWgfUvcl9ZiBX8xnwziuA0JpL AZtDRY4loCpLU2XbTRwjx3ORGMyC0SGaomcXsJIFPpFq1ZREtS5itp473WBl0A67b6pa +jAQ== X-Forwarded-Encrypted: i=1; AJvYcCXgXa0T4x2zj0mq/gFtrnXsnBkKw7T8mUQ2EKj3fjzdWG1Xpvh/wX2L/h1G+qwWyOi+XBlbvoiunXIk@vger.kernel.org X-Gm-Message-State: AOJu0Yyv7jIzfp5hGNkHp1XblgkgfdvArWFLl4UDH3Y4MaIQbgwBTi3E OiQuuirMzrSHLSY6uY2Yx+8PA88RHzw5adRcm6/upPYzN21UkfeOslHPmOsoSfCpBJw= X-Gm-Gg: ASbGnctPZFaIHZqhMIwSvRYUqUN0B9ravbRYEC96lIpaR4uL4ALSVIsfE0puOu00IIy WNfiquKr3W7rfOzRgMA7ZbYGUe7fsPA+ma2p8lvkbKfYiJnc6DPV8ih+Ce3gFK+KUIIc4llomFY vB8SbGVhJFDTTpyse2nnK5waEfr2ysbd3sO77114kL4imZ/B98oclayzVzsqiELEEmFDIFmi6ee 6dXHx7OtfWYMFBjfPBIolc8um5lUp0RbSs2Gz5AWbuvgVHUd3SVjcVrYndACCrBFBsx4gSU9oT2 wfiGjdtsw5Vzn1XsRsE1sou/OYtLjFDSug4x0umJaKlB1bUsSDCWlt6C2pxACQyCTR0nrulc5IF Y1nX8GJz1E8C7Uyq28Aivqr3i+vy5 X-Google-Smtp-Source: AGHT+IHGxdihft+ht1cVZVd1c6PNThCfkYZyuhsm/u3nH0+E43W34IXdgzMXTGbhOuFGPUkF42AqtQ== X-Received: by 2002:a05:6a00:7189:b0:742:ccf9:317a with SMTP id d2e1a72fcca58-748e7030b72mr2344031b3a.12.1750248974760; Wed, 18 Jun 2025 05:16:14 -0700 (PDT) Received: from localhost.localdomain ([122.171.23.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-748900d7e0asm11201177b3a.174.2025.06.18.05.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jun 2025 05:16:14 -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 , 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-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v6 14/23] ACPI: property: Add support for cells property Date: Wed, 18 Jun 2025 17:43:49 +0530 Message-ID: <20250618121358.503781-15-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250618121358.503781-1-apatel@ventanamicro.com> References: <20250618121358.503781-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sunil V L Currently, ACPI doesn't support cells property when fwnode_property_get_reference_args() is called. ACPI always expects the number of arguments to be passed. However, the above mentioned call being a common interface for OF and ACPI, it is better to have single calling convention which works for both. Hence, add support for cells property on the reference device to get the number of arguments dynamically. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/acpi/property.c | 22 ++++++++++++++++++++++ drivers/base/property.c | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index d4863746fb11..c9c3d6920326 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -882,6 +882,20 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f return &dn->fwnode; } +static unsigned int acpi_fwnode_get_args_count(const struct acpi_device *device, + const char *nargs_prop) +{ + const union acpi_object *obj; + + if (!nargs_prop) + return 0; + + if (acpi_dev_get_property(device, nargs_prop, ACPI_TYPE_INTEGER, &obj)) + return 0; + + return obj->integer.value; +} + 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, @@ -960,6 +974,9 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, if (!device) return -EINVAL; + if (nargs_prop) + args_count = acpi_fwnode_get_args_count(device, nargs_prop); + element++; ret = acpi_get_ref_args(idx == index ? args : NULL, @@ -978,6 +995,11 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, if (!ref_fwnode) return -EINVAL; + if (nargs_prop) { + device = to_acpi_device_node(ref_fwnode); + args_count = acpi_fwnode_get_args_count(device, nargs_prop); + } + element++; ret = acpi_get_ref_args(idx == index ? args : NULL, diff --git a/drivers/base/property.c b/drivers/base/property.c index f626d5bbe806..6a63860579dd 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -578,7 +578,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_property_string); * @prop: The name of the property * @nargs_prop: The name of the property telling the number of * arguments in the referred node. NULL if @nargs is known, - * otherwise @nargs is ignored. Only relevant on OF. + * otherwise @nargs is ignored. * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL. * @index: Index of the reference, from zero onwards. * @args: Result structure with reference and integer arguments. -- 2.43.0