[lkml]   [2009]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v2 4/7] [PATCH 4/8] can: Driver for the SJA1000 CAN controller
On Thu, 14 May 2009 11:03:53 +0200
Wolfgang Grandegger <> wrote:

> > So you're still using the "put the higher-level structure at the top so we
> > can treat it like either kind of pointer" trick. I'd still recommend
> > against that. Far better to do something like:
> >
> > struct can_priv *canpriv = netdev_priv(dev);
> > struct sja_1000_priv *priv = container_of(canpriv, struct sja_1000_priv, can);
> >
> > Of course, you can put that dance into a helper function.
> There is no way to initialize the value returned by netdev_priv() as it
> does not point to a member of struct net_device. I already commented here:
> Have I missed something?

I'm confused. It points to the struct can_priv that you registered at
the beginning. Since that structure is contained within struct
sja1000_priv, you can use container_of(), as described above, to get

I would probably just write something like:

static inline struct sja1000_priv *to_sja1000_priv(struct net_device *dev)
return container_of(netdev_priv(dev), struct sja1000_priv, can);

So have *I* missed something?


 \ /
  Last update: 2009-05-15 22:43    [W:0.070 / U:12.692 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site