[Intel-gfx] [PATCH v2 4/5] drm/i915: Wrap access to module params into macro

Michal Wajdeczko michal.wajdeczko at intel.com
Thu Sep 14 14:03:00 UTC 2017


On Thu, 14 Sep 2017 15:10:22 +0200, Jani Nikula  
<jani.nikula at linux.intel.com> wrote:

> On Thu, 14 Sep 2017, Michal Wajdeczko <michal.wajdeczko at intel.com> wrote:
>> @@ -1031,9 +1031,9 @@ static void i915_driver_cleanup_mmio(struct  
>> drm_i915_private *dev_priv)
>>
>>  static void intel_sanitize_options(struct drm_i915_private *dev_priv)
>>  {
>> -	i915.enable_execlists =
>> +	i915_param(enable_execlists) =
>
> I disapprove using a function-like macro expansion as an lvalue. If you
> want to use a getter macro, also provide a setter, and use them
> separately.
>

What about this set of macros:

#define i915_param(n)          ({ i915_params.n; })
#define i915_param_set(n,e)    ({ i915_params.n = e; })
#define i915_param_inc(n)      ({ i915_params.n++; })
#define i915_param_dec(n)      ({ i915_params.n--; })
#define i915_param_ptr(n)      ({ &i915_params.n; })

then corresponding code update can be done with:

@@
identifier n;
expression e;
@@

(
-	i915_param(n) = e;
+	i915_param_set(n, e);
|
-	i915_param(n)++;
+	i915_param_inc(n);
|
-	i915_param(n)--;
+	i915_param_dec(n);
)

Michal

> BR,
> Jani.
>


More information about the Intel-gfx mailing list