Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] how to replace obsolete #ifdef's
@ 2019-06-05 16:25 Enrico Weigelt, metux IT consult
  2019-06-05 19:51 ` [Cocci] How to replace obsolete #ifdef's? Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-05 16:25 UTC (permalink / raw)
  To: cocci

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 :(

Any idea how I could solve this ?


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, back to index

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05 16:25 [Cocci] how to replace obsolete #ifdef's Enrico Weigelt, metux IT consult
2019-06-05 19:51 ` [Cocci] How to replace obsolete #ifdef's? Markus Elfring
2019-06-05 20:52 ` [Cocci] how to replace obsolete #ifdef's Julia Lawall
2019-06-05 21:42   ` Enrico Weigelt, metux IT consult
2019-06-06  5:46     ` Julia Lawall
2019-06-06  9:30       ` [Cocci] How to replace obsolete #ifdef's? Markus Elfring
2019-06-06 10:34         ` Julia Lawall
2019-06-06 14:20           ` Markus Elfring
2019-06-06 15:34             ` David Young
2019-06-07 12:01           ` Enrico Weigelt, metux IT consult
2019-06-07 12:30             ` Julia Lawall
2019-06-06  9:15     ` Markus Elfring
2019-06-06  9:39       ` Julia Lawall
2019-06-07 12:05         ` Enrico Weigelt, metux IT consult
2019-06-07 12:32           ` Julia Lawall
2019-06-07 13:40             ` Markus Elfring
2019-06-07 16:33               ` Julia Lawall
2019-06-07 17:26                 ` Markus Elfring
2019-06-07 17:36                 ` Markus Elfring
2019-06-07 18:48 ` Markus Elfring
2019-06-07 18:59   ` Julia Lawall
2019-06-08  7:49   ` [Cocci] Handling of designated initialisers by SmPL? Markus Elfring

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox