devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Darren Hart <dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Mika Westerberg
	<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: "Rafael J. Wysocki"
	<rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Aaron Lu <aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Max Eliaser <max.eliaser-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC PATCH 4/9] of: Add property_ops callback for devices with of_node
Date: Mon, 18 Aug 2014 07:44:45 -0500	[thread overview]
Message-ID: <D0175E0D.A1C9E%dvhart@linux.intel.com> (raw)
In-Reply-To: <20140818092937.GT2462-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>

On 8/18/14, 4:29, "Mika Westerberg" <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
wrote:

>On Sun, Aug 17, 2014 at 01:54:16PM +0100, Grant Likely wrote:
>> On Sun, 17 Aug 2014 09:04:14 +0300, Mika Westerberg
>><mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
>> > From: Aaron Lu <aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> > 
>> > With the unified device properties interface in place, add device
>>tree support.
>> > By adding the dev_prop_ops for of_node devices, drivers can access
>>properties
>> > from ACPI or Device Tree in a generic way.
>> > 
>> > Signed-off-by: Aaron Lu <aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> > Reviewed-by: Darren Hart <dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>> > Signed-off-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>> 
>> Hi Mika,
>> 
>> As commented on patch 3, the new API currently throws away type
>> information so the compiler won't warn on an error. That needs to be
>> fixed and this patch reworked accordingly.
>
>The compiler should warn when we add static inline property accessor
>functions for each type.
>
>> 
>> g.
>> 
>> ---
>> >  drivers/of/base.c        | 194
>>++++++++++++++++++++++++++++++++++++++++++++++-
>> >  drivers/of/platform.c    |   4 +-
>> >  include/linux/property.h |   4 +
>> >  3 files changed, 200 insertions(+), 2 deletions(-)
>> > 
>> > diff --git a/drivers/of/base.c b/drivers/of/base.c
>> > index b9864806e9b8..527004d01423 100644
>> > --- a/drivers/of/base.c
>> > +++ b/drivers/of/base.c
>> > @@ -20,7 +20,7 @@
>> >  #include <linux/ctype.h>
>> >  #include <linux/cpu.h>
>> >  #include <linux/module.h>
>> > -#include <linux/of.h>
>> > +#include <linux/property.h>
>> >  #include <linux/of_graph.h>
>> >  #include <linux/spinlock.h>
>> >  #include <linux/slab.h>
>> > @@ -1343,6 +1343,39 @@ int of_property_read_u64(const struct
>>device_node *np, const char *propname,
>> >  EXPORT_SYMBOL_GPL(of_property_read_u64);
>> >  
>> >  /**
>> > + * of_property_read_u64_array - Find and read an array of 64 bit
>>integers
>> > + * from a property.
>> > + *
>> > + * @np:		device node from which the property value is to be read.
>> > + * @propname:	name of the property to be searched.
>> > + * @out_values:	pointer to return value, modified only if return
>>value is 0.
>> > + * @sz:		number of array elements to read
>> > + *
>> > + * Search for a property in a device node and read 64-bit value(s)
>>from
>> > + * it. Returns 0 on success, -EINVAL if the property does not exist,
>> > + * -ENODATA if property does not have a value, and -EOVERFLOW if the
>> > + * property data isn't large enough.
>> > + *
>> > + * The out_values is modified only if a valid u64 value can be
>>decoded.
>> > + */
>> > +int of_property_read_u64_array(const struct device_node *np,
>> > +			       const char *propname, u64 *out_values,
>> > +			       size_t sz)
>> > +{
>> > +	const __be32 *val = of_find_property_value_of_size(np, propname,
>> > +						(sz * sizeof(*out_values)));
>> > +
>> > +	if (IS_ERR(val))
>> > +		return PTR_ERR(val);
>> > +
>> > +	while (sz--) {
>> > +		*out_values++ = of_read_number(val, 2);
>> > +		val += 2;
>> > +	};
>> > +	return 0;
>> > +}
>> 
>> Considering we don't even have a user of u64 arrays in all of the DT
>> drivers, do we even need this type hook in the generic API?
>
>Indeed, I think we can remove it for now.
>

Keep in mind that existing DT drivers are not the only user of this
interface.

This series enables ACPI systems to make use of such drivers (or lays the
groundwork, each driver does need an update to the new API), but there are
also new drivers being developed today that are ACPI first. While the
DT-space may not need this interface now, I don't see the value in
preventing it from being used in the future by removing it from the
generic interface.

Adding it later, if needed, isn't as trivial as it sounds as we first have
to put developers through the pain of finding the interface doesn't exist
for a valid type, many of whom will decide to work around the limitation
rather than take the discussion to the infamous LKML - resulting in
suboptimal firmware descriptions.

I'd much rather see us enable them to help themselves and then get out of
their way by supporting all the valid types initially.

-- 
Darren Hart					Open Source Technology Center
darren.hart-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org				            Intel Corporation



--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-08-18 12:44 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-17  6:04 [RFC PATCH 0/9] Add ACPI _DSD and unified device properties support Mika Westerberg
2014-08-17  6:04 ` [RFC PATCH 1/9] ACPI: Add support for device specific properties Mika Westerberg
2014-08-18  8:13   ` Hanjun Guo
2014-08-18  8:27     ` Mika Westerberg
2014-08-18  8:57       ` Hanjun Guo
2014-08-18 12:37       ` Darren Hart
2014-08-17  6:04 ` [RFC PATCH 3/9] Driver core: Unified device properties interface for platform firmware Mika Westerberg
2014-08-17 12:49   ` Grant Likely
2014-08-17 17:31     ` Darren Hart
2014-08-18  4:55       ` Rafael J. Wysocki
2014-08-18  4:46     ` Rafael J. Wysocki
2014-08-17  6:04 ` [RFC PATCH 4/9] of: Add property_ops callback for devices with of_node Mika Westerberg
2014-08-17 12:54   ` Grant Likely
2014-08-18  9:29     ` Mika Westerberg
     [not found]       ` <20140818092937.GT2462-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2014-08-18 12:44         ` Darren Hart [this message]
2014-08-18  0:44   ` Rob Herring
2014-08-17  6:04 ` [RFC PATCH 5/9] mfd: Add ACPI support Mika Westerberg
2014-08-28 11:29   ` Lee Jones
2014-08-28 11:45     ` Mika Westerberg
     [not found] ` <1408255459-17625-1-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-08-17  6:04   ` [RFC PATCH 2/9] ACPI: Document ACPI device specific properties Mika Westerberg
2014-08-18 10:54     ` Mark Rutland
2014-08-18 16:05       ` Mika Westerberg
2014-08-19  5:45       ` Darren Hart
2014-08-19 16:51         ` Mark Rutland
2014-08-17  6:04   ` [RFC PATCH 6/9] gpiolib: add API to get gpio desc and flags Mika Westerberg
2014-08-17 13:00     ` Grant Likely
2014-08-17 17:43       ` Darren Hart
2014-08-18  4:57         ` Rafael J. Wysocki
     [not found]           ` <1927766.GeLld99ozq-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2014-08-18  7:16             ` Aaron Lu
2014-08-19 15:58             ` Grant Likely
2014-08-17  6:04   ` [RFC PATCH 7/9] gpio: sch: Consolidate core and resume banks Mika Westerberg
2014-08-17  6:04 ` [RFC PATCH 8/9] Input: gpio_keys_polled - Make use of device property API Mika Westerberg
2014-08-17  6:04 ` [RFC PATCH 9/9] leds: leds-gpio: " Mika Westerberg
  -- strict thread matches above, loose matches on Subject: below --
2014-08-16  6:53 [RFC PATCH 0/9] Add ACPI _DSD and unified device properties support Mika Westerberg
2014-08-16  6:53 ` [RFC PATCH 4/9] of: Add property_ops callback for devices with of_node Mika Westerberg

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=D0175E0D.A1C9E%dvhart@linux.intel.com \
    --to=dvhart-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=aaron.lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=max.eliaser-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).