• Daniel Vetter's avatar
    drm/vgem: Use devm_drm_dev_alloc · bcc0ef7f
    Daniel Vetter authored
    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: default avatarMelissa Wen <melissa.srw@gmail.com>
    Signed-off-by: default avatarDaniel 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
    bcc0ef7f
vgem_drv.c 11.6 KB