From patchwork Sun Mar 26 14:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 96012 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp853445qgd; Sun, 26 Mar 2017 07:43:12 -0700 (PDT) X-Received: by 10.84.213.16 with SMTP id f16mr23749281pli.156.1490539392307; Sun, 26 Mar 2017 07:43:12 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a74si6836527pfj.78.2017.03.26.07.43.12; Sun, 26 Mar 2017 07:43:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751317AbdCZOmk (ORCPT + 1 other); Sun, 26 Mar 2017 10:42:40 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:36648 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbdCZOmi (ORCPT ); Sun, 26 Mar 2017 10:42:38 -0400 Received: by mail-wr0-f179.google.com with SMTP id w11so10702639wrc.3 for ; Sun, 26 Mar 2017 07:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k7wbhBR1FgkhlaT+yf8h6b4Tthbkw9zuvc04Wju8OuI=; b=DB56WgbA5UdRlXs/ToCLLPTL5S0WJDB9WR8R9V5DMy90SsARAy03z/FgJ92IXtATZu NZfvIEgEy5aZN2JZFpUXh9H+w5/hK+j68ws/RWhWsDKLn2Tlwf44JffTfvWAXHcSsHE2 jrQ8B1q7Pix9D2EDHlc9g9TexOiQhJHbBGCsE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k7wbhBR1FgkhlaT+yf8h6b4Tthbkw9zuvc04Wju8OuI=; b=IlFECk0Jc7Cltz2/zq69VV/jwSNqFq9BKPpc8WF+BV+qKA4YJY1pNMTp+hHBvLeIbQ MBdkaHEpx6rxTYvFGbz5D/6kVncdeMY94O0R4nF1XP9IMw5uUm345Hfaramyn14yLJbg 8Irnvrx2bUklvEyEStg4WaWnMaAs3iA2CfLzrMISm0Ym8EGViOoJ1eQ8e6g5eQalShwF p6UtesvMe7PXZPLk+GMpNg92cYb/5FBSaiQqhelXl+tz859NKg7P0pm0pQAyzNScGYnW G4XEQ15fb7emrVJ76mGcy6k3MbN1qYbTREW5wqJcFOMkKlw0SZ3VAflnUWljhLU3v/EF H5ug== X-Gm-Message-State: AFeK/H1IQ7PSzZK1K9ksslKNNnPVDW+ESyywpB23AawBlvOOAaqbOHKfqrHAeY+bMJ++EgHP X-Received: by 10.223.170.210 with SMTP id i18mr17604570wrc.114.1490539356132; Sun, 26 Mar 2017 07:42:36 -0700 (PDT) Received: from localhost.localdomain (li1529-187.members.linode.com. [139.162.244.187]) by smtp.gmail.com with ESMTPSA id l90sm10619516wmi.25.2017.03.26.07.42.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Mar 2017 07:42:35 -0700 (PDT) From: Leo Yan To: Russell King , Dmitry Torokhov , Alessandro Zummo , Alexandre Belloni , Linus Walleij , Baptiste Reynal , Alex Williamson , Jaroslav Kysela , Takashi Iwai , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, alsa-devel@alsa-project.org Cc: Leo Yan Subject: [PATCH 2/5] drivers/rtc/rtc-pl030.c: Convert to use devm_*() Date: Sun, 26 Mar 2017 22:41:51 +0800 Message-Id: <1490539314-9681-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> References: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Convert driver to use devm_*() APIs so rely on driver model core layer to manage resources. This eliminates error path boilerplate and makes code neat. Signed-off-by: Leo Yan --- drivers/rtc/rtc-pl030.c | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Linus Walleij diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index f85a1a9..372b1fd 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c @@ -102,49 +102,30 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) struct pl030_rtc *rtc; int ret; - ret = amba_request_regions(dev, NULL); - if (ret) - goto err_req; - rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL); - if (!rtc) { - ret = -ENOMEM; - goto err_rtc; - } + if (!rtc) + return -ENOMEM; - rtc->base = ioremap(dev->res.start, resource_size(&dev->res)); - if (!rtc->base) { - ret = -ENOMEM; - goto err_rtc; - } + rtc->base = devm_ioremap_resource(&dev->dev, &dev->res); + if (IS_ERR(rtc->base)) + return PTR_ERR(rtc->base); __raw_writel(0, rtc->base + RTC_CR); __raw_writel(0, rtc->base + RTC_EOI); amba_set_drvdata(dev, rtc); - ret = request_irq(dev->irq[0], pl030_interrupt, 0, - "rtc-pl030", rtc); + ret = devm_request_irq(&dev->dev, dev->irq[0], pl030_interrupt, 0, + "rtc-pl030", rtc); if (ret) - goto err_irq; + return ret; - rtc->rtc = rtc_device_register("pl030", &dev->dev, &pl030_ops, - THIS_MODULE); - if (IS_ERR(rtc->rtc)) { - ret = PTR_ERR(rtc->rtc); - goto err_reg; - } + rtc->rtc = devm_rtc_device_register(&dev->dev, "pl030", &pl030_ops, + THIS_MODULE); + if (IS_ERR(rtc->rtc)) + return PTR_ERR(rtc->rtc); return 0; - - err_reg: - free_irq(dev->irq[0], rtc); - err_irq: - iounmap(rtc->base); - err_rtc: - amba_release_regions(dev); - err_req: - return ret; } static int pl030_remove(struct amba_device *dev) @@ -152,12 +133,6 @@ static int pl030_remove(struct amba_device *dev) struct pl030_rtc *rtc = amba_get_drvdata(dev); writel(0, rtc->base + RTC_CR); - - free_irq(dev->irq[0], rtc); - rtc_device_unregister(rtc->rtc); - iounmap(rtc->base); - amba_release_regions(dev); - return 0; }