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