[v1,05/16] drm/fsl-dcu: fix opencoded use of drm_panel_*
diff mbox series

Message ID 20190804201637.1240-6-sam@ravnborg.org
State New
Headers show
Series
  • drm: panel related updates
Related show

Commit Message

Sam Ravnborg Aug. 4, 2019, 8:16 p.m. UTC
Use drm_panel_get_modes() to access modes.
This has a nice side effect to simplify the code.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Alison Wang <alison.wang@nxp.com>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

Comments

Stefan Agner Aug. 5, 2019, 9:16 a.m. UTC | #1
On 2019-08-04 22:16, Sam Ravnborg wrote:
> Use drm_panel_get_modes() to access modes.
> This has a nice side effect to simplify the code.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Stefan Agner <stefan@agner.ch>
> Cc: Alison Wang <alison.wang@nxp.com>
> ---
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> index 279d83eaffc0..a92fd6c70b09 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> @@ -65,17 +65,9 @@ static const struct drm_connector_funcs
> fsl_dcu_drm_connector_funcs = {
>  static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
>  {
>  	struct fsl_dcu_drm_connector *fsl_connector;
> -	int (*get_modes)(struct drm_panel *panel);
> -	int num_modes = 0;
>  
>  	fsl_connector = to_fsl_dcu_connector(connector);
> -	if (fsl_connector->panel && fsl_connector->panel->funcs &&
> -	    fsl_connector->panel->funcs->get_modes) {
> -		get_modes = fsl_connector->panel->funcs->get_modes;
> -		num_modes = get_modes(fsl_connector->panel);
> -	}
> -
> -	return num_modes;
> +	return drm_panel_get_modes(fsl_connector->panel);

Oh, that old code looks rather messy. Thanks for the simplification!

This behaves slightly different since it now returns -EINVAL or -ENOSYS,
but that is what we want.

Acked-by: Stefan Agner <stefan@agner.ch>

--
Stefan

>  }
>  
>  static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector,
Sam Ravnborg Aug. 5, 2019, 11:54 a.m. UTC | #2
Hi Stefan.

Thanks for the feedback.

On Mon, Aug 05, 2019 at 11:16:26AM +0200, Stefan Agner wrote:
> On 2019-08-04 22:16, Sam Ravnborg wrote:
> > Use drm_panel_get_modes() to access modes.
> > This has a nice side effect to simplify the code.
> > 
> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Stefan Agner <stefan@agner.ch>
> > Cc: Alison Wang <alison.wang@nxp.com>
> > ---
> >  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +---------
> >  1 file changed, 1 insertion(+), 9 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> > b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> > index 279d83eaffc0..a92fd6c70b09 100644
> > --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> > +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
> > @@ -65,17 +65,9 @@ static const struct drm_connector_funcs
> > fsl_dcu_drm_connector_funcs = {
> >  static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
> >  {
> >  	struct fsl_dcu_drm_connector *fsl_connector;
> > -	int (*get_modes)(struct drm_panel *panel);
> > -	int num_modes = 0;
> >  
> >  	fsl_connector = to_fsl_dcu_connector(connector);
> > -	if (fsl_connector->panel && fsl_connector->panel->funcs &&
> > -	    fsl_connector->panel->funcs->get_modes) {
> > -		get_modes = fsl_connector->panel->funcs->get_modes;
> > -		num_modes = get_modes(fsl_connector->panel);
> > -	}
> > -
> > -	return num_modes;
> > +	return drm_panel_get_modes(fsl_connector->panel);
> 
> Oh, that old code looks rather messy. Thanks for the simplification!
> 
> This behaves slightly different since it now returns -EINVAL or -ENOSYS,
> but that is what we want.

You are right, and I will add this to the changelog when I apply.

	Sam

Patch
diff mbox series

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
index 279d83eaffc0..a92fd6c70b09 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -65,17 +65,9 @@  static const struct drm_connector_funcs fsl_dcu_drm_connector_funcs = {
 static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
 {
 	struct fsl_dcu_drm_connector *fsl_connector;
-	int (*get_modes)(struct drm_panel *panel);
-	int num_modes = 0;
 
 	fsl_connector = to_fsl_dcu_connector(connector);
-	if (fsl_connector->panel && fsl_connector->panel->funcs &&
-	    fsl_connector->panel->funcs->get_modes) {
-		get_modes = fsl_connector->panel->funcs->get_modes;
-		num_modes = get_modes(fsl_connector->panel);
-	}
-
-	return num_modes;
+	return drm_panel_get_modes(fsl_connector->panel);
 }
 
 static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector,