All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: devicetree@vger.kernel.org, Christian Eggers <CEggers@arri.de>,
	linux-kernel@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH v2] nvmem: core: don't consider subnodes not matching binding
Date: Wed, 15 Apr 2020 10:05:13 +0200	[thread overview]
Message-ID: <4e861088-c17d-0eca-6efa-c50b55fdecd1@pengutronix.de> (raw)
In-Reply-To: <bb0dcf33-f67d-7078-9341-08282d8da217@pengutronix.de>

On 4/6/20 4:20 PM, Ahmad Fatoum wrote:
> Hello,
> 
> On 4/6/20 2:33 PM, Srinivas Kandagatla wrote:
>>
>>
>> On 23/03/2020 15:28, Ahmad Fatoum wrote:
>>> The nvmem cell binding applies to objects which match "^.*@[0-9a-f]+$",
>>> but so far the driver has matched all objects and failed if they didn't
>>> have the expected properties.
>>>
>>> The driver's behavior in this regard precludes future extension of
>>> EEPROMs by child nodes other than nvmem and clashes with the barebox
>>> bootloader binding that extends the fixed-partitions MTD binding to
>>> EEPROMs as it tries to interpret the "fixed-partitions"-compatible
>>> partitions node as a nvmem cell.
>>>
>>> Solve this issue by skipping all subnodes that don't contain an @.
>>>
>>> This still allows for cell names like `partitions@0,0', but this
>> NACK.. thats nasty hack!
>> Its standard practice as per device tree specs to have nodes name as "node-name@unit-address"
>>
>> Ref: https://github.com/devicetree-org/devicetree-specification/releases/download/v0.3/devicetree-specification-v0.3.pdf
> 
> I didn't say otherwise. I just argued if we verify there's a @ symbol in the
> node name, before considering whether it is a NVMEM cell, we will skip fixed-partitions
> while adhering to the NVMEM cell binding.
> 
>>> is much less likely to cause future collisions.
>>
>> There have been discussions on this topic in the past at:
>>
>> https://patchwork.ozlabs.org/patch/890741/
>>
>> We need to come up with a better solution!
> 
> Thanks for the link, I didn't find it when I searched whether this has
> come up before.
> 
> As you probably noticed, your suggested approach there wouldn't work for me though,
> because this time it can't be worked around in the MTD driver.
> If the suggestion here is not palatable, how do you think about (in
> my preferred order):
> 
> - If the cell has a compatible node, it must be "nvmem-cell".
>   Otherwise, a cell with a compatible node is skipped.
> 
> - Adding a nvmem cell container with a compatible and making support for
>   the old binding configurable
> 
> - Skipping cells that are malformed and lack a reg = < > property _without_
>   error

gentle ping. I can prepare another patch if you indicate which approach
you'd prefer.

> 
> Cheers
> Ahmad
> 
>>
>> --srini
>>
>>>
>>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>>> ---
>>> v1 -> v2:
>>>    use ->full_name instead of ->name as to not break existing correct
>>>    cells (Christian)
>>> ---
>>>   drivers/nvmem/core.c | 2 ++
>>>   1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
>>> index ef326f243f36..f051051fb1a8 100644
>>> --- a/drivers/nvmem/core.c
>>> +++ b/drivers/nvmem/core.c
>>> @@ -278,6 +278,8 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
>>>       parent = dev->of_node;
>>>         for_each_child_of_node(parent, child) {
>>> +        if (!strchr(kbasename(child->full_name), '@'))
>>> +            continue;
>>>           addr = of_get_property(child, "reg", &len);
>>>           if (!addr || (len < 2 * sizeof(u32))) {
>>>               dev_err(dev, "nvmem: invalid reg on %pOF\n", child);
>>>
>>
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2020-04-15  8:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23 15:28 [PATCH v2] nvmem: core: don't consider subnodes not matching binding Ahmad Fatoum
2020-04-06 11:29 ` Ahmad Fatoum
2020-04-06 12:33 ` Srinivas Kandagatla
2020-04-06 14:20   ` Ahmad Fatoum
2020-04-15  8:05     ` Ahmad Fatoum [this message]
2020-04-15  8:46       ` Srinivas Kandagatla

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=4e861088-c17d-0eca-6efa-c50b55fdecd1@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=CEggers@arri.de \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.kandagatla@linaro.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 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.