* [PATCH] i2c: slave-eeprom: add support for 24c512 EEPROMs
@ 2020-05-12 14:20 Wolfram Sang
2020-05-12 20:45 ` Patrick Williams
2020-05-15 10:00 ` Wolfram Sang
0 siblings, 2 replies; 3+ messages in thread
From: Wolfram Sang @ 2020-05-12 14:20 UTC (permalink / raw)
To: linux-i2c; +Cc: linux-renesas-soc, Wolfram Sang, Patrick Williams
I don't plan to support every EEPROM type, but the 24c512 ones need a
tiny code update, so let's have that upstream.
Reported-by: Patrick Williams <patrick@stwcx.xyz>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Tested on a Renesas Lager board (R-Car H2).
drivers/i2c/i2c-slave-eeprom.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c
index f868dfc362a6..787fdb7f332f 100644
--- a/drivers/i2c/i2c-slave-eeprom.c
+++ b/drivers/i2c/i2c-slave-eeprom.c
@@ -41,7 +41,7 @@ struct eeprom_data {
#define I2C_SLAVE_BYTELEN GENMASK(15, 0)
#define I2C_SLAVE_FLAG_ADDR16 BIT(16)
#define I2C_SLAVE_FLAG_RO BIT(17)
-#define I2C_SLAVE_DEVICE_MAGIC(_len, _flags) ((_flags) | (_len))
+#define I2C_SLAVE_DEVICE_MAGIC(_len, _flags) ((_flags) | ((_len) - 1))
static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
enum i2c_slave_event event, u8 *val)
@@ -145,7 +145,7 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_de
{
struct eeprom_data *eeprom;
int ret;
- unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, id->driver_data);
+ unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, id->driver_data) + 1;
unsigned int flag_addr16 = FIELD_GET(I2C_SLAVE_FLAG_ADDR16, id->driver_data);
eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL);
@@ -200,6 +200,8 @@ static const struct i2c_device_id i2c_slave_eeprom_id[] = {
{ "slave-24c32ro", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
{ "slave-24c64", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16) },
{ "slave-24c64ro", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
+ { "slave-24c512", I2C_SLAVE_DEVICE_MAGIC(524288 / 8, I2C_SLAVE_FLAG_ADDR16) },
+ { "slave-24c512ro", I2C_SLAVE_DEVICE_MAGIC(524288 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
{ }
};
MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id);
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: slave-eeprom: add support for 24c512 EEPROMs
2020-05-12 14:20 [PATCH] i2c: slave-eeprom: add support for 24c512 EEPROMs Wolfram Sang
@ 2020-05-12 20:45 ` Patrick Williams
2020-05-15 10:00 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Patrick Williams @ 2020-05-12 20:45 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c, linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
On Tue, May 12, 2020 at 04:20:46PM +0200, Wolfram Sang wrote:
> I don't plan to support every EEPROM type, but the 24c512 ones need a
> tiny code update, so let's have that upstream.
>
> Reported-by: Patrick Williams <patrick@stwcx.xyz>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>
> Tested on a Renesas Lager board (R-Car H2).
>
> drivers/i2c/i2c-slave-eeprom.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
Reviewed-by: Patrick Williams <patrick@stwcx.xyz>
--
Patrick Williams
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: slave-eeprom: add support for 24c512 EEPROMs
2020-05-12 14:20 [PATCH] i2c: slave-eeprom: add support for 24c512 EEPROMs Wolfram Sang
2020-05-12 20:45 ` Patrick Williams
@ 2020-05-15 10:00 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2020-05-15 10:00 UTC (permalink / raw)
To: linux-i2c; +Cc: linux-renesas-soc, Patrick Williams
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
On Tue, May 12, 2020 at 04:20:46PM +0200, Wolfram Sang wrote:
> I don't plan to support every EEPROM type, but the 24c512 ones need a
> tiny code update, so let's have that upstream.
>
> Reported-by: Patrick Williams <patrick@stwcx.xyz>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-15 10:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 14:20 [PATCH] i2c: slave-eeprom: add support for 24c512 EEPROMs Wolfram Sang
2020-05-12 20:45 ` Patrick Williams
2020-05-15 10:00 ` Wolfram Sang
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.