Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	linux-doc@vger.kernel.org, Tony Lindgren <tony@atomide.com>,
	Stefan Agner <stefan@agner.ch>,
	linux-sunxi@googlegroups.com, linux-mtd@lists.infradead.org,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Alexander Clouter <alex@digriz.org.uk>,
	devel@driverdev.osuosl.org,
	Jesper Nilsson <jesper.nilsson@axis.com>,
	linux-samsung-soc@vger.kernel.org,
	Maxim Levitsky <maximlevitsky@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Marek Vasut <marek.vasut@gmail.com>, Chen-Yu Tsai <wens@csie.org>,
	Kukjin Kim <kgene@kernel.org>,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
	Josh Wu <josh.wu@atmel.com>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Jason Cooper <jason@lakedaemon.net>,
	Wan ZongShun <mcuos.com@gmail.com>,
	Steven Miao <realmz6@gmail.com>,
	adi-buildroot-devel@lists.sourceforge.net, Ha
Subject: Re: [PATCH 14/27] mtd: nand: use the mtd instance embedded in struct nand_chip
Date: Tue, 17 Nov 2015 10:05:03 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.10.1511170957100.2455@hadrien> (raw)
In-Reply-To: <20151117093836.052c86b5@bbrezillon>

> > (This isn't the worst one, but it just happens to be one of the first.)
> > There are many cases where the typical style would be to declare a new
> > variable at the top of the function, where you perform the
> > macro/function-call to convert from one abstraction to another. Like
> >
> > static int nfc_set_sram_bank(struct atmel_nand_host *host, unsigned int bank)
> > {
> > 	struct mtd_info *mtd = nand_to_mtd(&hot->nand_chip);
> > 	...
> >
> > and then use it later. Can that be done very easily?
> >
> > >  			return -EINVAL;
> > >  		nfc_writel(host->nfc->hsmc_regs, BANK, ATMEL_HSMC_NFC_BANK1);
> > >  	} else {
> >
> > ...
>
> Honestly, I don't know how to do that with a coccinelle script, and it
> will probably take me more time to find how to do it than addressing
> those problems manually.
>
> Julia, could you give us some hint?

Probably something like the following would be easiest.  You can just run
it after your other transformations:

@r exists@
identifier f;
expression e;
@@

f(...) { <+...  nand_to_mtd(e) ...+> }

@@
identifier r.f;
expression r.e;
@@

f(...) {
+ struct mtd_info *mtd = nand_to_mtd(e);
...
}

This won't work if there is more than one possible value of e.  If that is
likely, then I could come up with something more complex.  It also assumes
that you want to convert all such calls.  If you only want to convert calls
that occur in a particular context, eg a field reference, then you could
enhance the pattern inside the <+... ...+> in the first rule.

julia

  reply	other threads:[~2015-11-17  9:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16 13:37 [PATCH 00/27] mtd: nand: refactor the NAND subsystem (part 1) Boris Brezillon
2015-11-16 13:37 ` [PATCH 02/27] mtd: nand: add an mtd_to_nand() helper Boris Brezillon
     [not found]   ` <1447681080-31232-3-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2015-11-19 19:19     ` Brian Norris
2015-11-16 13:37 ` [PATCH 03/27] mtd: nand: update examples in the documentation to use mtd_to_nand() Boris Brezillon
2015-11-19 19:22   ` Brian Norris
2015-11-16 13:37 ` [PATCH 05/27] blackfin: nand: make use of mtd_to_nand() where appropriate Boris Brezillon
2015-11-16 13:37 ` [PATCH 06/27] cris: " Boris Brezillon
2015-11-16 13:37 ` [PATCH 07/27] mips: " Boris Brezillon
     [not found] ` <1447681080-31232-1-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2015-11-16 13:37   ` [PATCH 01/27] mtd: nand: fix drivers abusing mtd->priv Boris Brezillon
2015-11-19 19:07     ` Brian Norris
2015-11-16 13:37   ` [PATCH 04/27] ARM: nand: make use of mtd_to_nand() where appropriate Boris Brezillon
2015-11-16 13:37   ` [PATCH 08/27] sh: " Boris Brezillon
2015-11-16 13:37   ` [PATCH 11/27] staging: mt29f_spinand: make use of mtd_to_nand() Boris Brezillon
2015-11-16 13:37   ` [PATCH 12/27] mtd: nand: embed an mtd_info structure into nand_chip Boris Brezillon
2015-11-16 13:37   ` [PATCH 14/27] mtd: nand: use the mtd instance embedded in struct nand_chip Boris Brezillon
     [not found]     ` <1447681080-31232-15-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2015-11-17  3:00       ` Brian Norris
     [not found]         ` <20151117030019.GY8456-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-11-17  8:38           ` Boris Brezillon
2015-11-17  9:05             ` Julia Lawall [this message]
2015-11-17 14:22               ` Boris Brezillon
2015-11-17 15:32                 ` Julia Lawall
2015-11-16 13:37   ` [PATCH 15/27] mtd: nand: update the documentation to reflect framework changes Boris Brezillon
2015-11-16 13:37   ` [PATCH 16/27] staging: mt29f_spinand: use the mtd instance embedded in struct nand_chip Boris Brezillon
2015-11-16 13:37   ` [PATCH 19/27] mtd: nand: remove useless mtd->priv = chip assignments Boris Brezillon
2015-11-16 13:37   ` [PATCH 20/27] cris: " Boris Brezillon
2015-11-16 13:37   ` [PATCH 21/27] staging: mt29f_spinand: remove useless mtd->priv = chip assignment Boris Brezillon
2015-11-16 13:37   ` [PATCH 23/27] mtd: nand: kill the chip->flash_node field Boris Brezillon
2015-11-16 13:37   ` [PATCH 24/27] mtd: nand: add helpers to access ->priv Boris Brezillon
2015-11-16 13:37   ` [PATCH 26/27] mtd: nand: make use of nand_set/get_controller_data() helpers Boris Brezillon
2015-11-16 13:38   ` [PATCH 27/27] staging: mt29f_spinand: " Boris Brezillon
2015-11-16 13:37 ` [PATCH 09/27] mtd: nand: make use of mtd_to_nand() in NAND core code Boris Brezillon
2015-11-16 13:37 ` [PATCH 10/27] mtd: nand: make use of mtd_to_nand() in NAND drivers Boris Brezillon
2015-11-16 13:37 ` [PATCH 13/27] mtd: nand: add nand_to_mtd() helper Boris Brezillon
2015-11-16 13:37 ` [PATCH 17/27] cris: nand: use the mtd instance embedded in struct nand_chip Boris Brezillon
2015-11-16 13:37 ` [PATCH 18/27] mtd: nand: update mtd_to_nand() Boris Brezillon
2015-11-17  3:03   ` Brian Norris
     [not found]     ` <20151117030353.GZ8456-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-11-17  8:26       ` Boris Brezillon
2015-11-16 13:37 ` [PATCH 22/27] mtd: nand: simplify nand_dt_init() usage Boris Brezillon
2015-11-16 13:37 ` [PATCH 25/27] ARM: make use of nand_set/get_controller_data() helpers Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.10.1511170957100.2455@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=adi-buildroot-devel@lists.sourceforge.net \
    --cc=alex@digriz.org.uk \
    --cc=andrew@lunn.ch \
    --cc=boris.brezillon@free-electrons.com \
    --cc=corbet@lwn.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=jesper.nilsson@axis.com \
    --cc=josh.wu@atmel.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=marek.vasut@gmail.com \
    --cc=maximlevitsky@gmail.com \
    --cc=mcuos.com@gmail.com \
    --cc=realmz6@gmail.com \
    --cc=robert.jarzmik@free.fr \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=stefan@agner.ch \
    --cc=tony@atomide.com \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox