-
Notifications
You must be signed in to change notification settings - Fork 193
fix driver optoe twoaddr a2h read write bug #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 202012
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
From 3e289806e5d3c45c6afc2a6caeb935828a5032eb 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 | ||
|
||
songqh2022 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Signed-off-by: Qinghua Song <[email protected]> | ||
--- | ||
drivers/misc/eeprom/optoe.c | 26 ++++++++++++++++++++++++-- | ||
1 file changed, 24 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c | ||
index 16287fdc5..a277cc28c 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,26 @@ 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the Linux kernel coding style. Mainly please use tabs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have used the Linux kernel coding style-use tabs,please help to check again,thank you! |
||
+{ | ||
+ /* 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, | ||
@@ -529,6 +548,8 @@ static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe, | ||
return ret; | ||
} | ||
} | ||
+ | ||
+ optoe_update_client(optoe, &off, &client); | ||
|
||
while (count) { | ||
ssize_t status; | ||
@@ -551,7 +572,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 | ||
|
Uh oh!
There was an error while loading. Please reload this page.