Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2393826ybh; Mon, 16 Mar 2020 02:17:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuUWwD3BtBdtF0zSB3kEKDHNVn7abpPwo+DKIWXjcCV0gTCljBogQqzRevQFZ4N600yQTKC X-Received: by 2002:a9d:a51:: with SMTP id 75mr21133974otg.112.1584350228749; Mon, 16 Mar 2020 02:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584350228; cv=none; d=google.com; s=arc-20160816; b=au6/yGLGe9KU4HQPBlOBHSu1XNTHkLAYcIJhBnDglUqWXIxSIH6bG1v3mZJEbhS48/ CzBiuux8b2r61DIYk1fDQXAMZ7Da77WER2PHxHDhwuYFkIiT1XhzCcurhdbHAzyNlll+ VXSOpgF7Wj7u9qPUKji20JYKfJWXqlMGLvHO7yr5GXRa17m2SU5SCI1GrCyGeHpILhRS JllN/oxXzm47QjWV6QItBRoy8hX/L2lcr9yOo8wQzsMgenlB66gDZJ4t4geHpuCfjtI+ EEZAVGiCQImw4yHvraNMzkPZ2gL1HSH3NEsLxKeac/IX7Pi9sdiS04mDlzWRAf2/L/9I KqTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=fd6w0gc/lKL6G2uMGS77uiIIc7Aks5O8nVo6TxVkv3E=; b=A4uaCKm2LaZE4G8e50TIsUkc4wZTxy85oC6iiUTG4Xf1jwnODWwrR3QwhUWQWlfMW9 1GQGWmdqiNPQOU+GGyaNnjtpgp0dXESW+0SNMU04iJ03R8XomXYPKCiNtMxsJ/pv0JZQ EaK8yS2vOS9I3lDpNHQJpUYBRmH8J4s6l4kO65H6oQ5dWpUMeRtuXAtzy+B8kYwMHmCX i6NLEOKYRvYzUuSZOngeQ3ImnEpGkG5LocNflkkeqTPMdmVE0HJdumWY4oa6g9AvZ7LY ehYBpQIO4UZSDb+jTsZJBHXJni+SRHadMFtCrd63my5QTPiaBHcNbSFy/Lo/YzQa2zv+ cevA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si9458955oth.274.2020.03.16.02.16.55; Mon, 16 Mar 2020 02:17:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730321AbgCPJQ2 (ORCPT + 99 others); Mon, 16 Mar 2020 05:16:28 -0400 Received: from inva020.nxp.com ([92.121.34.13]:42698 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730056AbgCPJQ2 (ORCPT ); Mon, 16 Mar 2020 05:16:28 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 310F91A094F; Mon, 16 Mar 2020 10:16:26 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 349B51A0945; Mon, 16 Mar 2020 10:16:23 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 3CAD2402C4; Mon, 16 Mar 2020 17:16:19 +0800 (SGT) From: Anson Huang To: a.zummo@towertech.it, alexandre.belloni@bootlin.com, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH] rtc: mxc: Use devm_add_action_or_reset() for calls to clk_disable_unprepare() Date: Mon, 16 Mar 2020 17:09:45 +0800 Message-Id: <1584349785-27042-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_add_action_or_reset() for calls to clk_disable_unprepare(), which can simplify the error handling, and .remove callback can be dropped. Signed-off-by: Anson Huang --- drivers/rtc/rtc-mxc.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 902d57d..a8cfbde 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c @@ -307,6 +307,14 @@ static const struct rtc_class_ops mxc_rtc_ops = { .alarm_irq_enable = mxc_rtc_alarm_irq_enable, }; +static void mxc_rtc_action(void *p) +{ + struct rtc_plat_data *pdata = p; + + clk_disable_unprepare(pdata->clk_ref); + clk_disable_unprepare(pdata->clk_ipg); +} + static int mxc_rtc_probe(struct platform_device *pdev) { struct rtc_device *rtc; @@ -366,14 +374,20 @@ static int mxc_rtc_probe(struct platform_device *pdev) pdata->clk_ref = devm_clk_get(&pdev->dev, "ref"); if (IS_ERR(pdata->clk_ref)) { + clk_disable_unprepare(pdata->clk_ipg); dev_err(&pdev->dev, "unable to get ref clock!\n"); - ret = PTR_ERR(pdata->clk_ref); - goto exit_put_clk_ipg; + return PTR_ERR(pdata->clk_ref); } ret = clk_prepare_enable(pdata->clk_ref); + if (ret) { + clk_disable_unprepare(pdata->clk_ipg); + return ret; + } + + ret = devm_add_action_or_reset(&pdev->dev, mxc_rtc_action, pdata); if (ret) - goto exit_put_clk_ipg; + return ret; rate = clk_get_rate(pdata->clk_ref); @@ -385,16 +399,14 @@ static int mxc_rtc_probe(struct platform_device *pdev) reg = RTC_INPUT_CLK_38400HZ; else { dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", rate); - ret = -EINVAL; - goto exit_put_clk_ref; + return -EINVAL; } reg |= RTC_ENABLE_BIT; writew(reg, (pdata->ioaddr + RTC_RTCCTL)); if (((readw(pdata->ioaddr + RTC_RTCCTL)) & RTC_ENABLE_BIT) == 0) { dev_err(&pdev->dev, "hardware module can't be enabled!\n"); - ret = -EIO; - goto exit_put_clk_ref; + return -EIO; } platform_set_drvdata(pdev, pdata); @@ -417,29 +429,10 @@ static int mxc_rtc_probe(struct platform_device *pdev) } ret = rtc_register_device(rtc); - if (ret) - goto exit_put_clk_ref; - - return 0; - -exit_put_clk_ref: - clk_disable_unprepare(pdata->clk_ref); -exit_put_clk_ipg: - clk_disable_unprepare(pdata->clk_ipg); return ret; } -static int mxc_rtc_remove(struct platform_device *pdev) -{ - struct rtc_plat_data *pdata = platform_get_drvdata(pdev); - - clk_disable_unprepare(pdata->clk_ref); - clk_disable_unprepare(pdata->clk_ipg); - - return 0; -} - static struct platform_driver mxc_rtc_driver = { .driver = { .name = "mxc_rtc", @@ -447,7 +440,6 @@ static struct platform_driver mxc_rtc_driver = { }, .id_table = imx_rtc_devtype, .probe = mxc_rtc_probe, - .remove = mxc_rtc_remove, }; module_platform_driver(mxc_rtc_driver) -- 2.7.4