From patchwork Mon Nov 7 11:47:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 16384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2000201wru; Mon, 7 Nov 2022 03:53:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6PTCyt34PPWwsfyRGgbi3gpGJwxtIePCVI1Vu7FhLG/1kAHMuBdOYCzp9/tZFeKq9pYxcl X-Received: by 2002:a17:906:a157:b0:7ae:5d04:c96 with SMTP id bu23-20020a170906a15700b007ae5d040c96mr7824053ejb.564.1667822009849; Mon, 07 Nov 2022 03:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667822009; cv=none; d=google.com; s=arc-20160816; b=Cv1LApR/pqgk8Xd7zO7qiuXuWBpqCfDaKRmmwXzbOscs9gigTzYSmTu5y9AyMaOB+3 uUBGu/l7rnEKh1/a7tfvT0S2/j99oEIqsBHQOxKTTy6uz3kybl7NutZ3m/S6nREp9aZv Y9LhJ3r58m0hBaguS2EhvaM7q5t0QwDSBsdZSzM2Cts4427PT8c/paoM7FGaGs/VPdLt oIRanVAogaieNKwhpfAxIbyubVm3u4F+jQz2vhrKz4zdnq6N09ncW4Qswn89BJ8wVhbe 5yFhM0M8F+/qDES3A17ScTOTsER1/f43RNlFozOkHqD0T9N+MgDvxwMIk+SaqyWfeHbY jHPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=EjdqGj77kZX7BdzBwYal3mc/7aZEl+OAgMkczfDOcv8=; b=ch28zZLAoWiKNd/8AOh3ciBAdL6JTuU8Nc+7NKraM8zIl6idLBx9Ux5dSWWFsCj+Tc VpL+hcBmuY67LJhxI9mbPGHTmJ5m8o8CtpMx7KdfZ4RbGluzQ9mqABt1BIizVxn/AcOi anNVmQCbuedSo0KA26fmqI5gh45O+Crhgpy68UYdXesk5dVHVCD7SCxmZVQlgPunUdRY 9w+10Pxs83PU5EUG43Ek1x3BIAhxz4oXsMYh3rlCOtkPj1Qqsh1dec7ZdNtE6KDXKA5A aLcj/PO9MVyjfKSE2KY49VAYv2E+G882F3lIXC21qVoLi722Zr1jlxBkLCBsq8n6TH6D pwdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a056402190600b00461c0fd2597si11605384edz.89.2022.11.07.03.53.05; Mon, 07 Nov 2022 03:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbiKGLrS (ORCPT + 99 others); Mon, 7 Nov 2022 06:47:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbiKGLrO (ORCPT ); Mon, 7 Nov 2022 06:47:14 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46159167F2 for ; Mon, 7 Nov 2022 03:47:13 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1os0at-00025I-Fz; Mon, 07 Nov 2022 12:47:11 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1os0ar-002qN3-5E; Mon, 07 Nov 2022 12:47:10 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1os0ar-00ExHH-Gw; Mon, 07 Nov 2022 12:47:09 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Julia Lawall , Nicolas Palix Cc: linux-kernel@vger.kernel.org, cocci@inria.fr, kernel@pengutronix.de Subject: [PATCH v1] coccinelle: api: Don't use devm_platform_get_and_ioremap_resource with res==NULL Date: Mon, 7 Nov 2022 12:47:02 +0100 Message-Id: <20221107114702.15706-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748838131690631914?= X-GMAIL-MSGID: =?utf-8?q?1748838131690631914?= devm_platform_get_and_ioremap_resource(pdev, index, NULL) is equivalent to the shorter devm_platform_ioremap_resource(pdev, index). Signed-off-by: Uwe Kleine-König --- Hello, a potential improvement is to check for invocations of devm_platform_get_and_ioremap_resource() where the res parameter isn't used afterwards, but my coccinelle foo isn't strong enough for that. Best regards Uwe .../api/devm_platform_ioremap_resource.cocci | 44 +++++++++++++++++++ 1 file changed, 44 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..401610b9a17d --- /dev/null +++ b/scripts/coccinelle/api/devm_platform_ioremap_resource.cocci @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-only +/// Don't use devm_platform_get_and_ioremap_resource with NULL as third parameter +// Confidence: High + +virtual patch +virtual context +virtual org +virtual report + +@r1@ +position p; +@@ + devm_platform_ioremap_resource(...) { + ... + devm_platform_get_and_ioremap_resource@p(...) + ... + } + +@depends on patch@ +expression pdev,index; +position p != r1.p; +@@ + +- devm_platform_get_and_ioremap_resource@p(pdev, index, NULL) ++ devm_platform_ioremap_resource(pdev, index) + +@r2 depends on !patch exists@ +expression pdev,index; +position p; +@@ + +* devm_platform_get_and_ioremap_resource@p(pdev, index, NULL) + +@script:python depends on org@ +p << r2.p; +@@ + +cocci.print_main("WARNING opportunity for devm_platform_ioremap_resource", p) + +@script:python depends on report@ +p << r2.p; +@@ + +coccilib.report.print_report(p[0], "WARNING opportunity for devm_platform_ioremap_resource")