From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: ssantosh@kernel.org, "Rafael J. Wysocki" <rjw@rjwysocki.net>,
khilman@linaro.org, linux-pm@vger.kernel.org,
Rob Herring <robh+dt@kernel.org>,
grant.likely@secretlab.ca, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
Ulf Hansson <ulf.hansson@linaro.org>,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH v4 1/3] PM / clock_ops: Add pm_clk_add_clk()
Date: Thu, 6 Nov 2014 09:31:28 -0800 [thread overview]
Message-ID: <20141106173128.GC34214@dtor-ws> (raw)
In-Reply-To: <1415281862-23764-2-git-send-email-grygorii.strashko@ti.com>
On Thu, Nov 06, 2014 at 03:51:00PM +0200, Grygorii Strashko wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
>
> The existing pm_clk_add() allows to pass a clock by con_id. However,
> when referring to a specific clock from DT, no con_id is available.
>
> Add pm_clk_add_clk(), which allows to specify the struct clk * directly.
> The will will increment refcount on clock pointer, so the caller has
> to use clk_put() on clock pointer when done.
>
> CC: Ulf Hansson <ulf.hansson@linaro.org>
> CC: Geert Uytterhoeven <geert@linux-m68k.org>
> CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/base/power/clock_ops.c | 47 +++++++++++++++++++++++++++++++++---------
> include/linux/pm_clock.h | 8 +++++++
> 2 files changed, 45 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> index 7836930..f061eaa 100644
> --- a/drivers/base/power/clock_ops.c
> +++ b/drivers/base/power/clock_ops.c
> @@ -12,6 +12,7 @@
> #include <linux/pm.h>
> #include <linux/pm_clock.h>
> #include <linux/clk.h>
> +#include <linux/clkdev.h>
> #include <linux/slab.h>
> #include <linux/err.h>
>
> @@ -53,7 +54,8 @@ static inline int __pm_clk_enable(struct device *dev, struct clk *clk)
> */
> static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> {
> - ce->clk = clk_get(dev, ce->con_id);
> + if (!ce->clk)
> + ce->clk = clk_get(dev, ce->con_id);
> if (IS_ERR(ce->clk)) {
> ce->status = PCE_STATUS_ERROR;
> } else {
> @@ -63,15 +65,8 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> }
> }
>
> -/**
> - * pm_clk_add - Start using a device clock for power management.
> - * @dev: Device whose clock is going to be used for power management.
> - * @con_id: Connection ID of the clock.
> - *
> - * Add the clock represented by @con_id to the list of clocks used for
> - * the power management of @dev.
> - */
> -int pm_clk_add(struct device *dev, const char *con_id)
> +static int __pm_clk_add(struct device *dev, const char *con_id,
> + struct clk *clk)
> {
> struct pm_subsys_data *psd = dev_to_psd(dev);
> struct pm_clock_entry *ce;
> @@ -93,6 +88,12 @@ int pm_clk_add(struct device *dev, const char *con_id)
> kfree(ce);
> return -ENOMEM;
> }
> + } else {
> + if (IS_ERR(ce->clk) || !__clk_get(clk)) {
> + kfree(ce);
> + return -ENOENT;
> + }
> + ce->clk = clk;
> }
>
> pm_clk_acquire(dev, ce);
> @@ -104,6 +105,32 @@ int pm_clk_add(struct device *dev, const char *con_id)
> }
>
> /**
> + * pm_clk_add - Start using a device clock for power management.
> + * @dev: Device whose clock is going to be used for power management.
> + * @con_id: Connection ID of the clock.
> + *
> + * Add the clock represented by @con_id to the list of clocks used for
> + * the power management of @dev.
> + */
> +int pm_clk_add(struct device *dev, const char *con_id)
> +{
> + return __pm_clk_add(dev, con_id, NULL);
> +}
> +
> +/**
> + * pm_clk_add_clk - Start using a device clock for power management.
> + * @dev: Device whose clock is going to be used for power management.
> + * @clk: Clock pointer
> + *
> + * Add the clock to the list of clocks used for the power management of @dev.
> + * It will increment refcount on clock pointer, use clk_put() on it when done.
> + */
> +int pm_clk_add_clk(struct device *dev, struct clk *clk)
> +{
> + return __pm_clk_add(dev, NULL, clk);
> +}
> +
> +/**
> * __pm_clk_remove - Destroy PM clock entry.
> * @ce: PM clock entry to destroy.
> */
> diff --git a/include/linux/pm_clock.h b/include/linux/pm_clock.h
> index 8348866..0b00396 100644
> --- a/include/linux/pm_clock.h
> +++ b/include/linux/pm_clock.h
> @@ -18,6 +18,8 @@ struct pm_clk_notifier_block {
> char *con_ids[];
> };
>
> +struct clk;
> +
> #ifdef CONFIG_PM_CLK
> static inline bool pm_clk_no_clocks(struct device *dev)
> {
> @@ -29,6 +31,7 @@ extern void pm_clk_init(struct device *dev);
> extern int pm_clk_create(struct device *dev);
> extern void pm_clk_destroy(struct device *dev);
> extern int pm_clk_add(struct device *dev, const char *con_id);
> +extern int pm_clk_add_clk(struct device *dev, struct clk *clk);
> extern void pm_clk_remove(struct device *dev, const char *con_id);
> extern int pm_clk_suspend(struct device *dev);
> extern int pm_clk_resume(struct device *dev);
> @@ -51,6 +54,11 @@ static inline int pm_clk_add(struct device *dev, const char *con_id)
> {
> return -EINVAL;
> }
> +
> +static inline int pm_clk_add_clk(struct device *dev, struct clk *clk)
> +{
> + return -EINVAL;
> +}
> static inline void pm_clk_remove(struct device *dev, const char *con_id)
> {
> }
> --
> 1.9.1
>
--
Dmitry
WARNING: multiple messages have this Message-ID (diff)
From: dmitry.torokhov@gmail.com (Dmitry Torokhov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 1/3] PM / clock_ops: Add pm_clk_add_clk()
Date: Thu, 6 Nov 2014 09:31:28 -0800 [thread overview]
Message-ID: <20141106173128.GC34214@dtor-ws> (raw)
In-Reply-To: <1415281862-23764-2-git-send-email-grygorii.strashko@ti.com>
On Thu, Nov 06, 2014 at 03:51:00PM +0200, Grygorii Strashko wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
>
> The existing pm_clk_add() allows to pass a clock by con_id. However,
> when referring to a specific clock from DT, no con_id is available.
>
> Add pm_clk_add_clk(), which allows to specify the struct clk * directly.
> The will will increment refcount on clock pointer, so the caller has
> to use clk_put() on clock pointer when done.
>
> CC: Ulf Hansson <ulf.hansson@linaro.org>
> CC: Geert Uytterhoeven <geert@linux-m68k.org>
> CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/base/power/clock_ops.c | 47 +++++++++++++++++++++++++++++++++---------
> include/linux/pm_clock.h | 8 +++++++
> 2 files changed, 45 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> index 7836930..f061eaa 100644
> --- a/drivers/base/power/clock_ops.c
> +++ b/drivers/base/power/clock_ops.c
> @@ -12,6 +12,7 @@
> #include <linux/pm.h>
> #include <linux/pm_clock.h>
> #include <linux/clk.h>
> +#include <linux/clkdev.h>
> #include <linux/slab.h>
> #include <linux/err.h>
>
> @@ -53,7 +54,8 @@ static inline int __pm_clk_enable(struct device *dev, struct clk *clk)
> */
> static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> {
> - ce->clk = clk_get(dev, ce->con_id);
> + if (!ce->clk)
> + ce->clk = clk_get(dev, ce->con_id);
> if (IS_ERR(ce->clk)) {
> ce->status = PCE_STATUS_ERROR;
> } else {
> @@ -63,15 +65,8 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
> }
> }
>
> -/**
> - * pm_clk_add - Start using a device clock for power management.
> - * @dev: Device whose clock is going to be used for power management.
> - * @con_id: Connection ID of the clock.
> - *
> - * Add the clock represented by @con_id to the list of clocks used for
> - * the power management of @dev.
> - */
> -int pm_clk_add(struct device *dev, const char *con_id)
> +static int __pm_clk_add(struct device *dev, const char *con_id,
> + struct clk *clk)
> {
> struct pm_subsys_data *psd = dev_to_psd(dev);
> struct pm_clock_entry *ce;
> @@ -93,6 +88,12 @@ int pm_clk_add(struct device *dev, const char *con_id)
> kfree(ce);
> return -ENOMEM;
> }
> + } else {
> + if (IS_ERR(ce->clk) || !__clk_get(clk)) {
> + kfree(ce);
> + return -ENOENT;
> + }
> + ce->clk = clk;
> }
>
> pm_clk_acquire(dev, ce);
> @@ -104,6 +105,32 @@ int pm_clk_add(struct device *dev, const char *con_id)
> }
>
> /**
> + * pm_clk_add - Start using a device clock for power management.
> + * @dev: Device whose clock is going to be used for power management.
> + * @con_id: Connection ID of the clock.
> + *
> + * Add the clock represented by @con_id to the list of clocks used for
> + * the power management of @dev.
> + */
> +int pm_clk_add(struct device *dev, const char *con_id)
> +{
> + return __pm_clk_add(dev, con_id, NULL);
> +}
> +
> +/**
> + * pm_clk_add_clk - Start using a device clock for power management.
> + * @dev: Device whose clock is going to be used for power management.
> + * @clk: Clock pointer
> + *
> + * Add the clock to the list of clocks used for the power management of @dev.
> + * It will increment refcount on clock pointer, use clk_put() on it when done.
> + */
> +int pm_clk_add_clk(struct device *dev, struct clk *clk)
> +{
> + return __pm_clk_add(dev, NULL, clk);
> +}
> +
> +/**
> * __pm_clk_remove - Destroy PM clock entry.
> * @ce: PM clock entry to destroy.
> */
> diff --git a/include/linux/pm_clock.h b/include/linux/pm_clock.h
> index 8348866..0b00396 100644
> --- a/include/linux/pm_clock.h
> +++ b/include/linux/pm_clock.h
> @@ -18,6 +18,8 @@ struct pm_clk_notifier_block {
> char *con_ids[];
> };
>
> +struct clk;
> +
> #ifdef CONFIG_PM_CLK
> static inline bool pm_clk_no_clocks(struct device *dev)
> {
> @@ -29,6 +31,7 @@ extern void pm_clk_init(struct device *dev);
> extern int pm_clk_create(struct device *dev);
> extern void pm_clk_destroy(struct device *dev);
> extern int pm_clk_add(struct device *dev, const char *con_id);
> +extern int pm_clk_add_clk(struct device *dev, struct clk *clk);
> extern void pm_clk_remove(struct device *dev, const char *con_id);
> extern int pm_clk_suspend(struct device *dev);
> extern int pm_clk_resume(struct device *dev);
> @@ -51,6 +54,11 @@ static inline int pm_clk_add(struct device *dev, const char *con_id)
> {
> return -EINVAL;
> }
> +
> +static inline int pm_clk_add_clk(struct device *dev, struct clk *clk)
> +{
> + return -EINVAL;
> +}
> static inline void pm_clk_remove(struct device *dev, const char *con_id)
> {
> }
> --
> 1.9.1
>
--
Dmitry
next prev parent reply other threads:[~2014-11-06 17:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-06 13:50 [PATCH v4 0/3] PM / clock_ops: add pm_clk_add_clk() Grygorii Strashko
2014-11-06 13:50 ` Grygorii Strashko
2014-11-06 13:50 ` Grygorii Strashko
2014-11-06 13:51 ` [PATCH v4 1/3] PM / clock_ops: Add pm_clk_add_clk() Grygorii Strashko
2014-11-06 13:51 ` Grygorii Strashko
2014-11-06 13:51 ` Grygorii Strashko
2014-11-06 17:31 ` Dmitry Torokhov [this message]
2014-11-06 17:31 ` Dmitry Torokhov
2014-11-06 13:51 ` [PATCH v4 2/3] PM / clock_ops: make __pm_clk_enable more generic Grygorii Strashko
2014-11-06 13:51 ` Grygorii Strashko
2014-11-06 13:51 ` Grygorii Strashko
[not found] ` <1415281862-23764-3-git-send-email-grygorii.strashko-l0cyMroinI0@public.gmane.org>
2014-11-06 17:31 ` Dmitry Torokhov
2014-11-06 17:31 ` Dmitry Torokhov
2014-11-06 17:31 ` Dmitry Torokhov
2014-11-07 19:25 ` Kevin Hilman
2014-11-07 19:25 ` Kevin Hilman
2014-11-07 19:25 ` Kevin Hilman
2014-11-06 13:51 ` [RFC PATCH v4 3/3] PM / clock_ops: add and enable clocks always if !CONFIG_PM_RUNTIME Grygorii Strashko
2014-11-06 13:51 ` Grygorii Strashko
2014-11-06 13:51 ` Grygorii Strashko
2014-11-06 18:09 ` Dmitry Torokhov
2014-11-06 18:09 ` Dmitry Torokhov
2014-11-07 12:43 ` Grygorii Strashko
2014-11-07 12:43 ` Grygorii Strashko
2014-11-07 12:43 ` Grygorii Strashko
2014-11-14 23:55 ` [PATCH v4 0/3] PM / clock_ops: add pm_clk_add_clk() Rafael J. Wysocki
2014-11-14 23:55 ` Rafael J. Wysocki
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=20141106173128.GC34214@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=geert@linux-m68k.org \
--cc=grant.likely@secretlab.ca \
--cc=grygorii.strashko@ti.com \
--cc=khilman@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=robh+dt@kernel.org \
--cc=ssantosh@kernel.org \
--cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.