From patchwork Sat Jul 8 05:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13305583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3BC2EB64DA for ; Sat, 8 Jul 2023 06:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229569AbjGHGAI (ORCPT ); Sat, 8 Jul 2023 02:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjGHGAH (ORCPT ); Sat, 8 Jul 2023 02:00:07 -0400 X-Greylist: delayed 450 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 07 Jul 2023 23:00:06 PDT Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CD3A1FD7 for ; Fri, 7 Jul 2023 23:00:06 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id I0rxqTlyvRB5SI0rxquFMX; Sat, 08 Jul 2023 07:52:34 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1688795554; bh=EGyCQ+d+OCqRwxDpLY5KNbRs5E578htE1W8st+IJ468=; h=From:To:Cc:Subject:Date; b=Dui6EM4NFd593PWVsaO0qpmZ9aFC5da/oWzPekGtAcOsAuhiR0ldfmxWXbDN9oQ8O WKT15IGBP4I8q7bYNfiCn9ro0y1zyKrY2gQu4dHQmtq1izRrYuHIu8PGmmMRq4lN9M 1FlydBmKeggC44TLVoUj5Tl2PSA5x4/tlp54ruLRdDpvg6FDdnfj/O+S9kZHxpUg5Q XtqVuez2vfFnllirHeczZeVwubOkiDhzr/wBzzvjaTg1v7AuYTFA/GXTDfa1sDKf8i PI+EiChH+RP9KNqqie1j+vlcQKP1gAl3S8UcixzTwIkWCvvtXiUC1Lsn+iayRMQ7Ml 8+Qqxy2uJS+Bg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 08 Jul 2023 07:52:34 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jean Delvare , Guenter Roeck Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-hwmon@vger.kernel.org Subject: [PATCH] hwmon: lan966x: Use the devm_clk_get_enabled() helper function Date: Sat, 8 Jul 2023 07:52:31 +0200 Message-Id: <25f2ab4c61d4fc48e8200f8754bb446f2b89ea89.1688795527.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Use the devm_clk_get_enabled() helper function instead of hand-writing it. It saves some line of codes. Signed-off-by: Christophe JAILLET --- drivers/hwmon/lan966x-hwmon.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/hwmon/lan966x-hwmon.c b/drivers/hwmon/lan966x-hwmon.c index f8658359a098..7247c03e4f44 100644 --- a/drivers/hwmon/lan966x-hwmon.c +++ b/drivers/hwmon/lan966x-hwmon.c @@ -334,24 +334,6 @@ static struct regmap *lan966x_init_regmap(struct platform_device *pdev, return devm_regmap_init_mmio(&pdev->dev, base, ®map_config); } -static void lan966x_clk_disable(void *data) -{ - struct lan966x_hwmon *hwmon = data; - - clk_disable_unprepare(hwmon->clk); -} - -static int lan966x_clk_enable(struct device *dev, struct lan966x_hwmon *hwmon) -{ - int ret; - - ret = clk_prepare_enable(hwmon->clk); - if (ret) - return ret; - - return devm_add_action_or_reset(dev, lan966x_clk_disable, hwmon); -} - static int lan966x_hwmon_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -363,15 +345,11 @@ static int lan966x_hwmon_probe(struct platform_device *pdev) if (!hwmon) return -ENOMEM; - hwmon->clk = devm_clk_get(dev, NULL); + hwmon->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(hwmon->clk)) return dev_err_probe(dev, PTR_ERR(hwmon->clk), "failed to get clock\n"); - ret = lan966x_clk_enable(dev, hwmon); - if (ret) - return dev_err_probe(dev, ret, "failed to enable clock\n"); - hwmon->clk_rate = clk_get_rate(hwmon->clk); hwmon->regmap_pvt = lan966x_init_regmap(pdev, "pvt");