diff mbox series

[2/4] drm/i915: Use named initializers for the crc source name array

Message ID 20190214192219.3858-2-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/4] drm/i915: Remove the "pf" crc source | expand

Commit Message

Ville Syrjala Feb. 14, 2019, 7:22 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

We assume that the index of the string in the crc source names
array matches the enum value for the crc source. Let's use named
initializers to make sure that is indeed the case even if someone
rearranges either the enum or the array.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_pipe_crc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Rodrigo Vivi Feb. 14, 2019, 8:33 p.m. UTC | #1
On Thu, Feb 14, 2019 at 09:22:17PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> We assume that the index of the string in the crc source names
> array matches the enum value for the crc source. Let's use named
> initializers to make sure that is indeed the case even if someone
> rearranges either the enum or the array.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/i915/intel_pipe_crc.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c b/drivers/gpu/drm/i915/intel_pipe_crc.c
> index a3a3ad760158..fe0ff89b980b 100644
> --- a/drivers/gpu/drm/i915/intel_pipe_crc.c
> +++ b/drivers/gpu/drm/i915/intel_pipe_crc.c
> @@ -31,15 +31,15 @@
>  #include "intel_drv.h"
>  
>  static const char * const pipe_crc_sources[] = {
> -	"none",
> -	"plane1",
> -	"plane2",
> -	"pipe",
> -	"TV",
> -	"DP-B",
> -	"DP-C",
> -	"DP-D",
> -	"auto",
> +	[INTEL_PIPE_CRC_SOURCE_NONE] = "none",
> +	[INTEL_PIPE_CRC_SOURCE_PLANE1] = "plane1",
> +	[INTEL_PIPE_CRC_SOURCE_PLANE2] = "plane2",
> +	[INTEL_PIPE_CRC_SOURCE_PIPE] = "pipe",
> +	[INTEL_PIPE_CRC_SOURCE_TV] = "TV",
> +	[INTEL_PIPE_CRC_SOURCE_DP_B] = "DP-B",
> +	[INTEL_PIPE_CRC_SOURCE_DP_C] = "DP-C",
> +	[INTEL_PIPE_CRC_SOURCE_DP_D] = "DP-D",
> +	[INTEL_PIPE_CRC_SOURCE_AUTO] = "auto",
>  };
>  
>  static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
> -- 
> 2.19.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c b/drivers/gpu/drm/i915/intel_pipe_crc.c
index a3a3ad760158..fe0ff89b980b 100644
--- a/drivers/gpu/drm/i915/intel_pipe_crc.c
+++ b/drivers/gpu/drm/i915/intel_pipe_crc.c
@@ -31,15 +31,15 @@ 
 #include "intel_drv.h"
 
 static const char * const pipe_crc_sources[] = {
-	"none",
-	"plane1",
-	"plane2",
-	"pipe",
-	"TV",
-	"DP-B",
-	"DP-C",
-	"DP-D",
-	"auto",
+	[INTEL_PIPE_CRC_SOURCE_NONE] = "none",
+	[INTEL_PIPE_CRC_SOURCE_PLANE1] = "plane1",
+	[INTEL_PIPE_CRC_SOURCE_PLANE2] = "plane2",
+	[INTEL_PIPE_CRC_SOURCE_PIPE] = "pipe",
+	[INTEL_PIPE_CRC_SOURCE_TV] = "TV",
+	[INTEL_PIPE_CRC_SOURCE_DP_B] = "DP-B",
+	[INTEL_PIPE_CRC_SOURCE_DP_C] = "DP-C",
+	[INTEL_PIPE_CRC_SOURCE_DP_D] = "DP-D",
+	[INTEL_PIPE_CRC_SOURCE_AUTO] = "auto",
 };
 
 static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,