linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: nvmem creates multiple devices with the same name
Date: Mon, 8 Jul 2019 09:14:19 +0200	[thread overview]
Message-ID: <20190708071419.eqhajizbipt24xl3@pengutronix.de> (raw)
In-Reply-To: <45d0cfaf-2511-4b1e-f4da-b67fa9f9e867@linaro.org>

On Tue, Jul 02, 2019 at 05:54:54PM +0100, Srinivas Kandagatla wrote:
> Hi Sascha,
> 
> On 01/07/2019 09:06, Sascha Hauer wrote:
> > Hi Srinivas,
> > 
> > On Tue, May 21, 2019 at 11:21:07AM +0200, Sascha Hauer wrote:
> > > On Tue, May 21, 2019 at 10:02:32AM +0100, Srinivas Kandagatla wrote:
> > > > 
> > > > 
> > > > On 21/05/2019 09:56, Sascha Hauer wrote:
> > > > > . Are there any suggestions how to register the nvmem devices
> > > > > with a different name?
> > > > 
> > > > struct nvmem_config provides id field for this purpose, this will be used by
> > > > nvmem to set the device name space along with name field.
> > > 
> > > There's no way for a caller to know a unique name/id combination.
> > > The mtd layer could initialize the id field with the mtd number, but
> > > that would still not guarantee that another caller, like an EEPROM
> > > driver or such, doesn't use the same name/id combination.
> > 
> > This is still an unresolved issue. Do you have any input how we could
> > proceed here?
> 
> Sorry for the delay!
> I think simplest solution would be to check if there is already an nvmem
> provider with the same name before assigning name to the device and then
> append the id in case it exists.
> 
> Let me know if below patch helps the situation so that I can take this in
> next cycle!
> 
> ----------------------------------->cut<----------------------------
>     nvmem: core: Check nvmem device name before adding the same one
> 
>     In some usecases where nvmem names are directly derived from
>     partition names, its likely that different devices might have
>     same partition name.
>     This will be an issue as we will be creating two different
>     nvmem devices with same name and sysfs will not be very happy with that.
> 
>     Simple solution is to check the existance of the nvmem provider with
>     same name and append an id if it exists before creating the device name.

This solution obviously works for me. I am not sure if that's really
what we want as the resulting names in sysfs are not predictable in any
way. In that case we might be better off using mtdx as Boris suggested.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2019-07-08  7:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21  8:56 nvmem creates multiple devices with the same name Sascha Hauer
2019-05-21  9:02 ` Srinivas Kandagatla
2019-05-21  9:21   ` Sascha Hauer
2019-07-01  8:06     ` Sascha Hauer
2019-07-02 16:54       ` Srinivas Kandagatla
2019-07-08  7:14         ` Sascha Hauer [this message]
2019-07-02 18:59 ` Boris Brezillon

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=20190708071419.eqhajizbipt24xl3@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.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 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).