diff mbox

[1/6] drm/i915: Turn DEV_INFO_FLAGS into for foreach style macro

Message ID 1366652441-2511-2-git-send-email-damien.lespiau@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lespiau, Damien April 22, 2013, 5:40 p.m. UTC
DEV_INFO_FOR_FLAG() now takes 2 parameters:
  • A function to apply to the flag
  • A separator

This will allow us to use the macro twice in the DRM_DEBUG_DRIVER() call
of i915_dump_device_info().

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  8 +++---
 drivers/gpu/drm/i915/i915_dma.c     |  8 +++---
 drivers/gpu/drm/i915/i915_drv.h     | 50 ++++++++++++++++++-------------------
 3 files changed, 31 insertions(+), 35 deletions(-)

Comments

Jani Nikula April 23, 2013, 7:20 a.m. UTC | #1
On Mon, 22 Apr 2013, Damien Lespiau <damien.lespiau@intel.com> wrote:
> DEV_INFO_FOR_FLAG() now takes 2 parameters:
>   • A function to apply to the flag
>   • A separator

Oooh, fancy bullets. ;)

Tiny bikeshed, is leaving out #undefs for the temp macros intentional?

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

>
> This will allow us to use the macro twice in the DRM_DEBUG_DRIVER() call
> of i915_dump_device_info().
>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c |  8 +++---
>  drivers/gpu/drm/i915/i915_dma.c     |  8 +++---
>  drivers/gpu/drm/i915/i915_drv.h     | 50 ++++++++++++++++++-------------------
>  3 files changed, 31 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 367b534..5e43c19 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -61,11 +61,9 @@ static int i915_capabilities(struct seq_file *m, void *data)
>  
>  	seq_printf(m, "gen: %d\n", info->gen);
>  	seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
> -#define DEV_INFO_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
> -#define DEV_INFO_SEP ;
> -	DEV_INFO_FLAGS;
> -#undef DEV_INFO_FLAG
> -#undef DEV_INFO_SEP
> +#define PRINT_FLAG(x)  seq_printf(m, #x ": %s\n", yesno(info->x))
> +#define SEP_SEMICOLON ;
> +	DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON);
>  
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 3b315ba..8ac8dd2 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1445,15 +1445,13 @@ static void i915_dump_device_info(struct drm_i915_private *dev_priv)
>  {
>  	const struct intel_device_info *info = dev_priv->info;
>  
> -#define DEV_INFO_FLAG(name) info->name ? #name "," : ""
> -#define DEV_INFO_SEP ,
> +#define PRINT_FLAG(name) info->name ? #name "," : ""
> +#define SEP_COMMA ,
>  	DRM_DEBUG_DRIVER("i915 device info: gen=%i, pciid=0x%04x flags="
>  			 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
>  			 info->gen,
>  			 dev_priv->dev->pdev->device,
> -			 DEV_INFO_FLAGS);
> -#undef DEV_INFO_FLAG
> -#undef DEV_INFO_SEP
> +			 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_COMMA));
>  }
>  
>  /**
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index d80bced..725d53d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -333,31 +333,31 @@ struct drm_i915_gt_funcs {
>  	void (*force_wake_put)(struct drm_i915_private *dev_priv);
>  };
>  
> -#define DEV_INFO_FLAGS \
> -	DEV_INFO_FLAG(is_mobile) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_i85x) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_i915g) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_i945gm) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_g33) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(need_gfx_hws) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_g4x) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_pineview) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_broadwater) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_crestline) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_ivybridge) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_valleyview) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(is_haswell) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_force_wake) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_fbc) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_pipe_cxsr) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_hotplug) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(cursor_needs_physical) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_overlay) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(overlay_needs_physical) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(supports_tv) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_bsd_ring) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_blt_ring) DEV_INFO_SEP \
> -	DEV_INFO_FLAG(has_llc)
> +#define DEV_INFO_FOR_EACH_FLAG(func, sep) \
> +	func(is_mobile) sep \
> +	func(is_i85x) sep \
> +	func(is_i915g) sep \
> +	func(is_i945gm) sep \
> +	func(is_g33) sep \
> +	func(need_gfx_hws) sep \
> +	func(is_g4x) sep \
> +	func(is_pineview) sep \
> +	func(is_broadwater) sep \
> +	func(is_crestline) sep \
> +	func(is_ivybridge) sep \
> +	func(is_valleyview) sep \
> +	func(is_haswell) sep \
> +	func(has_force_wake) sep \
> +	func(has_fbc) sep \
> +	func(has_pipe_cxsr) sep \
> +	func(has_hotplug) sep \
> +	func(cursor_needs_physical) sep \
> +	func(has_overlay) sep \
> +	func(overlay_needs_physical) sep \
> +	func(supports_tv) sep \
> +	func(has_bsd_ring) sep \
> +	func(has_blt_ring) sep \
> +	func(has_llc)
>  
>  struct intel_device_info {
>  	u32 display_mmio_offset;
> -- 
> 1.8.1.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula April 23, 2013, 7:31 a.m. UTC | #2
On Tue, 23 Apr 2013, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> On Mon, 22 Apr 2013, Damien Lespiau <damien.lespiau@intel.com> wrote:
>> DEV_INFO_FOR_FLAG() now takes 2 parameters:
>>   • A function to apply to the flag
>>   • A separator
>
> Oooh, fancy bullets. ;)
>
> Tiny bikeshed, is leaving out #undefs for the temp macros intentional?

Forgot to nitpick about the extra "for" in the subject.

J.

>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
>>
>> This will allow us to use the macro twice in the DRM_DEBUG_DRIVER() call
>> of i915_dump_device_info().
>>
>> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
>> ---
>>  drivers/gpu/drm/i915/i915_debugfs.c |  8 +++---
>>  drivers/gpu/drm/i915/i915_dma.c     |  8 +++---
>>  drivers/gpu/drm/i915/i915_drv.h     | 50 ++++++++++++++++++-------------------
>>  3 files changed, 31 insertions(+), 35 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
>> index 367b534..5e43c19 100644
>> --- a/drivers/gpu/drm/i915/i915_debugfs.c
>> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
>> @@ -61,11 +61,9 @@ static int i915_capabilities(struct seq_file *m, void *data)
>>  
>>  	seq_printf(m, "gen: %d\n", info->gen);
>>  	seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
>> -#define DEV_INFO_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
>> -#define DEV_INFO_SEP ;
>> -	DEV_INFO_FLAGS;
>> -#undef DEV_INFO_FLAG
>> -#undef DEV_INFO_SEP
>> +#define PRINT_FLAG(x)  seq_printf(m, #x ": %s\n", yesno(info->x))
>> +#define SEP_SEMICOLON ;
>> +	DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON);
>>  
>>  	return 0;
>>  }
>> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
>> index 3b315ba..8ac8dd2 100644
>> --- a/drivers/gpu/drm/i915/i915_dma.c
>> +++ b/drivers/gpu/drm/i915/i915_dma.c
>> @@ -1445,15 +1445,13 @@ static void i915_dump_device_info(struct drm_i915_private *dev_priv)
>>  {
>>  	const struct intel_device_info *info = dev_priv->info;
>>  
>> -#define DEV_INFO_FLAG(name) info->name ? #name "," : ""
>> -#define DEV_INFO_SEP ,
>> +#define PRINT_FLAG(name) info->name ? #name "," : ""
>> +#define SEP_COMMA ,
>>  	DRM_DEBUG_DRIVER("i915 device info: gen=%i, pciid=0x%04x flags="
>>  			 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
>>  			 info->gen,
>>  			 dev_priv->dev->pdev->device,
>> -			 DEV_INFO_FLAGS);
>> -#undef DEV_INFO_FLAG
>> -#undef DEV_INFO_SEP
>> +			 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_COMMA));
>>  }
>>  
>>  /**
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>> index d80bced..725d53d 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -333,31 +333,31 @@ struct drm_i915_gt_funcs {
>>  	void (*force_wake_put)(struct drm_i915_private *dev_priv);
>>  };
>>  
>> -#define DEV_INFO_FLAGS \
>> -	DEV_INFO_FLAG(is_mobile) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_i85x) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_i915g) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_i945gm) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_g33) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(need_gfx_hws) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_g4x) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_pineview) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_broadwater) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_crestline) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_ivybridge) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_valleyview) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(is_haswell) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_force_wake) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_fbc) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_pipe_cxsr) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_hotplug) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(cursor_needs_physical) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_overlay) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(overlay_needs_physical) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(supports_tv) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_bsd_ring) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_blt_ring) DEV_INFO_SEP \
>> -	DEV_INFO_FLAG(has_llc)
>> +#define DEV_INFO_FOR_EACH_FLAG(func, sep) \
>> +	func(is_mobile) sep \
>> +	func(is_i85x) sep \
>> +	func(is_i915g) sep \
>> +	func(is_i945gm) sep \
>> +	func(is_g33) sep \
>> +	func(need_gfx_hws) sep \
>> +	func(is_g4x) sep \
>> +	func(is_pineview) sep \
>> +	func(is_broadwater) sep \
>> +	func(is_crestline) sep \
>> +	func(is_ivybridge) sep \
>> +	func(is_valleyview) sep \
>> +	func(is_haswell) sep \
>> +	func(has_force_wake) sep \
>> +	func(has_fbc) sep \
>> +	func(has_pipe_cxsr) sep \
>> +	func(has_hotplug) sep \
>> +	func(cursor_needs_physical) sep \
>> +	func(has_overlay) sep \
>> +	func(overlay_needs_physical) sep \
>> +	func(supports_tv) sep \
>> +	func(has_bsd_ring) sep \
>> +	func(has_blt_ring) sep \
>> +	func(has_llc)
>>  
>>  struct intel_device_info {
>>  	u32 display_mmio_offset;
>> -- 
>> 1.8.1.4
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Lespiau, Damien April 23, 2013, 11:08 a.m. UTC | #3
On Tue, Apr 23, 2013 at 10:20:54AM +0300, Jani Nikula wrote:
> On Mon, 22 Apr 2013, Damien Lespiau <damien.lespiau@intel.com> wrote:
> > DEV_INFO_FOR_FLAG() now takes 2 parameters:
> >   • A function to apply to the flag
> >   • A separator
> 
> Oooh, fancy bullets. ;)

2013 is definitely the year of Unicode!

> Tiny bikeshed, is leaving out #undefs for the temp macros intentional?

It was. Before when wanting two invocations of DEV_INFO_FLAGS, you had
to define the same macros twice (DEV_INFO_FLAG/DEV_INFO_SEP), so to be
defensive about that #undef was added after DEV_INFO_FLAGS.

Now DEV_INFO_FOR_EACH_FLAG() takes the macro/sep to apply to each flag so
you can leave the macro defined, the second invocation will define its
own transformation (or reuse an existing one).
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 367b534..5e43c19 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -61,11 +61,9 @@  static int i915_capabilities(struct seq_file *m, void *data)
 
 	seq_printf(m, "gen: %d\n", info->gen);
 	seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
-#define DEV_INFO_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
-#define DEV_INFO_SEP ;
-	DEV_INFO_FLAGS;
-#undef DEV_INFO_FLAG
-#undef DEV_INFO_SEP
+#define PRINT_FLAG(x)  seq_printf(m, #x ": %s\n", yesno(info->x))
+#define SEP_SEMICOLON ;
+	DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 3b315ba..8ac8dd2 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1445,15 +1445,13 @@  static void i915_dump_device_info(struct drm_i915_private *dev_priv)
 {
 	const struct intel_device_info *info = dev_priv->info;
 
-#define DEV_INFO_FLAG(name) info->name ? #name "," : ""
-#define DEV_INFO_SEP ,
+#define PRINT_FLAG(name) info->name ? #name "," : ""
+#define SEP_COMMA ,
 	DRM_DEBUG_DRIVER("i915 device info: gen=%i, pciid=0x%04x flags="
 			 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
 			 info->gen,
 			 dev_priv->dev->pdev->device,
-			 DEV_INFO_FLAGS);
-#undef DEV_INFO_FLAG
-#undef DEV_INFO_SEP
+			 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_COMMA));
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d80bced..725d53d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -333,31 +333,31 @@  struct drm_i915_gt_funcs {
 	void (*force_wake_put)(struct drm_i915_private *dev_priv);
 };
 
-#define DEV_INFO_FLAGS \
-	DEV_INFO_FLAG(is_mobile) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_i85x) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_i915g) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_i945gm) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_g33) DEV_INFO_SEP \
-	DEV_INFO_FLAG(need_gfx_hws) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_g4x) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_pineview) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_broadwater) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_crestline) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_ivybridge) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_valleyview) DEV_INFO_SEP \
-	DEV_INFO_FLAG(is_haswell) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_force_wake) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_fbc) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_pipe_cxsr) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_hotplug) DEV_INFO_SEP \
-	DEV_INFO_FLAG(cursor_needs_physical) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_overlay) DEV_INFO_SEP \
-	DEV_INFO_FLAG(overlay_needs_physical) DEV_INFO_SEP \
-	DEV_INFO_FLAG(supports_tv) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_bsd_ring) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_blt_ring) DEV_INFO_SEP \
-	DEV_INFO_FLAG(has_llc)
+#define DEV_INFO_FOR_EACH_FLAG(func, sep) \
+	func(is_mobile) sep \
+	func(is_i85x) sep \
+	func(is_i915g) sep \
+	func(is_i945gm) sep \
+	func(is_g33) sep \
+	func(need_gfx_hws) sep \
+	func(is_g4x) sep \
+	func(is_pineview) sep \
+	func(is_broadwater) sep \
+	func(is_crestline) sep \
+	func(is_ivybridge) sep \
+	func(is_valleyview) sep \
+	func(is_haswell) sep \
+	func(has_force_wake) sep \
+	func(has_fbc) sep \
+	func(has_pipe_cxsr) sep \
+	func(has_hotplug) sep \
+	func(cursor_needs_physical) sep \
+	func(has_overlay) sep \
+	func(overlay_needs_physical) sep \
+	func(supports_tv) sep \
+	func(has_bsd_ring) sep \
+	func(has_blt_ring) sep \
+	func(has_llc)
 
 struct intel_device_info {
 	u32 display_mmio_offset;