Skip to content

Commit 68cbdb1

Browse files
andy-shevPaolo Abeni
authored andcommitted
net: dl2k: Use proper conversion of dev_addr before IO to device
The driver is using iowriteXX()/ioreadXX() APIs which are LE IO accessors simplified as 1. Convert given value _from_ CPU _to_ LE 2. Write it to the device as is The dev_addr is a byte stream, but because the driver uses 16-bit IO accessors, it wants to perform double conversion on BE CPUs, but it took it wrong, as it effectivelly does two times _from_ CPU _to_ LE. What it has to do is to consider dev_addr as an array of LE16 and hence do _from_ LE _to_ CPU conversion, followed by implied _from_ CPU _to_ LE in the iowrite16(). To achieve that, use get_unaligned_le16(). This will make it correct and allows to avoid sparse warning as reported by LKP. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 68c8428 commit 68cbdb1

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/net/ethernet/dlink/dl2k.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,7 @@ static void rio_hw_init(struct net_device *dev)
565565
* too. However, it doesn't work on IP1000A so we use 16-bit access.
566566
*/
567567
for (i = 0; i < 3; i++)
568-
dw16(StationAddr0 + 2 * i,
569-
cpu_to_le16(((const u16 *)dev->dev_addr)[i]));
568+
dw16(StationAddr0 + 2 * i, get_unaligned_le16(&dev->dev_addr[2 * i]));
570569

571570
set_multicast (dev);
572571
if (np->coalesce) {

0 commit comments

Comments
 (0)