All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 5/6] clk: Support multiple instances of the same clock
Date: Mon, 11 Jul 2011 09:34:39 +0000	[thread overview]
Message-ID: <20110711093439.GB3239@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1310352837-4277-5-git-send-email-broonie@opensource.wolfsonmicro.com>

On Mon, Jul 11, 2011 at 11:53:56AM +0900, Mark Brown wrote:
> Currently the generic clk API identifies clocks internally using the name
> of the clock. This is OK for on-SoC clocks where we have enough control to
> disambiguate but doesn't work well for clocks provided on external chips
> where a system design may include more than one instance of the same chip
> (the Wolfson Speyside system is an example of this) or may have namespace
> collisions.
> 
> Address this by allowing the clock provider to supply a struct device for
> the clock for use in disambiguation. As a first pass if it is provided we
> prefix the clock name with the dev_name() of the device. With a device
> tree binding for clocks it should be possible to remove this mangling and
> instead use the struct device to provide access to the binding information.
> 
> In order to avoid needless noise in names and memory usage it is strongly
> recommended that on-SoC clocks do not provide a struct device until the
> implementation is improved.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/clk/clk.c   |   36 ++++++++++++++++++++++++++++++++----
>  include/linux/clk.h |   14 ++++++++++----
>  2 files changed, 42 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 1df6e23..f36f637 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -13,6 +13,7 @@
>  #include <linux/mutex.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
> +#include <linux/device.h>
>  
>  struct clk {
>  	const char		*name;
> @@ -252,20 +253,44 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
>  }
>  EXPORT_SYMBOL_GPL(clk_set_parent);
>  
> -struct clk *clk_register(const struct clk_hw_ops *ops, struct clk_hw *hw,
> -		const char *name)
> +struct clk *clk_register(struct device *dev, const struct clk_hw_ops *ops,
> +			 struct clk_hw *hw, const char *name)
>  {
>  	struct clk *clk;
> +	char *new_name;
> +	size_t name_len;
>  
>  	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
>  	if (!clk)
>  		return NULL;
>  
> -	clk->name = name;
>  	clk->ops = ops;
>  	clk->hw = hw;
>  	hw->clk = clk;
>  
> +	/* Since we currently match clock providers on a purely string
> +	 * based method add a prefix based on the device name if a
> +	 * device is provided.  When we have support for device tree
> +	 * based clock matching it should be possible to avoid this
> +	 * mangling and instead use the struct device to hook into
> +	 * the bindings.
> +	 *
> +	 * As we don't currently support unregistering clocks we don't
> +	 * need to worry about cleanup as yet.
> +	 */
> +	if (dev) {
> +		name_len = strlen(name) + strlen(dev_name(dev)) + 2;
> +		new_name = kzalloc(name_len, GFP_KERNEL);
> +		if (!new_name)
> +			goto err;
> +
> +		snprintf(new_name, name_len, "%s-%s", dev_name(dev), name);
> +
> +		clk->name = new_name;
> +	} else {
> +		clk->name = name;
> +	}

This "clk consolidation" is really idiotic.  The clk matching mechanism
should have _nothing_ to do with the rest of the clk API, especially the
consolidation effort.

It should not matter whether clkdev is used, or an alternative method
to specify this stuff via DT.  Keep the clk_get()/clk_put() _separate_
from the consolidation of the rest.

WARNING: multiple messages have this Message-ID (diff)
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Jeremy Kerr <jeremy.kerr@canonical.com>,
	Grant Likely <grant@secretlab.ca>,
	linux-sh@vger.kernel.org, patches@opensource.wolfsonmicro.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 5/6] clk: Support multiple instances of the same clock provider
Date: Mon, 11 Jul 2011 10:34:39 +0100	[thread overview]
Message-ID: <20110711093439.GB3239@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1310352837-4277-5-git-send-email-broonie@opensource.wolfsonmicro.com>

