Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Maxime Ripard
On Thu, Aug 20, 2015 at 06:38:51PM +0200, Andrew Lunn wrote:
> > It's true that this is something that we might have overlooked. Is it
> > expected to maintain that compatibility when moving a driver from one
> > framework to another (and this is a real question, not a troll)?
> 
> Yes. There will be user space applications reading from the eeprom
> file in /sys. In fact, until the NVMEM framework arrived, it was not
> easy to access the eeprom from kernel space, meaning the majority of
> users must of been user space...

Ack.

> > If so, we might provide a compatibility layer to add the former file
> > too, protected by a kconfig option maybe ?
> 
> There is one other detail you might of missed. Both AT24 and AT25 do
> have an in kernel API. In the at24_platform_data you can have a
> callback function "setup" which gets called when the device is
> probed. setup() is called with a struct memory_accessor which contains
> function pointers for reading and writing to the EEPROM. A few
> platforms use these for getting the MAC address out of the EEPROM.
> And these platforms are old style, not DT.

Actually, we took it into account. The in-kernel API is even a big
chunk of the framework. The only thing we still need to figure out is
what interface we need to register cells statically.

AT25's memory accessor can be removed, there's no users for it. The
only user of the AT24 is some omap l138 boards is mach-davinci.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Wolfram Sang

> Wolfram Sang has been maintaining the AT24 driver since 2008. We need
> his ACK to this change, and since this is an i2c driver, he is also
> probably the path into mainline for this change.

Yes, currently I pick up at24 patches. I am open to move it to some
NVMEM framework in the future...

> But we should also look at the bigger picture. The AT25, MAX6875 and
> sunxi_sid drivers also have a binary file in /sys. It would be good to
> have some sort of plan what to do with these drivers, even if at the
> moment only AT24 is under discussion.

... but this surely has to be solved first.

Regards,

   Wolfram



signature.asc
Description: Digital signature


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Andrew Lunn
> It's true that this is something that we might have overlooked. Is it
> expected to maintain that compatibility when moving a driver from one
> framework to another (and this is a real question, not a troll)?

Yes. There will be user space applications reading from the eeprom
file in /sys. In fact, until the NVMEM framework arrived, it was not
easy to access the eeprom from kernel space, meaning the majority of
users must of been user space...
 
> If so, we might provide a compatibility layer to add the former file
> too, protected by a kconfig option maybe ?

There is one other detail you might of missed. Both AT24 and AT25 do
have an in kernel API. In the at24_platform_data you can have a
callback function "setup" which gets called when the device is
probed. setup() is called with a struct memory_accessor which contains
function pointers for reading and writing to the EEPROM. A few
platforms use these for getting the MAC address out of the EEPROM.
And these platforms are old style, not DT.

Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Maxime Ripard
On Mon, Aug 17, 2015 at 05:25:04PM +0200, Andrew Lunn wrote:
> On Mon, Aug 17, 2015 at 03:59:23PM +0100, Srinivas Kandagatla wrote:
> > 
> > 
> > On 17/08/15 14:09, Andrew Lunn wrote:
> > >On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:
> > >>
> > >>+Adding Maxime in the loop
> > >>
> > >>On 16/08/15 16:37, Stefan Wahren wrote:
> > >Another question which spring to mind is, do we want the eeprom to be
> > >in /sys twice, the old and the new way? Backwards compatibility says
> > >the old must stay. Do we want a way to suppress the new? Or should we
> > >be going as far as refractoring the code into a core library, and two
> > >wrapper drivers, old and new?
> > >>>I think these are questions for the framework maintainers.
> > >>>
> > >>One of the reasons for the NVMEM framework is to remove that
> > >>duplicate code in the every driver.  There was no framework/ABI
> > >>which was guiding such old eeprom sysfs entry in first place, so I
> > >>dont see an issue in removing it for good. Correct me if am wrong.
> > >
> > >The reason for keeping it is backwards compatibility. Having the
> > >contents of the EEPROM as a file in /sys via this driver is now a part
> > >of the Linux ABI. You cannot argue it is not an ABI, just because
> > >there is no framework. Userspace will be assuming it exists at the
> > >specified location. So we cannot remove it, for existing uses of the
> > >driver.
> > Am Ok as long as someone is happy to maintain it.
> 
> Wolfram Sang has been maintaining the AT24 driver since 2008. We need
> his ACK to this change, and since this is an i2c driver, he is also
> probably the path into mainline for this change.
> 
> But we should also look at the bigger picture. The AT25, MAX6875 and
> sunxi_sid drivers also have a binary file in /sys. It would be good to
> have some sort of plan what to do with these drivers, even if at the
> moment only AT24 is under discussion.

It's true that this is something that we might have overlooked. Is it
expected to maintain that compatibility when moving a driver from one
framework to another (and this is a real question, not a troll)?

If so, we might provide a compatibility layer to add the former file
too, protected by a kconfig option maybe ?

In the sunxi_sid case, I'm not sure anyone will really notice. It
wasn't used for anything but debug at this point, but it will be
noticed for the much more generic AT24 and At25 drivers.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Wolfram Sang

 Wolfram Sang has been maintaining the AT24 driver since 2008. We need
 his ACK to this change, and since this is an i2c driver, he is also
 probably the path into mainline for this change.

Yes, currently I pick up at24 patches. I am open to move it to some
NVMEM framework in the future...

 But we should also look at the bigger picture. The AT25, MAX6875 and
 sunxi_sid drivers also have a binary file in /sys. It would be good to
 have some sort of plan what to do with these drivers, even if at the
 moment only AT24 is under discussion.

... but this surely has to be solved first.

Regards,

   Wolfram



signature.asc
Description: Digital signature


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Maxime Ripard
On Thu, Aug 20, 2015 at 06:38:51PM +0200, Andrew Lunn wrote:
  It's true that this is something that we might have overlooked. Is it
  expected to maintain that compatibility when moving a driver from one
  framework to another (and this is a real question, not a troll)?
 
 Yes. There will be user space applications reading from the eeprom
 file in /sys. In fact, until the NVMEM framework arrived, it was not
 easy to access the eeprom from kernel space, meaning the majority of
 users must of been user space...

Ack.

  If so, we might provide a compatibility layer to add the former file
  too, protected by a kconfig option maybe ?
 
 There is one other detail you might of missed. Both AT24 and AT25 do
 have an in kernel API. In the at24_platform_data you can have a
 callback function setup which gets called when the device is
 probed. setup() is called with a struct memory_accessor which contains
 function pointers for reading and writing to the EEPROM. A few
 platforms use these for getting the MAC address out of the EEPROM.
 And these platforms are old style, not DT.

Actually, we took it into account. The in-kernel API is even a big
chunk of the framework. The only thing we still need to figure out is
what interface we need to register cells statically.

AT25's memory accessor can be removed, there's no users for it. The
only user of the AT24 is some omap l138 boards is mach-davinci.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Andrew Lunn
 It's true that this is something that we might have overlooked. Is it
 expected to maintain that compatibility when moving a driver from one
 framework to another (and this is a real question, not a troll)?

Yes. There will be user space applications reading from the eeprom
file in /sys. In fact, until the NVMEM framework arrived, it was not
easy to access the eeprom from kernel space, meaning the majority of
users must of been user space...
 
 If so, we might provide a compatibility layer to add the former file
 too, protected by a kconfig option maybe ?

There is one other detail you might of missed. Both AT24 and AT25 do
have an in kernel API. In the at24_platform_data you can have a
callback function setup which gets called when the device is
probed. setup() is called with a struct memory_accessor which contains
function pointers for reading and writing to the EEPROM. A few
platforms use these for getting the MAC address out of the EEPROM.
And these platforms are old style, not DT.

Andrew
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-20 Thread Maxime Ripard
On Mon, Aug 17, 2015 at 05:25:04PM +0200, Andrew Lunn wrote:
 On Mon, Aug 17, 2015 at 03:59:23PM +0100, Srinivas Kandagatla wrote:
  
  
  On 17/08/15 14:09, Andrew Lunn wrote:
  On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:
  
  +Adding Maxime in the loop
  
  On 16/08/15 16:37, Stefan Wahren wrote:
  Another question which spring to mind is, do we want the eeprom to be
  in /sys twice, the old and the new way? Backwards compatibility says
  the old must stay. Do we want a way to suppress the new? Or should we
  be going as far as refractoring the code into a core library, and two
  wrapper drivers, old and new?
  I think these are questions for the framework maintainers.
  
  One of the reasons for the NVMEM framework is to remove that
  duplicate code in the every driver.  There was no framework/ABI
  which was guiding such old eeprom sysfs entry in first place, so I
  dont see an issue in removing it for good. Correct me if am wrong.
  
  The reason for keeping it is backwards compatibility. Having the
  contents of the EEPROM as a file in /sys via this driver is now a part
  of the Linux ABI. You cannot argue it is not an ABI, just because
  there is no framework. Userspace will be assuming it exists at the
  specified location. So we cannot remove it, for existing uses of the
  driver.
  Am Ok as long as someone is happy to maintain it.
 
 Wolfram Sang has been maintaining the AT24 driver since 2008. We need
 his ACK to this change, and since this is an i2c driver, he is also
 probably the path into mainline for this change.
 
 But we should also look at the bigger picture. The AT25, MAX6875 and
 sunxi_sid drivers also have a binary file in /sys. It would be good to
 have some sort of plan what to do with these drivers, even if at the
 moment only AT24 is under discussion.

It's true that this is something that we might have overlooked. Is it
expected to maintain that compatibility when moving a driver from one
framework to another (and this is a real question, not a troll)?

If so, we might provide a compatibility layer to add the former file
too, protected by a kconfig option maybe ?

In the sunxi_sid case, I'm not sure anyone will really notice. It
wasn't used for anything but debug at this point, but it will be
noticed for the much more generic AT24 and At25 drivers.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla



On 17/08/15 16:25, Andrew Lunn wrote:

On Mon, Aug 17, 2015 at 03:59:23PM +0100, Srinivas Kandagatla wrote:



On 17/08/15 14:09, Andrew Lunn wrote:

On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:


+Adding Maxime in the loop

On 16/08/15 16:37, Stefan Wahren wrote:

Another question which spring to mind is, do we want the eeprom to be
in /sys twice, the old and the new way? Backwards compatibility says
the old must stay. Do we want a way to suppress the new? Or should we
be going as far as refractoring the code into a core library, and two
wrapper drivers, old and new?

I think these are questions for the framework maintainers.


One of the reasons for the NVMEM framework is to remove that
duplicate code in the every driver.  There was no framework/ABI
which was guiding such old eeprom sysfs entry in first place, so I
dont see an issue in removing it for good. Correct me if am wrong.


The reason for keeping it is backwards compatibility. Having the
contents of the EEPROM as a file in /sys via this driver is now a part
of the Linux ABI. You cannot argue it is not an ABI, just because
there is no framework. Userspace will be assuming it exists at the
specified location. So we cannot remove it, for existing uses of the
driver.

Am Ok as long as someone is happy to maintain it.


Wolfram Sang has been maintaining the AT24 driver since 2008. We need
his ACK to this change, and since this is an i2c driver, he is also
probably the path into mainline for this change.

But we should also look at the bigger picture. The AT25, MAX6875 and
sunxi_sid drivers also have a binary file in /sys. It would be good to
have some sort of plan what to do with these drivers, even if at the
moment only AT24 is under discussion.#


+1




Andrew


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Andrew Lunn
On Mon, Aug 17, 2015 at 03:59:23PM +0100, Srinivas Kandagatla wrote:
> 
> 
> On 17/08/15 14:09, Andrew Lunn wrote:
> >On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:
> >>
> >>+Adding Maxime in the loop
> >>
> >>On 16/08/15 16:37, Stefan Wahren wrote:
> >Another question which spring to mind is, do we want the eeprom to be
> >in /sys twice, the old and the new way? Backwards compatibility says
> >the old must stay. Do we want a way to suppress the new? Or should we
> >be going as far as refractoring the code into a core library, and two
> >wrapper drivers, old and new?
> >>>I think these are questions for the framework maintainers.
> >>>
> >>One of the reasons for the NVMEM framework is to remove that
> >>duplicate code in the every driver.  There was no framework/ABI
> >>which was guiding such old eeprom sysfs entry in first place, so I
> >>dont see an issue in removing it for good. Correct me if am wrong.
> >
> >The reason for keeping it is backwards compatibility. Having the
> >contents of the EEPROM as a file in /sys via this driver is now a part
> >of the Linux ABI. You cannot argue it is not an ABI, just because
> >there is no framework. Userspace will be assuming it exists at the
> >specified location. So we cannot remove it, for existing uses of the
> >driver.
> Am Ok as long as someone is happy to maintain it.

Wolfram Sang has been maintaining the AT24 driver since 2008. We need
his ACK to this change, and since this is an i2c driver, he is also
probably the path into mainline for this change.

But we should also look at the bigger picture. The AT25, MAX6875 and
sunxi_sid drivers also have a binary file in /sys. It would be good to
have some sort of plan what to do with these drivers, even if at the
moment only AT24 is under discussion.

   Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla



On 17/08/15 14:09, Andrew Lunn wrote:

On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:


+Adding Maxime in the loop

On 16/08/15 16:37, Stefan Wahren wrote:

Another question which spring to mind is, do we want the eeprom to be
in /sys twice, the old and the new way? Backwards compatibility says
the old must stay. Do we want a way to suppress the new? Or should we
be going as far as refractoring the code into a core library, and two
wrapper drivers, old and new?

I think these are questions for the framework maintainers.


One of the reasons for the NVMEM framework is to remove that
duplicate code in the every driver.  There was no framework/ABI
which was guiding such old eeprom sysfs entry in first place, so I
dont see an issue in removing it for good. Correct me if am wrong.


The reason for keeping it is backwards compatibility. Having the
contents of the EEPROM as a file in /sys via this driver is now a part
of the Linux ABI. You cannot argue it is not an ABI, just because
there is no framework. Userspace will be assuming it exists at the
specified location. So we cannot remove it, for existing uses of the
driver.

Am Ok as long as someone is happy to maintain it.

--srini


However, for new uses of this driver, it is O.K. to only have the
NVMEM file.

   Andrew


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Andrew Lunn
On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:
> 
> +Adding Maxime in the loop
> 
> On 16/08/15 16:37, Stefan Wahren wrote:
> >>>Another question which spring to mind is, do we want the eeprom to be
> >>>in /sys twice, the old and the new way? Backwards compatibility says
> >>>the old must stay. Do we want a way to suppress the new? Or should we
> >>>be going as far as refractoring the code into a core library, and two
> >>>wrapper drivers, old and new?
> >I think these are questions for the framework maintainers.
> >
> One of the reasons for the NVMEM framework is to remove that
> duplicate code in the every driver.  There was no framework/ABI
> which was guiding such old eeprom sysfs entry in first place, so I
> dont see an issue in removing it for good. Correct me if am wrong.

The reason for keeping it is backwards compatibility. Having the
contents of the EEPROM as a file in /sys via this driver is now a part
of the Linux ABI. You cannot argue it is not an ABI, just because
there is no framework. Userspace will be assuming it exists at the
specified location. So we cannot remove it, for existing uses of the
driver.

However, for new uses of this driver, it is O.K. to only have the
NVMEM file.

  Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla


+Adding Maxime in the loop

On 16/08/15 16:37, Stefan Wahren wrote:

>Another question which spring to mind is, do we want the eeprom to be
>in /sys twice, the old and the new way? Backwards compatibility says
>the old must stay. Do we want a way to suppress the new? Or should we
>be going as far as refractoring the code into a core library, and two
>wrapper drivers, old and new?

I think these are questions for the framework maintainers.

One of the reasons for the NVMEM framework is to remove that duplicate 
code in the every driver.  There was no framework/ABI which was guiding 
such old eeprom sysfs entry in first place, so I dont see an issue in 
removing it for good. Correct me if am wrong.


IMHO, its better to move on with nvmem for good reasons, rather than 
having two sysfs binary files.


--srini
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla

Hi Andrew,

Thanks for the patch, few comments other than Stefan's comments.

On 16/08/15 03:54, Andrew Lunn wrote:

Add a read only regmap for accessing the EEPROM, and then use that
with the NVMEM framework.

Signed-off-by: Andrew Lunn 
---
  drivers/misc/eeprom/at24.c | 65 ++
  1 file changed, 65 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 2d3db81be099..0e80c0c09d4e 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -22,6 +22,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  #include 

  /*
@@ -69,6 +71,10 @@ struct at24_data {
unsigned write_max;
unsigned num_addresses;

+   struct regmap_config regmap_config;
+   struct nvmem_config nvmem_config;
+   struct nvmem_device *nvmem;
+
/*
 * Some chips tie up multiple I2C addresses; dummy devices reserve
 * them for us, and we'll use them with SMBus calls.
@@ -471,6 +477,34 @@ static ssize_t at24_macc_write(struct memory_accessor 
*macc, const char *buf,

  /*-*/

+/*
+ * Provide a regmap interface, which is registered with the NVMEM
+ * framework
+*/
+static int at24_regmap_read(void *context, const void *reg, size_t reg_size,
+   void *val, size_t val_size)
+{
+   struct at24_data *at24 = context;
+   off_t offset = *(u32 *)reg;
+
+   return at24_read(at24, val, offset, val_size);
+}
+
+static int at24_regmap_write(void *context, const void *data, size_t count)
+{
+   struct at24_data *at24 = context;
+
+   return at24_write(at24, data, 0, count);
+}
+
+static const struct regmap_bus at24_regmap_bus = {
+   .read = at24_regmap_read,
+   .write = at24_regmap_write,
+   .reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
+};
+
+/*-*/
+
  #ifdef CONFIG_OF
  static void at24_get_ofdata(struct i2c_client *client,
struct at24_platform_data *chip)
@@ -502,6 +536,7 @@ static int at24_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
int err;
unsigned i, num_addresses;
kernel_ulong_t magic;
+   struct regmap *regmap;

