[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140917100126.GF31703@phenom.ffwll.local>
Date: Wed, 17 Sep 2014 12:01:26 +0200
From: Daniel Vetter <daniel@...ll.ch>
To: Fabian Frederick <fabf@...net.be>
Cc: One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
peter@...leysoftware.com
Subject: Re: [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where
possible
On Mon, Sep 15, 2014 at 08:15:54PM +0200, Fabian Frederick wrote:
>
>
> > On 15 September 2014 at 01:13 One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>
> > wrote:
> >
> >
> > On Sun, 14 Sep 2014 18:40:13 +0200
> > Fabian Frederick <fabf@...net.be> wrote:
> >
> > > Small patchset using container_of instead of casting on first structure
> > > member address.
> >
> > Why. Container_of is useful for random offsets but its just convoluting
> > and confusing code which is designed with the fields intentionally at the
> > start.
> >
> > Alan
>
> What if someone doesn't know about that intention one day and inserts
> some field in the structure at the "wrong place" ?
> This would need at least some comment in each declaration
> but once again it's hard to control.One other way is to
> commonly use container_of and get rid of every casting with
> some semantic script.
>
> Peter has been asking for container_of in the following:
>
> http://marc.info/?l=linux-arm-kernel&m=140838705729653&w=2
>
>
> struct uart_amba_port *uap = (struct uart_amba_port *)port
>
> (port/uart_port is the first field in uart_amba_port though)
fwiw I like this and I've picked it up into my topic/core-stuff branch. So
if driver writers don't outright nack this it'll all land in Dave's
drm-next (probably still for 3.18).
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists