Skip to content
/ linux Public

Commit ff1b8bc

Browse files
m42ukoSasha Levin
authored andcommitted
misc: eeprom: Fix EWEN/EWDS/ERAL commands for 93xx56 and 93xx66
[ Upstream commit b54c82d ] commit 14374fb ("misc: eeprom_93xx46: Add new 93c56 and 93c66 compatible strings") added support for 93xx56 and 93xx66 eeproms, but didn't take into account that the write enable/disable + erase all commands are hardcoded for the 6-bit address of the 93xx46. This commit fixes the command word generation by increasing the number of shifts as the address field grows, keeping the command intact. Also, the check for 8-bit or 16-bit mode is no longer required as this is already taken into account in the edev->addrlen field. Signed-off-by: Markus Perkins <markus@notsyncing.net> Link: https://patch.msgid.link/20251202104823.429869-3-markus@notsyncing.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 741c5a3 commit ff1b8bc

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/misc/eeprom/eeprom_93xx46.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define OP_START 0x4
2424
#define OP_WRITE (OP_START | 0x1)
2525
#define OP_READ (OP_START | 0x2)
26+
/* The following addresses are offset for the 1K EEPROM variant in 16-bit mode */
2627
#define ADDR_EWDS 0x00
2728
#define ADDR_ERAL 0x20
2829
#define ADDR_EWEN 0x30
@@ -173,10 +174,7 @@ static int eeprom_93xx46_ew(struct eeprom_93xx46_dev *edev, int is_on)
173174
bits = edev->addrlen + 3;
174175

175176
cmd_addr = OP_START << edev->addrlen;
176-
if (edev->pdata->flags & EE_ADDR8)
177-
cmd_addr |= (is_on ? ADDR_EWEN : ADDR_EWDS) << 1;
178-
else
179-
cmd_addr |= (is_on ? ADDR_EWEN : ADDR_EWDS);
177+
cmd_addr |= (is_on ? ADDR_EWEN : ADDR_EWDS) << (edev->addrlen - 6);
180178

181179
if (has_quirk_instruction_length(edev)) {
182180
cmd_addr <<= 2;
@@ -320,10 +318,7 @@ static int eeprom_93xx46_eral(struct eeprom_93xx46_dev *edev)
320318
bits = edev->addrlen + 3;
321319

322320
cmd_addr = OP_START << edev->addrlen;
323-
if (edev->pdata->flags & EE_ADDR8)
324-
cmd_addr |= ADDR_ERAL << 1;
325-
else
326-
cmd_addr |= ADDR_ERAL;
321+
cmd_addr |= ADDR_ERAL << (edev->addrlen - 6);
327322

328323
if (has_quirk_instruction_length(edev)) {
329324
cmd_addr <<= 2;

0 commit comments

Comments
 (0)