Re: [RFC] drm/i915: make dev_priv usage explitic in some macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2023-02-01 at 15:53 +0200, Luca Coelho wrote:
> There are a few macros (e.g. DPLL()) that implicitly use dev_priv, by
> using other macros that implcitily use dev_priv.
> 
> In an effort to align all definitions of struct drm_i915_private to be
> declared as i915 instead of arbitrarily using either i915 or dev_priv,
> we need to make these macros explicitly use dev_priv, so that we can
> change them later to be defined as i915.
> 
> In order to find and change all occurrences, the following semantic
> patch rules were used:
> 
> @macros_noargs@
> identifier m;
> expression e =~ "dev_priv";
> @@
> 
> @nested_macros@
> identifier macros_noargs.m;
> identifier nm;
> identifier list il;
> @@
> 
> @@
> identifier nested_macros.nm;
> identifier dev_priv, f;
> expression list el;
> @@
> f(...) {
> 	...
> 	struct drm_i915_private *dev_priv = ...;
> 
> 	<+...
> 	nm(
> +	dev_priv,
> 	el)
> 	...+>
> }
> 
> @@
> identifier nested_macros.nm;
> identifier dev_priv, f;
> expression list el;
> @@
> f(..., struct drm_i915_private *dev_priv, ...) {
> 	<+...
> 	nm(
> +	dev_priv,
> 	el)
> 	...+>
> }
> 
> @@
> identifier nested_macros.nm;
> identifier list il;
> expression e;
> @@
> -#define nm(il) e
> +#define nm(dev_priv,il) e
> 
> Signed-off-by: Luca Coelho <luciano.coelho@xxxxxxxxx>
> ---

Running this rules require --recursive-includes as argument to cocci
and takes a looong time, so I had to run some rules and files
separately.  Additionally, I had to use the latest git head of cocci
from github, where some bugs related to finding which files to include
were fixed.

This patch may still need some manual trimming.  But before I spend
more time on this, I would like to know what you all thing about it, so
comments are very welcome.

If this is the right way to go, I can create more rules to change the
inner macros to also receive dev_priv as a parameter and, later, to
change all dev_priv's to i915. :)

--
Cheers,
Luca.




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux