Re: [PATCH v2 2/2] nvmem: add ONIE NVMEM cells support
From: Vadym Kochan
Date: Fri Aug 14 2020 - 07:57:01 EST
Hi Srinivas,
On Mon, Jun 15, 2020 at 12:06:11PM +0100, Srinivas Kandagatla wrote:
>
>
> On 05/06/2020 11:53, Vadym Kochan wrote:
> > > One of the example is atmel eeprom (at24), but there might be different
> > > devices.
> > >
> > > But can you please explain what is the technical/conceptual issue with
> > > this approach ?
> > >
> > > Thanks,
> > I just I'd like to clarify if there is a way it can be acceptable. The
> > problem is that there is TLV format which might be used on any nvmem
> > device which contains for example mac address which needs to be exposed
> > as nvmem cell. If to populate cells via nvmem_config then anyway I need
> > to parse these cells from the "target" nvmem device.
>
>
>
> As a first step this need to be part of the provider logic to parse this
> before nvmem provider is registered. If there are more users for such
> parsing, we can think of adding some level of parsing to nvmem core itself.
>
> Hope this answers your query.
>
> Thanks,
> srini
Thank you for suggestion, I did not answered because I was not sure
about the way how to provide this cell parser registering, still
I am not sure about the preferred way. What about the following way:
1) nvmem provides API for registering cell-parser.
Looks like it might be similar to the API for adding the
cell-table by using device's name.
2) cell-parser driver registers itself using API from above
(I am not sure on which initcall stage better to perform
registration to be registered before the nvmem drivers probe)
3) during nvmem_register() (before adding cells from table) core
tries to find parser by matching on device's name.
If parser is found - then core calls the callback with passing the pointer to
nvmem device.
4) cell-driver is called via on-parse callback.
During this callback the cell-parser driver can parse the nvmem
device and register cell table.
5) core adds cells from registered tables.
Thank you,