Skip to content

Commit 57df0fb

Browse files
hayesorzkuba-moo
authored andcommitted
r8152: adjust generic_ocp_write function
Reduce the control transfer if all bytes of first or the last DWORD are written. The original method is to split the control transfer into three parts (the first DWORD, middle continuous data, and the last DWORD). However, they could be combined if whole bytes of the first DWORD or last DWORD are written. That is, the first DWORD or the last DWORD could be combined with the middle continuous data, if the byte_en is 0xff. Signed-off-by: Hayes Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3bdd85e commit 57df0fb

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

drivers/net/usb/r8152.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,16 +1314,24 @@ static int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen,
13141314
byteen_end = byteen & BYTE_EN_END_MASK;
13151315

13161316
byen = byteen_start | (byteen_start << 4);
1317-
ret = set_registers(tp, index, type | byen, 4, data);
1318-
if (ret < 0)
1319-
goto error1;
13201317

1321-
index += 4;
1322-
data += 4;
1323-
size -= 4;
1318+
/* Split the first DWORD if the byte_en is not 0xff */
1319+
if (byen != BYTE_EN_DWORD) {
1320+
ret = set_registers(tp, index, type | byen, 4, data);
1321+
if (ret < 0)
1322+
goto error1;
13241323

1325-
if (size) {
1324+
index += 4;
1325+
data += 4;
13261326
size -= 4;
1327+
}
1328+
1329+
if (size) {
1330+
byen = byteen_end | (byteen_end >> 4);
1331+
1332+
/* Split the last DWORD if the byte_en is not 0xff */
1333+
if (byen != BYTE_EN_DWORD)
1334+
size -= 4;
13271335

13281336
while (size) {
13291337
if (size > limit) {
@@ -1350,10 +1358,9 @@ static int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen,
13501358
}
13511359
}
13521360

1353-
byen = byteen_end | (byteen_end >> 4);
1354-
ret = set_registers(tp, index, type | byen, 4, data);
1355-
if (ret < 0)
1356-
goto error1;
1361+
/* Set the last DWORD */
1362+
if (byen != BYTE_EN_DWORD)
1363+
ret = set_registers(tp, index, type | byen, 4, data);
13571364
}
13581365

13591366
error1:

0 commit comments

Comments
 (0)