[PATCH 3/5] drm/solomon: Simplify mode_valid() using DRM helper

Iker Pedrosa posted 5 patches 2 weeks, 6 days ago
[PATCH 3/5] drm/solomon: Simplify mode_valid() using DRM helper
Posted by Iker Pedrosa 2 weeks, 6 days ago
The ssd130x_crtc_mode_valid() function contains a manual implementation
to validate the display mode against the panel's single fixed resolution.

This pattern is common for simple displays, and the DRM core already
provides the drm_crtc_helper_mode_valid_fixed() helper for this exact
use case.

Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
 drivers/gpu/drm/solomon/ssd130x.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index c6939377ec4b5a42ce0f40d070ce60d544d8516d..2058d188159c3eae28de1614b9fffb06ac5551be 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -1470,15 +1470,7 @@ static enum drm_mode_status ssd130x_crtc_mode_valid(struct drm_crtc *crtc,
 {
 	struct ssd130x_device *ssd130x = drm_to_ssd130x(crtc->dev);
 
-	if (mode->hdisplay != ssd130x->mode.hdisplay &&
-	    mode->vdisplay != ssd130x->mode.vdisplay)
-		return MODE_ONE_SIZE;
-	else if (mode->hdisplay != ssd130x->mode.hdisplay)
-		return MODE_ONE_WIDTH;
-	else if (mode->vdisplay != ssd130x->mode.vdisplay)
-		return MODE_ONE_HEIGHT;
-
-	return MODE_OK;
+	return drm_crtc_helper_mode_valid_fixed(crtc, mode, &ssd130x->mode);
 }
 
 static int ssd130x_crtc_atomic_check(struct drm_crtc *crtc,

-- 
2.51.0
Re: [PATCH 3/5] drm/solomon: Simplify mode_valid() using DRM helper
Posted by Javier Martinez Canillas 2 weeks, 1 day ago
Iker Pedrosa <ikerpedrosam@gmail.com> writes:

> The ssd130x_crtc_mode_valid() function contains a manual implementation
> to validate the display mode against the panel's single fixed resolution.
>
> This pattern is common for simple displays, and the DRM core already
> provides the drm_crtc_helper_mode_valid_fixed() helper for this exact
> use case.
>
> Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
> ---

Indeed.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat