From patchwork Thu Jun 8 19:12:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 105089 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp488073vqr; Thu, 8 Jun 2023 12:13:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MU4FjSA/t8G2W3J2r+lDfmr7uRwJer6CKLYiv5yDCOT3lSTedcglNJUIRMEfeC3HHqVJK X-Received: by 2002:a05:6a20:b796:b0:10f:52e2:49ec with SMTP id fh22-20020a056a20b79600b0010f52e249ecmr3692060pzb.53.1686251608959; Thu, 08 Jun 2023 12:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686251608; cv=none; d=google.com; s=arc-20160816; b=ify/m96n3xlfMvKlH6Aa5Kd+a7V3uJ9cMAuky1cgq8M1hQUw/XiYPUNwB4Pb2NrFAr bY7d2S92PBa/4uGB7fB8EjaZPKbVEJblNhvBnxGA3DygBJOIX4fZf7NqB7Azwb0G3KDa XCBw60d7EGNDpMm4Hm738eCO3YSaVWBBszVE//DQ7B+u/Uxisrt1e/au64x4A57tEMv5 uRfjVIWzD6vcuEe9/sXe5oK2syPvmYFQV78LgJFiCEDjlw777GW1RDVu+PvUG4cz1juQ +Fr9rAeHR/JMVaEShLpSdMOR9NsWJ0rwjusGHwhm/ECer0CwIselmCcoWz9PjfPtndKa zfiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hqcGyIGMqLhHLJ6KCJoyUKD++6o+2VySY5s7lD2Ospo=; b=JB7fUIiMhCLqV/4MhxnFBpZBoWCGEeNmP9p1gSSJQNB42no9hUTuDAvNttJoQCU/gc m/yaxUPAXK0ni78VlHAhsk1q8k8wQgRaxoKb0ekzwaHwDOs0BD5YbuEJi7UfhcNlq8YO z3kEGti0nDbWDFAsldU9uV5IhfEBFFA95avQGgbCUeFAV9Tu7+FpAQ2Y2pc2btNR3VqB ao0zyihs+jlzYT2dF1J+cUtRfXcAUfIIXv6fhnm8CnxHvtQQFUXtbxV4D9cuzSKVZIdw xenR/ie3TJJB0QLPnLu87G/T3g6t/Byfne/h659KMZi7MdsUoL8m4z6lHxpZ9zV3Hukt GPXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=adYpnyWI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n19-20020a635c53000000b005300dbf81d5si1407177pgm.496.2023.06.08.12.13.13; Thu, 08 Jun 2023 12:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=adYpnyWI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236125AbjFHTMO (ORCPT + 99 others); Thu, 8 Jun 2023 15:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232139AbjFHTML (ORCPT ); Thu, 8 Jun 2023 15:12:11 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F27552D56 for ; Thu, 8 Jun 2023 12:12:04 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 7L3Bqt4nXtjdE7L3Cqf3FS; Thu, 08 Jun 2023 21:12:03 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686251523; bh=hqcGyIGMqLhHLJ6KCJoyUKD++6o+2VySY5s7lD2Ospo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=adYpnyWIsE+lirv6ljQWvlWdzTp6I48lT1yTbJYGXniMO5ygVe0wz0PnqAlRXM/Cq 2WqQ0HOxhI0ls4xsKOAasQ9k6NMHnQAiOI4oANs4ZuaX0prxGpcxU5IHZ+kCN+QLcX dBnmgq0UWPkHF14yyG/0UgsHV/a5KI+NKBchUZEc2nMf8eCM4UOTnyWiFBo12P/dKO FHXPIww/myOobUQoYv96RI3DWHadN+c0/PudBPpvbIWJ+lBeq7NNVpPhO4WIHIaF89 mweY/oxObL4dc1prmtq4IwUSFc1jPIFecI+Sk0uNSr5qgT8zanhSQ5y1X+z9KR7qM3 8+pwSBOSsYnTQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 08 Jun 2023 21:12:03 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Patrice Chotard , Alessandro Zummo , Alexandre Belloni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org Subject: [PATCH 2/2] rtc: st-lpc: Simplify clk handling in st_rtc_probe() Date: Thu, 8 Jun 2023 21:12:00 +0200 Message-Id: <992dd8c31be0bb5b8a9d8b5e8e94807ab0848a66.1686251455.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <866af6adbc7454a7b4505eb6c28fbdc86ccff39e.1686251455.git.christophe.jaillet@wanadoo.fr> References: <866af6adbc7454a7b4505eb6c28fbdc86ccff39e.1686251455.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768162966823451641?= X-GMAIL-MSGID: =?utf-8?q?1768162966823451641?= Use devm_clk_get_enabled() instead of hand writing it. This simplifies error handling and removes some lines of code. Also use dev_err_probe() which filters -EPROBE_DEFER. Signed-off-by: Christophe JAILLET --- drivers/rtc/rtc-st-lpc.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-st-lpc.c b/drivers/rtc/rtc-st-lpc.c index d04d46f9cc65..d492a2d26600 100644 --- a/drivers/rtc/rtc-st-lpc.c +++ b/drivers/rtc/rtc-st-lpc.c @@ -228,17 +228,13 @@ static int st_rtc_probe(struct platform_device *pdev) enable_irq_wake(rtc->irq); disable_irq(rtc->irq); - rtc->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(rtc->clk)) { - dev_err(&pdev->dev, "Unable to request clock\n"); - return PTR_ERR(rtc->clk); - } - - clk_prepare_enable(rtc->clk); + rtc->clk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(rtc->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(rtc->clk), + "Unable to request clock\n"); rtc->clkrate = clk_get_rate(rtc->clk); if (!rtc->clkrate) { - clk_disable_unprepare(rtc->clk); dev_err(&pdev->dev, "Unable to fetch clock rate\n"); return -EINVAL; } @@ -252,10 +248,8 @@ static int st_rtc_probe(struct platform_device *pdev) do_div(rtc->rtc_dev->range_max, rtc->clkrate); ret = devm_rtc_register_device(rtc->rtc_dev); - if (ret) { - clk_disable_unprepare(rtc->clk); + if (ret) return ret; - } return 0; }