Skip to content

Commit 8487b4a

Browse files
hayesorzkuba-moo
authored andcommitted
r8152: fix the firmware doesn't work
generic_ocp_write() asks the parameter "size" must be 4 bytes align. Therefore, write the bp would fail, if the mac->bp_num is odd. Align the size to 4 for fixing it. The way may write an extra bp, but the rtl8152_is_fw_mac_ok() makes sure the value must be 0 for the bp whose index is more than mac->bp_num. That is, there is no influence for the firmware. Besides, I check the return value of generic_ocp_write() to make sure everything is correct. Fixes: e5c266a ("r8152: set bp in bulk") Signed-off-by: Hayes Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7e41969 commit 8487b4a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/net/usb/r8152.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5178,14 +5178,23 @@ static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
51785178
data = (u8 *)mac;
51795179
data += __le16_to_cpu(mac->fw_offset);
51805180

5181-
generic_ocp_write(tp, __le16_to_cpu(mac->fw_reg), 0xff, length, data,
5182-
type);
5181+
if (generic_ocp_write(tp, __le16_to_cpu(mac->fw_reg), 0xff, length,
5182+
data, type) < 0) {
5183+
dev_err(&tp->intf->dev, "Write %s fw fail\n",
5184+
type ? "PLA" : "USB");
5185+
return;
5186+
}
51835187

51845188
ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
51855189
__le16_to_cpu(mac->bp_ba_value));
51865190

5187-
generic_ocp_write(tp, __le16_to_cpu(mac->bp_start), BYTE_EN_DWORD,
5188-
__le16_to_cpu(mac->bp_num) << 1, mac->bp, type);
5191+
if (generic_ocp_write(tp, __le16_to_cpu(mac->bp_start), BYTE_EN_DWORD,
5192+
ALIGN(__le16_to_cpu(mac->bp_num) << 1, 4),
5193+
mac->bp, type) < 0) {
5194+
dev_err(&tp->intf->dev, "Write %s bp fail\n",
5195+
type ? "PLA" : "USB");
5196+
return;
5197+
}
51895198

51905199
bp_en_addr = __le16_to_cpu(mac->bp_en_addr);
51915200
if (bp_en_addr)

0 commit comments

Comments
 (0)