Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1800691ybh; Fri, 13 Mar 2020 07:38:31 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt1v1xZ2uxQz2X0bL9icZQmtEcVW3qigXQTZWgIUNAheUahCfrSgvVTCjdGkMRX+FIEQm2M X-Received: by 2002:aca:fd44:: with SMTP id b65mr6828095oii.119.1584110311251; Fri, 13 Mar 2020 07:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584110311; cv=none; d=google.com; s=arc-20160816; b=J9V++CRcApqbizR0u33QKQbU4yNIvqJXAODEBsueM0OeHchNZIGMU9ET4Wwk2OXZI2 BYYYUsHoLk8iLJ5tDEJRyN4ZStVZD6oaLwl2/8qZVC6e31mVUzmFOnY/8/sbHQdiq/Gf xYLgoCn17uqWU/qrqzwzOgo+n/G2XHY6UN43eLWuWECBr5rxJ079T18y/vyHuCyWfv6/ EdYa/Sn62LZxLi0ZrFzGeyHWO9DITlq9wPgo4wyihNoVCXxR48OLeMttHefJb+GGFs+n dcchOkZbuXxE/pJk8TnITz+AoQ/ihSMHqk34Adyr8uELQF9QG3OJeM8BbmnlR3R3D4F8 KIQw== 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=lOP3z4VbcZ5Kaost3np93kVe8ibUUF3kRf2K/t7bnmo=; b=M3KpLQ23g589iIms6vcqkSfuggIhJietsLqi9ntJHwvu5Owkgu7AS6laGBKPySZVv4 Dlma7FRGIQqEhrcM/l893jhOa0WTCRY1drAGbqglaaTucFwgmnx0qkmdh5dGUP6NYwiz vEw6z+2rbpDo+mpgRBq+azGYAg+EIR2wuXC2+gKMgBosgAKuBF0zZW8XggC4Bsu4rrLa G9HZd14Ip5sEQYxkVp+jfGajQoQBkmp+/QmmpF6se7003+mROygu5r3I3xW/tCz+ImSV kMFsJLOOO92YL/v+1vKF3i/k0lkp2bSdFraV2efxkIM6FXlpcfgBgJvPEQph8reBe9P9 3Mvg== 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 d7si4870666ote.131.2020.03.13.07.38.19; Fri, 13 Mar 2020 07:38:31 -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 S1726691AbgCMOhY (ORCPT + 99 others); Fri, 13 Mar 2020 10:37:24 -0400 Received: from inva020.nxp.com ([92.121.34.13]:34874 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726216AbgCMOhY (ORCPT ); Fri, 13 Mar 2020 10:37:24 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D733A1A1499; Fri, 13 Mar 2020 15:37:21 +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 D9CEE1A1478; Fri, 13 Mar 2020 15:37:18 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id E18AE402A5; Fri, 13 Mar 2020 22:37:14 +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: snvs: Use devm_add_action_or_reset() for calls to clk_disable_unprepare() Date: Fri, 13 Mar 2020 22:30:49 +0800 Message-Id: <1584109849-21402-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. Signed-off-by: Anson Huang --- drivers/rtc/rtc-snvs.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index 7630089..319ed1d 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c @@ -263,6 +263,12 @@ static const struct regmap_config snvs_rtc_config = { .reg_stride = 4, }; +static void snvs_rtc_action(void *data) +{ + if (data) + clk_disable_unprepare(data); +} + static int snvs_rtc_probe(struct platform_device *pdev) { struct snvs_rtc_data *data; @@ -313,6 +319,10 @@ static int snvs_rtc_probe(struct platform_device *pdev) } } + ret = devm_add_action_or_reset(&pdev->dev, snvs_rtc_action, data->clk); + if (ret) + return ret; + platform_set_drvdata(pdev, data); /* Initialize glitch detect */ @@ -325,7 +335,7 @@ static int snvs_rtc_probe(struct platform_device *pdev) ret = snvs_rtc_enable(data, true); if (ret) { dev_err(&pdev->dev, "failed to enable rtc %d\n", ret); - goto error_rtc_device_register; + return ret; } device_init_wakeup(&pdev->dev, true); @@ -338,22 +348,14 @@ static int snvs_rtc_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "failed to request irq %d: %d\n", data->irq, ret); - goto error_rtc_device_register; + return ret; } data->rtc->ops = &snvs_rtc_ops; data->rtc->range_max = U32_MAX; ret = rtc_register_device(data->rtc); - if (ret) { + if (ret) dev_err(&pdev->dev, "failed to register rtc: %d\n", ret); - goto error_rtc_device_register; - } - - return 0; - -error_rtc_device_register: - if (data->clk) - clk_disable_unprepare(data->clk); return ret; } -- 2.7.4