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: 9645405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F70D602BF for ; Mon, 27 Mar 2017 07:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 619D328334 for ; Mon, 27 Mar 2017 07:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 567F328358; Mon, 27 Mar 2017 07:08:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9201028334 for ; Mon, 27 Mar 2017 07:08:51 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6F150266925; Mon, 27 Mar 2017 09:07:58 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id B639C266BF5; Sun, 26 Mar 2017 16:42:38 +0200 (CEST) Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by alsa0.perex.cz (Postfix) with ESMTP id AB02A266947 for ; Sun, 26 Mar 2017 16:42:36 +0200 (CEST) Received: by mail-wr0-f179.google.com with SMTP id u1so22386346wra.2 for ; Sun, 26 Mar 2017 07:42:36 -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=VHJ5J9fazhkJVv090x4Lf9W2xfXoz7lmTxuZIu1jNw//NSVxL3eDD6bMVGgi17dayR yQuQZPMZllo8vmWkaSOEBSPsGBrD5aHtSQYQq1hoaP7XY0EZ0x/X3TblcL7pBaD3o1ro uCp3ceROoH/dHgM5mHrO2LfYZchP5Fi8lULkHzDR1o+c7C5BsFQH8V4AiQ4p4WNYbHnq 7EApMi/dkG68dPyYNM+TkjV7C6PNDXBkqrKbjCre5TOrFURxDN61t4FlOluqRlYITGw+ +V7RJjSe+BAKEcrokc2LVru3p5CuHbnBLCn//l76KY//4jknPYqqVxIBkJMIhjvou/Pw 2xzg== X-Gm-Message-State: AFeK/H1Ovq+7qpmmlDoOdvT+xEA72NRb1DmWd6s/O65Jmnsp3aq3xeeAAdG1jUODbax8AMgk 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 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> X-Mailman-Approved-At: Mon, 27 Mar 2017 09:07:53 +0200 Cc: Leo Yan Subject: [alsa-devel] [PATCH 2/5] drivers/rtc/rtc-pl030.c: Convert to use devm_*() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Linus Walleij --- drivers/rtc/rtc-pl030.c | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) 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; }