Skip to content

Commit 8511de3

Browse files
committed
fix driver optoe twoaddr a2h read write bug
1 parent 694b338 commit 8511de3

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
From 3e289806e5d3c45c6afc2a6caeb935828a5032eb Mon Sep 17 00:00:00 2001
2+
From: "Song,Qinghua" <[email protected]>
3+
Date: Fri, 20 Sep 2024 19:32:52 +0800
4+
Subject: [PATCH] fix driver optoe twoaddr a2h read/write bug
5+
6+
Signed-off-by: Qinghua Song <[email protected]>
7+
---
8+
drivers/misc/eeprom/optoe.c | 26 ++++++++++++++++++++++++--
9+
1 file changed, 24 insertions(+), 2 deletions(-)
10+
11+
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c
12+
index 16287fdc5..a277cc28c 100644
13+
--- a/drivers/misc/eeprom/optoe.c
14+
+++ b/drivers/misc/eeprom/optoe.c
15+
@@ -284,7 +284,6 @@ static uint8_t optoe_translate_offset(struct optoe_data *optoe,
16+
if (optoe->dev_class == TWO_ADDR) {
17+
if (*offset > 255) {
18+
/* like QSFP, but shifted to client[1] */
19+
- *client = optoe->client[1];
20+
*offset -= 256;
21+
}
22+
}
23+
@@ -304,6 +303,26 @@ static uint8_t optoe_translate_offset(struct optoe_data *optoe,
24+
25+
return page; /* note also returning client and offset */
26+
}
27+
+static void optoe_update_client(struct optoe_data *optoe, 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, loff_t *offset, struct i2c_client **client)
41+
+{
42+
+ *client = optoe->client[0];
43+
+
44+
+ return;
45+
+}
46+
+
47+
48+
static ssize_t optoe_eeprom_read(struct optoe_data *optoe,
49+
struct i2c_client *client,
50+
@@ -529,6 +548,8 @@ static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe,
51+
return ret;
52+
}
53+
}
54+
+
55+
+ optoe_update_client(optoe, &off, &client);
56+
57+
while (count) {
58+
ssize_t status;
59+
@@ -551,7 +572,8 @@ static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe,
60+
retval += status;
61+
}
62+
63+
-
64+
+ optoe_reset_client(optoe, &off, &client);
65+
+
66+
if (page > 0) {
67+
/* return the page register to page 0 (why?) */
68+
page = 0;
69+
--
70+
2.25.1
71+

patch/series

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ cisco-npu-disable-other-bars.patch
107107
#
108108
# Marvell platform patches for 4.19
109109
armhf_secondary_boot_online.patch
110+
111+
# optoe patches
112+
0001-fix-driver-optoe-twoaddr-a2h-read-write-bug.patch
110113
############################################################
111114
#
112115
# Internal patches will be added below (placeholder)

0 commit comments

Comments
 (0)