public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@snapgear.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Mike Turquette <mturquette@ti.com>,
	Russell King <linux@arm.linux.org.uk>,
	Greg Ungerer <gerg@uclinux.org>,
	Mark Brown <broonie@sirena.org.uk>,
	Julia Lawall <julia.lawall@lip6.fr>,
	Artem Bityutskiy <dedekind1@gmail.com>,
	<linux-m68k@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] clk: Make the managed clk functions generically available
Date: Mon, 10 Sep 2012 13:10:21 +1000	[thread overview]
Message-ID: <504D5A1D.2090808@snapgear.com> (raw)
In-Reply-To: <1347202862-1617-1-git-send-email-lars@metafoo.de>

Hi Lars-Peter,

On 10/09/12 01:01, Lars-Peter Clausen wrote:
> The managed clk functions are currently only available when the generic clk
> lookup framework is build. But the managed clk functions are merely wrappers
> around clk_get and clk_put and do not depend on any specifics of the generic
> lookup functions and there are still quite a few custom implementations of the
> clk API. So make the managed functions available whenever the clk API is
> implemented.
>
> The patch also removes the custom implementation of devm_clk_get for the
> coldfire platform.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Nice work, thanks.

Acked-by: Greg Ungerer <gerg@uclinux.org>

Regards
Greg



> ---
>   arch/m68k/platform/coldfire/clk.c |    6 ----
>   drivers/clk/Makefile              |    1 +
>   drivers/clk/clk-devres.c          |   55 +++++++++++++++++++++++++++++++++++++
>   drivers/clk/clkdev.c              |   45 ------------------------------
>   4 files changed, 56 insertions(+), 51 deletions(-)
>   create mode 100644 drivers/clk/clk-devres.c
>
> diff --git a/arch/m68k/platform/coldfire/clk.c b/arch/m68k/platform/coldfire/clk.c
> index 75f9ee9..9cd13b4 100644
> --- a/arch/m68k/platform/coldfire/clk.c
> +++ b/arch/m68k/platform/coldfire/clk.c
> @@ -146,9 +146,3 @@ struct clk_ops clk_ops1 = {
>   };
>   #endif /* MCFPM_PPMCR1 */
>   #endif /* MCFPM_PPMCR0 */
> -
> -struct clk *devm_clk_get(struct device *dev, const char *id)
> -{
> -	return NULL;
> -}
> -EXPORT_SYMBOL(devm_clk_get);
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 6327536..b7b8620 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -1,4 +1,5 @@
>   # common clock types
> +obj-$(CONFIG_HAVE_CLK)		+= clk-devres.o
>   obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
>   obj-$(CONFIG_COMMON_CLK)	+= clk.o clk-fixed-rate.o clk-gate.o \
>   				   clk-mux.o clk-divider.o clk-fixed-factor.o
> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
> new file mode 100644
> index 0000000..f1e7a83
> --- /dev/null
> +++ b/drivers/clk/clk-devres.c
> @@ -0,0 +1,55 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/export.h>
> +#include <linux/gfp.h>
> +
> +static void devm_clk_release(struct device *dev, void *res)
> +{
> +	clk_put(*(struct clk **)res);
> +}
> +
> +struct clk *devm_clk_get(struct device *dev, const char *id)
> +{
> +	struct clk **ptr, *clk;
> +
> +	ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
> +	if (!ptr)
> +		return ERR_PTR(-ENOMEM);
> +
> +	clk = clk_get(dev, id);
> +	if (!IS_ERR(clk)) {
> +		*ptr = clk;
> +		devres_add(dev, ptr);
> +	} else {
> +		devres_free(ptr);
> +	}
> +
> +	return clk;
> +}
> +EXPORT_SYMBOL(devm_clk_get);
> +
> +static int devm_clk_match(struct device *dev, void *res, void *data)
> +{
> +	struct clk **c = res;
> +	if (!c || !*c) {
> +		WARN_ON(!c || !*c);
> +		return 0;
> +	}
> +	return *c == data;
> +}
> +
> +void devm_clk_put(struct device *dev, struct clk *clk)
> +{
> +	int ret;
> +
> +	ret = devres_destroy(dev, devm_clk_release, devm_clk_match, clk);
> +
> +	WARN_ON(ret);
> +}
> +EXPORT_SYMBOL(devm_clk_put);
> diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
> index d423c9b..442a313 100644
> --- a/drivers/clk/clkdev.c
> +++ b/drivers/clk/clkdev.c
> @@ -171,51 +171,6 @@ void clk_put(struct clk *clk)
>   }
>   EXPORT_SYMBOL(clk_put);
>
> -static void devm_clk_release(struct device *dev, void *res)
> -{
> -	clk_put(*(struct clk **)res);
> -}
> -
> -struct clk *devm_clk_get(struct device *dev, const char *id)
> -{
> -	struct clk **ptr, *clk;
> -
> -	ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
> -	if (!ptr)
> -		return ERR_PTR(-ENOMEM);
> -
> -	clk = clk_get(dev, id);
> -	if (!IS_ERR(clk)) {
> -		*ptr = clk;
> -		devres_add(dev, ptr);
> -	} else {
> -		devres_free(ptr);
> -	}
> -
> -	return clk;
> -}
> -EXPORT_SYMBOL(devm_clk_get);
> -
> -static int devm_clk_match(struct device *dev, void *res, void *data)
> -{
> -	struct clk **c = res;
> -	if (!c || !*c) {
> -		WARN_ON(!c || !*c);
> -		return 0;
> -	}
> -	return *c == data;
> -}
> -
> -void devm_clk_put(struct device *dev, struct clk *clk)
> -{
> -	int ret;
> -
> -	ret = devres_destroy(dev, devm_clk_release, devm_clk_match, clk);
> -
> -	WARN_ON(ret);
> -}
> -EXPORT_SYMBOL(devm_clk_put);
> -
>   void clkdev_add(struct clk_lookup *cl)
>   {
>   	mutex_lock(&clocks_mutex);
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

      parent reply	other threads:[~2012-09-10  3:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-09 15:01 [PATCH] clk: Make the managed clk functions generically available Lars-Peter Clausen
2012-09-09 20:57 ` Russell King - ARM Linux
2012-09-09 23:50 ` Mark Brown
2012-09-10  0:15   ` Russell King - ARM Linux
2012-09-10  0:20     ` Mark Brown
2012-09-10  0:39       ` Russell King - ARM Linux
2012-09-11 14:44         ` Lars-Peter Clausen
2012-09-11 14:50           ` Artem Bityutskiy
2012-09-12  1:32             ` Greg Ungerer
2012-09-12 20:43               ` Lars-Peter Clausen
2012-09-15 21:31                 ` Russell King - ARM Linux
2012-09-16  0:15                   ` Greg Ungerer
2012-09-18  8:00                   ` Thierry Reding
2012-09-18  9:35                     ` Russell King - ARM Linux
2012-09-18 11:25                       ` Thierry Reding
2012-09-18 20:40                         ` Russell King - ARM Linux
2012-09-19  6:55                           ` Thierry Reding
2012-09-11 17:51           ` Russell King - ARM Linux
2012-09-10  3:10 ` Greg Ungerer [this message]

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=504D5A1D.2090808@snapgear.com \
    --to=gerg@snapgear.com \
    --cc=broonie@sirena.org.uk \
    --cc=dedekind1@gmail.com \
    --cc=gerg@uclinux.org \
    --cc=julia.lawall@lip6.fr \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mturquette@ti.com \
    /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