Skip to content

Commit 6554e8b

Browse files
committed
fix driver optoe twoaddr a2h read write bug
1 parent 271f7ef commit 6554e8b

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
From d5ebdde3738ece56566469c1ddda07f2d6475000 Mon Sep 17 00:00:00 2001
2+
From: songqh <songqh@clounix.com>
3+
Date: Mon, 23 Sep 2024 10:47:17 +0800
4+
Subject: [PATCH] fix driver optoe twoaddr a2h read write bug
5+
6+
---
7+
drivers/misc/eeprom/optoe.c | 28 ++++++++++++++++++++++++++--
8+
1 file changed, 26 insertions(+), 2 deletions(-)
9+
10+
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c
11+
index f34bfe88b..c578a13b3 100644
12+
--- a/drivers/misc/eeprom/optoe.c
13+
+++ b/drivers/misc/eeprom/optoe.c
14+
@@ -282,7 +282,6 @@ static uint8_t optoe_translate_offset(struct optoe_data *optoe,
15+
if (optoe->dev_class == TWO_ADDR) {
16+
if (*offset > 255) {
17+
/* like QSFP, but shifted to client[1] */
18+
- *client = optoe->client[1];
19+
*offset -= 256;
20+
}
21+
}
22+
@@ -303,6 +302,28 @@ static uint8_t optoe_translate_offset(struct optoe_data *optoe,
23+
return page; /* note also returning client and offset */
24+
}
25+
26+
+static void optoe_update_client(struct optoe_data *optoe,
27+
+ loff_t *offset, struct i2c_client **client)
28+
+{
29+
+ /* if SFP style, offset > 255, shift to i2c addr 0x51 */
30+
+ if (optoe->dev_class == TWO_ADDR) {
31+
+ if (*offset > 255) {
32+
+ *client = optoe->client[1];
33+
+ } else {
34+
+ *client = optoe->client[0];
35+
+ }
36+
+ }
37+
+ return;
38+
+}
39+
+
40+
+static void optoe_reset_client(struct optoe_data *optoe,
41+
+ loff_t *offset, struct i2c_client **client)
42+
+{
43+
+ *client = optoe->client[0];
44+
+
45+
+ return;
46+
+}
47+
+
48+
static ssize_t optoe_eeprom_read(struct optoe_data *optoe,
49+
struct i2c_client *client,
50+
char *buf, unsigned int offset, size_t count)
51+
@@ -528,6 +549,8 @@ static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe,
52+
}
53+
}
54+
55+
+ optoe_update_client(optoe, &off, &client);
56+
+
57+
while (count) {
58+
ssize_t status;
59+
60+
@@ -548,7 +571,8 @@ static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe,
61+
count -= status;
62+
retval += status;
63+
}
64+
-
65+
+
66+
+ optoe_reset_client(optoe, &off, &client);
67+
68+
if (page > 0) {
69+
/* return the page register to page 0 (why?) */
70+
--
71+
2.17.1
72+

patch/series

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ armhf_secondary_boot_online.patch
218218
0019-dt-bindings-marvell-Add-ARMADA-7K-properties.patch
219219
0020-dts-marvell-Add-support-for-7020-comexpress.patch
220220

221-
#
221+
#optoe
222+
0001-fix-driver-optoe-twoaddr-a2h-read-write-bug.patch
222223
#
223224
############################################################
224225
#

0 commit comments

Comments
 (0)