diff mbox series

[13/14] backport: convert int led activate op to void when needed

Message ID 20180920112842.27198-14-luca@coelho.fi (mailing list archive)
State Accepted
Headers show
Series backport: updates for 4.19 | expand

Commit Message

Luca Coelho Sept. 20, 2018, 11:28 a.m. UTC
From: Luca Coelho <luciano.coelho@intel.com>

In kernel v4.19-rc1, the activate op in struct led_trigger, changed
from void to int.  To solve this, add a semantic patch to insert a
wrapper function that returns void and calls the function that returns
int.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 patches/led_activate.cocci | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 patches/led_activate.cocci

Comments

Hauke Mehrtens Sept. 23, 2018, 12:30 p.m. UTC | #1
On 09/20/2018 01:28 PM, Luca Coelho wrote:
> From: Luca Coelho <luciano.coelho@intel.com>
> 
> In kernel v4.19-rc1, the activate op in struct led_trigger, changed
> from void to int.  To solve this, add a semantic patch to insert a
> wrapper function that returns void and calls the function that returns
> int.
> 
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> ---
>  patches/led_activate.cocci | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>  create mode 100644 patches/led_activate.cocci
> 
> diff --git a/patches/led_activate.cocci b/patches/led_activate.cocci
> new file mode 100644
> index 000000000000..df8211d29462
> --- /dev/null
> +++ b/patches/led_activate.cocci
> @@ -0,0 +1,24 @@
> +@act@
> +identifier activate_fn, p;
> +identifier m =~ "rx_led|tx_led|assoc_led|radio_led|tpt_led";
> +fresh identifier activate_fn_wrap = "bp_" ## activate_fn;
> +@@
> +<...
> ++#if LINUX_VERSION_IS_GEQ(4,19,0)
> +p->m.activate = activate_fn;
> ++#else
> ++p->m.activate = activate_fn_wrap;
> ++#endif
> +...>

Please use <+--- ---+> here it improves the speed by some magnitudes.

> +
> +@@
> +identifier act.activate_fn;
> +identifier act.activate_fn_wrap;
> +@@
> +int activate_fn(...) {...}
> ++#if LINUX_VERSION_IS_LESS(4,19,0)
> ++static void activate_fn_wrap(struct led_classdev *led_cdev)
> ++{
> ++	activate_fn(led_cdev);
> ++}
> ++#endif
>
Luca Coelho Sept. 24, 2018, 9:24 a.m. UTC | #2
On Sun, 2018-09-23 at 14:30 +0200, Hauke Mehrtens wrote:
> On 09/20/2018 01:28 PM, Luca Coelho wrote:
> > From: Luca Coelho <luciano.coelho@intel.com>
> > 
> > In kernel v4.19-rc1, the activate op in struct led_trigger, changed
> > from void to int.  To solve this, add a semantic patch to insert a
> > wrapper function that returns void and calls the function that
> > returns
> > int.
> > 
> > Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> > ---
> >  patches/led_activate.cocci | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >  create mode 100644 patches/led_activate.cocci
> > 
> > diff --git a/patches/led_activate.cocci
> > b/patches/led_activate.cocci
> > new file mode 100644
> > index 000000000000..df8211d29462
> > --- /dev/null
> > +++ b/patches/led_activate.cocci
> > @@ -0,0 +1,24 @@
> > +@act@
> > +identifier activate_fn, p;
> > +identifier m =~ "rx_led|tx_led|assoc_led|radio_led|tpt_led";
> > +fresh identifier activate_fn_wrap = "bp_" ## activate_fn;
> > +@@
> > +<...
> > ++#if LINUX_VERSION_IS_GEQ(4,19,0)
> > +p->m.activate = activate_fn;
> > ++#else
> > ++p->m.activate = activate_fn_wrap;
> > ++#endif
> > +...>
> 
> Please use <+--- ---+> here it improves the speed by some magnitudes.

Thanks for pointing out.  I remember the discussion about this with
Julia.  Johannes already fixed this in-place before applying my patch.

--
Cheers,
Luca.

--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox series

Patch

diff --git a/patches/led_activate.cocci b/patches/led_activate.cocci
new file mode 100644
index 000000000000..df8211d29462
--- /dev/null
+++ b/patches/led_activate.cocci
@@ -0,0 +1,24 @@ 
+@act@
+identifier activate_fn, p;
+identifier m =~ "rx_led|tx_led|assoc_led|radio_led|tpt_led";
+fresh identifier activate_fn_wrap = "bp_" ## activate_fn;
+@@
+<...
++#if LINUX_VERSION_IS_GEQ(4,19,0)
+p->m.activate = activate_fn;
++#else
++p->m.activate = activate_fn_wrap;
++#endif
+...>
+
+@@
+identifier act.activate_fn;
+identifier act.activate_fn_wrap;
+@@
+int activate_fn(...) {...}
++#if LINUX_VERSION_IS_LESS(4,19,0)
++static void activate_fn_wrap(struct led_classdev *led_cdev)
++{
++	activate_fn(led_cdev);
++}
++#endif