if (client->dev.platform_data) {
chip = *(struct at24_platform_data *)client->dev.platform_data;
@@ -644,6 +679,30 @@ static int at24_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
if (err)
goto err_clients;

+   at24->regmap_config.reg_bits = 32;
+   at24->regmap_config.val_bits = 8;
+   at24->regmap_config.reg_stride = 1;
+   at24->regmap_config.max_register = at24->bin.size - 1;
+
+   regmap = devm_regmap_init(>dev, _regmap_bus, at24,
+ >regmap_config);
+   if (IS_ERR(regmap)) {
+   dev_err(>dev, "regmap init failed\n");
+   err = PTR_ERR(regmap);
+   goto err_sysfs;
+   }
+
+   at24->nvmem_config.name = dev_name(>dev);
+   at24->nvmem_config.dev = >dev;
+   at24->nvmem_config.read_only = !writable;
+   at24->nvmem_config.owner = THIS_MODULE;
+
+   at24->nvmem = nvmem_register(>nvmem_config);
+   if (IS_ERR(at24->nvmem)) {
+   err = PTR_ERR(at24->nvmem);
+   goto err_sysfs;
+   }
+
i2c_set_clientdata(client, at24);

dev_info(>dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
@@ -662,6 +721,9 @@ static int at24_probe(struct i2c_client *client, const 
struct i2c_device_id *id)

return 0;

+err_sysfs:
+   sysfs_remove_bin_file(>dev.kobj, >bin);
+


?? Not sure Why this code is still needed. Can't we remove it?

Is this the the same binary file which is exposed by nvmem in 
/sys/bus/nvmem too?


--srini

  err_clients:
for (i = 1; i < num_addresses; i++)
if (at24->client[i])
@@ -676,6 +738,9 @@ static int at24_remove(struct i2c_client *client)
int i;

at24 = i2c_get_clientdata(client);
+
+   nvmem_unregister(at24->nvmem);
+
sysfs_remove_bin_file(>dev.kobj, >bin);

for (i = 1; i < at24->num_addresses; i++)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla

Hi Andrew,

Thanks for the patch, few comments other than Stefan's comments.

On 16/08/15 03:54, Andrew Lunn wrote:

Add a read only regmap for accessing the EEPROM, and then use that
with the NVMEM framework.

Signed-off-by: Andrew Lunn and...@lunn.ch
---
  drivers/misc/eeprom/at24.c | 65 ++
  1 file changed, 65 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 2d3db81be099..0e80c0c09d4e 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -22,6 +22,8 @@
  #include linux/jiffies.h
  #include linux/of.h
  #include linux/i2c.h
+#include linux/nvmem-provider.h
+#include linux/regmap.h
  #include linux/platform_data/at24.h

  /*
@@ -69,6 +71,10 @@ struct at24_data {
unsigned write_max;
unsigned num_addresses;

+   struct regmap_config regmap_config;
+   struct nvmem_config nvmem_config;
+   struct nvmem_device *nvmem;
+
/*
 * Some chips tie up multiple I2C addresses; dummy devices reserve
 * them for us, and we'll use them with SMBus calls.
@@ -471,6 +477,34 @@ static ssize_t at24_macc_write(struct memory_accessor 
*macc, const char *buf,

  /*-*/

+/*
+ * Provide a regmap interface, which is registered with the NVMEM
+ * framework
+*/
+static int at24_regmap_read(void *context, const void *reg, size_t reg_size,
+   void *val, size_t val_size)
+{
+   struct at24_data *at24 = context;
+   off_t offset = *(u32 *)reg;
+
+   return at24_read(at24, val, offset, val_size);
+}
+
+static int at24_regmap_write(void *context, const void *data, size_t count)
+{
+   struct at24_data *at24 = context;
+
+   return at24_write(at24, data, 0, count);
+}
+
+static const struct regmap_bus at24_regmap_bus = {
+   .read = at24_regmap_read,
+   .write = at24_regmap_write,
+   .reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
+};
+
+/*-*/
+
  #ifdef CONFIG_OF
  static void at24_get_ofdata(struct i2c_client *client,
struct at24_platform_data *chip)
@@ -502,6 +536,7 @@ static int at24_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
int err;
unsigned i, num_addresses;
kernel_ulong_t magic;
+   struct regmap *regmap;

if (client-dev.platform_data) {
chip = *(struct at24_platform_data *)client-dev.platform_data;
@@ -644,6 +679,30 @@ static int at24_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
if (err)
goto err_clients;

+   at24-regmap_config.reg_bits = 32;
+   at24-regmap_config.val_bits = 8;
+   at24-regmap_config.reg_stride = 1;
+   at24-regmap_config.max_register = at24-bin.size - 1;
+
+   regmap = devm_regmap_init(client-dev, at24_regmap_bus, at24,
+ at24-regmap_config);
+   if (IS_ERR(regmap)) {
+   dev_err(client-dev, regmap init failed\n);
+   err = PTR_ERR(regmap);
+   goto err_sysfs;
+   }
+
+   at24-nvmem_config.name = dev_name(client-dev);
+   at24-nvmem_config.dev = client-dev;
+   at24-nvmem_config.read_only = !writable;
+   at24-nvmem_config.owner = THIS_MODULE;
+
+   at24-nvmem = nvmem_register(at24-nvmem_config);
+   if (IS_ERR(at24-nvmem)) {
+   err = PTR_ERR(at24-nvmem);
+   goto err_sysfs;
+   }
+
i2c_set_clientdata(client, at24);

dev_info(client-dev, %zu byte %s EEPROM, %s, %u bytes/write\n,
@@ -662,6 +721,9 @@ static int at24_probe(struct i2c_client *client, const 
struct i2c_device_id *id)

return 0;

+err_sysfs:
+   sysfs_remove_bin_file(client-dev.kobj, at24-bin);
+


?? Not sure Why this code is still needed. Can't we remove it?

Is this the the same binary file which is exposed by nvmem in 
/sys/bus/nvmem too?


--srini

  err_clients:
for (i = 1; i  num_addresses; i++)
if (at24-client[i])
@@ -676,6 +738,9 @@ static int at24_remove(struct i2c_client *client)
int i;

at24 = i2c_get_clientdata(client);
+
+   nvmem_unregister(at24-nvmem);
+
sysfs_remove_bin_file(client-dev.kobj, at24-bin);

for (i = 1; i  at24-num_addresses; i++)


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Andrew Lunn
On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:
 
 +Adding Maxime in the loop
 
 On 16/08/15 16:37, Stefan Wahren wrote:
 Another question which spring to mind is, do we want the eeprom to be
 in /sys twice, the old and the new way? Backwards compatibility says
 the old must stay. Do we want a way to suppress the new? Or should we
 be going as far as refractoring the code into a core library, and two
 wrapper drivers, old and new?
 I think these are questions for the framework maintainers.
 
 One of the reasons for the NVMEM framework is to remove that
 duplicate code in the every driver.  There was no framework/ABI
 which was guiding such old eeprom sysfs entry in first place, so I
 dont see an issue in removing it for good. Correct me if am wrong.

The reason for keeping it is backwards compatibility. Having the
contents of the EEPROM as a file in /sys via this driver is now a part
of the Linux ABI. You cannot argue it is not an ABI, just because
there is no framework. Userspace will be assuming it exists at the
specified location. So we cannot remove it, for existing uses of the
driver.

However, for new uses of this driver, it is O.K. to only have the
NVMEM file.

  Andrew
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla


+Adding Maxime in the loop

On 16/08/15 16:37, Stefan Wahren wrote:

Another question which spring to mind is, do we want the eeprom to be
in /sys twice, the old and the new way? Backwards compatibility says
the old must stay. Do we want a way to suppress the new? Or should we
be going as far as refractoring the code into a core library, and two
wrapper drivers, old and new?

I think these are questions for the framework maintainers.

One of the reasons for the NVMEM framework is to remove that duplicate 
code in the every driver.  There was no framework/ABI which was guiding 
such old eeprom sysfs entry in first place, so I dont see an issue in 
removing it for good. Correct me if am wrong.


IMHO, its better to move on with nvmem for good reasons, rather than 
having two sysfs binary files.


--srini
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla



On 17/08/15 14:09, Andrew Lunn wrote:

On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:


+Adding Maxime in the loop

On 16/08/15 16:37, Stefan Wahren wrote:

Another question which spring to mind is, do we want the eeprom to be
in /sys twice, the old and the new way? Backwards compatibility says
the old must stay. Do we want a way to suppress the new? Or should we
be going as far as refractoring the code into a core library, and two
wrapper drivers, old and new?

I think these are questions for the framework maintainers.


One of the reasons for the NVMEM framework is to remove that
duplicate code in the every driver.  There was no framework/ABI
which was guiding such old eeprom sysfs entry in first place, so I
dont see an issue in removing it for good. Correct me if am wrong.


The reason for keeping it is backwards compatibility. Having the
contents of the EEPROM as a file in /sys via this driver is now a part
of the Linux ABI. You cannot argue it is not an ABI, just because
there is no framework. Userspace will be assuming it exists at the
specified location. So we cannot remove it, for existing uses of the
driver.

Am Ok as long as someone is happy to maintain it.

--srini


However, for new uses of this driver, it is O.K. to only have the
NVMEM file.

   Andrew


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Srinivas Kandagatla



On 17/08/15 16:25, Andrew Lunn wrote:

On Mon, Aug 17, 2015 at 03:59:23PM +0100, Srinivas Kandagatla wrote:



On 17/08/15 14:09, Andrew Lunn wrote:

On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:


+Adding Maxime in the loop

On 16/08/15 16:37, Stefan Wahren wrote:

Another question which spring to mind is, do we want the eeprom to be
in /sys twice, the old and the new way? Backwards compatibility says
the old must stay. Do we want a way to suppress the new? Or should we
be going as far as refractoring the code into a core library, and two
wrapper drivers, old and new?

I think these are questions for the framework maintainers.


One of the reasons for the NVMEM framework is to remove that
duplicate code in the every driver.  There was no framework/ABI
which was guiding such old eeprom sysfs entry in first place, so I
dont see an issue in removing it for good. Correct me if am wrong.


The reason for keeping it is backwards compatibility. Having the
contents of the EEPROM as a file in /sys via this driver is now a part
of the Linux ABI. You cannot argue it is not an ABI, just because
there is no framework. Userspace will be assuming it exists at the
specified location. So we cannot remove it, for existing uses of the
driver.

Am Ok as long as someone is happy to maintain it.


Wolfram Sang has been maintaining the AT24 driver since 2008. We need
his ACK to this change, and since this is an i2c driver, he is also
probably the path into mainline for this change.

But we should also look at the bigger picture. The AT25, MAX6875 and
sunxi_sid drivers also have a binary file in /sys. It would be good to
have some sort of plan what to do with these drivers, even if at the
moment only AT24 is under discussion.#


+1




Andrew


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-17 Thread Andrew Lunn
On Mon, Aug 17, 2015 at 03:59:23PM +0100, Srinivas Kandagatla wrote:
 
 
 On 17/08/15 14:09, Andrew Lunn wrote:
 On Mon, Aug 17, 2015 at 02:01:24PM +0100, Srinivas Kandagatla wrote:
 
 +Adding Maxime in the loop
 
 On 16/08/15 16:37, Stefan Wahren wrote:
 Another question which spring to mind is, do we want the eeprom to be
 in /sys twice, the old and the new way? Backwards compatibility says
 the old must stay. Do we want a way to suppress the new? Or should we
 be going as far as refractoring the code into a core library, and two
 wrapper drivers, old and new?
 I think these are questions for the framework maintainers.
 
 One of the reasons for the NVMEM framework is to remove that
 duplicate code in the every driver.  There was no framework/ABI
 which was guiding such old eeprom sysfs entry in first place, so I
 dont see an issue in removing it for good. Correct me if am wrong.
 
 The reason for keeping it is backwards compatibility. Having the
 contents of the EEPROM as a file in /sys via this driver is now a part
 of the Linux ABI. You cannot argue it is not an ABI, just because
 there is no framework. Userspace will be assuming it exists at the
 specified location. So we cannot remove it, for existing uses of the
 driver.
 Am Ok as long as someone is happy to maintain it.

Wolfram Sang has been maintaining the AT24 driver since 2008. We need
his ACK to this change, and since this is an i2c driver, he is also
probably the path into mainline for this change.

But we should also look at the bigger picture. The AT25, MAX6875 and
sunxi_sid drivers also have a binary file in /sys. It would be good to
have some sort of plan what to do with these drivers, even if at the
moment only AT24 is under discussion.

   Andrew
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-16 Thread Stefan Wahren
Hi Andrew,

> Andrew Lunn  hat am 16. August 2015 um 15:11 geschrieben:
>
>
> On Sun, Aug 16, 2015 at 10:28:06AM +0200, Stefan Wahren wrote:
> > Hi Andrew,
> >
> > > Andrew Lunn  hat am 16. August 2015 um 04:54 geschrieben:
> > >
> > >
> > > Add a read only regmap for accessing the EEPROM, and then use that
> > > with the NVMEM framework.
> > >
> > > Signed-off-by: Andrew Lunn 
> > > ---
> > > drivers/misc/eeprom/at24.c | 65
> > > ++
> > > 1 file changed, 65 insertions(+)
> > >
> > > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> > > index 2d3db81be099..0e80c0c09d4e 100644
> > > --- a/drivers/misc/eeprom/at24.c
> > > +++ b/drivers/misc/eeprom/at24.c
> > > @@ -22,6 +22,8 @@
> > > #include 
> > > #include 
> > > #include 
> > > +#include 
> > > +#include 
> >
> > shouldn't the dependancies in Kconfig updated (depends on REGMAP) too?
>
> Hi Stefan
>
> This is why the patch is RFC.
>
> REGMAP has stub implementations for when it is not. NVMEM also has
> stub implementations. NVMEM does however select REGMAP. So it should
> be possible to compile this driver without NVMEM support. Hopefully
> 0day will find my git branch and compile it in different ways to see
> if i've got this right.

you are right.

>
> As part of RFC, is this O.K?
>
> Another question which spring to mind is, do we want the eeprom to be
> in /sys twice, the old and the new way? Backwards compatibility says
> the old must stay. Do we want a way to suppress the new? Or should we
> be going as far as refractoring the code into a core library, and two
> wrapper drivers, old and new?

I think these are questions for the framework maintainers.

>
> > > +static int at24_regmap_write(void *context, const void *data, size_t
> > > count)
> > > +{
> > > + struct at24_data *at24 = context;
> > > +
> > > + return at24_write(at24, data, 0, count);
> >
> > Since the patch only provides read only support this function could return
> > 0.
>
> Humm, the comment is out of date. Regmap does not work too well
> without a write method. So i ended up implementing it. But it has
> hardly been tested, where as i have hammered on read.

I think you didn't understand my comment. I know the write function is
necessary, but
calling at24_write() instead of simply returning 0 does make no sense to me.

Regards
Stefan

>
> Thanks
> Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-16 Thread Andrew Lunn
On Sun, Aug 16, 2015 at 10:28:06AM +0200, Stefan Wahren wrote:
> Hi Andrew,
> 
> > Andrew Lunn  hat am 16. August 2015 um 04:54 geschrieben:
> >
> >
> > Add a read only regmap for accessing the EEPROM, and then use that
> > with the NVMEM framework.
> >
> > Signed-off-by: Andrew Lunn 
> > ---
> > drivers/misc/eeprom/at24.c | 65 
> > ++
> > 1 file changed, 65 insertions(+)
> >
> > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> > index 2d3db81be099..0e80c0c09d4e 100644
> > --- a/drivers/misc/eeprom/at24.c
> > +++ b/drivers/misc/eeprom/at24.c
> > @@ -22,6 +22,8 @@
> > #include 
> > #include 
> > #include 
> > +#include 
> > +#include 
> 
> shouldn't the dependancies in Kconfig updated (depends on REGMAP) too?

Hi Stefan

This is why the patch is RFC.

REGMAP has stub implementations for when it is not. NVMEM also has
stub implementations. NVMEM does however select REGMAP. So it should
be possible to compile this driver without NVMEM support. Hopefully
0day will find my git branch and compile it in different ways to see
if i've got this right.

As part of RFC, is this O.K?

Another question which spring to mind is, do we want the eeprom to be
in /sys twice, the old and the new way? Backwards compatibility says
the old must stay. Do we want a way to suppress the new? Or should we
be going as far as refractoring the code into a core library, and two
wrapper drivers, old and new?
 
> > +static int at24_regmap_write(void *context, const void *data, size_t count)
> > +{
> > + struct at24_data *at24 = context;
> > +
> > + return at24_write(at24, data, 0, count);
> 
> Since the patch only provides read only support this function could return 0.

Humm, the comment is out of date. Regmap does not work too well
without a write method. So i ended up implementing it. But it has
hardly been tested, where as i have hammered on read.

Thanks
Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-16 Thread Stefan Wahren
Hi Andrew,

> Andrew Lunn  hat am 16. August 2015 um 04:54 geschrieben:
>
>
> Add a read only regmap for accessing the EEPROM, and then use that
> with the NVMEM framework.
>
> Signed-off-by: Andrew Lunn 
> ---
> drivers/misc/eeprom/at24.c | 65 ++
> 1 file changed, 65 insertions(+)
>
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 2d3db81be099..0e80c0c09d4e 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -22,6 +22,8 @@
> #include 
> #include 
> #include 
> +#include 
> +#include 

shouldn't the dependancies in Kconfig updated (depends on REGMAP) too?

> #include 
>
> /*
> @@ -69,6 +71,10 @@ struct at24_data {
> unsigned write_max;
> unsigned num_addresses;
>
> + struct regmap_config regmap_config;
> + struct nvmem_config nvmem_config;
> + struct nvmem_device *nvmem;
> +
> /*
> * Some chips tie up multiple I2C addresses; dummy devices reserve
> * them for us, and we'll use them with SMBus calls.
> @@ -471,6 +477,34 @@ static ssize_t at24_macc_write(struct memory_accessor
> *macc, const char *buf,
>
> /*-*/
>
> +/*
> + * Provide a regmap interface, which is registered with the NVMEM
> + * framework
> +*/
> +static int at24_regmap_read(void *context, const void *reg, size_t reg_size,
> + void *val, size_t val_size)
> +{
> + struct at24_data *at24 = context;
> + off_t offset = *(u32 *)reg;
> +
> + return at24_read(at24, val, offset, val_size);
> +}
> +
> +static int at24_regmap_write(void *context, const void *data, size_t count)
> +{
> + struct at24_data *at24 = context;
> +
> + return at24_write(at24, data, 0, count);

Since the patch only provides read only support this function could return 0.

Regards
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-16 Thread Stefan Wahren
Hi Andrew,

 Andrew Lunn and...@lunn.ch hat am 16. August 2015 um 04:54 geschrieben:


 Add a read only regmap for accessing the EEPROM, and then use that
 with the NVMEM framework.

 Signed-off-by: Andrew Lunn and...@lunn.ch
 ---
 drivers/misc/eeprom/at24.c | 65 ++
 1 file changed, 65 insertions(+)

 diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
 index 2d3db81be099..0e80c0c09d4e 100644
 --- a/drivers/misc/eeprom/at24.c
 +++ b/drivers/misc/eeprom/at24.c
 @@ -22,6 +22,8 @@
 #include linux/jiffies.h
 #include linux/of.h
 #include linux/i2c.h
 +#include linux/nvmem-provider.h
 +#include linux/regmap.h

shouldn't the dependancies in Kconfig updated (depends on REGMAP) too?

 #include linux/platform_data/at24.h

 /*
 @@ -69,6 +71,10 @@ struct at24_data {
 unsigned write_max;
 unsigned num_addresses;

 + struct regmap_config regmap_config;
 + struct nvmem_config nvmem_config;
 + struct nvmem_device *nvmem;
 +
 /*
 * Some chips tie up multiple I2C addresses; dummy devices reserve
 * them for us, and we'll use them with SMBus calls.
 @@ -471,6 +477,34 @@ static ssize_t at24_macc_write(struct memory_accessor
 *macc, const char *buf,

 /*-*/

 +/*
 + * Provide a regmap interface, which is registered with the NVMEM
 + * framework
 +*/
 +static int at24_regmap_read(void *context, const void *reg, size_t reg_size,
 + void *val, size_t val_size)
 +{
 + struct at24_data *at24 = context;
 + off_t offset = *(u32 *)reg;
 +
 + return at24_read(at24, val, offset, val_size);
 +}
 +
 +static int at24_regmap_write(void *context, const void *data, size_t count)
 +{
 + struct at24_data *at24 = context;
 +
 + return at24_write(at24, data, 0, count);

Since the patch only provides read only support this function could return 0.

Regards
Stefan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-16 Thread Andrew Lunn
On Sun, Aug 16, 2015 at 10:28:06AM +0200, Stefan Wahren wrote:
 Hi Andrew,
 
  Andrew Lunn and...@lunn.ch hat am 16. August 2015 um 04:54 geschrieben:
 
 
  Add a read only regmap for accessing the EEPROM, and then use that
  with the NVMEM framework.
 
  Signed-off-by: Andrew Lunn and...@lunn.ch
  ---
  drivers/misc/eeprom/at24.c | 65 
  ++
  1 file changed, 65 insertions(+)
 
  diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
  index 2d3db81be099..0e80c0c09d4e 100644
  --- a/drivers/misc/eeprom/at24.c
  +++ b/drivers/misc/eeprom/at24.c
  @@ -22,6 +22,8 @@
  #include linux/jiffies.h
  #include linux/of.h
  #include linux/i2c.h
  +#include linux/nvmem-provider.h
  +#include linux/regmap.h
 
 shouldn't the dependancies in Kconfig updated (depends on REGMAP) too?

Hi Stefan

This is why the patch is RFC.

REGMAP has stub implementations for when it is not. NVMEM also has
stub implementations. NVMEM does however select REGMAP. So it should
be possible to compile this driver without NVMEM support. Hopefully
0day will find my git branch and compile it in different ways to see
if i've got this right.

As part of RFC, is this O.K?

Another question which spring to mind is, do we want the eeprom to be
in /sys twice, the old and the new way? Backwards compatibility says
the old must stay. Do we want a way to suppress the new? Or should we
be going as far as refractoring the code into a core library, and two
wrapper drivers, old and new?
 
  +static int at24_regmap_write(void *context, const void *data, size_t count)
  +{
  + struct at24_data *at24 = context;
  +
  + return at24_write(at24, data, 0, count);
 
 Since the patch only provides read only support this function could return 0.

Humm, the comment is out of date. Regmap does not work too well
without a write method. So i ended up implementing it. But it has
hardly been tested, where as i have hammered on read.

Thanks
Andrew
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework

2015-08-16 Thread Stefan Wahren
Hi Andrew,

 Andrew Lunn and...@lunn.ch hat am 16. August 2015 um 15:11 geschrieben:


 On Sun, Aug 16, 2015 at 10:28:06AM +0200, Stefan Wahren wrote:
  Hi Andrew,
 
   Andrew Lunn and...@lunn.ch hat am 16. August 2015 um 04:54 geschrieben:
  
  
   Add a read only regmap for accessing the EEPROM, and then use that
   with the NVMEM framework.
  
   Signed-off-by: Andrew Lunn and...@lunn.ch
   ---
   drivers/misc/eeprom/at24.c | 65
   ++
   1 file changed, 65 insertions(+)
  
   diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
   index 2d3db81be099..0e80c0c09d4e 100644
   --- a/drivers/misc/eeprom/at24.c
   +++ b/drivers/misc/eeprom/at24.c
   @@ -22,6 +22,8 @@
   #include linux/jiffies.h
   #include linux/of.h
   #include linux/i2c.h
   +#include linux/nvmem-provider.h
   +#include linux/regmap.h
 
  shouldn't the dependancies in Kconfig updated (depends on REGMAP) too?

 Hi Stefan

 This is why the patch is RFC.

 REGMAP has stub implementations for when it is not. NVMEM also has
 stub implementations. NVMEM does however select REGMAP. So it should
 be possible to compile this driver without NVMEM support. Hopefully
 0day will find my git branch and compile it in different ways to see
 if i've got this right.

you are right.


 As part of RFC, is this O.K?

 Another question which spring to mind is, do we want the eeprom to be
 in /sys twice, the old and the new way? Backwards compatibility says
 the old must stay. Do we want a way to suppress the new? Or should we
 be going as far as refractoring the code into a core library, and two
 wrapper drivers, old and new?

I think these are questions for the framework maintainers.


   +static int at24_regmap_write(void *context, const void *data, size_t
   count)
   +{
   + struct at24_data *at24 = context;
   +
   + return at24_write(at24, data, 0, count);
 
  Since the patch only provides read only support this function could return
  0.

 Humm, the comment is out of date. Regmap does not work too well
 without a write method. So i ended up implementing it. But it has
 hardly been tested, where as i have hammered on read.

I think you didn't understand my comment. I know the write function is
necessary, but
calling at24_write() instead of simply returning 0 does make no sense to me.

Regards
Stefan


 Thanks
 Andrew
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/