From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-kernel@vger.kernel.org,
Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: Re: [PATCH v1] device property: Add helpers to count items in an array
Date: Mon, 20 May 2019 16:48:59 +0300 [thread overview]
Message-ID: <20190520134859.GB9224@smile.fi.intel.com> (raw)
In-Reply-To: <20190520133758.GG1887@kuha.fi.intel.com>
On Mon, May 20, 2019 at 04:37:58PM +0300, Heikki Krogerus wrote:
> On Mon, May 20, 2019 at 03:38:48PM +0300, Andy Shevchenko wrote:
> > The usual pattern to allocate the necessary space for an array of properties is
> > to count them fist using:
> >
> > count = device_property_read_uXX_array(dev, propname, NULL, 0);
> >
> > Introduce helpers device_property_count_uXX() to count items by supplying hard
> > coded last two parameters to device_property_readXX_array().
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> OK by me. FWIW:
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Thanks!
> Off topic question: Shouldn't we also be able to read the number of
> references a reference property holds? I mean, shouldn't
> fwnode_property_get_referece_args() also return the number of
> references in the property if called without the value parameter?
>
> There can be "empty" references in the middle of the "array" of
> references which cause the function to return -ENOENT just like when
> called with index out of bounds, so the caller now has in practice
> know how many references the property actually has in advance.
The idea is good, though I'm not so familiar with reference sub-API, don't know
what would be the best approach to cover all: ACPI, DT, swnode.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2019-05-20 13:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 12:38 [PATCH v1] device property: Add helpers to count items in an array Andy Shevchenko
2019-05-20 12:52 ` Sakari Ailus
2019-05-20 13:37 ` Heikki Krogerus
2019-05-20 13:48 ` Andy Shevchenko [this message]
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=20190520134859.GB9224@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=sakari.ailus@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox