Re: [PATCH 09/18] drm/i915: Pass intel_encoder to infoframe functions

Ville Syrjälä
2018-09-21T15:03:55Z

On Fri, Sep 21, 2018 at 03:59:06PM +0200, Daniel Vetter wrote:
> On Thu, Sep 20, 2018 at 09:51:36PM +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Make life simpler by passing around intel_encoder instead of
> > drm_encoder.
> >
> > @r1@
> > identifier F =~ "infoframe";
> > identifier I, M;
> > @@
> > F(
> > - struct drm_encoder *I
> > + struct intel_encoder *I
> > , ...)
> > {
> > <...
> > (
> > - I->M
> > + I->base.M
> > |
> > - I
> > + &I->base
> > )
> > ...>
> > }
> >
> > @r2@
> > identifier F =~ "infoframe";
> > identifier I;
> > type T, ST;
> > @@
> > ST {
> > ...
> > T (*F)(
> > - struct drm_encoder *I
> > + struct intel_encoder *encoder
> > , ...);
> > ...
> > };
> >
> > @@
> > identifier r1.F;
> > expression E;
> > @@
> > F(
> > - E
> > + to_intel_encoder(E)
> > ,...)
> >
> > @@
> > identifier r2.F;
> > expression E, X;
> > @@
> > (
> > X.F(
> > - E
> > + to_intel_encoder(E)
> > ,...)
> > |
> > X->F(
> > - E
> > + to_intel_encoder(E)
> > ,...)
> > )
> >
> > @@
> > expression E;
> > @@
> > (
> > - to_intel_encoder(&E->base)
> > + E
> > |
> > - to_intel_encoder(&E->base.base)
> > + &E->base
> > )
> >
> > @@
> > identifier D, M;
> > expression E;
> > @@
> > D = enc_to_dig_port(&E->base)
> > <...
> > (
> > - D->base.M
> > + E->M
> > |
> > - &D->base
> > + E
> > )
> > ...>
> >
> > @@
> > identifier D;
> > expression E;
> > type T;
> > @@
> > - T D = enc_to_dig_port(E);
> > ... when != D
>
> Someone knows a lot more cocci than I do, impressive. How do you figure
> this stuff out? Read the source?

A combination of reading the docs, looking at other cocci scripts,
cursing, and lost hair. And every time I repeat the process
because I've forgotten what I learned last time around.

>
> Also seems to have some manual fixups below, so I just looked at the diff.
> That looks fine.

I might have accidentally tweaked things when I rebased this. Should
have re-run the cocci script actually. Would be nice if git rebase
did that for you automagically.

I just re-ran spatch and that highlighted five occurances of the
following manual change I had made "accidentally" while rebasing:

++<<<<<<< HEAD
+ struct drm_device *dev = encoder->base.dev;
+ struct drm_i915_private *dev_priv = to_i915(dev);
++=======
+ struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
++>>>>>>> 8cdf27dd7e50... drm/i915: Pass intel_encoder to infoframe functions

Nothing else had been tweaked apparently.

>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Thanks.

--
Ville Syrjälä
Intel