Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp330919rwe; Wed, 24 Aug 2022 01:32:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7hJV5Xk2KgWJrZ2p6/jj6R3Mscpg0OyCLRdeL+fHj+4hKqbJYqjuBwnd/rWcSXmA8g9nns X-Received: by 2002:a63:cf44:0:b0:42a:277:1cb8 with SMTP id b4-20020a63cf44000000b0042a02771cb8mr23431071pgj.198.1661329953799; Wed, 24 Aug 2022 01:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661329953; cv=none; d=google.com; s=arc-20160816; b=W9b07A6+Q27E5Q8sUCkN5YMYHtuWeuHEojz2bAXW8ZAVprBNGxdQHw/ok/GroAI38S 1JK43jETBAXDBP/HfWsfNg1Ner1437lctMlYL5mrd0nvLrW7MTuyqAaoJNin8WAmpY13 P2Pj55UJusGmZmfQ0AVd4djW07T+q2l8bi9Wuc3//bjhjojICrc0mDG+XaTBxgGdTEY9 LTVUOFmQIMP4mZY+/jRgS5DiykXqtv6rCJuZhyly6+BUTmnorwp+ej8zX7xa/U49wGtZ 4nuAhpRu7DOFJkG879S74rFvaiiV45ZCDbLZnEMS66MY7NEyrecjw9I8g/aojLOzoyfR PpoA== 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 :message-id:date:subject:cc:to:from; bh=jt2/VXbNd+56rTGJJzI5TCjyK7BZ5VlH/u/PmJ26pio=; b=a489p/hKaEVjQ56bVG9GnMM3r4L9S+AatgBjD5CT2zx9TKzzmQaK0dlMu4DJqRibRX PnZZcty7a+yJnMv7o2M5DahJB1lNCB7g4PRCgiYoAxTb3K8DmcrdezdX1aBMuckMrMqZ 0AoakxqEO0qdAjFlcVCjqCmQCuisMriY/mO5j6bpPJCfdiXvcM+NaVbTQL1H0wxRUZlC aLnL6F3i/h5DbGH3pck4oA8v1HSMB0wFDOJLa4T5AxZH25I29nTT8HOPZC51eIkKUyBY rjOvG0Cnrw2WoHQnHgKoGxxoOIr+qg5pS5XImEeTgBdyqi+bFMbcPw9IME6THNahfbuq c9KA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my11-20020a17090b4c8b00b001fb706e96adsi864489pjb.136.2022.08.24.01.32.22; Wed, 24 Aug 2022 01:32:33 -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; 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 S235602AbiHXISi (ORCPT + 99 others); Wed, 24 Aug 2022 04:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234996AbiHXISd (ORCPT ); Wed, 24 Aug 2022 04:18:33 -0400 Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4495D861D8 for ; Wed, 24 Aug 2022 01:18:31 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id QlamoIOe1ez1rQlamoU0BV; Wed, 24 Aug 2022 10:18:29 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 24 Aug 2022 10:18:29 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Conor Dooley , Daire McNamara , Alessandro Zummo , Alexandre Belloni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-riscv@lists.infradead.org, linux-rtc@vger.kernel.org Subject: [PATCH] rtc: mpfs: Use devm_clk_get_enabled() helper Date: Wed, 24 Aug 2022 10:18:25 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 The devm_clk_get_enabled() helper: - calls devm_clk_get() - calls clk_prepare_enable() and registers what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code, the error handling paths and avoid the need of a dedicated function used with devm_add_action_or_reset(). That said, mpfs_rtc_init_clk() is the same as devm_clk_get_enabled(), so use this function directly instead. This also fixes an (unlikely) unchecked devm_add_action_or_reset() error. Based on my test with allyesconfig, this reduces the .o size from: text data bss dec hex filename 5330 2208 0 7538 1d72 drivers/rtc/rtc-mpfs.o down to: 5074 2208 0 7282 1c72 drivers/rtc/rtc-mpfs.o Signed-off-by: Christophe JAILLET --- devm_clk_get_enabled() is new and is part of 6.0-rc1 --- drivers/rtc/rtc-mpfs.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/rtc/rtc-mpfs.c b/drivers/rtc/rtc-mpfs.c index 944ad1036516..2a479d44f198 100644 --- a/drivers/rtc/rtc-mpfs.c +++ b/drivers/rtc/rtc-mpfs.c @@ -193,23 +193,6 @@ static int mpfs_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) return 0; } -static inline struct clk *mpfs_rtc_init_clk(struct device *dev) -{ - struct clk *clk; - int ret; - - clk = devm_clk_get(dev, "rtc"); - if (IS_ERR(clk)) - return clk; - - ret = clk_prepare_enable(clk); - if (ret) - return ERR_PTR(ret); - - devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare, clk); - return clk; -} - static irqreturn_t mpfs_rtc_wakeup_irq_handler(int irq, void *dev) { struct mpfs_rtc_dev *rtcdev = dev; @@ -251,7 +234,7 @@ static int mpfs_rtc_probe(struct platform_device *pdev) /* range is capped by alarm max, lower reg is 31:0 & upper is 10:0 */ rtcdev->rtc->range_max = GENMASK_ULL(42, 0); - clk = mpfs_rtc_init_clk(&pdev->dev); + clk = devm_clk_get_enabled(&pdev->dev, "rtc"); if (IS_ERR(clk)) return PTR_ERR(clk); -- 2.34.1