From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6697C433B4 for ; Mon, 10 May 2021 17:09:01 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36C16613C8 for ; Mon, 10 May 2021 17:09:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36C16613C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=Huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BJrdnXrb/nmK+FdlHUKKUCrh9IUL9N0vd4VbUBx0YVY=; b=efj90hgayQJ4CV/D3EojPF+Zl 2uJzsPkZ69LWAWFxVs1B78fYIcDWObGq4Tnp4+d0Lt2iyb0NvJ792EjTGuXCaESU2klAUrD2MFkb+ 6If67ZNCLr8hXRo6amndiOEm1IMV8AraQ5+4Ib1UUv0Jxj+ba3MELt98FQ1BMl+sKwTA0uDTYm0TQ 6bITpfd0RDEfeZcrkgn9vGClZZaII47xfax+vSEnUf8/mAtlgKIjLdbxLiTKn0Pfi+ljDn9pHjuO0 HXxS3+bezKgtD7d/8qA6J/msA9G6+KJvd8iG9h5qygarEqhXR1HcKMdUXe57zo7J3ymUK1GYl8CC2 dePX1AOfQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lg9NI-00F683-KA; Mon, 10 May 2021 17:07:21 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lg9NE-00F67B-4o for linux-arm-kernel@desiato.infradead.org; Mon, 10 May 2021 17:07:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:CC:To: From:Date:Sender:Reply-To:Content-ID:Content-Description; bh=9KWADxnx+QXt10bwXRGHLQLDkrkzPwRNkYwnHhp1aDo=; b=F17xKwfly3eMJkZo8PQrvFqEn0 +8vGJLPCH8DCk9ZFsRPfiCAkomFRao7bfWSKm1hFqBqR3dvYWrz+DOOy1FFhU+NmsAY9YNM8h8PbY V43HAOApDiQtWly8xJLMa/OTd06MekUGXc5up+dmylXEu1GvNIl7Mim4cBQHiJfYKByhDVeNyWxCs 8DNKfS6WX0jvFuz0Q1s3HLBpx30+kmo18kWF/0dWAvM2CwXllbBSx+Q/2SbpCyEcYTjYLq6hIT5lX CijF+/4Mdpw7qlL3NPxFI6qox3CeDF7y8l083zuNJng8xARaYyYWjHcJAg9IELXGVGsKTYZ8fsFJp Dlb718sw==; Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lg9NA-008xYI-Tj for linux-arm-kernel@lists.infradead.org; Mon, 10 May 2021 17:07:14 +0000 Received: from fraeml734-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Ff6lH00Jvz6rnGg; Tue, 11 May 2021 01:01:14 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml734-chm.china.huawei.com (10.206.15.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 10 May 2021 19:07:11 +0200 Received: from localhost (10.52.123.16) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 10 May 2021 18:07:09 +0100 Date: Mon, 10 May 2021 18:05:27 +0100 From: Jonathan Cameron To: Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= CC: Michael Turquette , Stephen Boyd , , , Alexandre Belloni , Alessandro Zummo , Mark Brown , Claudiu Beznea , Wolfram Sang , "Oleksij Rempel" , Ludovic Desroches , Thierry Reding , , Andrew Morton , , Lee Jones , , Subject: Re: [PATCH v6 RESEND 2/6] clk: Provide new devm_clk_helpers for prepared and enabled clocks Message-ID: <20210510180527.00006fbf@Huawei.com> In-Reply-To: <20210510061724.940447-3-u.kleine-koenig@pengutronix.de> References: <20210510061724.940447-1-u.kleine-koenig@pengutronix.de> <20210510061724.940447-3-u.kleine-koenig@pengutronix.de> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.52.123.16] X-ClientProxiedBy: lhreml720-chm.china.huawei.com (10.201.108.71) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_100713_287052_95717813 X-CRM114-Status: GOOD ( 27.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 10 May 2021 08:17:20 +0200 Uwe Kleine-K=F6nig wrote: > When a driver keeps a clock prepared (or enabled) during the whole > lifetime of the driver, these helpers allow to simplify the drivers. > = > Signed-off-by: Uwe Kleine-K=F6nig Given it's not hard to do, might be nice to keep the docs lines under 80 ch= ars. Other than that... Does what it says on the tin. Reviewed-by: Jonathan Cameron > --- > drivers/clk/clk-devres.c | 31 ++++++++++++++ > include/linux/clk.h | 87 +++++++++++++++++++++++++++++++++++++++- > 2 files changed, 117 insertions(+), 1 deletion(-) > = > diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c > index 91c995815b57..b54f7f0f2a35 100644 > --- a/drivers/clk/clk-devres.c > +++ b/drivers/clk/clk-devres.c > @@ -67,12 +67,43 @@ struct clk *devm_clk_get(struct device *dev, const ch= ar *id) > } > EXPORT_SYMBOL(devm_clk_get); > = > +struct clk *devm_clk_get_prepared(struct device *dev, const char *id) > +{ > + return __devm_clk_get(dev, id, clk_get, clk_prepare, clk_unprepare); > + > +} > +EXPORT_SYMBOL(devm_clk_get_prepared); > + > +struct clk *devm_clk_get_enabled(struct device *dev, const char *id) > +{ > + return __devm_clk_get(dev, id, clk_get, > + clk_prepare_enable, clk_disable_unprepare); > + > +} > +EXPORT_SYMBOL(devm_clk_get_enabled); > + > struct clk *devm_clk_get_optional(struct device *dev, const char *id) > { > return __devm_clk_get(dev, id, clk_get_optional, NULL, NULL); > } > EXPORT_SYMBOL(devm_clk_get_optional); > = > +struct clk *devm_clk_get_optional_prepared(struct device *dev, const cha= r *id) > +{ > + return __devm_clk_get(dev, id, clk_get_optional, > + clk_prepare, clk_unprepare); > + > +} > +EXPORT_SYMBOL(devm_clk_get_optional_prepared); > + > +struct clk *devm_clk_get_optional_enabled(struct device *dev, const char= *id) > +{ > + return __devm_clk_get(dev, id, clk_get_optional, > + clk_prepare_enable, clk_disable_unprepare); > + > +} > +EXPORT_SYMBOL(devm_clk_get_optional_enabled); > + > struct clk_bulk_devres { > struct clk_bulk_data *clks; > int num_clks; > diff --git a/include/linux/clk.h b/include/linux/clk.h > index 266e8de3cb51..b3c5da388b08 100644 > --- a/include/linux/clk.h > +++ b/include/linux/clk.h > @@ -449,7 +449,7 @@ int __must_check devm_clk_bulk_get_all(struct device = *dev, > * the clock producer. (IOW, @id may be identical strings, but > * clk_get may return different clock producers depending on @dev.) > * > - * Drivers must assume that the clock source is not enabled. > + * Drivers must assume that the clock source is neither prepared nor ena= bled. > * > * devm_clk_get should not be called from within interrupt context. > * > @@ -458,6 +458,47 @@ int __must_check devm_clk_bulk_get_all(struct device= *dev, > */ > struct clk *devm_clk_get(struct device *dev, const char *id); > = > +/** > + * devm_clk_get_prepared - devm_clk_get() + clk_prepare() > + * @dev: device for clock "consumer" > + * @id: clock consumer ID > + * > + * Returns a struct clk corresponding to the clock producer, or > + * valid IS_ERR() condition containing errno. The implementation > + * uses @dev and @id to determine the clock consumer, and thereby > + * the clock producer. (IOW, @id may be identical strings, but > + * clk_get may return different clock producers depending on @dev.) > + * > + * The returned clk (if valid) is prepared. Drivers must however assume = that the > + * clock is not enabled. > + * > + * devm_clk_get_prepared should not be called from within interrupt cont= ext. > + * > + * The clock will automatically be unprepared and freed when the > + * device is unbound from the bus. > + */ > +struct clk *devm_clk_get_prepared(struct device *dev, const char *id); > + > +/** > + * devm_clk_get_enabled - devm_clk_get() + clk_prepare_enable() > + * @dev: device for clock "consumer" > + * @id: clock consumer ID > + * > + * Returns a struct clk corresponding to the clock producer, or > + * valid IS_ERR() condition containing errno. The implementation > + * uses @dev and @id to determine the clock consumer, and thereby > + * the clock producer. (IOW, @id may be identical strings, but > + * clk_get may return different clock producers depending on @dev.) > + * > + * The returned clk (if valid) is prepared and enabled. > + * > + * devm_clk_get_prepared should not be called from within interrupt cont= ext. > + * > + * The clock will automatically be disabled, unprepared and freed when t= he > + * device is unbound from the bus. > + */ > +struct clk *devm_clk_get_enabled(struct device *dev, const char *id); > + > /** > * devm_clk_get_optional - lookup and obtain a managed reference to an o= ptional > * clock producer. > @@ -469,6 +510,26 @@ struct clk *devm_clk_get(struct device *dev, const c= har *id); > */ > struct clk *devm_clk_get_optional(struct device *dev, const char *id); > = > +/** > + * devm_clk_get_optional_prepared - devm_clk_get_optional() + clk_prepar= e() > + * @dev: device for clock "consumer" > + * @id: clock consumer ID > + * > + * Behaves the same as devm_clk_get_prepared() except where there is no = clock producer. > + * In this case, instead of returning -ENOENT, the function returns NULL. > + */ > +struct clk *devm_clk_get_optional_prepared(struct device *dev, const cha= r *id); > + > +/** > + * devm_clk_get_optional_enabled - devm_clk_get_optional() + clk_prepare= _enable() > + * @dev: device for clock "consumer" > + * @id: clock consumer ID > + * > + * Behaves the same as devm_clk_get_enabled() except where there is no c= lock producer. > + * In this case, instead of returning -ENOENT, the function returns NULL. > + */ > +struct clk *devm_clk_get_optional_enabled(struct device *dev, const char= *id); > + > /** > * devm_get_clk_from_child - lookup and obtain a managed reference to a > * clock producer from child node. > @@ -813,12 +874,36 @@ static inline struct clk *devm_clk_get(struct devic= e *dev, const char *id) > return NULL; > } > = > +static inline struct clk *devm_clk_get_prepared(struct device *dev, > + const char *id) > +{ > + return NULL; > +} > + > +static inline struct clk *devm_clk_get_enabled(struct device *dev, > + const char *id) > +{ > + return NULL; > +} > + > static inline struct clk *devm_clk_get_optional(struct device *dev, > const char *id) > { > return NULL; > } > = > +static inline struct clk *devm_clk_get_optional_prepared(struct device *= dev, > + const char *id) > +{ > + return NULL; > +} > + > +static inline struct clk *devm_clk_get_optional_enabled(struct device *d= ev, > + const char *id) > +{ > + return NULL; > +} > + > static inline int __must_check devm_clk_bulk_get(struct device *dev, int= num_clks, > struct clk_bulk_data *clks) > { _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel