Michal Suchanek e37794
From 644a1f19c6c8393d0c4168a5adf79056da6822eb Mon Sep 17 00:00:00 2001
Michal Suchanek e37794
From: Heiner Kallweit <hkallweit1@gmail.com>
Michal Suchanek e37794
Date: Mon, 27 Nov 2017 20:46:22 +0100
Michal Suchanek e37794
Subject: [PATCH] eeprom: at24: fix reading from 24MAC402/24MAC602
Michal Suchanek e37794
Michal Suchanek e37794
References: bsc#1052766
Michal Suchanek e37794
Patch-mainline: v4.15-rc2
Michal Suchanek e37794
Git-commit: 644a1f19c6c8393d0c4168a5adf79056da6822eb
Michal Suchanek e37794
Michal Suchanek e37794
Chip datasheet mentions that word addresses other than the actual
Michal Suchanek e37794
start position of the MAC delivers undefined results. So fix this.
Michal Suchanek e37794
Current implementation doesn't work due to this wrong offset.
Michal Suchanek e37794
Michal Suchanek e37794
Cc: stable@vger.kernel.org
Michal Suchanek e37794
Fixes: 0b813658c115 ("eeprom: at24: add support for at24mac series")
Michal Suchanek e37794
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Michal Suchanek e37794
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Michal Suchanek e37794
Acked-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek e37794
---
Michal Suchanek e37794
 drivers/misc/eeprom/at24.c | 3 ++-
Michal Suchanek e37794
 1 file changed, 2 insertions(+), 1 deletion(-)
Michal Suchanek e37794
Michal Suchanek e37794
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
Michal Suchanek e37794
index 783244b485cc..8ca6772b3baf 100644
Michal Suchanek e37794
--- a/drivers/misc/eeprom/at24.c
Michal Suchanek e37794
+++ b/drivers/misc/eeprom/at24.c
Michal Suchanek e37794
@@ -425,7 +425,8 @@ static ssize_t at24_eeprom_read_mac(struct at24_data *at24, char *buf,
Michal Suchanek e37794
 	memset(msg, 0, sizeof(msg));
Michal Suchanek e37794
 	msg[0].addr = client->addr;
Michal Suchanek e37794
 	msg[0].buf = addrbuf;
Michal Suchanek e37794
-	addrbuf[0] = 0x90 + offset;
Michal Suchanek e37794
+	/* EUI-48 starts from 0x9a, EUI-64 from 0x98 */
Michal Suchanek e37794
+	addrbuf[0] = 0xa0 - at24->chip.byte_len + offset;
Michal Suchanek e37794
 	msg[0].len = 1;
Michal Suchanek e37794
 	msg[1].addr = client->addr;
Michal Suchanek e37794
 	msg[1].flags = I2C_M_RD;
Michal Suchanek e37794
-- 
Michal Suchanek e37794
2.13.6
Michal Suchanek e37794