Skip to content

Commit

Permalink
fix driver optoe twoaddr a2h read write bug
Browse files Browse the repository at this point in the history
Signed-off-by: Qinghua Song <[email protected]>
  • Loading branch information
songqh2022 committed Oct 10, 2024
1 parent 271f7ef commit 4e287f3
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
72 changes: 72 additions & 0 deletions patch/0001-fix-driver-optoe-twoaddr-a2h-read-write-bug.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
From d5ebdde3738ece56566469c1ddda07f2d6475000 Mon Sep 17 00:00:00 2001
From: songqh <[email protected]>
Date: Mon, 23 Sep 2024 10:47:17 +0800
Subject: [PATCH] fix driver optoe twoaddr a2h read write bug
Signed-off-by: Qinghua song <[email protected]>
---
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

3 changes: 2 additions & 1 deletion patch/series
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ armhf_secondary_boot_online.patch
0019-dt-bindings-marvell-Add-ARMADA-7K-properties.patch
0020-dts-marvell-Add-support-for-7020-comexpress.patch

#
#optoe
0001-fix-driver-optoe-twoaddr-a2h-read-write-bug.patch
#
############################################################
#
Expand Down

0 comments on commit 4e287f3

Please sign in to comment.