LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Himanshu Jha <himanshujha199640@gmail.com>
Cc: yamada.masahiro@socionext.com,
	Julia Lawall <Julia.Lawall@lip6.fr>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	nicolas.palix@imag.fr, michal.lkml@markovi.net,
	linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr,
	bgolaszewski@baylibre.com, gregkh@linuxfoundation.org,
	andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] coccinelle: api: add devm_platform_ioremap_resource script
Date: Sat, 6 Apr 2019 08:31:49 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.1904060831120.4486@hadrien> (raw)
In-Reply-To: <20190406061112.31620-1-himanshujha199640@gmail.com>



On Sat, 6 Apr 2019, Himanshu Jha wrote:

> Use recently introduced devm_platform_ioremap_resource
> helper which wraps platform_get_resource() and
> devm_ioremap_resource() together. This helps produce much
> cleaner code while removing local `struct resource` declaration.
>
> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>

Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Thanks for taking up this issue.

julia

> ---
>
> Tree wide changes has been tested through 0-day test service
> with build success.
>
> BUILD SUCCESS 74ebaaca5d14d3d9b03e911f0b4995b78a4d60f0
> tree/branch: https://github.com/himanshujha199640/linux-next  20190401-devm_platform_ioremap_resource-final
> branch HEAD: 74ebaaca5d14d3d9b03e911f0b4995b78a4d60f0  Coccinelle: api: Add devm_platform_ioremap_resource.cocci
>
> elapsed time: 385m
> configs tested: 162
>
>
> Stats:
> 916 files changed, 1028 insertions(+), 2921 deletions(-)
>
> Note: cases where the `struct resource *res` variable is
> used subsequently in the function have been ignored out because
> those cases produce:
>
> eg., drivers/bus/da8xx-mstpri.c
>
> warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> due to:
> 	if (prio_descr->reg + sizeof(u32) > resource_size(res)) {
>
> which seems correct as `res` isn't initialized in the scope of
> the function(da8xx_mstpri_probe) and instead initialized inside:
>
>    void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
>                                                 unsigned int index)
>    {
>            struct resource *res;
>
>            res = platform_get_resource(pdev, IORESOURCE_MEM, index);
>            return devm_ioremap_resource(&pdev->dev, res);
>    }
>    EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
>
>
>  .../api/devm_platform_ioremap_resource.cocci  | 63 +++++++++++++++++++
>  1 file changed, 63 insertions(+)
>  create mode 100644 scripts/coccinelle/api/devm_platform_ioremap_resource.cocci
>
> diff --git a/scripts/coccinelle/api/devm_platform_ioremap_resource.cocci b/scripts/coccinelle/api/devm_platform_ioremap_resource.cocci
> new file mode 100644
> index 000000000000..a28274af14df
> --- /dev/null
> +++ b/scripts/coccinelle/api/devm_platform_ioremap_resource.cocci
> @@ -0,0 +1,63 @@
> +/// Use devm_platform_ioremap_resource helper which wraps
> +/// platform_get_resource() and devm_ioremap_resource() together.
> +///
> +// Confidence: High
> +// Copyright: (C) 2019 Himanshu Jha GPLv2.
> +// Copyright: (C) 2019 Julia Lawall, Inria/LIP6. GPLv2.
> +// Keywords: platform_get_resource, devm_ioremap_resource,
> +// Keywords: devm_platform_ioremap_resource
> +
> +virtual patch
> +virtual report
> +
> +@r depends on patch && !report@
> +expression e1, e2, arg1, arg2, arg3, arg4;
> +identifier id;
> +@@
> +
> +(
> +- id = platform_get_resource(arg1, arg2, arg3);
> +|
> +- struct resource *id = platform_get_resource(arg1, arg2, arg3);
> +)
> +  ... when != id
> +- e1 = devm_ioremap_resource(arg4, id);
> ++ e1 = devm_platform_ioremap_resource(arg1, arg3);
> +  ... when != id
> +? id = e2
> +
> +@r1 depends on patch && !report@
> +identifier r.id;
> +type T;
> +@@
> +
> +- T *id;
> +  ...when != id
> +
> +// ----------------------------------------------------------------------------
> +
> +@r2 depends on report && !patch@
> +identifier id;
> +expression e1, e2, arg1, arg2, arg3, arg4;
> +position j0;
> +@@
> +
> +(
> +  id = platform_get_resource(arg1, arg2, arg3);
> +|
> +  struct resource *id = platform_get_resource(arg1, arg2, arg3);
> +)
> +  ... when != id
> +  e1@j0 = devm_ioremap_resource(arg4, id);
> +  ... when != id
> +? id = e2
> +
> +// ----------------------------------------------------------------------------
> +
> +@script:python depends on report && !patch@
> +e1 << r2.e1;
> +j0 << r2.j0;
> +@@
> +
> +msg = "WARNING: Use devm_platform_ioremap_resource for %s" % (e1)
> +coccilib.report.print_report(j0[0], msg)
> --
> 2.17.1
>
>

  reply index

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-06  6:11 Himanshu Jha
2019-04-06  6:31 ` Julia Lawall [this message]
2019-04-06  6:34   ` Julia Lawall
2019-07-06 12:16     ` [Cocci] " Masahiro Yamada
2019-07-06 13:39       ` Julia Lawall
2019-07-07  9:55         ` Coccinelle: " Markus Elfring
2019-07-07 12:38           ` Masahiro Yamada
2019-04-06 12:36 ` [PATCH] coccinelle: " Markus Elfring
2019-06-08 15:24 ` Coccinelle: " Markus Elfring
2019-06-08 17:26   ` Julia Lawall
2019-06-09  8:55     ` Markus Elfring
2019-06-11 20:40       ` Enrico Weigelt, metux IT consult
2019-06-12  5:28         ` Julia Lawall
2019-06-12  6:24         ` Markus Elfring
2019-06-14  9:22         ` [PATCH] drivers: Inline code in devm_platform_ioremap_resource() from two functions Markus Elfring
2019-06-14  9:27           ` [Cocci] " Julia Lawall
2019-06-15 11:00             ` Markus Elfring
2019-06-14 10:07           ` [PATCH] " Greg Kroah-Hartman
2019-06-17 20:21           ` Enrico Weigelt, metux IT consult
2019-06-18  5:37             ` Markus Elfring
2019-06-18  9:35               ` Enrico Weigelt, metux IT consult
2019-06-18 10:21                 ` Dan Carpenter
2019-06-18 11:44                 ` Markus Elfring

Reply instructions:

You may reply publically 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.21.1904060831120.4486@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=Gilles.Muller@lip6.fr \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=cocci@systeme.lip6.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=himanshujha199640@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=nicolas.palix@imag.fr \
    --cc=yamada.masahiro@socionext.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

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


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


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