[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZNTlniWf8Ou9hHOT@smile.fi.intel.com>
Date: Thu, 10 Aug 2023 16:26:54 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Antoniu Miclaus <antoniu.miclaus@...log.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Gerald Loacker <gerald.loacker@...fvision.net>,
Gwendal Grignou <gwendal@...omium.org>,
linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org, Daniel Scally <djrscally@...il.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>
Subject: Re: [PATCH v1 2/6] device property: Add
fwnode_property_match_property_string()
On Wed, Aug 09, 2023 at 06:59:44PM +0100, Jonathan Cameron wrote:
> On Tue, 8 Aug 2023 19:27:56 +0300
> Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:
...
> > +int fwnode_property_match_property_string(const struct fwnode_handle *fwnode,
> > + const char *propname, const char * const *array, size_t n)
>
> Hi Andy,
>
> Whilst I'm not 100% sold on adding ever increasing complexity to what we
> match, this one feels like a common enough thing to be worth providing.
Yep, that's why I considered it's good to add (and because of new comers).
> Looking at the usecases I wonder if it would be better to pass in
> an unsigned int *ret which is only updated on a match?
So the question is here are we going to match (pun intended) the prototype to
the device_property_match*() family of functions or to device_property_read_*()
one. If the latter, this has to be renamed, but then it probably will contradict
the semantics as we are _matching_ against something and not just _reading_
something.
That said, do you agree that current implementation is (slightly) better from
these aspects? Anyway, look at the below.
> That way the common properties approach of not checking the return value
> if we have an optional property would apply.
>
> e.g. patch 3
Only?
> would end up with a block that looks like:
>
> st->input_mode = ADMV1014_IQ_MODE;
> device_property_match_property_string(&spi->dev, "adi,input-mode",
> input_mode_names,
> ARRAY_SIZE(input_mode_names),
> &st->input_mode);
>
> Only neat and tidy if the thing being optionally read into is an unsigned int
> though (otherwise you still need a local variable)
We also can have a hybrid variant, returning in both sides
int device_property_match_property_string(..., size_t *index)
{
if (index)
*index = ret;
return ret;
}
(also note the correct return type as it has to match to @n).
Would it be still okay or too over engineered?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists