From patchwork Thu Dec 13 18:49:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dromede@gmail.com X-Patchwork-Id: 1875911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 6B3C13FC81 for ; Thu, 13 Dec 2012 18:53:40 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TjDqt-0006Kj-0M; Thu, 13 Dec 2012 18:49:47 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TjDqp-0006KR-Ub for linux-arm-kernel@lists.infradead.org; Thu, 13 Dec 2012 18:49:44 +0000 Received: by mail-bk0-f49.google.com with SMTP id jm19so1266319bkc.36 for ; Thu, 13 Dec 2012 10:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=BlVCxkldwNFD3rFqY8wc7woKYyy6Zt0Q7WJu5QYaxpc=; b=cfh2yWL0yUa12GoGaWqbU/RDl9jzcuUsa4vJQj4CuDdP4NgkxjgVg+gp5WXSk5Z6oa TmPZggEXFh7+DN+ItxcRmtcuHGacSQOv+0PfxrnMBGGhkazAP1nq9d4wLT2ZxpdAAQ4z aX9YfRjWV1ZiIXkuWqKMxtkF91b4Sdb3ndo8MbkaiuacKjnHxdmqZUl4qsdH9Xc5VMtb zVN2kykGehfjV1xY3XyJk6HqJjBuJdz3NsLp0JMxQ2VAb2QGRgwK+JMJx4zFwYbidurG QYf0mg5SzUJ/Mtr+XgZckn0iMLKBuS862i2dzCTDInM+xmkQvbpgQJdIlp1oeZ9TXNdM ZCLg== Received: by 10.204.143.147 with SMTP id v19mr1501686bku.32.1355424581847; Thu, 13 Dec 2012 10:49:41 -0800 (PST) Received: from dromedary.sx76x.gigaset.net (93-142-254-158.adsl.net.t-com.hr. [93.142.254.158]) by mx.google.com with ESMTPS id hm8sm2362985bkc.10.2012.12.13.10.49.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Dec 2012 10:49:41 -0800 (PST) From: dromede@gmail.com To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] [ARM] scoop.c: Use devm_xxx functions in scoop_probe() Date: Thu, 13 Dec 2012 19:49:15 +0100 Message-Id: <1355424555-13504-1-git-send-email-dromede@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121213_134944_166308_21D5AD9B X-CRM114-Status: GOOD ( 10.74 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dromede[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Marko Katic , richard.purdie@linuxfoundation.org, linux@arm.linux.org.uk X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Marko Katic Use devm_kzalloc and devm_ioremap and reduce the amount of error handling and deallocation code. Signed-off-by: Marko Katic --- arch/arm/common/scoop.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index 0c616d5..1901b4e 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c @@ -187,19 +187,18 @@ static int __devinit scoop_probe(struct platform_device *pdev) if (!mem) return -EINVAL; - devptr = kzalloc(sizeof(struct scoop_dev), GFP_KERNEL); + devptr = devm_kzalloc(&pdev->dev, sizeof(struct scoop_dev), GFP_KERNEL); + if (!devptr) return -ENOMEM; spin_lock_init(&devptr->scoop_lock); inf = pdev->dev.platform_data; - devptr->base = ioremap(mem->start, resource_size(mem)); + devptr->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); - if (!devptr->base) { - ret = -ENOMEM; - goto err_ioremap; - } + if (!devptr->base) + return -ENOMEM; platform_set_drvdata(pdev, devptr); @@ -234,12 +233,9 @@ static int __devinit scoop_probe(struct platform_device *pdev) if (devptr->gpio.base != -1) temp = gpiochip_remove(&devptr->gpio); + err_gpio: platform_set_drvdata(pdev, NULL); -err_ioremap: - iounmap(devptr->base); - kfree(devptr); - return ret; } @@ -260,8 +256,6 @@ static int __devexit scoop_remove(struct platform_device *pdev) } platform_set_drvdata(pdev, NULL); - iounmap(sdev->base); - kfree(sdev); return 0; }