drm: manage drm_minor cleanup with drmm_
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 24 Mar 2020 20:39:36 +0000 (21:39 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 26 Mar 2020 14:37:31 +0000 (15:37 +0100)
commitf96306f9892b3a28ece4c65c4d1b95f631b3e63c
treee259f3640c1077d63664ea9e6906ee3ae983bf4e
parent2cbf7fc6718b9443ecd6261308c6348d8ffcccae
drm: manage drm_minor cleanup with drmm_

The cleanup here is somewhat tricky, since we can't tell apart the
allocated minor index from 0. So register a cleanup action first, and
if the index allocation fails, unregister that cleanup action again to
avoid bad mistakes.

The kdev for the minor already handles NULL, so no problem there.

Hence add drmm_remove_action() to the drm_managed library.

v2: Make pointer math around void ** consistent with what Laurent
suggested.

v3: Use drmm_add_action_or_reset and remove drmm_remove_action. Noticed
because of some questions from Thomas. This also means we need to move
the drmm_add_action_or_reset helper earlier in the series.

v4: Uh ... fix slightly embarrassing bug CI spotted.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200324203936.3330994-1-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_managed.c
include/drm/drm_managed.h