diff mbox

[34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons

Message ID 1479498793-31021-35-git-send-email-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjala Nov. 18, 2016, 7:53 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Rather than compare the format u32s of two format infos, we can direclty
compare the format info pointers themselves. Noramlly all the ->format
pointers all point to somwehere in the big array, so this is a valid
way to test for equality.

Also drivers may want to point ->format at a private format info struct
instead (eg. for special compressed formats with extra planes), so
just comparing the pixel format values wouldn't necessaritly even work.
But comparing the pointers will also take care of that case.

@@
struct drm_framebuffer *a;
struct drm_framebuffer *b;
@@
(
- a->format->format != b->format->format
+ a->format != b->format
|
- a->format->format == b->format->format
+ a->format == b->format
)

@@
struct drm_plane_state *a;
struct drm_plane_state *b;
@@
(
- a->fb->format->format != b->fb->format->format
+ a->fb->format != b->fb->format
|
- a->fb->format->format == b->fb->format->format
+ a->fb->format == b->fb->format
)

@@
struct drm_crtc *crtc;
struct drm_framebuffer *x;
@@
(
- crtc->primary->fb->format->format != x->format->format
+ crtc->primary->fb->format != x->format
|
- x->format->format != crtc->primary->fb->format->format
+ x->format != crtc->primary->fb->format
)

@@
struct drm_mode_set *set;
@@
- set->fb->format->format != set->crtc->primary->fb->format->format
+ set->fb->format != set->crtc->primary->fb->format

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/armada/armada_crtc.c      | 2 +-
 drivers/gpu/drm/drm_crtc_helper.c         | 3 +--
 drivers/gpu/drm/drm_plane.c               | 2 +-
 drivers/gpu/drm/i915/intel_display.c      | 2 +-
 drivers/gpu/drm/imx/ipuv3-plane.c         | 6 +++---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 2 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c     | 2 +-
 7 files changed, 9 insertions(+), 10 deletions(-)

Comments

Laurent Pinchart Nov. 19, 2016, 2:56 a.m. UTC | #1
Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:53:10 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Rather than compare the format u32s of two format infos, we can direclty
> compare the format info pointers themselves. Noramlly all the ->format
> pointers all point to somwehere in the big array, so this is a valid
> way to test for equality.
> 
> Also drivers may want to point ->format at a private format info struct
> instead (eg. for special compressed formats with extra planes), so
> just comparing the pixel format values wouldn't necessaritly even work.
> But comparing the pointers will also take care of that case.
> 
> @@
> struct drm_framebuffer *a;
> struct drm_framebuffer *b;
> @@
> (
> - a->format->format != b->format->format
> + a->format != b->format
> 
> - a->format->format == b->format->format
> + a->format == b->format
> )
> 
> @@
> struct drm_plane_state *a;
> struct drm_plane_state *b;
> @@
> (
> - a->fb->format->format != b->fb->format->format
> + a->fb->format != b->fb->format
> 
> - a->fb->format->format == b->fb->format->format
> + a->fb->format == b->fb->format
> )
> 
> @@
> struct drm_crtc *crtc;
> struct drm_framebuffer *x;
> @@
> (
> - crtc->primary->fb->format->format != x->format->format
> + crtc->primary->fb->format != x->format
> 
> - x->format->format != crtc->primary->fb->format->format
> + x->format != crtc->primary->fb->format
> )
> 
> @@
> struct drm_mode_set *set;
> @@
> - set->fb->format->format != set->crtc->primary->fb->format->format
> + set->fb->format != set->crtc->primary->fb->format
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/armada/armada_crtc.c      | 2 +-
>  drivers/gpu/drm/drm_crtc_helper.c         | 3 +--
>  drivers/gpu/drm/drm_plane.c               | 2 +-
>  drivers/gpu/drm/i915/intel_display.c      | 2 +-
>  drivers/gpu/drm/imx/ipuv3-plane.c         | 6 +++---
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 2 +-
>  drivers/gpu/drm/tilcdc/tilcdc_plane.c     | 2 +-
>  7 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_crtc.c
> b/drivers/gpu/drm/armada/armada_crtc.c index 52e139dc9e38..baebf3775f60
> 100644
> --- a/drivers/gpu/drm/armada/armada_crtc.c
> +++ b/drivers/gpu/drm/armada/armada_crtc.c
> @@ -996,7 +996,7 @@ static int armada_drm_crtc_page_flip(struct drm_crtc
> *crtc, int ret;
> 
>  	/* We don't support changing the pixel format */
> -	if (fb->format->format != crtc->primary->fb->format->format)
> +	if (fb->format != crtc->primary->fb->format)
>  		return -EINVAL;
> 
>  	work = kmalloc(sizeof(*work), GFP_KERNEL);
> diff --git a/drivers/gpu/drm/drm_crtc_helper.c
> b/drivers/gpu/drm/drm_crtc_helper.c index 94bce0b462aa..9d007f5f9732 100644
> --- a/drivers/gpu/drm/drm_crtc_helper.c
> +++ b/drivers/gpu/drm/drm_crtc_helper.c
> @@ -588,8 +588,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
> if (set->crtc->primary->fb == NULL) {
>  			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
>  			mode_changed = true;
> -		} else if (set->fb->format->format !=
> -			   set->crtc->primary->fb->format->format) {
> +		} else if (set->fb->format != set->crtc->primary->fb->format) 
{
>  			mode_changed = true;
>  		} else
>  			fb_changed = true;
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index ac1e06df7280..1d90520457d7 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -854,7 +854,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	if (ret)
>  		goto out;
> 
> -	if (crtc->primary->fb->format->format != fb->format->format) {
> +	if (crtc->primary->fb->format != fb->format) {
>  		DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer
> format.\n"); ret = -EINVAL;
>  		goto out;
> diff --git a/drivers/gpu/drm/i915/intel_display.c
> b/drivers/gpu/drm/i915/intel_display.c index f5f9f1422d69..7b7135be3b9e
> 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -12148,7 +12148,7 @@ static int intel_crtc_page_flip(struct drm_crtc
> *crtc, return -EBUSY;
> 
>  	/* Can't change pixel format via MI display flips. */
> -	if (fb->format->format != crtc->primary->fb->format->format)
> +	if (fb->format != crtc->primary->fb->format)
>  		return -EINVAL;
> 
>  	/*
> diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c
> b/drivers/gpu/drm/imx/ipuv3-plane.c index 0b945f077344..8b5294d47cee 100644
> --- a/drivers/gpu/drm/imx/ipuv3-plane.c
> +++ b/drivers/gpu/drm/imx/ipuv3-plane.c
> @@ -281,7 +281,7 @@ static int ipu_plane_atomic_check(struct drm_plane
> *plane, */
>  	if (old_fb && (state->src_w != old_state->src_w ||
>  			      state->src_h != old_state->src_h ||
> -			      fb->format->format != old_fb->format->format))
> +			      fb->format != old_fb->format))
>  		crtc_state->mode_changed = true;
> 
>  	eba = drm_plane_state_to_eba(state);
> @@ -315,7 +315,7 @@ static int ipu_plane_atomic_check(struct drm_plane
> *plane, if (vbo & 0x7 || vbo > 0xfffff8)
>  			return -EINVAL;
> 
> -		if (old_fb && (fb->format->format == old_fb->format->format)) 
{
> +		if (old_fb && (fb->format == old_fb->format)) {
>  			old_vbo = drm_plane_state_to_vbo(old_state);
>  			if (vbo != old_vbo)
>  				crtc_state->mode_changed = true;
> @@ -332,7 +332,7 @@ static int ipu_plane_atomic_check(struct drm_plane
> *plane, if (ubo & 0x7 || ubo > 0xfffff8)
>  			return -EINVAL;
> 
> -		if (old_fb && (fb->format->format == old_fb->format->format)) 
{
> +		if (old_fb && (fb->format == old_fb->format)) {
>  			old_ubo = drm_plane_state_to_ubo(old_state);
>  			if (ubo != old_ubo)
>  				crtc_state->mode_changed = true;
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c index
> b90e9e497260..6ecc6bc1f531 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> @@ -340,7 +340,7 @@ static int mdp5_plane_atomic_check(struct drm_plane
> *plane, if (plane_enabled(state) && plane_enabled(old_state)) {
>  		/* we cannot change SMP block configuration during scanout: */
>  		bool full_modeset = false;
> -		if (state->fb->format->format != old_state->fb->format-
>format) {
> +		if (state->fb->format != old_state->fb->format) {
>  			DBG("%s: pixel_format change!", mdp5_plane->name);
>  			full_modeset = true;
>  		}
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> b/drivers/gpu/drm/tilcdc/tilcdc_plane.c index 4b7519dfd1b9..ba0d66c0d8ac
> 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> @@ -77,7 +77,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane
> *plane, }
> 
>  	if (state->fb && old_state->fb &&
> -	    state->fb->format->format != old_state->fb->format->format) {
> +	    state->fb->format != old_state->fb->format) {
>  		dev_dbg(plane->dev->dev,
>  			"%s(): pixel format change requires mode_change\n",
>  			__func__);
diff mbox

Patch

diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 52e139dc9e38..baebf3775f60 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -996,7 +996,7 @@  static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
 	int ret;
 
 	/* We don't support changing the pixel format */
-	if (fb->format->format != crtc->primary->fb->format->format)
+	if (fb->format != crtc->primary->fb->format)
 		return -EINVAL;
 
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 94bce0b462aa..9d007f5f9732 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -588,8 +588,7 @@  int drm_crtc_helper_set_config(struct drm_mode_set *set)
 		if (set->crtc->primary->fb == NULL) {
 			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
 			mode_changed = true;
-		} else if (set->fb->format->format !=
-			   set->crtc->primary->fb->format->format) {
+		} else if (set->fb->format != set->crtc->primary->fb->format) {
 			mode_changed = true;
 		} else
 			fb_changed = true;
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index ac1e06df7280..1d90520457d7 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -854,7 +854,7 @@  int drm_mode_page_flip_ioctl(struct drm_device *dev,
 	if (ret)
 		goto out;
 
-	if (crtc->primary->fb->format->format != fb->format->format) {
+	if (crtc->primary->fb->format != fb->format) {
 		DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n");
 		ret = -EINVAL;
 		goto out;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index f5f9f1422d69..7b7135be3b9e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12148,7 +12148,7 @@  static int intel_crtc_page_flip(struct drm_crtc *crtc,
 		return -EBUSY;
 
 	/* Can't change pixel format via MI display flips. */
-	if (fb->format->format != crtc->primary->fb->format->format)
+	if (fb->format != crtc->primary->fb->format)
 		return -EINVAL;
 
 	/*
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index 0b945f077344..8b5294d47cee 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -281,7 +281,7 @@  static int ipu_plane_atomic_check(struct drm_plane *plane,
 	 */
 	if (old_fb && (state->src_w != old_state->src_w ||
 			      state->src_h != old_state->src_h ||
-			      fb->format->format != old_fb->format->format))
+			      fb->format != old_fb->format))
 		crtc_state->mode_changed = true;
 
 	eba = drm_plane_state_to_eba(state);
@@ -315,7 +315,7 @@  static int ipu_plane_atomic_check(struct drm_plane *plane,
 		if (vbo & 0x7 || vbo > 0xfffff8)
 			return -EINVAL;
 
-		if (old_fb && (fb->format->format == old_fb->format->format)) {
+		if (old_fb && (fb->format == old_fb->format)) {
 			old_vbo = drm_plane_state_to_vbo(old_state);
 			if (vbo != old_vbo)
 				crtc_state->mode_changed = true;
@@ -332,7 +332,7 @@  static int ipu_plane_atomic_check(struct drm_plane *plane,
 		if (ubo & 0x7 || ubo > 0xfffff8)
 			return -EINVAL;
 
-		if (old_fb && (fb->format->format == old_fb->format->format)) {
+		if (old_fb && (fb->format == old_fb->format)) {
 			old_ubo = drm_plane_state_to_ubo(old_state);
 			if (ubo != old_ubo)
 				crtc_state->mode_changed = true;
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index b90e9e497260..6ecc6bc1f531 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -340,7 +340,7 @@  static int mdp5_plane_atomic_check(struct drm_plane *plane,
 	if (plane_enabled(state) && plane_enabled(old_state)) {
 		/* we cannot change SMP block configuration during scanout: */
 		bool full_modeset = false;
-		if (state->fb->format->format != old_state->fb->format->format) {
+		if (state->fb->format != old_state->fb->format) {
 			DBG("%s: pixel_format change!", mdp5_plane->name);
 			full_modeset = true;
 		}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index 4b7519dfd1b9..ba0d66c0d8ac 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -77,7 +77,7 @@  static int tilcdc_plane_atomic_check(struct drm_plane *plane,
 	}
 
 	if (state->fb && old_state->fb &&
-	    state->fb->format->format != old_state->fb->format->format) {
+	    state->fb->format != old_state->fb->format) {
 		dev_dbg(plane->dev->dev,
 			"%s(): pixel format change requires mode_change\n",
 			__func__);