From patchwork Wed Aug 14 09:11:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 266994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wi0-x23f.google.com (mail-wi0-x23f.google.com [IPv6:2a00:1450:400c:c05::23f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id A42422C0198 for ; Wed, 14 Aug 2013 19:11:43 +1000 (EST) Received: by mail-wi0-f191.google.com with SMTP id en1sf809730wid.28 for ; Wed, 14 Aug 2013 02:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:sender:list-subscribe:list-unsubscribe:content-type; bh=eIRw+7H7HZUjqb5xyXX+Q/yLdKFCMgxTtX2XQX84XOc=; b=wM0j5+InnS6oyAyzYcMuAbgsAPvaBhY4KSNNxRCYeo24Hp7rOp8xO53iv1NleDUc4S C68uELvhOvO1IVlOac95OulewBn4UGjwgTzh5xvrgKed1TDmDHPg0anzmVvX3pDKa6y2 pPHkkVDCxQZGb0OxKS3K0+Ry5EOaXmEbVbW4zIr7U/HQEIoYMh8RdRCQFzPub0xD7Ccq G44vUW8yVo3MTH9dvh6+l5R+WfHFJbaDdA6sPEmZ1DhlqE3JL23Z7K6kTjZQMyN1FWR1 U0cmqMpGntjaWzOcuH32b1YMTTQiXevg7FLvsqchb7wD6cDPwJiFlpDwTfpWCIZKUND9 vsFA== X-Received: by 10.180.8.131 with SMTP id r3mr59477wia.20.1376471499404; Wed, 14 Aug 2013 02:11:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.180.102.65 with SMTP id fm1ls603864wib.40.canary; Wed, 14 Aug 2013 02:11:38 -0700 (PDT) X-Received: by 10.15.41.206 with SMTP id s54mr255858eev.6.1376471498947; Wed, 14 Aug 2013 02:11:38 -0700 (PDT) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr. [192.134.164.104]) by gmr-mx.google.com with ESMTPS id a1si8166672ees.1.2013.08.14.02.11.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 14 Aug 2013 02:11:38 -0700 (PDT) Received-SPF: neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of Julia.Lawall@lip6.fr) client-ip=192.134.164.104; X-IronPort-AV: E=Sophos;i="4.89,875,1367964000"; d="scan'208";a="23908328" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 14 Aug 2013 11:11:38 +0200 From: Julia Lawall To: Alessandro Zummo Cc: kernel-janitors@vger.kernel.org, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [rtc-linux] [PATCH 17/29] drivers/rtc: simplify use of devm_ioremap_resource Date: Wed, 14 Aug 2013 11:11:21 +0200 Message-Id: <1376471493-22215-18-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1376471493-22215-1-git-send-email-Julia.Lawall@lip6.fr> References: <1376471493-22215-1-git-send-email-Julia.Lawall@lip6.fr> X-Original-Sender: julia.lawall@lip6.fr X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of Julia.Lawall@lip6.fr) smtp.mail=Julia.Lawall@lip6.fr Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , From: Julia Lawall Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Julia Lawall Acked-by: Viresh Kumar --- drivers/rtc/rtc-ds1216.c | 4 +--- drivers/rtc/rtc-ds1286.c | 4 +--- drivers/rtc/rtc-spear.c | 7 +------ 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c index 9c04fd2..c948bd3 100644 --- a/drivers/rtc/rtc-ds1216.c +++ b/drivers/rtc/rtc-ds1216.c @@ -144,15 +144,13 @@ static int __init ds1216_rtc_probe(struct platform_device *pdev) struct ds1216_priv *priv; u8 dummy[8]; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENODEV; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; platform_set_drvdata(pdev, priv); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->ioaddr = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->ioaddr)) return PTR_ERR(priv->ioaddr); diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index 50e109b..14c4b24 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c @@ -332,13 +332,11 @@ static int ds1286_probe(struct platform_device *pdev) struct resource *res; struct ds1286_priv *priv; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENODEV; priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL); if (!priv) return -ENOMEM; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->rtcregs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->rtcregs)) return PTR_ERR(priv->rtcregs); diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c index c492cf0..6470641 100644 --- a/drivers/rtc/rtc-spear.c +++ b/drivers/rtc/rtc-spear.c @@ -358,12 +358,6 @@ static int spear_rtc_probe(struct platform_device *pdev) int status = 0; int irq; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "no resource defined\n"); - return -EBUSY; - } - config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); if (!config) { dev_err(&pdev->dev, "out of memory\n"); @@ -385,6 +379,7 @@ static int spear_rtc_probe(struct platform_device *pdev) return status; } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); config->ioaddr = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(config->ioaddr)) return PTR_ERR(config->ioaddr);