Re: [PATCH v2 4/7] [PATCH 4/8] can: Driver for the SJA1000 CAN controller

Jonathan Corbet
2009-05-20T21:32:19Z

On Sat, 16 May 2009 08:57:03 +0200
Wolfgang Grandegger <wg@grandegger.com> wrote:

> > But "struct net_device" does not have a "priv" member. netdev_priv(dev)
> > always points to the beginning of the private data area. See:
> >
> > http://lxr.linux.no/linux+v2.6.29/include/linux/netdevice.h#L953
>
> I could use container_of() as you suggested, of course, if the "struct
> can_priv" remains the first member of "struct sja1000_priv". Would that
> already be an improvement?

Ah, OK, I'm a little slow, sorry. I do get what the problem is here.

Using container_of() in that situation doesn't help a whole lot. The
point is to get away from this assumption that struct can_priv is the
first element of the structure.

Perhaps what you have is as good as it gets for now, but please add a
comment to the structure noting that struct can_priv has to come first
and why.

Thanks,

jon