Thread (59 messages) 59 messages, 6 authors, 2011-01-24
STALE5608d

[PATCH v4 05/10] net/fec: add dual fec support for mx28

From: Uwe Kleine-König <hidden>
Date: 2011-01-14 07:52:23
Also in: netdev

On Fri, Jan 14, 2011 at 01:48:40PM +0800, Shawn Guo wrote:
Hi Uwe,

On Thu, Jan 13, 2011 at 03:48:05PM +0100, Uwe Kleine-K?nig wrote:

[...]
quoted
quoted
+/* Controller is ENET-MAC */
+#define FEC_QUIRK_ENET_MAC           (1 << 0)
does this really qualify to be a quirk?
My understanding is that ENET-MAC is a type of "quirky" FEC
controller.
quoted
quoted
+/* Controller needs driver to swap frame */
+#define FEC_QUIRK_SWAP_FRAME         (1 << 1)
IMHO this is a bit misnamed.  FEC_QUIRK_NEEDS_BE_DATA or similar would
be more accurate.
When your make this change, you may want to pick a better name for
function swap_buffer too.

[...]
quoted
quoted
+static void *swap_buffer(void *bufaddr, int len)
+{
+     int i;
+     unsigned int *buf = bufaddr;
+
+     for (i = 0; i < (len + 3) / 4; i++, buf++)
+             *buf = cpu_to_be32(*buf);
if len isn't a multiple of 4 this accesses bytes behind len.  Is this
generally OK here?  (E.g. because skbs always have a length that is a
multiple of 4?)
The len may not be a multiple of 4.  But I believe bufaddr is always
a buffer allocated in a length that is a multiple of 4, and the 1~3
bytes exceeding the len very likely has no data that matters.  But
yes, it deserves a safer implementation.
Did you test what happens if bufaddr isn't aligned?  Does it work at all
then?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help