From: Sunil V L <sunilvl@ventanamicro.com>
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 <sunilvl@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
drivers/acpi/property.c | 22 ++++++++++++++++++----
drivers/base/property.c | 2 +-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index d4863746fb11..d08b0ea5c915 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -882,6 +882,17 @@ 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 (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,
@@ -892,6 +903,7 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
const struct acpi_device_data *data;
struct fwnode_handle *ref_fwnode;
struct acpi_device *device;
+ unsigned int nargs_count;
int ret, idx = 0;
data = acpi_device_data_of_node(fwnode);
@@ -960,11 +972,12 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
if (!device)
return -EINVAL;
+ nargs_count = acpi_fwnode_get_args_count(device, nargs_prop);
element++;
-
ret = acpi_get_ref_args(idx == index ? args : NULL,
acpi_fwnode_handle(device),
- &element, end, args_count);
+ &element, end,
+ nargs_count ? nargs_count : args_count);
if (ret < 0)
return ret;
@@ -978,11 +991,12 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
if (!ref_fwnode)
return -EINVAL;
+ device = to_acpi_device_node(ref_fwnode);
+ nargs_count = acpi_fwnode_get_args_count(device, nargs_prop);
element++;
-
ret = acpi_get_ref_args(idx == index ? args : NULL,
ref_fwnode, &element, end,
- args_count);
+ nargs_count ? nargs_count : args_count);
if (ret < 0)
return ret;
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
On Wed, Jul 02, 2025 at 10:43:36AM +0530, Anup Patel wrote: > From: Sunil V L <sunilvl@ventanamicro.com> > > 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. You can use Elvis to shorten lines, but in my opinion this is okay change overall. FWIW, Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > element++; > - u probably want to leave this blank line and rather move the new code here element++; nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > ret = acpi_get_ref_args(idx == index ? args : NULL, > acpi_fwnode_handle(device), > - &element, end, args_count); > + &element, end, > + nargs_count ? nargs_count : args_count); &element, end, nargs_count ?: args_count); > if (ret < 0) > return ret; ... > + device = to_acpi_device_node(ref_fwnode); > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > element++; > - > ret = acpi_get_ref_args(idx == index ? args : NULL, > ref_fwnode, &element, end, > - args_count); > + nargs_count ? nargs_count : args_count); > if (ret < 0) > return ret; As per above. -- With Best Regards, Andy Shevchenko
On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote:
>
> From: Sunil V L <sunilvl@ventanamicro.com>
>
> Currently, ACPI doesn't support cells property when
> fwnode_property_get_reference_args() is called.
What exactly do you mean by "cells property" here and below?
> 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 <sunilvl@ventanamicro.com>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
> drivers/acpi/property.c | 22 ++++++++++++++++++----
> drivers/base/property.c | 2 +-
> 2 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index d4863746fb11..d08b0ea5c915 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -882,6 +882,17 @@ 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 (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,
> @@ -892,6 +903,7 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
> const struct acpi_device_data *data;
> struct fwnode_handle *ref_fwnode;
> struct acpi_device *device;
> + unsigned int nargs_count;
> int ret, idx = 0;
>
> data = acpi_device_data_of_node(fwnode);
> @@ -960,11 +972,12 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
> if (!device)
> return -EINVAL;
>
> + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop);
I think it should work the same way as it used to for the callers that
pass args_count, so maybe
if (!args_count)
args_count = acpi_fwnode_get_args_count(device, nargs_prop);
> element++;
> -
> ret = acpi_get_ref_args(idx == index ? args : NULL,
> acpi_fwnode_handle(device),
> - &element, end, args_count);
> + &element, end,
> + nargs_count ? nargs_count : args_count);
And this change would not be necessary?
And analogously below.
> if (ret < 0)
> return ret;
>
> @@ -978,11 +991,12 @@ static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
> if (!ref_fwnode)
> return -EINVAL;
>
> + device = to_acpi_device_node(ref_fwnode);
> + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop);
> element++;
> -
> ret = acpi_get_ref_args(idx == index ? args : NULL,
> ref_fwnode, &element, end,
> - args_count);
> + nargs_count ? nargs_count : args_count);
> if (ret < 0)
> return ret;
>
> 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.
> --
On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: ... > > 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, > > const struct acpi_device_data *data; > > struct fwnode_handle *ref_fwnode; > > struct acpi_device *device; > > + unsigned int nargs_count; > > int ret, idx = 0; > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > I think it should work the same way as it used to for the callers that > pass args_count, so maybe > > if (!args_count) > args_count = acpi_fwnode_get_args_count(device, nargs_prop); But this is different variable. > > element++; > > - > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > acpi_fwnode_handle(device), > > - &element, end, args_count); > > + &element, end, > > + nargs_count ? nargs_count : args_count); > > And this change would not be necessary? This is not the same check as proposed above. But this can be made shorter with Elvis in use: &element, end, nargs_count ?: args_count); > And analogously below. And below. And in case if there is a new proposal to have if (!nargs_count) args_count = acpi_fwnode_get_args_count(device, nargs_prop); that is exactly what I asked to drop as it's included in the acpi_fwnode_get_args_count() already, i.e. no need to check this in the caller and in the callee. > > if (ret < 0) > > return ret; ... > > if (!ref_fwnode) > > return -EINVAL; > > > > + device = to_acpi_device_node(ref_fwnode); > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > element++; > > - > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > ref_fwnode, &element, end, > > - args_count); > > + nargs_count ? nargs_count : args_count); > > if (ret < 0) > > return ret; -- With Best Regards, Andy Shevchenko
On Wed, Jul 2, 2025 at 1:38 PM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: > > ... > > > > 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, > > > > const struct acpi_device_data *data; > > > struct fwnode_handle *ref_fwnode; > > > struct acpi_device *device; > > > + unsigned int nargs_count; > > > int ret, idx = 0; > > > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > I think it should work the same way as it used to for the callers that > > pass args_count, so maybe > > > > if (!args_count) > > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > But this is different variable. Of course it is different. It is an acpi_fwnode_get_reference_args() parameter. > > > element++; > > > - > > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > > acpi_fwnode_handle(device), > > > - &element, end, args_count); > > > + &element, end, > > > + nargs_count ? nargs_count : args_count); > > > > And this change would not be necessary? > > This is not the same check as proposed above. No, it is not. It just makes the function work the same way it did before the change for the callers who passed nozero args_count and so they might be forgiven expecting that it would be taken into account.
On Wed, Jul 02, 2025 at 02:39:30PM +0200, Rafael J. Wysocki wrote: > On Wed, Jul 2, 2025 at 1:38 PM Andy Shevchenko > <andriy.shevchenko@linux.intel.com> wrote: > > > > On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > > > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: > > > > ... > > > > > > 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, > > > > > > const struct acpi_device_data *data; > > > > struct fwnode_handle *ref_fwnode; > > > > struct acpi_device *device; > > > > + unsigned int nargs_count; > > > > int ret, idx = 0; > > > > > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > I think it should work the same way as it used to for the callers that > > > pass args_count, so maybe > > > > > > if (!args_count) > > > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > But this is different variable. > > Of course it is different. It is an acpi_fwnode_get_reference_args() parameter. > > > > > element++; > > > > - > > > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > > > acpi_fwnode_handle(device), > > > > - &element, end, args_count); > > > > + &element, end, > > > > + nargs_count ? nargs_count : args_count); > > > > > > And this change would not be necessary? > > > > This is not the same check as proposed above. > > No, it is not. > > It just makes the function work the same way it did before the change > for the callers who passed nozero args_count and so they might be > forgiven expecting that it would be taken into account. But if we do like this, the expectation of fwnode_property_get_reference_args() will differ for DT and ACPI, right? I mean nargs_prop should take higher precedence than nargs. Thanks! Sunil
On Wed, Jul 2, 2025 at 5:06 PM Sunil V L <sunilvl@ventanamicro.com> wrote: > > On Wed, Jul 02, 2025 at 02:39:30PM +0200, Rafael J. Wysocki wrote: > > On Wed, Jul 2, 2025 at 1:38 PM Andy Shevchenko > > <andriy.shevchenko@linux.intel.com> wrote: > > > > > > On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > > > > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: > > > > > > ... > > > > > > > > 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, > > > > > > > > const struct acpi_device_data *data; > > > > > struct fwnode_handle *ref_fwnode; > > > > > struct acpi_device *device; > > > > > + unsigned int nargs_count; > > > > > int ret, idx = 0; > > > > > > > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > > > I think it should work the same way as it used to for the callers that > > > > pass args_count, so maybe > > > > > > > > if (!args_count) > > > > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > But this is different variable. > > > > Of course it is different. It is an acpi_fwnode_get_reference_args() parameter. > > > > > > > element++; > > > > > - > > > > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > > > > acpi_fwnode_handle(device), > > > > > - &element, end, args_count); > > > > > + &element, end, > > > > > + nargs_count ? nargs_count : args_count); > > > > > > > > And this change would not be necessary? > > > > > > This is not the same check as proposed above. > > > > No, it is not. > > > > It just makes the function work the same way it did before the change > > for the callers who passed nozero args_count and so they might be > > forgiven expecting that it would be taken into account. > > But if we do like this, the expectation of > fwnode_property_get_reference_args() will differ for DT and ACPI, right? > I mean nargs_prop should take higher precedence than nargs. So you basically want acpi_fwnode_get_reference_args() to take nargs_prop into account (which could be explained much cleaner in the patch changelogs). Also, your changes don't modify the behavior of __acpi_node_get_property_reference() AFAICS, so this is OK. Never mind then, but you could pass nargs_prop along with the additional device parameter to acpi_get_ref_args() and make that function obtain the nargs_prop value. In the patch, you need to get the nargs_prop value before calling it anyway in both places in which it is used.
On Wed, Jul 02, 2025 at 06:56:48PM +0200, Rafael J. Wysocki wrote: > On Wed, Jul 2, 2025 at 5:06 PM Sunil V L <sunilvl@ventanamicro.com> wrote: > > > > On Wed, Jul 02, 2025 at 02:39:30PM +0200, Rafael J. Wysocki wrote: > > > On Wed, Jul 2, 2025 at 1:38 PM Andy Shevchenko > > > <andriy.shevchenko@linux.intel.com> wrote: > > > > > > > > On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > > > > > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: > > > > > > > > ... > > > > > > > > > > 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, > > > > > > > > > > const struct acpi_device_data *data; > > > > > > struct fwnode_handle *ref_fwnode; > > > > > > struct acpi_device *device; > > > > > > + unsigned int nargs_count; > > > > > > int ret, idx = 0; > > > > > > > > > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > > > > > I think it should work the same way as it used to for the callers that > > > > > pass args_count, so maybe > > > > > > > > > > if (!args_count) > > > > > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > > > But this is different variable. > > > > > > Of course it is different. It is an acpi_fwnode_get_reference_args() parameter. > > > > > > > > > element++; > > > > > > - > > > > > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > > > > > acpi_fwnode_handle(device), > > > > > > - &element, end, args_count); > > > > > > + &element, end, > > > > > > + nargs_count ? nargs_count : args_count); > > > > > > > > > > And this change would not be necessary? > > > > > > > > This is not the same check as proposed above. > > > > > > No, it is not. > > > > > > It just makes the function work the same way it did before the change > > > for the callers who passed nozero args_count and so they might be > > > forgiven expecting that it would be taken into account. > > > > But if we do like this, the expectation of > > fwnode_property_get_reference_args() will differ for DT and ACPI, right? > > I mean nargs_prop should take higher precedence than nargs. > > So you basically want acpi_fwnode_get_reference_args() to take > nargs_prop into account (which could be explained much cleaner in the > patch changelogs). > Sure. Let me improve the commit message in the next version. . > Also, your changes don't modify the behavior of > __acpi_node_get_property_reference() AFAICS, so this is OK. > That's correct. > Never mind then, but you could pass nargs_prop along with the > additional device parameter to acpi_get_ref_args() and make that > function obtain the nargs_prop value. In the patch, you need to get > the nargs_prop value before calling it anyway in both places in which > it is used. That's better. Let me update acpi_get_ref_args() itself in the next version. Thanks! Sunil
On Wed, Jul 02, 2025 at 02:39:30PM +0200, Rafael J. Wysocki wrote: > On Wed, Jul 2, 2025 at 1:38 PM Andy Shevchenko > <andriy.shevchenko@linux.intel.com> wrote: > > On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > > > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: ... > > > > 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, > > > > > > const struct acpi_device_data *data; > > > > struct fwnode_handle *ref_fwnode; > > > > struct acpi_device *device; > > > > + unsigned int nargs_count; > > > > int ret, idx = 0; > > > > > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > I think it should work the same way as it used to for the callers that > > > pass args_count, so maybe > > > > > > if (!args_count) > > > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > But this is different variable. > > Of course it is different. It is an acpi_fwnode_get_reference_args() parameter. > > > > > element++; > > > > - > > > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > > > acpi_fwnode_handle(device), > > > > - &element, end, args_count); > > > > + &element, end, > > > > + nargs_count ? nargs_count : args_count); > > > > > > And this change would not be necessary? > > > > This is not the same check as proposed above. > > No, it is not. > > It just makes the function work the same way it did before the change > for the callers who passed nozero args_count and so they might be > forgiven expecting that it would be taken into account. I see your point now. But do we have such a user? I dunno. -- With Best Regards, Andy Shevchenko
On Wed, Jul 2, 2025 at 2:56 PM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Wed, Jul 02, 2025 at 02:39:30PM +0200, Rafael J. Wysocki wrote: > > On Wed, Jul 2, 2025 at 1:38 PM Andy Shevchenko > > <andriy.shevchenko@linux.intel.com> wrote: > > > On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > > > > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: > > ... > > > > > > 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, > > > > > > > > const struct acpi_device_data *data; > > > > > struct fwnode_handle *ref_fwnode; > > > > > struct acpi_device *device; > > > > > + unsigned int nargs_count; > > > > > int ret, idx = 0; > > > > > > > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > > > I think it should work the same way as it used to for the callers that > > > > pass args_count, so maybe > > > > > > > > if (!args_count) > > > > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > > > But this is different variable. > > > > Of course it is different. It is an acpi_fwnode_get_reference_args() parameter. > > > > > > > element++; > > > > > - > > > > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > > > > acpi_fwnode_handle(device), > > > > > - &element, end, args_count); > > > > > + &element, end, > > > > > + nargs_count ? nargs_count : args_count); > > > > > > > > And this change would not be necessary? > > > > > > This is not the same check as proposed above. > > > > No, it is not. > > > > It just makes the function work the same way it did before the change > > for the callers who passed nozero args_count and so they might be > > forgiven expecting that it would be taken into account. > > I see your point now. But do we have such a user? I dunno. Well, __acpi_node_get_property_reference() gets called in a couple of places.
On Wed, Jul 02, 2025 at 02:37:58PM +0300, Andy Shevchenko wrote: > On Wed, Jul 02, 2025 at 12:20:55PM +0200, Rafael J. Wysocki wrote: > > On Wed, Jul 2, 2025 at 7:16 AM Anup Patel <apatel@ventanamicro.com> wrote: ... > > > 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, > > > > const struct acpi_device_data *data; > > > struct fwnode_handle *ref_fwnode; > > > struct acpi_device *device; > > > + unsigned int nargs_count; > > > int ret, idx = 0; > > > > + nargs_count = acpi_fwnode_get_args_count(device, nargs_prop); > > > > I think it should work the same way as it used to for the callers that > > pass args_count, so maybe > > > > if (!args_count) > > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > But this is different variable. > > > > element++; > > > - > > > ret = acpi_get_ref_args(idx == index ? args : NULL, > > > acpi_fwnode_handle(device), > > > - &element, end, args_count); > > > + &element, end, > > > + nargs_count ? nargs_count : args_count); > > > > And this change would not be necessary? > > This is not the same check as proposed above. > But this can be made shorter with Elvis in use: > > &element, end, nargs_count ?: args_count); > > > And analogously below. > > And below. And in case if there is a new proposal to have > > if (!nargs_count) I meant if (!nargs_prop) here of course. > args_count = acpi_fwnode_get_args_count(device, nargs_prop); > > that is exactly what I asked to drop as it's included in the > acpi_fwnode_get_args_count() already, i.e. no need to check this in > the caller and in the callee. > > > > if (ret < 0) > > > return ret; -- With Best Regards, Andy Shevchenko
© 2016 - 2025 Red Hat, Inc.