diff mbox series

[3/5] drm/i915/fixed: simplify FP_16_16_MAX definition

Message ID 20181115120126.9545-3-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/5] drm/i915: extract fixed point math to i915_fixed.h | expand

Commit Message

Jani Nikula Nov. 15, 2018, 12:01 p.m. UTC
No need to use a compound statement enclosed in parenthesis where a C99
compound literal will do. No functional changes.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_fixed.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Joonas Lahtinen Nov. 16, 2018, 10:40 a.m. UTC | #1
Quoting Jani Nikula (2018-11-15 14:01:24)
> No need to use a compound statement enclosed in parenthesis where a C99
> compound literal will do. No functional changes.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Out of curiosity, did this have an effect on asm generation?
Presumably not.

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
Chris Wilson Nov. 16, 2018, 10:52 a.m. UTC | #2
Quoting Jani Nikula (2018-11-15 12:01:24)
> No need to use a compound statement enclosed in parenthesis where a C99
> compound literal will do. No functional changes.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_fixed.h | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_fixed.h b/drivers/gpu/drm/i915/i915_fixed.h
> index 08316e50167a..927c59395569 100644
> --- a/drivers/gpu/drm/i915/i915_fixed.h
> +++ b/drivers/gpu/drm/i915/i915_fixed.h
> @@ -7,11 +7,7 @@ typedef struct {
>         u32 val;
>  } uint_fixed_16_16_t;
>  
> -#define FP_16_16_MAX ({ \
> -       uint_fixed_16_16_t fp; \
> -       fp.val = UINT_MAX; \
> -       fp; \
> -})
> +#define FP_16_16_MAX ((uint_fixed_16_16_t){ .val = UINT_MAX })

Following the standard set by pgprot_t

#define u16_16(x) ((u16_16_t){ .val = (x) })
#define U16_16_MAX u16_16(U32_MAX)
-Chris
Jani Nikula Nov. 16, 2018, 10:54 a.m. UTC | #3
On Fri, 16 Nov 2018, Joonas Lahtinen <joonas.lahtinen@linux.intel.com> wrote:
> Quoting Jani Nikula (2018-11-15 14:01:24)
>> No need to use a compound statement enclosed in parenthesis where a C99
>> compound literal will do. No functional changes.
>> 
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> Out of curiosity, did this have an effect on asm generation?
> Presumably not.

For some reason it caused tons of label etc. changes so it was hard to
check, but I didn't spot any functional asm changes.

BR,
Jani.



>
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>
> Regards, Joonas
Jani Nikula Nov. 20, 2018, 11:12 a.m. UTC | #4
On Fri, 16 Nov 2018, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Quoting Jani Nikula (2018-11-15 12:01:24)
>> No need to use a compound statement enclosed in parenthesis where a C99
>> compound literal will do. No functional changes.
>> 
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/i915/i915_fixed.h | 6 +-----
>>  1 file changed, 1 insertion(+), 5 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/i915_fixed.h b/drivers/gpu/drm/i915/i915_fixed.h
>> index 08316e50167a..927c59395569 100644
>> --- a/drivers/gpu/drm/i915/i915_fixed.h
>> +++ b/drivers/gpu/drm/i915/i915_fixed.h
>> @@ -7,11 +7,7 @@ typedef struct {
>>         u32 val;
>>  } uint_fixed_16_16_t;
>>  
>> -#define FP_16_16_MAX ({ \
>> -       uint_fixed_16_16_t fp; \
>> -       fp.val = UINT_MAX; \
>> -       fp; \
>> -})
>> +#define FP_16_16_MAX ((uint_fixed_16_16_t){ .val = UINT_MAX })
>
> Following the standard set by pgprot_t
>
> #define u16_16(x) ((u16_16_t){ .val = (x) })
> #define U16_16_MAX u16_16(U32_MAX)

I left that for follow-up, and pushed v2 of the series.

I think the uint_fixed_16_16_t type name is a bit unwieldy, should we
rename that while at it...

BR,
Jani.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_fixed.h b/drivers/gpu/drm/i915/i915_fixed.h
index 08316e50167a..927c59395569 100644
--- a/drivers/gpu/drm/i915/i915_fixed.h
+++ b/drivers/gpu/drm/i915/i915_fixed.h
@@ -7,11 +7,7 @@  typedef struct {
 	u32 val;
 } uint_fixed_16_16_t;
 
-#define FP_16_16_MAX ({ \
-	uint_fixed_16_16_t fp; \
-	fp.val = UINT_MAX; \
-	fp; \
-})
+#define FP_16_16_MAX ((uint_fixed_16_16_t){ .val = UINT_MAX })
 
 static inline bool is_fixed16_zero(uint_fixed_16_16_t val)
 {