On Mon, Jul 11, 2011 at 11:53:56AM +0900, Mark Brown wrote:
> Currently the generic clk API identifies clocks internally using the name
> of the clock. This is OK for on-SoC clocks where we have enough control to
> disambiguate but doesn't work well for clocks provided on external chips
> where a system design may include more than one instance of the same chip
> (the Wolfson Speyside system is an example of this) or may have namespace
> collisions.
> 
> Address this by allowing the clock provider to supply a struct device for
> the clock for use in disambiguation. As a first pass if it is provided we
> prefix the clock name with the dev_name() of the device. With a device
> tree binding for clocks it should be possible to remove this mangling and
> instead use the struct device to provide access to the binding information.
> 
> In order to avoid needless noise in names and memory usage it is strongly
> recommended that on-SoC clocks do not provide a struct device until the
> implementation is improved.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/clk/clk.c   |   36 ++++++++++++++++++++++++++++++++----
>  include/linux/clk.h |   14 ++++++++++----
>  2 files changed, 42 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 1df6e23..f36f637 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -13,6 +13,7 @@
>  #include <linux/mutex.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
> +#include <linux/device.h>
>  
>  struct clk {
>  	const char		*name;
> @@ -252,20 +253,44 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
>  }
>  EXPORT_SYMBOL_GPL(clk_set_parent);
>  
> -struct clk *clk_register(const struct clk_hw_ops *ops, struct clk_hw *hw,
> -		const char *name)
> +struct clk *clk_register(struct device *dev, const struct clk_hw_ops *ops,
> +			 struct clk_hw *hw, const char *name)
>  {
>  	struct clk *clk;
> +	char *new_name;
> +	size_t name_len;
>  
>  	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
>  	if (!clk)
>  		return NULL;
>  
> -	clk->name = name;
>  	clk->ops = ops;
>  	clk->hw = hw;
>  	hw->clk = clk;
>  
> +	/* Since we currently match clock providers on a purely string
> +	 * based method add a prefix based on the device name if a
> +	 * device is provided.  When we have support for device tree
> +	 * based clock matching it should be possible to avoid this
> +	 * mangling and instead use the struct device to hook into
> +	 * the bindings.
> +	 *
> +	 * As we don't currently support unregistering clocks we don't
> +	 * need to worry about cleanup as yet.
> +	 */
> +	if (dev) {
> +		name_len = strlen(name) + strlen(dev_name(dev)) + 2;
> +		new_name = kzalloc(name_len, GFP_KERNEL);
> +		if (!new_name)
> +			goto err;
> +
> +		snprintf(new_name, name_len, "%s-%s", dev_name(dev), name);
> +
> +		clk->name = new_name;
> +	} else {
> +		clk->name = name;
> +	}

This "clk consolidation" is really idiotic.  The clk matching mechanism
should have _nothing_ to do with the rest of the clk API, especially the
consolidation effort.

It should not matter whether clkdev is used, or an alternative method
to specify this stuff via DT.  Keep the clk_get()/clk_put() _separate_
from the consolidation of the rest.

WARNING: multiple messages have this Message-ID (diff)
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/6] clk: Support multiple instances of the same clock provider
Date: Mon, 11 Jul 2011 10:34:39 +0100	[thread overview]
Message-ID: <20110711093439.GB3239@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1310352837-4277-5-git-send-email-broonie@opensource.wolfsonmicro.com>

On Mon, Jul 11, 2011 at 11:53:56AM +0900, Mark Brown wrote:
> Currently the generic clk API identifies clocks internally using the name
> of the clock. This is OK for on-SoC clocks where we have enough control to
> disambiguate but doesn't work well for clocks provided on external chips
> where a system design may include more than one instance of the same chip
> (the Wolfson Speyside system is an example of this) or may have namespace
> collisions.
> 
> Address this by allowing the clock provider to supply a struct device for
> the clock for use in disambiguation. As a first pass if it is provided we
> prefix the clock name with the dev_name() of the device. With a device
> tree binding for clocks it should be possible to remove this mangling and
> instead use the struct device to provide access to the binding information.
> 
> In order to avoid needless noise in names and memory usage it is strongly
> recommended that on-SoC clocks do not provide a struct device until the
> implementation is improved.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/clk/clk.c   |   36 ++++++++++++++++++++++++++++++++----
>  include/linux/clk.h |   14 ++++++++++----
>  2 files changed, 42 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 1df6e23..f36f637 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -13,6 +13,7 @@
>  #include <linux/mutex.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
> +#include <linux/device.h>
>  
>  struct clk {
>  	const char		*name;
> @@ -252,20 +253,44 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
>  }
>  EXPORT_SYMBOL_GPL(clk_set_parent);
>  
> -struct clk *clk_register(const struct clk_hw_ops *ops, struct clk_hw *hw,
> -		const char *name)
> +struct clk *clk_register(struct device *dev, const struct clk_hw_ops *ops,
> +			 struct clk_hw *hw, const char *name)
>  {
>  	struct clk *clk;
> +	char *new_name;
> +	size_t name_len;
>  
>  	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
>  	if (!clk)
>  		return NULL;
>  
> -	clk->name = name;
>  	clk->ops = ops;
>  	clk->hw = hw;
>  	hw->clk = clk;
>  
> +	/* Since we currently match clock providers on a purely string
> +	 * based method add a prefix based on the device name if a
> +	 * device is provided.  When we have support for device tree
> +	 * based clock matching it should be possible to avoid this
> +	 * mangling and instead use the struct device to hook into
> +	 * the bindings.
> +	 *
> +	 * As we don't currently support unregistering clocks we don't
> +	 * need to worry about cleanup as yet.
> +	 */
> +	if (dev) {
> +		name_len = strlen(name) + strlen(dev_name(dev)) + 2;
> +		new_name = kzalloc(name_len, GFP_KERNEL);
> +		if (!new_name)
> +			goto err;
> +
> +		snprintf(new_name, name_len, "%s-%s", dev_name(dev), name);
> +
> +		clk->name = new_name;
> +	} else {
> +		clk->name = name;
> +	}

This "clk consolidation" is really idiotic.  The clk matching mechanism
should have _nothing_ to do with the rest of the clk API, especially the
consolidation effort.

It should not matter whether clkdev is used, or an alternative method
to specify this stuff via DT.  Keep the clk_get()/clk_put() _separate_
from the consolidation of the rest.

  reply	other threads:[~2011-07-11  9:34 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-11  2:53 [PATCH 0/6] clk: Initial feedback for off-SoC slow bus clocks Mark Brown
2011-07-11  2:53 ` Mark Brown
2011-07-11  2:53 ` Mark Brown
2011-07-11  2:53 ` [PATCH 1/6] clk: Prototype and document clk_register() Mark Brown
2011-07-11  2:53   ` Mark Brown
2011-07-11  2:53   ` Mark Brown
2011-07-11  2:53   ` [PATCH 2/6] clk: Provide a dummy clk_unregister() Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53   ` [PATCH 3/6] clk: Constify struct clk_hw_ops Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53   ` [PATCH 4/6] clk: Add Kconfig option to build all generic clk drivers Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53   ` [PATCH 5/6] clk: Support multiple instances of the same clock provider Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  9:34     ` Russell King - ARM Linux [this message]
2011-07-11  9:34       ` Russell King - ARM Linux
2011-07-11  9:34       ` Russell King - ARM Linux
2011-07-11 10:53       ` [PATCH 5/6] clk: Support multiple instances of the same clock Mark Brown
2011-07-11 10:53         ` [PATCH 5/6] clk: Support multiple instances of the same clock provider Mark Brown
2011-07-11 10:53         ` Mark Brown
2011-07-11 11:11         ` [PATCH 5/6] clk: Support multiple instances of the same clock Russell King - ARM Linux
2011-07-11 11:11           ` [PATCH 5/6] clk: Support multiple instances of the same clock provider Russell King - ARM Linux
2011-07-11 11:11           ` Russell King - ARM Linux
2011-07-11 11:41           ` [PATCH 5/6] clk: Support multiple instances of the same clock Mark Brown
2011-07-11 11:41             ` [PATCH 5/6] clk: Support multiple instances of the same clock provider Mark Brown
2011-07-11 11:41             ` Mark Brown
2011-07-11  2:53   ` [PATCH 6/6] clk: Add initial WM831x clock driver Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-11  2:53     ` Mark Brown
2011-07-15  2:53     ` Grant Likely
2011-07-15  2:53       ` Grant Likely
2011-07-15  2:53       ` Grant Likely
2011-07-15  5:05       ` Mark Brown
2011-07-15  5:05         ` Mark Brown
2011-07-15  5:05         ` Mark Brown
2011-07-15  5:14         ` Ryan Mallon
2011-07-15  5:14           ` Ryan Mallon
2011-07-15  5:14           ` Ryan Mallon
2011-07-15  2:53   ` [PATCH 1/6] clk: Prototype and document clk_register() Grant Likely
2011-07-15  2:53     ` Grant Likely
2011-07-15  2:53     ` Grant Likely
2011-07-11  3:57 ` [PATCH 0/6] clk: Initial feedback for off-SoC slow bus clocks Mark Brown
2011-07-11  3:57   ` Mark Brown
2011-07-11  3:57   ` Mark Brown
2011-07-11  4:30   ` Mike Frysinger
2011-07-11  4:30     ` Mike Frysinger
2011-07-11  4:30     ` Mike Frysinger
2011-07-11  4:56     ` Barry Song
2011-07-11  4:56       ` Barry Song
2011-07-11  4:56       ` Barry Song
2011-07-11  5:01       ` [uclinux-dist-devel] [PATCH 0/6] clk: Initial feedback for Mike Frysinger
2011-07-11  5:01         ` [uclinux-dist-devel] [PATCH 0/6] clk: Initial feedback for off-SoC slow bus clocks Mike Frysinger
2011-07-11  5:01         ` Mike Frysinger
2011-07-11  9:31 ` Russell King - ARM Linux
2011-07-11  9:31   ` Russell King - ARM Linux
2011-07-11  9:31   ` Russell King - ARM Linux
2011-07-11 10:07   ` Sascha Hauer
2011-07-11 10:07     ` Sascha Hauer
2011-07-11 10:07     ` Sascha Hauer
2011-07-11 10:28     ` Russell King - ARM Linux
2011-07-11 10:28       ` Russell King - ARM Linux
2011-07-11 10:28       ` Russell King - ARM Linux
2011-07-11 10:46       ` Sascha Hauer
2011-07-11 10:46         ` Sascha Hauer
2011-07-11 10:46         ` Sascha Hauer
2011-07-11 11:43         ` Mark Brown
2011-07-11 11:43           ` Mark Brown
2011-07-11 11:43           ` Mark Brown

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=20110711093439.GB3239@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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.