linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
@ 2015-08-16  2:54 Andrew Lunn
       [not found] ` <1439693649-10809-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Lunn @ 2015-08-16  2:54 UTC (permalink / raw)
  To: wsa, srinivas.kandagatla; +Cc: linux-kernel, linux-i2c, Andrew Lunn

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

Signed-off-by: Andrew Lunn <andrew@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);
+
 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++)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found] ` <1439693649-10809-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
@ 2015-08-16  8:28   ` Stefan Wahren
  2015-08-16 13:11     ` Andrew Lunn
  2015-08-17  9:48   ` Srinivas Kandagatla
  1 sibling, 1 reply; 14+ messages in thread
From: Stefan Wahren @ 2015-08-16  8:28 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g,
	srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A

Hi Andrew,

> Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org> 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 <andrew-g2DYL2Zd6BY@public.gmane.org>
> ---
> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
  2015-08-16  8:28   ` Stefan Wahren
@ 2015-08-16 13:11     ` Andrew Lunn
       [not found]       ` <20150816131130.GC10094-g2DYL2Zd6BY@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Lunn @ 2015-08-16 13:11 UTC (permalink / raw)
  To: Stefan Wahren; +Cc: linux-kernel, linux-i2c, wsa, srinivas.kandagatla

On Sun, Aug 16, 2015 at 10:28:06AM +0200, Stefan Wahren wrote:
> Hi Andrew,
> 
> > Andrew Lunn <andrew@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 <andrew@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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]       ` <20150816131130.GC10094-g2DYL2Zd6BY@public.gmane.org>
@ 2015-08-16 15:37         ` Stefan Wahren
       [not found]           ` <1511754934.28154.1439739426390.JavaMail.open-xchange-0SF9iQWekqLZ78VGacPtK8gmgJlYmuWJ@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Wahren @ 2015-08-16 15:37 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g

Hi Andrew,

> Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org> 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 <andrew-g2DYL2Zd6BY@public.gmane.org> 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 <andrew-g2DYL2Zd6BY@public.gmane.org>
> > > ---
> > > 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found] ` <1439693649-10809-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
  2015-08-16  8:28   ` Stefan Wahren
@ 2015-08-17  9:48   ` Srinivas Kandagatla
  1 sibling, 0 replies; 14+ messages in thread
From: Srinivas Kandagatla @ 2015-08-17  9:48 UTC (permalink / raw)
  To: Andrew Lunn, wsa-z923LK4zBo2bacvFa/9K2g
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA

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 <andrew-g2DYL2Zd6BY@public.gmane.org>
> ---
>   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++)
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]           ` <1511754934.28154.1439739426390.JavaMail.open-xchange-0SF9iQWekqLZ78VGacPtK8gmgJlYmuWJ@public.gmane.org>
@ 2015-08-17 13:01             ` Srinivas Kandagatla
       [not found]               ` <55D1DB24.8090602-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Srinivas Kandagatla @ 2015-08-17 13:01 UTC (permalink / raw)
  To: Stefan Wahren, Andrew Lunn
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g,
	Maxime Ripard


+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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]               ` <55D1DB24.8090602-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-08-17 13:09                 ` Andrew Lunn
       [not found]                   ` <20150817130945.GE7537-g2DYL2Zd6BY@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Lunn @ 2015-08-17 13:09 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Stefan Wahren, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g,
	Maxime Ripard

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]                   ` <20150817130945.GE7537-g2DYL2Zd6BY@public.gmane.org>
@ 2015-08-17 14:59                     ` Srinivas Kandagatla
       [not found]                       ` <55D1F6CB.2010606-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Srinivas Kandagatla @ 2015-08-17 14:59 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Stefan Wahren, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g,
	Maxime Ripard



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
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]                       ` <55D1F6CB.2010606-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-08-17 15:25                         ` Andrew Lunn
       [not found]                           ` <20150817152504.GI7537-g2DYL2Zd6BY@public.gmane.org>
  2015-08-20 15:57                           ` Maxime Ripard
  0 siblings, 2 replies; 14+ messages in thread
From: Andrew Lunn @ 2015-08-17 15:25 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Stefan Wahren, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g,
	Maxime Ripard

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]                           ` <20150817152504.GI7537-g2DYL2Zd6BY@public.gmane.org>
@ 2015-08-17 15:41                             ` Srinivas Kandagatla
  2015-08-20 20:33                             ` Wolfram Sang
  1 sibling, 0 replies; 14+ messages in thread
From: Srinivas Kandagatla @ 2015-08-17 15:41 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Stefan Wahren, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g,
	Maxime Ripard



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
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
  2015-08-17 15:25                         ` Andrew Lunn
       [not found]                           ` <20150817152504.GI7537-g2DYL2Zd6BY@public.gmane.org>
@ 2015-08-20 15:57                           ` Maxime Ripard
  2015-08-20 16:38                             ` Andrew Lunn
  1 sibling, 1 reply; 14+ messages in thread
From: Maxime Ripard @ 2015-08-20 15:57 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Srinivas Kandagatla, Stefan Wahren, linux-kernel, linux-i2c, wsa

[-- Attachment #1: Type: text/plain, Size: 2632 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
  2015-08-20 15:57                           ` Maxime Ripard
@ 2015-08-20 16:38                             ` Andrew Lunn
       [not found]                               ` <20150820163851.GG27457-g2DYL2Zd6BY@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Lunn @ 2015-08-20 16:38 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Srinivas Kandagatla, Stefan Wahren,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g

> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]                           ` <20150817152504.GI7537-g2DYL2Zd6BY@public.gmane.org>
  2015-08-17 15:41                             ` Srinivas Kandagatla
@ 2015-08-20 20:33                             ` Wolfram Sang
  1 sibling, 0 replies; 14+ messages in thread
From: Wolfram Sang @ 2015-08-20 20:33 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Srinivas Kandagatla, Stefan Wahren,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Maxime Ripard

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]


> 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


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework
       [not found]                               ` <20150820163851.GG27457-g2DYL2Zd6BY@public.gmane.org>
@ 2015-08-20 21:52                                 ` Maxime Ripard
  0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2015-08-20 21:52 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Srinivas Kandagatla, Stefan Wahren,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g

[-- Attachment #1: Type: text/plain, Size: 1587 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-08-20 21:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-16  2:54 [PATCH RFC] eeprom: at24: extend driver to plug into the NVMEM framework Andrew Lunn
     [not found] ` <1439693649-10809-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2015-08-16  8:28   ` Stefan Wahren
2015-08-16 13:11     ` Andrew Lunn
     [not found]       ` <20150816131130.GC10094-g2DYL2Zd6BY@public.gmane.org>
2015-08-16 15:37         ` Stefan Wahren
     [not found]           ` <1511754934.28154.1439739426390.JavaMail.open-xchange-0SF9iQWekqLZ78VGacPtK8gmgJlYmuWJ@public.gmane.org>
2015-08-17 13:01             ` Srinivas Kandagatla
     [not found]               ` <55D1DB24.8090602-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-08-17 13:09                 ` Andrew Lunn
     [not found]                   ` <20150817130945.GE7537-g2DYL2Zd6BY@public.gmane.org>
2015-08-17 14:59                     ` Srinivas Kandagatla
     [not found]                       ` <55D1F6CB.2010606-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-08-17 15:25                         ` Andrew Lunn
     [not found]                           ` <20150817152504.GI7537-g2DYL2Zd6BY@public.gmane.org>
2015-08-17 15:41                             ` Srinivas Kandagatla
2015-08-20 20:33                             ` Wolfram Sang
2015-08-20 15:57                           ` Maxime Ripard
2015-08-20 16:38                             ` Andrew Lunn
     [not found]                               ` <20150820163851.GG27457-g2DYL2Zd6BY@public.gmane.org>
2015-08-20 21:52                                 ` Maxime Ripard
2015-08-17  9:48   ` Srinivas Kandagatla

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).