mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Coccinelle <cocci@systeme.lip6.fr>,
	Dejin Zheng <zhengdejin5@gmail.com>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	kernel-janitors@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Cocci] [PATCH v2] Coccinelle: api: Add SmPL script “use_devm_platform_get_and_ioremap_resource.cocci”
Date: Mon, 7 Sep 2020 19:03:05 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2009071900450.2476@hadrien> (raw)
In-Reply-To: <4b505afc-ae48-d8eb-f4e1-8e3f7192f73d@web.de>



On Mon, 7 Sep 2020, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 7 Sep 2020 18:38:04 +0200
>
> Another wrapper function is available since the commit 890cc39a879906b63912482dfc41944579df2dc6
> ("drivers: provide devm_platform_get_and_ioremap_resource()").
> Provide safe design options for the adjustment of affected source code
> by the means of the semantic patch language (Coccinelle software).
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>
> v2:
> Julia Lawall requested to omit case distinctions (disjunctions) from
> the first SmPL script.
> The usage of different expression metavariables for the first parameter
> of function calls was too questionable for the proposed source
> code transformation.
>
>
>  ...vm_platform_get_and_ioremap_resource.cocci | 48 +++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 scripts/coccinelle/api/use_devm_platform_get_and_ioremap_resource.cocci
>
> diff --git a/scripts/coccinelle/api/use_devm_platform_get_and_ioremap_resource.cocci b/scripts/coccinelle/api/use_devm_platform_get_and_ioremap_resource.cocci
> new file mode 100644
> index 000000000000..319583716ac8
> --- /dev/null
> +++ b/scripts/coccinelle/api/use_devm_platform_get_and_ioremap_resource.cocci
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/// Simplify a function call combination by using a known wrapper function.
> +//
> +// Keywords: wrapper function conversion ioremap resources
> +// Confidence: High

Shouldn't there be some options?  --no-includes and perhaps
--include-headers would seem reasonable.

Please also remove all of the rule names except for "or" which is
necessary.  The rest just add clutter and make it harder to find the
useful information, which is the depends on.  Rules only need names if
some other rule inherits their metavariables.

julia

> +
> +virtual context, patch, report, org
> +
> +@display depends on context@
> +expression base, device, index, resource;
> +@@
> +*resource = platform_get_resource(device, IORESOURCE_MEM, index);
> + base =
> +*       devm_ioremap_resource
> +                             (&device->dev, resource);
> +
> +@replacement depends on patch@
> +expression base, device, index, resource;
> +@@
> +-resource = platform_get_resource(device, IORESOURCE_MEM, index);
> + base =
> +-       devm_ioremap_resource
> ++       devm_platform_get_and_ioremap_resource
> +                             (
> +-                             &
> +                               device
> +-                                    ->dev
> +                              ,
> +-                             resource
> ++                             index, &resource
> +                             );
> +
> +@or depends on org || report@
> +expression base, device, index, resource;
> +position p;
> +@@
> + resource = platform_get_resource(device, IORESOURCE_MEM, index);
> + base = devm_ioremap_resource@p(&device->dev, resource);
> +
> +@script:python to_do depends on org@
> +p << or.p;
> +@@
> +coccilib.org.print_todo(p[0], "WARNING: opportunity for devm_platform_get_and_ioremap_resource()")
> +
> +@script:python reporting depends on report@
> +p << or.p;
> +@@
> +coccilib.report.print_report(p[0], "WARNING: opportunity for devm_platform_get_and_ioremap_resource()")
> --
> 2.28.0
>
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

  parent reply	other threads:[~2020-09-07 17:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <25b804fd-0d04-475d-f614-26c03c9fd544@web.de>
     [not found] ` <5f9fdd59-4b0b-1cb5-c3a2-92efc5bb3841@web.de>
2020-09-07 12:00   ` [Cocci] [PATCH] " Julia Lawall
     [not found]     ` <477abcea-e008-e509-d03f-f2753ebdfb20@web.de>
2020-09-07 13:11       ` Julia Lawall
     [not found]         ` <46d314d5-822e-3d73-2d70-015794556e56@web.de>
2020-09-07 13:46           ` Julia Lawall
     [not found]             ` <8aaa799f-0ec4-cfd0-854a-e1006d0d200a@web.de>
2020-09-07 14:18               ` Julia Lawall
     [not found]   ` <4b505afc-ae48-d8eb-f4e1-8e3f7192f73d@web.de>
2020-09-07 17:03     ` Julia Lawall [this message]
     [not found]       ` <8fb7782c-538b-b657-af13-da71124e6afa@web.de>
2020-09-07 17:31         ` [PATCH v2] " Julia Lawall

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.22.394.2009071900450.2476@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=Gilles.Muller@lip6.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=nicolas.palix@imag.fr \
    --cc=zhengdejin5@gmail.com \
    /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

all inboxes | Powered by JetHome®