Skip to contentSkip to conversation

drm: Remove drm_num_crtcs() helper

PATCH In review Thierry Reding 3 participants 3 messages Feb 27, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Remove drm_num_crtcs() helper

From: Thierry Reding <[email protected]>

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.

---
 drivers/gpu/drm/drm_crtc.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -14
index 6795624f16e7..82c665d3e74b 100644
@@ -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);
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thierry Reding

From: Thierry Reding <[email protected]>

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.

Quoted 37 lines
---
 drivers/gpu/drm/drm_crtc.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -14
index 6795624f16e7..82c665d3e74b 100644
@@ -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);
Signature · 1 line
Jani Nikula, Intel
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thierry Reding

Thierry Reding <[email protected]> writes:

Hello Thierry,

Quoted 8 lines

From: Thierry Reding <[email protected]>

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.

Quoted 5 lines
---
 drivers/gpu/drm/drm_crtc.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

Indeed. I don't see why this helper would be needed. Your patch makes sense to me.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat