]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm: Simplify drmm_alloc_ordered_workqueue return
authorMatthew Brost <matthew.brost@intel.com>
Wed, 2 Jul 2025 23:28:31 +0000 (16:28 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 3 Jul 2025 17:14:56 +0000 (10:14 -0700)
Rather than returning ERR_PTR or NULL on failure, replace the NULL
return with ERR_PTR(-ENOMEM). This simplifies error handling at the
caller. While here, add kernel documentation for
drmm_alloc_ordered_workqueue.

Cc: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Link: https://lore.kernel.org/r/20250702232831.3271328-2-matthew.brost@intel.com
drivers/gpu/drm/vkms/vkms_crtc.c
include/drm/drm_managed.h

index 8c9898b9055d4c9fff334516a2f8014aedee6d73..e60573e0f3e9510252e1f198b00e28bcc7987620 100644 (file)
@@ -302,8 +302,6 @@ struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *pri
        vkms_out->composer_workq = drmm_alloc_ordered_workqueue(dev, "vkms_composer", 0);
        if (IS_ERR(vkms_out->composer_workq))
                return ERR_CAST(vkms_out->composer_workq);
-       if (!vkms_out->composer_workq)
-               return ERR_PTR(-ENOMEM);
 
        return vkms_out;
 }
index 53017cc609ac617283e3be70cb5759908b049c4d..72bfac002c06273828cfefd201bd4819bd43ec8a 100644 (file)
@@ -129,14 +129,25 @@ void __drmm_mutex_release(struct drm_device *dev, void *res);
 
 void __drmm_workqueue_release(struct drm_device *device, void *wq);
 
+/**
+ * drmm_alloc_ordered_workqueue - &drm_device managed alloc_ordered_workqueue()
+ * @dev: DRM device
+ * @fmt: printf format for the name of the workqueue
+ * @flags: WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful)
+ * @args: args for @fmt
+ *
+ * This is a &drm_device-managed version of alloc_ordered_workqueue(). The
+ * allocated workqueue is automatically destroyed on the final drm_dev_put().
+ *
+ * Returns: workqueue on success, negative ERR_PTR otherwise.
+ */
 #define drmm_alloc_ordered_workqueue(dev, fmt, flags, args...)                                 \
        ({                                                                                      \
                struct workqueue_struct *wq = alloc_ordered_workqueue(fmt, flags, ##args);      \
                wq ? ({                                                                         \
                        int ret = drmm_add_action_or_reset(dev, __drmm_workqueue_release, wq);  \
                        ret ? ERR_PTR(ret) : wq;                                                \
-               }) :                                                                            \
-                       wq;                                                                     \
+               }) : ERR_PTR(-ENOMEM);                                                          \
        })
 
 #endif