From: Jonathan Cameron <jic23@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "Michael Turquette" <mturquette@baylibre.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Russell King" <linux@armlinux.org.uk>,
"Nuno Sá" <nuno.sa@analog.com>,
"Jean Delvare" <jdelvare@suse.com>,
"Guenter Roeck" <linux@roeck-us.net>,
"Lars Povlsen" <lars.povlsen@microchip.com>,
"Steen Hegelund" <Steen.Hegelund@microchip.com>,
UNGLinuxDriver@microchip.com, linux-hwmon@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Matt Mackall" <mpm@selenic.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Neil Armstrong" <narmstrong@baylibre.com>,
"David Airlie" <airlied@linux.ie>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Kevin Hilman" <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Paul Cercueil" <paul@crapouillou.net>,
"Alessandro Zummo" <a.zummo@towertech.it>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Wim Van Sebroeck" <wim@linux-watchdog.org>,
"Claudiu Beznea" <claudiu.beznea@microchip.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Lee Jones" <lee.jones@linaro.org>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Oleksij Rempel" <linux@rempel-privat.de>,
"Shawn Guo" <shawnguo@kernel.org>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP Linux Team" <linux-imx@nxp.com>,
"Mark Brown" <broonie@kernel.org>,
"Vinod Koul" <vkoul@kernel.org>,
linux-clk@vger.kernel.org, kernel@pengutronix.de,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Heiko Stuebner" <heiko@sntech.de>,
"Tomislav Denis" <tomislav.denis@avl.com>,
"Anand Ashok Dumbre" <anand.ashok.dumbre@xilinx.com>,
"Michal Simek" <michal.simek@xilinx.com>,
"André Gustavo Nakagomi Lopez" <andregnl@usp.br>,
"Cai Huoqing" <caihuoqing@baidu.com>,
linux-iio@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-amlogic@lists.infradead.org, linux-gpio@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-mips@vger.kernel.org,
linux-rtc@vger.kernel.org,
"Keguang Zhang" <keguang.zhang@gmail.com>,
"Andy Gross" <agross@kernel.org>,
"Bjorn Andersson" <bjorn.andersson@linaro.org>,
"Patrice Chotard" <patrice.chotard@foss.st.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Nobuhiro Iwamatsu" <nobuhiro1.iwamatsu@toshiba.co.jp>,
linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-pwm@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-spi@vger.kernel.org,
"Amireddy Mallikarjuna reddy"
<mallikarjunax.reddy@linux.intel.com>,
dmaengine@vger.kernel.org,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
"Alexandru Ardelean" <aardelean@deviqon.com>
Subject: Re: [PATCH v8 02/16] clk: Provide new devm_clk helpers for prepared and enabled clocks
Date: Sat, 19 Mar 2022 18:29:36 +0000 [thread overview]
Message-ID: <20220319182936.06d75742@jic23-huawei> (raw)
In-Reply-To: <20220314141643.22184-3-u.kleine-koenig@pengutronix.de>
On Mon, 14 Mar 2022 15:16:29 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> When a driver keeps a clock prepared (or enabled) during the whole
> lifetime of the driver, these helpers allow to simplify the drivers.
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
One trivial thing below.
> ---
> drivers/clk/clk-devres.c | 31 ++++++++++++++
> include/linux/clk.h | 90 +++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 120 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
> index fb7761888b30..4707fe718f0b 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 char *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);
Nitpick but this spacing before } in functions is rather unusual and not
in keeping with the existing code in this file.
> +
> +}
> +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 char *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..b011dbba7109 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 enabled.
> *
> * 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 context.
> + *
> + * 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 context.
> + *
> + * The clock will automatically be disabled, unprepared and freed when the
> + * 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 optional
> * clock producer.
> @@ -469,6 +510,29 @@ struct clk *devm_clk_get(struct device *dev, const char *id);
> */
> struct clk *devm_clk_get_optional(struct device *dev, const char *id);
>
> +/**
> + * devm_clk_get_optional_prepared - devm_clk_get_optional() + clk_prepare()
> + * @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 char *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 clock
> + * 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 +877,36 @@ static inline struct clk *devm_clk_get(struct device *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 *dev,
> + 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)
> {
next prev parent reply other threads:[~2022-03-19 18:22 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 14:16 [PATCH v8 00/16] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 01/16] clk: generalize devm_clk_get() a bit Uwe Kleine-König
2022-06-21 19:57 ` Jon Hunter
2022-06-21 20:49 ` Uwe Kleine-König
2022-06-22 10:36 ` Andy Shevchenko
2022-06-22 11:14 ` Neil Armstrong
2022-06-22 15:28 ` Jon Hunter
2022-03-14 14:16 ` [PATCH v8 02/16] clk: Provide new devm_clk helpers for prepared and enabled clocks Uwe Kleine-König
2022-03-19 18:29 ` Jonathan Cameron [this message]
2022-03-21 7:22 ` Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 03/16] hwmon: Make use of devm_clk_get_enabled() Uwe Kleine-König
2022-03-15 23:26 ` Guenter Roeck
2022-03-14 14:16 ` [PATCH v8 04/16] iio: " Uwe Kleine-König
2022-03-14 15:01 ` Sa, Nuno
2022-03-19 18:22 ` Jonathan Cameron
2022-03-21 7:41 ` Uwe Kleine-König
2022-03-22 20:34 ` Jonathan Cameron
2022-03-14 14:16 ` [PATCH v8 05/16] hwrng: meson - Don't open-code devm_clk_get_optional_enabled() Uwe Kleine-König
2022-03-16 8:32 ` Neil Armstrong
2022-03-14 14:16 ` [PATCH v8 06/16] bus: bt1: Don't open code devm_clk_get_enabled() Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 07/16] gpio: vf610: Simplify error handling in probe Uwe Kleine-König
2022-03-14 15:01 ` Bartosz Golaszewski
2022-03-14 14:16 ` [PATCH v8 08/16] drm/meson: dw-hdmi: Don't open code devm_clk_get_enabled() Uwe Kleine-König
2022-03-16 8:33 ` Neil Armstrong
2022-03-14 14:16 ` [PATCH v8 09/16] rtc: ingenic: Simplify using devm_clk_get_enabled() Uwe Kleine-König
2022-03-15 22:47 ` Paul Cercueil
2022-03-14 14:16 ` [PATCH v8 10/16] clk: meson: axg-audio: Don't duplicate devm_clk_get_enabled() Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 11/16] watchdog: Make use of devm_clk_get_enabled() Uwe Kleine-König
2022-03-16 1:29 ` Guenter Roeck
2022-03-14 14:16 ` [PATCH v8 12/16] pwm: atmel: Simplify using devm_clk_get_prepared() Uwe Kleine-König
2022-03-15 9:33 ` Claudiu.Beznea
2022-03-14 14:16 ` [PATCH v8 13/16] rtc: at91sam9: Simplify using devm_clk_get_enabled() Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 14/16] i2c: imx: " Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 15/16] spi: davinci: " Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 16/16] dmaengine: lgm: Fix error handling Uwe Kleine-König
2022-03-15 18:03 ` [PATCH v8 00/16] clk: provide new devm helpers for prepared and enabled clocks Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220319182936.06d75742@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=a.zummo@towertech.it \
--cc=aardelean@deviqon.com \
--cc=agross@kernel.org \
--cc=airlied@linux.ie \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=anand.ashok.dumbre@xilinx.com \
--cc=andregnl@usp.br \
--cc=bjorn.andersson@linaro.org \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=caihuoqing@baidu.com \
--cc=claudiu.beznea@microchip.com \
--cc=daniel@ffwll.ch \
--cc=dmaengine@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=heiko@sntech.de \
--cc=herbert@gondor.apana.org.au \
--cc=jbrunet@baylibre.com \
--cc=jdelvare@suse.com \
--cc=keguang.zhang@gmail.com \
--cc=kernel@pengutronix.de \
--cc=khilman@baylibre.com \
--cc=lars.povlsen@microchip.com \
--cc=lars@metafoo.de \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-mips@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rempel-privat.de \
--cc=linux@roeck-us.net \
--cc=mallikarjunax.reddy@linux.intel.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=michal.simek@xilinx.com \
--cc=mpm@selenic.com \
--cc=mturquette@baylibre.com \
--cc=narmstrong@baylibre.com \
--cc=nicolas.ferre@microchip.com \
--cc=nobuhiro1.iwamatsu@toshiba.co.jp \
--cc=nuno.sa@analog.com \
--cc=patrice.chotard@foss.st.com \
--cc=paul@crapouillou.net \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=tomislav.denis@avl.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vkoul@kernel.org \
--cc=vz@mleia.com \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox