drm/arm/hdlcd: plane: use drm managed resources
authorDanilo Krummrich <dakr@redhat.com>
Wed, 26 Oct 2022 15:34:30 +0000 (17:34 +0200)
committerLiviu Dudau <liviu.dudau@arm.com>
Mon, 7 Nov 2022 20:47:36 +0000 (20:47 +0000)
Use drm managed resource allocation (drmm_universal_plane_alloc()) in
order to get rid of the explicit destroy hook in struct drm_plane_funcs.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221026153431.72033-4-dakr@redhat.com
drivers/gpu/drm/arm/hdlcd_crtc.c

index 9662aeffb84490602fc574b604f3352ad6c61c5c..3cfefadc7c9d34b00ea15ef8eb28619ef2a265dd 100644 (file)
@@ -289,7 +289,6 @@ static const struct drm_plane_helper_funcs hdlcd_plane_helper_funcs = {
 static const struct drm_plane_funcs hdlcd_plane_funcs = {
        .update_plane           = drm_atomic_helper_update_plane,
        .disable_plane          = drm_atomic_helper_disable_plane,
-       .destroy                = drm_plane_cleanup,
        .reset                  = drm_atomic_helper_plane_reset,
        .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
        .atomic_destroy_state   = drm_atomic_helper_plane_destroy_state,
@@ -300,21 +299,16 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
        struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
        struct drm_plane *plane = NULL;
        u32 formats[ARRAY_SIZE(supported_formats)], i;
-       int ret;
-
-       plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
-       if (!plane)
-               return ERR_PTR(-ENOMEM);
 
        for (i = 0; i < ARRAY_SIZE(supported_formats); i++)
                formats[i] = supported_formats[i].fourcc;
 
-       ret = drm_universal_plane_init(drm, plane, 0xff, &hdlcd_plane_funcs,
-                                      formats, ARRAY_SIZE(formats),
-                                      NULL,
-                                      DRM_PLANE_TYPE_PRIMARY, NULL);
-       if (ret)
-               return ERR_PTR(ret);
+       plane = drmm_universal_plane_alloc(drm, struct drm_plane, dev, 0xff,
+                                          &hdlcd_plane_funcs,
+                                          formats, ARRAY_SIZE(formats),
+                                          NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+       if (IS_ERR(plane))
+               return plane;
 
        drm_plane_helper_add(plane, &hdlcd_plane_helper_funcs);
        hdlcd->plane = plane;