All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] eeprom: support for at24cs and at24mac
@ 2016-03-24 14:45 Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 01/13] eeprom: at24: remove a reduntant if Bartosz Golaszewski
                   ` (12 more replies)
  0 siblings, 13 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:45 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

Chips from the at24cs EEPROM series have an additional read-only
memory area containing a factory pre-programmed serial number. In
order to access it, a dummy write must be executed before reading
the serial number bytes.

Chips from the at24mac familiy, apart from the serial number, have
a second special memory area containing a factory programmed
EUI-48/EUI64 mac address.

The read-only serial/mac memory area is accessible on a different i2c
slave address (addr + 0x08). This patchset makes it possible to
instantiate a separate at24 device on this second address and access
the read-only area through the regular eeprom sysfs attribute or the
new nvmem subsystem.

This series also contains several patches intoducing some minor tweaks
and refactoring.

Tested with at24cs32 and at24cs02 chips (for both 16 and 8 bit address
pointers). I have no means of testing the support for at24mac chips, I
relied solely on the datasheet.

Bartosz Golaszewski (13):
  eeprom: at24: remove a reduntant if
  eeprom: at24: improve the device_id table readability
  eeprom: at24: platform_data: use BIT() macro
  eeprom: at24: make locking more fine-grained
  eeprom: at24: replace msleep() with usleep_range()
  eeprom: at24: add serial number flag
  eeprom: at24: support reading of the serial number
  eeprom: at24: call read and write routines via function pointers
  eeprom: at24: use at24cs_serial_read()
  eeprom: at24: add the at24cs series to the list of supported devices
  eeprom: at24: add at24mac series flag
  eeprom: at24: add support for at24mac series
  eeprom: at24: add at24mac chips to the list of supported devices

 drivers/misc/eeprom/at24.c         | 200 ++++++++++++++++++++++++++++---------
 include/linux/platform_data/at24.h |  10 +-
 2 files changed, 161 insertions(+), 49 deletions(-)

-- 
2.7.4

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

* [PATCH 01/13] eeprom: at24: remove a reduntant if
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
@ 2016-03-24 14:45 ` Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 02/13] eeprom: at24: improve the device_id table readability Bartosz Golaszewski
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:45 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

It seems as if the second check for I2C_FUNC_I2C functionality had
been introduced accidentally during a merge. Tt's reduntant, so
remove it.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 089d694..001a9af 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -544,10 +544,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		} else {
 			return -EPFNOSUPPORT;
 		}
-	}
 
-	/* Use I2C operations unless we're stuck with SMBus extensions. */
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		if (i2c_check_functionality(client->adapter,
 				I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
 			use_smbus_write = I2C_SMBUS_I2C_BLOCK_DATA;
-- 
2.7.4

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

* [PATCH 02/13] eeprom: at24: improve the device_id table readability
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 01/13] eeprom: at24: remove a reduntant if Bartosz Golaszewski
@ 2016-03-24 14:45 ` Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 03/13] eeprom: at24: platform_data: use BIT() macro Bartosz Golaszewski
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:45 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

As part of the preparation for introducing support for more chips,
improve the readability of the device table by separating columns
with tabs.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 001a9af..744c526 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -113,23 +113,23 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)");
 
 static const struct i2c_device_id at24_ids[] = {
 	/* needs 8 addresses as A0-A2 are ignored */
-	{ "24c00", AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR) },
+	{ "24c00",	AT24_DEVICE_MAGIC(128 / 8,	AT24_FLAG_TAKE8ADDR) },
 	/* old variants can't be handled with this generic entry! */
-	{ "24c01", AT24_DEVICE_MAGIC(1024 / 8, 0) },
-	{ "24c02", AT24_DEVICE_MAGIC(2048 / 8, 0) },
+	{ "24c01",	AT24_DEVICE_MAGIC(1024 / 8,	0) },
+	{ "24c02",	AT24_DEVICE_MAGIC(2048 / 8,	0) },
 	/* spd is a 24c02 in memory DIMMs */
-	{ "spd", AT24_DEVICE_MAGIC(2048 / 8,
-		AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
-	{ "24c04", AT24_DEVICE_MAGIC(4096 / 8, 0) },
+	{ "spd",	AT24_DEVICE_MAGIC(2048 / 8,
+				AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
+	{ "24c04",	AT24_DEVICE_MAGIC(4096 / 8,	0) },
 	/* 24rf08 quirk is handled at i2c-core */
-	{ "24c08", AT24_DEVICE_MAGIC(8192 / 8, 0) },
-	{ "24c16", AT24_DEVICE_MAGIC(16384 / 8, 0) },
-	{ "24c32", AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16) },
-	{ "24c64", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16) },
-	{ "24c128", AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16) },
-	{ "24c256", AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16) },
-	{ "24c512", AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16) },
-	{ "24c1024", AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16) },
+	{ "24c08",	AT24_DEVICE_MAGIC(8192 / 8,	0) },
+	{ "24c16",	AT24_DEVICE_MAGIC(16384 / 8,	0) },
+	{ "24c32",	AT24_DEVICE_MAGIC(32768 / 8,	AT24_FLAG_ADDR16) },
+	{ "24c64",	AT24_DEVICE_MAGIC(65536 / 8,	AT24_FLAG_ADDR16) },
+	{ "24c128",	AT24_DEVICE_MAGIC(131072 / 8,	AT24_FLAG_ADDR16) },
+	{ "24c256",	AT24_DEVICE_MAGIC(262144 / 8,	AT24_FLAG_ADDR16) },
+	{ "24c512",	AT24_DEVICE_MAGIC(524288 / 8,	AT24_FLAG_ADDR16) },
+	{ "24c1024",	AT24_DEVICE_MAGIC(1048576 / 8,	AT24_FLAG_ADDR16) },
 	{ "at24", 0 },
 	{ /* END OF LIST */ }
 };
-- 
2.7.4

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

* [PATCH 03/13] eeprom: at24: platform_data: use BIT() macro
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 01/13] eeprom: at24: remove a reduntant if Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 02/13] eeprom: at24: improve the device_id table readability Bartosz Golaszewski
@ 2016-03-24 14:45 ` Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 04/13] eeprom: at24: make locking more fine-grained Bartosz Golaszewski
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:45 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

Use BIT() macro to replace the 0xXX constants in platform_data flags
definitions.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 include/linux/platform_data/at24.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h
index dc9a13e..a543b93 100644
--- a/include/linux/platform_data/at24.h
+++ b/include/linux/platform_data/at24.h
@@ -43,10 +43,10 @@ struct at24_platform_data {
 	u32		byte_len;		/* size (sum of all addr) */
 	u16		page_size;		/* for writes */
 	u8		flags;
-#define AT24_FLAG_ADDR16	0x80	/* address pointer is 16 bit */
-#define AT24_FLAG_READONLY	0x40	/* sysfs-entry will be read-only */
-#define AT24_FLAG_IRUGO		0x20	/* sysfs-entry will be world-readable */
-#define AT24_FLAG_TAKE8ADDR	0x10	/* take always 8 addresses (24c00) */
+#define AT24_FLAG_ADDR16	BIT(7)	/* address pointer is 16 bit */
+#define AT24_FLAG_READONLY	BIT(6)	/* sysfs-entry will be read-only */
+#define AT24_FLAG_IRUGO		BIT(5)	/* sysfs-entry will be world-readable */
+#define AT24_FLAG_TAKE8ADDR	BIT(4)	/* take always 8 addresses (24c00) */
 
 	void		(*setup)(struct nvmem_device *nvmem, void *context);
 	void		*context;
-- 
2.7.4

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

* [PATCH 04/13] eeprom: at24: make locking more fine-grained
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2016-03-24 14:45 ` [PATCH 03/13] eeprom: at24: platform_data: use BIT() macro Bartosz Golaszewski
@ 2016-03-24 14:45 ` Bartosz Golaszewski
  2016-03-24 14:45 ` [PATCH 05/13] eeprom: at24: replace msleep() with usleep_range() Bartosz Golaszewski
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:45 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

The only field in struct at24_data that needs locking in the module
code is u8 *writebuf. Other data is already protected by i2c core.

Rename the lock in at24_data to wrbuf_lock and only use it where
writebuf is accessed.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 28 +++++-----------------------
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 744c526..9e01428 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -59,13 +59,8 @@ struct at24_data {
 	int use_smbus;
 	int use_smbus_write;
 
-	/*
-	 * Lock protects against activities from other Linux tasks,
-	 * but not from changes by other I2C masters.
-	 */
-	struct mutex lock;
-
 	u8 *writebuf;
+	struct mutex wrbuf_lock;
 	unsigned write_max;
 	unsigned num_addresses;
 
@@ -260,12 +255,6 @@ static ssize_t at24_read(struct at24_data *at24,
 	if (unlikely(!count))
 		return count;
 
-	/*
-	 * Read data from chip, protecting against concurrent updates
-	 * from this host, but not from other I2C masters.
-	 */
-	mutex_lock(&at24->lock);
-
 	while (count) {
 		ssize_t	status;
 
@@ -281,8 +270,6 @@ static ssize_t at24_read(struct at24_data *at24,
 		retval += status;
 	}
 
-	mutex_unlock(&at24->lock);
-
 	return retval;
 }
 
@@ -322,6 +309,8 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
 		msg.addr = client->addr;
 		msg.flags = 0;
 
+		mutex_lock(&at24->wrbuf_lock);
+
 		/* msg.buf is u8 and casts will mask the values */
 		msg.buf = at24->writebuf;
 		if (at24->chip.flags & AT24_FLAG_ADDR16)
@@ -356,6 +345,7 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
 				status = count;
 		} else {
 			status = i2c_transfer(client->adapter, &msg, 1);
+			mutex_unlock(&at24->wrbuf_lock);
 			if (status == 1)
 				status = count;
 		}
@@ -380,12 +370,6 @@ static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
 	if (unlikely(!count))
 		return count;
 
-	/*
-	 * Write data to chip, protecting against concurrent updates
-	 * from this host, but not from other I2C masters.
-	 */
-	mutex_lock(&at24->lock);
-
 	while (count) {
 		ssize_t	status;
 
@@ -401,8 +385,6 @@ static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
 		retval += status;
 	}
 
-	mutex_unlock(&at24->lock);
-
 	return retval;
 }
 
@@ -566,7 +548,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (!at24)
 		return -ENOMEM;
 
-	mutex_init(&at24->lock);
+	mutex_init(&at24->wrbuf_lock);
 	at24->use_smbus = use_smbus;
 	at24->use_smbus_write = use_smbus_write;
 	at24->chip = chip;
-- 
2.7.4

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

* [PATCH 05/13] eeprom: at24: replace msleep() with usleep_range()
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2016-03-24 14:45 ` [PATCH 04/13] eeprom: at24: make locking more fine-grained Bartosz Golaszewski
@ 2016-03-24 14:45 ` Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 06/13] eeprom: at24: add serial number flag Bartosz Golaszewski
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:45 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

We cannot expect msleep(1) to actually sleep for a period shorter than
20 ms. Replace all calls to msleep() with usleep_range().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 9e01428..bc5be1e 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -240,8 +240,7 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
 		if (status == count)
 			return count;
 
-		/* REVISIT: at HZ=100, this is sloooow */
-		msleep(1);
+		usleep_range(1000, 1500);
 	} while (time_before(read_time, timeout));
 
 	return -ETIMEDOUT;
@@ -355,8 +354,7 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
 		if (status == count)
 			return count;
 
-		/* REVISIT: at HZ=100, this is sloooow */
-		msleep(1);
+		usleep_range(1000, 1500);
 	} while (time_before(write_time, timeout));
 
 	return -ETIMEDOUT;
-- 
2.7.4

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

* [PATCH 06/13] eeprom: at24: add serial number flag
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2016-03-24 14:45 ` [PATCH 05/13] eeprom: at24: replace msleep() with usleep_range() Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 07/13] eeprom: at24: support reading of the serial number Bartosz Golaszewski
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

In preparation for supporting the at24cs EEPROM series add a new flag
to platform data. When set, it should tell the driver that the chip
has an additional read-only memory area that holds a factory
pre-programmed serial number.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 include/linux/platform_data/at24.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h
index a543b93..5bc02fe 100644
--- a/include/linux/platform_data/at24.h
+++ b/include/linux/platform_data/at24.h
@@ -47,6 +47,7 @@ struct at24_platform_data {
 #define AT24_FLAG_READONLY	BIT(6)	/* sysfs-entry will be read-only */
 #define AT24_FLAG_IRUGO		BIT(5)	/* sysfs-entry will be world-readable */
 #define AT24_FLAG_TAKE8ADDR	BIT(4)	/* take always 8 addresses (24c00) */
+#define AT24_FLAG_SERIAL	BIT(3)	/* factory-programmed serial number */
 
 	void		(*setup)(struct nvmem_device *nvmem, void *context);
 	void		*context;
-- 
2.7.4

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

* [PATCH 07/13] eeprom: at24: support reading of the serial number
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2016-03-24 14:46 ` [PATCH 06/13] eeprom: at24: add serial number flag Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 08/13] eeprom: at24: call read and write routines via function pointers Bartosz Golaszewski
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

The at24cs series EEPROM chips have an additional read-only memory area
containing a factory pre-programmed serial number. In order to access
it, one has to perform a dummy write before reading the serial number
bytes.

Add a function that allows to access the serial number.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index bc5be1e..a7d6c15 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -159,6 +159,65 @@ static struct i2c_client *at24_translate_offset(struct at24_data *at24,
 	return at24->client[i];
 }
 
+static int __attribute__((unused))
+at24cs_serial_read(struct at24_data *at24,
+		   char *buf, loff_t off, size_t count)
+{
+	unsigned long timeout, read_time;
+	struct i2c_client *client;
+	unsigned int offset = off;
+	struct i2c_msg msg[2];
+	u8 addrbuf[2];
+	int status;
+
+	client = at24_translate_offset(at24, &offset);
+
+	memset(msg, 0, sizeof(msg));
+	msg[0].addr = client->addr;
+	msg[0].buf = addrbuf;
+
+	/*
+	 * The address pointer of the device is shared between the regular
+	 * EEPROM array and the serial number block. The dummy write (part of
+	 * the sequential read protocol) ensures the address pointer is reset
+	 * to the desired position.
+	 */
+	if (at24->chip.flags & AT24_FLAG_ADDR16) {
+		/*
+		 * For 16 bit address pointers, the word address must contain
+		 * a '10' sequence in bits 11 and 10 regardless of the
+		 * intended position of the address pointer.
+		 */
+		addrbuf[0] = 0x08;
+		addrbuf[1] = offset;
+		msg[0].len = 2;
+	} else {
+		/*
+		 * Otherwise the word address must begin with a '10' sequence,
+		 * regardless of the intended address.
+		 */
+		addrbuf[0] = 0x80 + offset;
+		msg[0].len = 1;
+	}
+
+	msg[1].addr = client->addr;
+	msg[1].flags = I2C_M_RD;
+	msg[1].buf = buf;
+	msg[1].len = count;
+
+	timeout = jiffies + msecs_to_jiffies(write_timeout);
+	do {
+		read_time = jiffies;
+		status = i2c_transfer(client->adapter, msg, 2);
+		if (status == 2)
+			return count;
+
+		usleep_range(1000, 1500);
+	} while (time_before(read_time, timeout));
+
+	return -ETIMEDOUT;
+}
+
 static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
 		unsigned offset, size_t count)
 {
-- 
2.7.4

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

* [PATCH 08/13] eeprom: at24: call read and write routines via function pointers
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2016-03-24 14:46 ` [PATCH 07/13] eeprom: at24: support reading of the serial number Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  2016-03-24 15:12     ` kbuild test robot
  2016-03-24 15:13     ` kbuild test robot
  2016-03-24 14:46 ` [PATCH 09/13] eeprom: at24: use at24cs_serial_read() Bartosz Golaszewski
                   ` (4 subsequent siblings)
  12 siblings, 2 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

In order to support non-standard read/write functions (as part of the
at24cs series support) introduce two function pointers in struct
at24_data to which different implementations can be assigned.

For now we continue to use the regular read/write routines by default.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index a7d6c15..5b484bc 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -59,6 +59,9 @@ struct at24_data {
 	int use_smbus;
 	int use_smbus_write;
 
+	int (*read_func)(struct at24_data *, char *, loff_t, size_t);
+	int (*write_func)(struct at24_data *, const char *, loff_t, size_t);
+
 	u8 *writebuf;
 	struct mutex wrbuf_lock;
 	unsigned write_max;
@@ -458,7 +461,7 @@ static int at24_regmap_read(void *context, const void *reg, size_t reg_size,
 	off_t offset = *(u32 *)reg;
 	int err;
 
-	err = at24_read(at24, val, offset, val_size);
+	err = at24->read_func(at24, val, offset, val_size);
 	if (err)
 		return err;
 	return 0;
@@ -476,7 +479,7 @@ static int at24_regmap_write(void *context, const void *data, size_t count)
 	buf = (const char *)data + sizeof(offset);
 	len = count - sizeof(offset);
 
-	err = at24_write(at24, buf, offset, len);
+	err = at24->write_func(at24, buf, offset, len);
 	if (err)
 		return err;
 	return 0;
@@ -611,6 +614,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	at24->chip = chip;
 	at24->num_addresses = num_addresses;
 
+	at24->read_func = at24_read;
+	at24->write_func = at24_write;
+
 	writable = !(chip.flags & AT24_FLAG_READONLY);
 	if (writable) {
 		if (!use_smbus || use_smbus_write) {
-- 
2.7.4

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

* [PATCH 09/13] eeprom: at24: use at24cs_serial_read()
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (7 preceding siblings ...)
  2016-03-24 14:46 ` [PATCH 08/13] eeprom: at24: call read and write routines via function pointers Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 10/13] eeprom: at24: add the at24cs series to the list of supported devices Bartosz Golaszewski
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

Assign at24cs_serial_read() to at24->read_func if the chip allows serial
number read operation.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 5b484bc..9515001 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -162,9 +162,8 @@ static struct i2c_client *at24_translate_offset(struct at24_data *at24,
 	return at24->client[i];
 }
 
-static int __attribute__((unused))
-at24cs_serial_read(struct at24_data *at24,
-		   char *buf, loff_t off, size_t count)
+static int at24cs_serial_read(struct at24_data *at24,
+			      char *buf, loff_t off, size_t count)
 {
 	unsigned long timeout, read_time;
 	struct i2c_client *client;
@@ -614,8 +613,12 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	at24->chip = chip;
 	at24->num_addresses = num_addresses;
 
-	at24->read_func = at24_read;
-	at24->write_func = at24_write;
+	if (chip.flags & AT24_FLAG_SERIAL) {
+		at24->read_func = at24cs_serial_read;
+	} else {
+		at24->read_func = at24_read;
+		at24->write_func = at24_write;
+	}
 
 	writable = !(chip.flags & AT24_FLAG_READONLY);
 	if (writable) {
-- 
2.7.4

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

* [PATCH 10/13] eeprom: at24: add the at24cs series to the list of supported devices
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (8 preceding siblings ...)
  2016-03-24 14:46 ` [PATCH 09/13] eeprom: at24: use at24cs_serial_read() Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 11/13] eeprom: at24: add at24mac series flag Bartosz Golaszewski
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

The infrastructure for reading of the factory-programmed serial number
for at24cs EEPROM series is now in place. Add the chips that are actually
equipped with the serial number memory area to the list of supported
devices.

The chips from the at24cs family have two memory areas - a regular
read-write block and a read-only area containing the serial number.

The latter is visible on a different slave address (the address of the
wr memory block + 0x08). In order to access both blocks the user needs
to instantiate a regular at24c device for the wr block address and a
corresponding at24cs device on the serial number block address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 9515001..a95a301 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -114,16 +114,34 @@ static const struct i2c_device_id at24_ids[] = {
 	{ "24c00",	AT24_DEVICE_MAGIC(128 / 8,	AT24_FLAG_TAKE8ADDR) },
 	/* old variants can't be handled with this generic entry! */
 	{ "24c01",	AT24_DEVICE_MAGIC(1024 / 8,	0) },
+	{ "24cs01",	AT24_DEVICE_MAGIC(128 / 8,
+				AT24_FLAG_SERIAL | AT24_FLAG_READONLY) },
 	{ "24c02",	AT24_DEVICE_MAGIC(2048 / 8,	0) },
+	{ "24cs02",	AT24_DEVICE_MAGIC(128 / 8,
+				AT24_FLAG_SERIAL | AT24_FLAG_READONLY) },
 	/* spd is a 24c02 in memory DIMMs */
 	{ "spd",	AT24_DEVICE_MAGIC(2048 / 8,
 				AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
 	{ "24c04",	AT24_DEVICE_MAGIC(4096 / 8,	0) },
+	{ "24cs04",	AT24_DEVICE_MAGIC(128 / 8,
+				AT24_FLAG_SERIAL | AT24_FLAG_READONLY) },
 	/* 24rf08 quirk is handled at i2c-core */
 	{ "24c08",	AT24_DEVICE_MAGIC(8192 / 8,	0) },
+	{ "24cs08",	AT24_DEVICE_MAGIC(128 / 8,
+				AT24_FLAG_SERIAL | AT24_FLAG_READONLY) },
 	{ "24c16",	AT24_DEVICE_MAGIC(16384 / 8,	0) },
+	{ "24cs16",	AT24_DEVICE_MAGIC(128 / 8,
+				AT24_FLAG_SERIAL | AT24_FLAG_READONLY) },
 	{ "24c32",	AT24_DEVICE_MAGIC(32768 / 8,	AT24_FLAG_ADDR16) },
+	{ "24cs32",	AT24_DEVICE_MAGIC(128 / 8,
+				AT24_FLAG_ADDR16 |
+				AT24_FLAG_SERIAL |
+				AT24_FLAG_READONLY) },
 	{ "24c64",	AT24_DEVICE_MAGIC(65536 / 8,	AT24_FLAG_ADDR16) },
+	{ "24cs64",	AT24_DEVICE_MAGIC(128 / 8,
+				AT24_FLAG_ADDR16 |
+				AT24_FLAG_SERIAL |
+				AT24_FLAG_READONLY) },
 	{ "24c128",	AT24_DEVICE_MAGIC(131072 / 8,	AT24_FLAG_ADDR16) },
 	{ "24c256",	AT24_DEVICE_MAGIC(262144 / 8,	AT24_FLAG_ADDR16) },
 	{ "24c512",	AT24_DEVICE_MAGIC(524288 / 8,	AT24_FLAG_ADDR16) },
-- 
2.7.4

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

* [PATCH 11/13] eeprom: at24: add at24mac series flag
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (9 preceding siblings ...)
  2016-03-24 14:46 ` [PATCH 10/13] eeprom: at24: add the at24cs series to the list of supported devices Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 12/13] eeprom: at24: add support for at24mac series Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 13/13] eeprom: at24: add at24mac chips to the list of supported devices Bartosz Golaszewski
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

As part of supporting the at24mac series add a new flag to the at24
platform data. When set, it indicates that this chip exposes the
factory-programmed EUI-48 or EUI-64 address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 include/linux/platform_data/at24.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h
index 5bc02fe..fa89605 100644
--- a/include/linux/platform_data/at24.h
+++ b/include/linux/platform_data/at24.h
@@ -48,6 +48,7 @@ struct at24_platform_data {
 #define AT24_FLAG_IRUGO		BIT(5)	/* sysfs-entry will be world-readable */
 #define AT24_FLAG_TAKE8ADDR	BIT(4)	/* take always 8 addresses (24c00) */
 #define AT24_FLAG_SERIAL	BIT(3)	/* factory-programmed serial number */
+#define AT24_FLAG_MAC		BIT(2)	/* factory-programmed mac address */
 
 	void		(*setup)(struct nvmem_device *nvmem, void *context);
 	void		*context;
-- 
2.7.4

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

* [PATCH 12/13] eeprom: at24: add support for at24mac series
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (10 preceding siblings ...)
  2016-03-24 14:46 ` [PATCH 11/13] eeprom: at24: add at24mac series flag Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  2016-03-24 14:46 ` [PATCH 13/13] eeprom: at24: add at24mac chips to the list of supported devices Bartosz Golaszewski
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

Add a new read function to the at24 driver allowing to retrieve the
factory-programmed mac address embedded in chips from the at24mac
family.

These chips can be instantiated similarily to the at24cs family,
except that there's no way of having access to both the serial number
and the mac address at the same time - the user must instantiate
either an at24cs or at24mac device as both special memory areas are
accessible on the same slave address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index a95a301..26c28c2 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -238,6 +238,41 @@ static int at24cs_serial_read(struct at24_data *at24,
 	return -ETIMEDOUT;
 }
 
+static int at24mac_mac_read(struct at24_data *at24,
+			   char *buf, loff_t off, size_t count)
+{
+	unsigned long timeout, read_time;
+	struct i2c_client *client;
+	unsigned int offset = off;
+	struct i2c_msg msg[2];
+	u8 addrbuf[2];
+	int status;
+
+	client = at24_translate_offset(at24, &offset);
+
+	memset(msg, 0, sizeof(msg));
+	msg[0].addr = client->addr;
+	msg[0].buf = addrbuf;
+	addrbuf[0] = 0x90 + offset;
+	msg[0].len = 1;
+	msg[1].addr = client->addr;
+	msg[1].flags = I2C_M_RD;
+	msg[1].buf = buf;
+	msg[1].len = count;
+
+	timeout = jiffies + msecs_to_jiffies(write_timeout);
+	do {
+		read_time = jiffies;
+		status = i2c_transfer(client->adapter, msg, 2);
+		if (status == 2)
+			return count;
+
+		usleep_range(1000, 1500);
+	} while (time_before(read_time, timeout));
+
+	return -ETIMEDOUT;
+}
+
 static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
 		unsigned offset, size_t count)
 {
@@ -631,8 +666,16 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	at24->chip = chip;
 	at24->num_addresses = num_addresses;
 
+	if ((chip.flags & AT24_FLAG_SERIAL) && (chip.flags & AT24_FLAG_MAC)) {
+		dev_err(&client->dev,
+			"invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
+		return -EINVAL;
+	}
+
 	if (chip.flags & AT24_FLAG_SERIAL) {
 		at24->read_func = at24cs_serial_read;
+	} else if (chip.flags & AT24_FLAG_MAC) {
+		at24->read_func = at24mac_mac_read;
 	} else {
 		at24->read_func = at24_read;
 		at24->write_func = at24_write;
-- 
2.7.4

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

* [PATCH 13/13] eeprom: at24: add at24mac chips to the list of supported devices
  2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
                   ` (11 preceding siblings ...)
  2016-03-24 14:46 ` [PATCH 12/13] eeprom: at24: add support for at24mac series Bartosz Golaszewski
@ 2016-03-24 14:46 ` Bartosz Golaszewski
  12 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2016-03-24 14:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c, LKML; +Cc: Andrew Lunn, Bartosz Golaszewski

Now with the infrastructue for reading the factory-programmed mac
address in place, add the two available chips from the at24mac
family: at24mac402 and at24mac602 to the device ID list.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/misc/eeprom/at24.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 26c28c2..f620d33 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -119,6 +119,10 @@ static const struct i2c_device_id at24_ids[] = {
 	{ "24c02",	AT24_DEVICE_MAGIC(2048 / 8,	0) },
 	{ "24cs02",	AT24_DEVICE_MAGIC(128 / 8,
 				AT24_FLAG_SERIAL | AT24_FLAG_READONLY) },
+	{ "24mac402",	AT24_DEVICE_MAGIC(48 / 8,
+				AT24_FLAG_MAC | AT24_FLAG_READONLY) },
+	{ "24mac602",	AT24_DEVICE_MAGIC(64 / 8,
+				AT24_FLAG_MAC | AT24_FLAG_READONLY) },
 	/* spd is a 24c02 in memory DIMMs */
 	{ "spd",	AT24_DEVICE_MAGIC(2048 / 8,
 				AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
-- 
2.7.4

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

* Re: [PATCH 08/13] eeprom: at24: call read and write routines via function pointers
  2016-03-24 14:46 ` [PATCH 08/13] eeprom: at24: call read and write routines via function pointers Bartosz Golaszewski
@ 2016-03-24 15:12     ` kbuild test robot
  2016-03-24 15:13     ` kbuild test robot
  1 sibling, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-03-24 15:12 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: kbuild-all, Wolfram Sang, linux-i2c, LKML, Andrew Lunn,
	Bartosz Golaszewski

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

Hi Bartosz,

[auto build test ERROR on next-20160324]
[cannot apply to v4.5-rc7 v4.5-rc6 v4.5-rc5 v4.5]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/eeprom-support-for-at24cs-and-at24mac/20160324-230008
config: x86_64-randconfig-x012-201612 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/misc/eeprom/at24.c: In function 'at24_probe':
>> drivers/misc/eeprom/at24.c:617:18: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     at24->read_func = at24_read;
                     ^
   drivers/misc/eeprom/at24.c:618:19: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     at24->write_func = at24_write;
                      ^
   cc1: some warnings being treated as errors

vim +617 drivers/misc/eeprom/at24.c

   611		mutex_init(&at24->wrbuf_lock);
   612		at24->use_smbus = use_smbus;
   613		at24->use_smbus_write = use_smbus_write;
   614		at24->chip = chip;
   615		at24->num_addresses = num_addresses;
   616	
 > 617		at24->read_func = at24_read;
   618		at24->write_func = at24_write;
   619	
   620		writable = !(chip.flags & AT24_FLAG_READONLY);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 20892 bytes --]

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

* Re: [PATCH 08/13] eeprom: at24: call read and write routines via function pointers
@ 2016-03-24 15:12     ` kbuild test robot
  0 siblings, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-03-24 15:12 UTC (permalink / raw)
  Cc: kbuild-all, Wolfram Sang, linux-i2c, LKML, Andrew Lunn,
	Bartosz Golaszewski

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

Hi Bartosz,

[auto build test ERROR on next-20160324]
[cannot apply to v4.5-rc7 v4.5-rc6 v4.5-rc5 v4.5]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/eeprom-support-for-at24cs-and-at24mac/20160324-230008
config: x86_64-randconfig-x012-201612 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/misc/eeprom/at24.c: In function 'at24_probe':
>> drivers/misc/eeprom/at24.c:617:18: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     at24->read_func = at24_read;
                     ^
   drivers/misc/eeprom/at24.c:618:19: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     at24->write_func = at24_write;
                      ^
   cc1: some warnings being treated as errors

vim +617 drivers/misc/eeprom/at24.c

   611		mutex_init(&at24->wrbuf_lock);
   612		at24->use_smbus = use_smbus;
   613		at24->use_smbus_write = use_smbus_write;
   614		at24->chip = chip;
   615		at24->num_addresses = num_addresses;
   616	
 > 617		at24->read_func = at24_read;
   618		at24->write_func = at24_write;
   619	
   620		writable = !(chip.flags & AT24_FLAG_READONLY);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 20892 bytes --]

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

* Re: [PATCH 08/13] eeprom: at24: call read and write routines via function pointers
  2016-03-24 14:46 ` [PATCH 08/13] eeprom: at24: call read and write routines via function pointers Bartosz Golaszewski
@ 2016-03-24 15:13     ` kbuild test robot
  2016-03-24 15:13     ` kbuild test robot
  1 sibling, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-03-24 15:13 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: kbuild-all, Wolfram Sang, linux-i2c, LKML, Andrew Lunn,
	Bartosz Golaszewski

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

Hi Bartosz,

[auto build test WARNING on next-20160324]
[cannot apply to v4.5-rc7 v4.5-rc6 v4.5-rc5 v4.5]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/eeprom-support-for-at24cs-and-at24mac/20160324-230008
config: sparc64-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All warnings (new ones prefixed by >>):

   drivers/misc/eeprom/at24.c: In function 'at24_probe':
>> drivers/misc/eeprom/at24.c:617:18: warning: assignment from incompatible pointer type
     at24->read_func = at24_read;
                     ^
   drivers/misc/eeprom/at24.c:618:19: warning: assignment from incompatible pointer type
     at24->write_func = at24_write;
                      ^

vim +617 drivers/misc/eeprom/at24.c

   601			num_addresses = 8;
   602		else
   603			num_addresses =	DIV_ROUND_UP(chip.byte_len,
   604				(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
   605	
   606		at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
   607			num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
   608		if (!at24)
   609			return -ENOMEM;
   610	
   611		mutex_init(&at24->wrbuf_lock);
   612		at24->use_smbus = use_smbus;
   613		at24->use_smbus_write = use_smbus_write;
   614		at24->chip = chip;
   615		at24->num_addresses = num_addresses;
   616	
 > 617		at24->read_func = at24_read;
   618		at24->write_func = at24_write;
   619	
   620		writable = !(chip.flags & AT24_FLAG_READONLY);
   621		if (writable) {
   622			if (!use_smbus || use_smbus_write) {
   623	
   624				unsigned write_max = chip.page_size;
   625	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 45943 bytes --]

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

* Re: [PATCH 08/13] eeprom: at24: call read and write routines via function pointers
@ 2016-03-24 15:13     ` kbuild test robot
  0 siblings, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-03-24 15:13 UTC (permalink / raw)
  Cc: kbuild-all, Wolfram Sang, linux-i2c, LKML, Andrew Lunn,
	Bartosz Golaszewski

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

Hi Bartosz,

[auto build test WARNING on next-20160324]
[cannot apply to v4.5-rc7 v4.5-rc6 v4.5-rc5 v4.5]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/eeprom-support-for-at24cs-and-at24mac/20160324-230008
config: sparc64-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All warnings (new ones prefixed by >>):

   drivers/misc/eeprom/at24.c: In function 'at24_probe':
>> drivers/misc/eeprom/at24.c:617:18: warning: assignment from incompatible pointer type
     at24->read_func = at24_read;
                     ^
   drivers/misc/eeprom/at24.c:618:19: warning: assignment from incompatible pointer type
     at24->write_func = at24_write;
                      ^

vim +617 drivers/misc/eeprom/at24.c

   601			num_addresses = 8;
   602		else
   603			num_addresses =	DIV_ROUND_UP(chip.byte_len,
   604				(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
   605	
   606		at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
   607			num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
   608		if (!at24)
   609			return -ENOMEM;
   610	
   611		mutex_init(&at24->wrbuf_lock);
   612		at24->use_smbus = use_smbus;
   613		at24->use_smbus_write = use_smbus_write;
   614		at24->chip = chip;
   615		at24->num_addresses = num_addresses;
   616	
 > 617		at24->read_func = at24_read;
   618		at24->write_func = at24_write;
   619	
   620		writable = !(chip.flags & AT24_FLAG_READONLY);
   621		if (writable) {
   622			if (!use_smbus || use_smbus_write) {
   623	
   624				unsigned write_max = chip.page_size;
   625	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 45943 bytes --]

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

end of thread, other threads:[~2016-03-24 15:17 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-24 14:45 [PATCH 00/13] eeprom: support for at24cs and at24mac Bartosz Golaszewski
2016-03-24 14:45 ` [PATCH 01/13] eeprom: at24: remove a reduntant if Bartosz Golaszewski
2016-03-24 14:45 ` [PATCH 02/13] eeprom: at24: improve the device_id table readability Bartosz Golaszewski
2016-03-24 14:45 ` [PATCH 03/13] eeprom: at24: platform_data: use BIT() macro Bartosz Golaszewski
2016-03-24 14:45 ` [PATCH 04/13] eeprom: at24: make locking more fine-grained Bartosz Golaszewski
2016-03-24 14:45 ` [PATCH 05/13] eeprom: at24: replace msleep() with usleep_range() Bartosz Golaszewski
2016-03-24 14:46 ` [PATCH 06/13] eeprom: at24: add serial number flag Bartosz Golaszewski
2016-03-24 14:46 ` [PATCH 07/13] eeprom: at24: support reading of the serial number Bartosz Golaszewski
2016-03-24 14:46 ` [PATCH 08/13] eeprom: at24: call read and write routines via function pointers Bartosz Golaszewski
2016-03-24 15:12   ` kbuild test robot
2016-03-24 15:12     ` kbuild test robot
2016-03-24 15:13   ` kbuild test robot
2016-03-24 15:13     ` kbuild test robot
2016-03-24 14:46 ` [PATCH 09/13] eeprom: at24: use at24cs_serial_read() Bartosz Golaszewski
2016-03-24 14:46 ` [PATCH 10/13] eeprom: at24: add the at24cs series to the list of supported devices Bartosz Golaszewski
2016-03-24 14:46 ` [PATCH 11/13] eeprom: at24: add at24mac series flag Bartosz Golaszewski
2016-03-24 14:46 ` [PATCH 12/13] eeprom: at24: add support for at24mac series Bartosz Golaszewski
2016-03-24 14:46 ` [PATCH 13/13] eeprom: at24: add at24mac chips to the list of supported devices Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.