[PATCH V2 3/3] ethernet: Convert mac address uses of 6 to ETH_ALEN
Joe Perches
joe at perches.com
Thu Aug 1 17:04:47 EDT 2013
On Thu, 2013-08-01 at 21:58 +0100, Russell King - ARM Linux wrote:
> On Thu, Aug 01, 2013 at 01:55:28PM -0700, Joe Perches wrote:
> > On Thu, 2013-08-01 at 21:33 +0100, Russell King - ARM Linux wrote:
> > > On Thu, Aug 01, 2013 at 01:31:09PM -0700, Olof Johansson wrote:
> > > > On Thu, Aug 1, 2013 at 1:14 PM, Joe Perches <joe at perches.com> wrote:
> > > > > diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.h b/drivers/net/ethernet/pasemi/pasemi_mac.h
> > []
> > > > > @@ -79,11 +79,11 @@ struct pasemi_mac {
> > > > > int last_cs;
> > > > > int num_cs;
> > > > > u32 dma_if;
> > > > > - u8 type;
> > > > > #define MAC_TYPE_GMAC 1
> > > > > #define MAC_TYPE_XAUI 2
> > > > >
> > > > > - u8 mac_addr[6];
> > > > > + u8 mac_addr[ETH_ALEN];
> > > > > + u8 type;
> > > >
> > > > Just promote 'type' to u32 instead, saves you from moving the #defines
> > > > down, etc, etc.
> >
> > type is already u8, why change it?
> > That would also change struct size.
> >
> > > There's a more fundamental question which has to be asked: what is the
> > > point of moving that in the first place?
> >
> > Some is_<foo>_ether_addr tests assume __aligned(2)
> > by a casting char * to u16/be16 * and dereferencing.
> >
> > see patch 0/3 and include/linux/etherdevice.h
>
> This seems rather obscure - I mean, it's not obvious to driver authors
> that should be the case. Would it not be better to make this a little
> more obvious somehow? Maybe __aligned(2) against mac_addr? Or
> maybe have a debugging check for it?
That'd be for David Miller (cc'd).
I believe he's argued in the past that any alignment check
for mac addresses was unnecessary.
For all I know it really might not matter because pasemi
can successfully dereference a ushort against an odd char
pointer.
I just noticed it and thought it'd be better moved.
More information about the linux-arm-kernel
mailing list