[PATCH 2/2] drm: omapdrm: Perform initialization/cleanup at probe/remove time

Daniel Vetter daniel at ffwll.ch
Tue Dec 13 21:48:50 UTC 2016


On Tue, Dec 13, 2016 at 11:41:09PM +0200, Laurent Pinchart wrote:
> On Tuesday 13 Dec 2016 22:21:10 Daniel Vetter wrote:
> > On Tue, Dec 13, 2016 at 05:21:43PM +0200, Laurent Pinchart wrote:
> > > +
> > > +	/* Allocate and initialize the DRM device. */
> > > +	ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev);
> > 
> > Since this is a driver you work on, embedding is recommended, see
> > drm_dev_init(). Looks soo much better.
> 
> How does that work with drm_dev_unref() then ? When the last reference goes 
> away drm_dev_release() will kfree() the drm_device instance, which is only 
> valid if I allocate it dynamically.

This is drm, we only solve shit half-assed until we realize how silly
we've been. Meanwhile just place the drm_device as the first thing in your
driver struct. The kerneldoc for drm_dev_init even bothers to explain this
all!
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list