Re: [PATCHv4 2/7] nvmem: Add backwards compatibility support for older EEPROM drivers.

From: Andrew Lunn
Date: Wed Feb 17 2016 - 08:27:30 EST


On Wed, Feb 17, 2016 at 10:17:34AM +0000, Srinivas Kandagatla wrote:
>
>
> On 16/02/16 23:41, Andrew Lunn wrote:
> >Older drivers made an 'eeprom' file available in the /sys device
> >directory. Have the NVMEM core provide this to retain backwards
> >compatibility.
> >
> >Signed-off-by: Andrew Lunn <andrew@xxxxxxx>
> >---
> >v4: Add lockdep support
> >---
> > drivers/nvmem/core.c | 84 ++++++++++++++++++++++++++++++++++++++----
> > include/linux/nvmem-provider.h | 4 +-
> > 2 files changed, 79 insertions(+), 9 deletions(-)
> >
> >diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> >index 4ccf03da6467..9ad1c2cf75ac 100644
> >--- a/drivers/nvmem/core.c
> >+++ b/drivers/nvmem/core.c
> >@@ -38,8 +38,13 @@ struct nvmem_device {
> > int users;
> > size_t size;
> > bool read_only;
> >+ int flags;
> >+ struct bin_attribute eeprom;
> >+ struct device *base_dev;
>
> Any reason why should this base_dev be any different to the dev in
> the nvmem_config?
> Should we just not reuse dev? unless am missing something obvious.

Hi Srinivas

For backwards compatibility, we need the 'eeprom' file to be in the
i2c or spi device directory under /sys. This is the base_dev. The
nvmem file should be in the /sys/class/nvmem directory. This is the
dev in nvmem_device structure. I don't think you can merge them.

e.g. consider:

nvmem->dev.type = &nvmem_provider_type;
nvmem->dev.bus = &nvmem_bus_type;
nvmem->dev.parent = config->dev;
np = config->dev->of_node;

The base device is an i2c device on an i2c bus. Would it work if it
suddenly became an nvmem_provider on an nvmem_bus?

Thanks

Andrew