Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4509439ybi; Sat, 6 Jul 2019 06:40:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvpUY5WQknDs/lwZxf8Py829Cb6dOtFGtL13o2rqHgysVgm2wh2S/LFeodM77TGJKMUzbT X-Received: by 2002:a17:90b:8d2:: with SMTP id ds18mr12019049pjb.132.1562420405485; Sat, 06 Jul 2019 06:40:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562420405; cv=none; d=google.com; s=arc-20160816; b=vPgn0sYc6Ohdpm7bMnCZK9YSTrrqnOdd7sV/ZQaAcVUZhVfHHQQ4ADxznpNN1UQXgP Fo4uO6kNhBHr6ibaQVqVoTLy5ev/xFeL/nj8uw8jnsVrmfb0W6imiq78X5TivxSJcf7s S27Kn4qXnVyx/tT6C6zw6PLFnEFlFk3vhL2/7gBCvWpq2VUzzI7dEMwa3cma51aYl++8 h2j8rBT0JM27xzGg1Jr4WWRO2DUe4xvTqA2fmlySaVcfWWFhWchkxK5ooPDL3BxiFPk7 icfxNTfT792iSXRR2uncmp/w3X7vYTQHviUUA4egRH6Ksyp8gy7/gpnFx7sLNjBAGR0c PMrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=hWibNyRC4f6w8Axxc9rQoZUwvIZBeHqADUT9dd0S/0o=; b=xcRFTx6Itgyj6KmAiT6kTS7Yzb2/FQiZheNdHzhMIxTUHaBfajhunpnQR91O9W5Fsp ShZwrrq+o7WJebPD49EwJF7WLCwkHoJv/anDXjJJxqwSStvyy5aUQCrGCjcZQOByQK37 OyaytUV3+djFuKF/GPie4a7zQQbMhHxmWzEspQQtDK55LHUr0umi5L3JQIC+UlL422kk DUS8XvNxr+SAE1oXM7FA5qh8LGsXMENw7AMrZn1l1H7iMkab2SjeV36W1WwE30VBhho7 lT82vYufykDaA55gK9lJV9b0bG4m1VmOBLfvjX8fQeU1htMC2g3hhuhRg9uwjMZAdyWl vu9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si799096pgl.448.2019.07.06.06.39.47; Sat, 06 Jul 2019 06:40:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbfGFNjP (ORCPT + 99 others); Sat, 6 Jul 2019 09:39:15 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:41061 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfGFNjP (ORCPT ); Sat, 6 Jul 2019 09:39:15 -0400 X-IronPort-AV: E=Sophos;i="5.63,458,1557180000"; d="scan'208";a="312640623" Received: from abo-12-105-68.mrs.modulonet.fr (HELO hadrien) ([85.68.105.12]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jul 2019 15:39:12 +0200 Date: Sat, 6 Jul 2019 15:39:11 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Masahiro Yamada cc: Himanshu Jha , kernel-janitors@vger.kernel.org, Michal Marek , Greg Kroah-Hartman , Linus Walleij , Nicolas Palix , Linux Kernel Mailing List , Bartosz Golaszewski , Andy Shevchenko , cocci@systeme.lip6.fr Subject: Re: [Cocci] [PATCH] coccinelle: api: add devm_platform_ioremap_resource script In-Reply-To: Message-ID: References: <20190406061112.31620-1-himanshujha199640@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 6 Jul 2019, Masahiro Yamada wrote: > On Sat, Apr 6, 2019 at 3:34 PM Julia Lawall wrote: > > > > > > > > On Sat, 6 Apr 2019, Julia Lawall wrote: > > > > > > > > > > > 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 > > > > > > Acked-by: Julia Lawall > > > > > > Thanks for taking up this issue. > > > > Maybe this should be > > > > Signed-off-by: Julia Lawall > > > > since I contributed two lines to the script :) > > I will apply with Julia's Signed-off-by instead of Acked-by. > I will also add SPDX tag. > > Is this OK? Yes, thanks. julia > > > > > julia > > > > > > > > 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 > > > > > > > > > > > > > _______________________________________________ > > Cocci mailing list > > Cocci@systeme.lip6.fr > > https://systeme.lip6.fr/mailman/listinfo/cocci > > > > -- > Best Regards > Masahiro Yamada >