All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sean Anderson <sean.anderson@linux.dev>
Cc: Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@google.com>,
	devicetree@vger.kernel.org,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Daniel Scally <djrscally@gmail.com>,
	linux-kernel@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>,
	linux-acpi@vger.kernel.org
Subject: Re: [PATCH 1/2] device property: Add optional nargs_prop for get_reference_args
Date: Tue, 8 Apr 2025 11:37:19 +0300	[thread overview]
Message-ID: <Z_TgP0epJ3cJzlUt@smile.fi.intel.com> (raw)
In-Reply-To: <20250407223714.2287202-2-sean.anderson@linux.dev>

On Mon, Apr 07, 2025 at 06:37:13PM -0400, Sean Anderson wrote:
> get_reference_args does not permit falling back to nargs when nargs_prop
> is missing. This makes it difficult to support older devicetrees where
> nargs_prop may not be present. Add support for this by converting nargs
> to a signed value. Where before nargs was ignored if nargs_prop was
> passed, now nargs is only ignored if it is strictly negative. When it is
> positive, nargs represents the fallback cells to use if nargs_prop is
> absent.

And what is the case to support old DTs on most likely outdated hardware?

...

>  	ret = fwnode_call_int_op(fwnode, get_reference_args, prop, nargs_prop,
> -				 nargs, index, args);
> +				 nargs_prop ? -1 : nargs, index, args);

>  	return fwnode_call_int_op(fwnode->secondary, get_reference_args, prop, nargs_prop,
> -				  nargs, index, args);
> +				  nargs_prop ? -1 : nargs, index, args);

I don't understand why it's needed here. The nargs_prop is passed to the callee.

...

> -				 unsigned int nargs, unsigned int index,
> +				 int nargs, unsigned int index,

As per above.

...

>  		error = property_entry_read_int_array(ref->node->properties,
>  						      nargs_prop, sizeof(u32),
>  						      &nargs_prop_val, 1);
> -		if (error)

> +

Stray blank line.

> +		if (error == -EINVAL) {

Why do we need an explicit error code check? This is fragile. Just check the
parameter before calling the above.

> +			if (nargs < 0)
> +				return error;
> +		} else if (error) {
>  			return error;
> -
> -		nargs = nargs_prop_val;
> +		} else {
> +			nargs = nargs_prop_val;
> +		}

...

>  of_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
>  			     const char *prop, const char *nargs_prop,
> -			     unsigned int nargs, unsigned int index,
> +			     int nargs, unsigned int index,
>  			     struct fwnode_reference_args *args)

Same comments as per above.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-04-08  8:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 22:37 [PATCH 0/2] device property: Add fwnode_property_get_reference_optional_args Sean Anderson
2025-04-07 22:37 ` [PATCH 1/2] device property: Add optional nargs_prop for get_reference_args Sean Anderson
2025-04-08  8:37   ` Andy Shevchenko [this message]
2025-04-08 12:52     ` Rob Herring
2025-04-08  9:14   ` Sakari Ailus
2025-04-08 12:55     ` Rob Herring
2025-04-07 22:37 ` [PATCH 2/2] device property: Add fwnode_property_get_reference_optional_args Sean Anderson
2025-04-08  8:39   ` Andy Shevchenko
2025-04-08 15:10     ` Sean Anderson
2025-04-08 13:00   ` Rob Herring
2025-04-08 15:12     ` Sean Anderson
2025-04-08 15:19       ` Rob Herring
2025-04-08 15:28         ` Sean Anderson
2025-04-08 17:19           ` Rob Herring
2025-04-08  8:40 ` [PATCH 0/2] " Andy Shevchenko
2025-04-08 15:13   ` Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z_TgP0epJ3cJzlUt@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=dakr@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=djrscally@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=saravanak@google.com \
    --cc=sean.anderson@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.