On Wed, 5 Jun 2019, Enrico Weigelt, metux IT consult wrote:

> Hi folks,
>
>
> is there a way to replace obsolete #ifdef's via spatch ?
>
> Here's my scenario:
>
> In the linux kernel we have many places where drivers statically assign
> pointers to match tables (eg. for oftree or acpi) into a global driver
> struct - sometimes this is enclosed into some #ifdef CONFIG_..., when
> things like oftree or acpi are optional.
>
> Example patch for illustrating what I'd like to do:
>
> --- a/sound/soc/codecs/pcm3060-i2c.c
> +++ b/sound/soc/codecs/pcm3060-i2c.c
> @@ -45,9 +45,7 @@ static int pcm3060_i2c_probe(struct i2c_client *i2c,
>  static struct i2c_driver pcm3060_i2c_driver = {
>         .driver = {
>                 .name = "pcm3060",
> -#ifdef CONFIG_OF
> -               .of_match_table = pcm3060_of_match,
> -#endif /* CONFIG_OF */
> +               .of_match_table = of_match_ptr(pcm3060_of_match),
>         },
>         .id_table = pcm3060_i2c_id,
>         .probe = pcm3060_i2c_probe,
>
>
> Just wrapping the assignment into the macro call turned out to be easy.
> But I haven't found a way to remove the now #ifdef :(

In principle you can remove some initializations and add them back.  But
doing so would have the unfortunate side effect of removing the newlines.
So I am trying to fix that.

julia


>
> Any idea how I could solve this ?
>
>
> --mtx
>
> --
> Enrico Weigelt, metux IT consult
> Free software and Linux embedded engineering
> i...@metux.net -- +49-151-27565287
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to