drm: Remove drm_num_crtcs() helper
authorThierry Reding <treding@nvidia.com>
Tue, 27 Feb 2024 11:20:38 +0000 (12:20 +0100)
committerThierry Reding <treding@nvidia.com>
Wed, 28 Feb 2024 11:18:07 +0000 (12:18 +0100)
The drm_num_crtcs() helper determines the number of CRTCs by iterating
over the list of CRTCs that have been registered with the mode config.
However, we already keep track of that number in the mode config's
num_crtcs field, so we can simply retrieve the value from that and
remove the extra helper function.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240227112038.411846-1-thierry.reding@gmail.com
drivers/gpu/drm/drm_crtc.c

index 6795624f16e769aedcd73ace83a3f1d629e2533d..82c665d3e74bcd47abe254ac8326e3584d39c7ea 100644 (file)
@@ -107,18 +107,6 @@ int drm_crtc_force_disable(struct drm_crtc *crtc)
        return drm_mode_set_config_internal(&set);
 }
 
-static unsigned int drm_num_crtcs(struct drm_device *dev)
-{
-       unsigned int num = 0;
-       struct drm_crtc *tmp;
-
-       drm_for_each_crtc(tmp, dev) {
-               num++;
-       }
-
-       return num;
-}
-
 int drm_crtc_register_all(struct drm_device *dev)
 {
        struct drm_crtc *crtc;
@@ -278,8 +266,7 @@ static int __drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *
        if (name) {
                crtc->name = kvasprintf(GFP_KERNEL, name, ap);
        } else {
-               crtc->name = kasprintf(GFP_KERNEL, "crtc-%d",
-                                      drm_num_crtcs(dev));
+               crtc->name = kasprintf(GFP_KERNEL, "crtc-%d", config->num_crtc);
        }
        if (!crtc->name) {
                drm_mode_object_unregister(dev, &crtc->base);