-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix driver optoe twoaddr a2h read write bug
- Loading branch information
1 parent
694b338
commit 21a6d4c
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
patch/0001-fix-driver-optoe-twoaddr-a2h-read-write-bug.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
From 4338f175d03e83b3dd187c4d2af193e9e6f86039 Mon Sep 17 00:00:00 2001 | ||
From: "Song,Qinghua" <[email protected]> | ||
Date: Fri, 20 Sep 2024 19:32:52 +0800 | ||
Subject: [PATCH] fix driver optoe twoaddr a2h read/write bug | ||
|
||
--- | ||
drivers/misc/eeprom/optoe.c | 29 ++++++++++++++++++++++++++--- | ||
1 file changed, 26 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c | ||
index 16287fdc5..c6fdce9c9 100644 | ||
--- a/drivers/misc/eeprom/optoe.c | ||
+++ b/drivers/misc/eeprom/optoe.c | ||
@@ -284,7 +284,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; | ||
} | ||
} | ||
@@ -304,6 +303,27 @@ 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, | ||
@@ -523,12 +543,14 @@ static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe, | ||
ret = optoe_eeprom_write(optoe, client, &page, | ||
OPTOE_PAGE_SELECT_REG, 1); | ||
if (ret < 0) { | ||
- dev_dbg(&client->dev, | ||
+ dev_err(&client->dev, | ||
"Write page register for page %d failed ret:%d!\n", | ||
page, ret); | ||
return ret; | ||
} | ||
} | ||
+ | ||
+ optoe_update_client(optoe, &off, &client); | ||
|
||
while (count) { | ||
ssize_t status; | ||
@@ -551,7 +573,8 @@ static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe, | ||
retval += status; | ||
} | ||
|
||
- | ||
+ optoe_reset_client(optoe, &off, &client); | ||
+ | ||
if (page > 0) { | ||
/* return the page register to page 0 (why?) */ | ||
page = 0; | ||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters