[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B729E@saturn3.aculab.com>
Date: Fri, 21 Jun 2013 09:38:09 +0100
From: "David Laight" <David.Laight@...LAB.COM>
To: "Johannes Berg" <johannes@...solutions.net>,
<netdev@...r.kernel.org>
Cc: <ben@...adent.org.uk>
Subject: RE: [PATCH 5/6] alx: fix MAC address alignment problem
> In two places, parts of MAC addresses are used as u32/u16
> values. This can cause alignment problems, use put_unaligned
> and get_unaligned to fix this.
I suspect they are always 16bit aligned, so 16bit accesses
would be ok - rather than using byte accesses.
However I wouldn't know how to request this with the available
definitions....
David
...
> /* addr should be big-endian */
> - *(__be32 *)(addr + 2) = cpu_to_be32(mac0);
> - *(__be16 *)addr = cpu_to_be16(mac1);
> + put_unaligned(cpu_to_be32(mac0), (__be32 *)(addr + 2));
> + put_unaligned(cpu_to_be16(mac1), (__be16 *)addr);
...
> - val = be32_to_cpu(*(__be32 *)(addr + 2));
> + val = be32_to_cpu(get_unaligned((__be32 *)(addr + 2)));
> alx_write_mem32(hw, ALX_STAD0, val);
> - val = be16_to_cpu(*(__be16 *)addr);
> + val = be16_to_cpu(get_unaligned((__be16 *)addr));
> alx_write_mem32(hw, ALX_STAD1, val);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists