OSDN Git Service

drm/vgem: Use devm_drm_dev_alloc
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 9 Sep 2020 12:07:45 +0000 (14:07 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 11 Sep 2020 08:47:19 +0000 (10:47 +0200)
commitbcc0ef7f57e51e5a5607eafb2a8ab63c6c1f21ff
tree0db03301419a3a87a55650bc6037c36ca3d79c69
parentc2c25c1cf96927a0b6ddb6aaa063f1fdcc90d749
drm/vgem: Use devm_drm_dev_alloc

This means we also need to slightly restructure the exit code, so that
final cleanup of the drm_device is triggered by unregistering the
platform device. Note that devres is both clean up when the driver is
unbound (not the case for vgem, we don't bind), and also when unregistering
the device (very much the case for vgem). Therefore we can rely on devres
even though vgem isn't a proper platform device driver.

This also somewhat untangles the load code, since the drm and platform device
setup are no longer interleaved, but two distinct steps.

v2: use devres_open/release_group so we can use devm without real
hacks in the driver core or having to create an entire fake bus for
testing drivers. Might want to extract this into helpers eventually,
maybe as a mock_drm_dev_alloc or test_drm_dev_alloc.

v3: Fix error code handling (Melissa)

Cc: Melissa Wen <melissa.srw@gmail.com>
Reviewed-by: Melissa Wen <melissa.srw@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Rob Clark <robdclark@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200909120745.716178-1-daniel.vetter@ffwll.ch
drivers/gpu/drm/vgem/vgem_drv.c