linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] at91: switch to CLKDEV_LOOKUP
Date: Wed, 20 Apr 2011 10:16:24 +0200	[thread overview]
Message-ID: <20110420081624.GT31131@pengutronix.de> (raw)
In-Reply-To: <1303271969-9794-1-git-send-email-plagnioj@jcrosoft.com>

Hello Jean-Christophe,

On Wed, Apr 20, 2011 at 05:59:29AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
>  /*
>   * The five programmable clocks.
>   * You must configure pin multiplexing to bring these signals out.
> @@ -234,6 +265,13 @@ static struct clk pck3 = {
>  	.id		= 3,
>  };
>  
> +static struct clk_lookup program_clocks_lookups[] = {
> +	CLKDEV_CON_ID("pck0", &pck0),
> +	CLKDEV_CON_ID("pck1", &pck1),
> +	CLKDEV_CON_ID("pck2", &pck2),
> +	CLKDEV_CON_ID("pck3", &pck3),
> +};
> +
>  static struct clk mAgicV_mem_clk = {
>  	.name		= "mAgicV_mem_clk",
>  	.pmc_mask	= AT91_PMC_PCK4,
> @@ -241,6 +279,9 @@ static struct clk mAgicV_mem_clk = {
>  	.id		= 4,
>  };
>  
> +static struct clk_lookup mAgicV_mem_clk_lookup =
> +	CLKDEV_CON_ID("mAgicV_mem_clk", &mAgicV_mem_clk);
> +
>  /* HClocks */
>  static struct clk hck0 = {
>  	.name		= "hck0",
> @@ -255,6 +296,11 @@ static struct clk hck1 = {
>  	.id		= 1,
>  };
>  
> +static struct clk_lookup hc_clocks_lookups[] = {
> +	CLKDEV_CON_ID("hck0", &hck0),
> +	CLKDEV_CON_ID("hck1", &hck1),
> +};
> +
>  static void __init at572d940hf_register_clocks(void)
>  {
>  	int i;
> @@ -262,14 +308,32 @@ static void __init at572d940hf_register_clocks(void)
>  	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
>  		clk_register(periph_clocks[i]);
>  
> +	clkdev_add_table(periph_clocks_lookups,
> +			 ARRAY_SIZE(periph_clocks_lookups));
> +
Does it make sense to add a (maybe global) helper function ? la:

	void __init clkdev_register_and_add_table(struct clk_lookup *cl, size_t num)
	{
		while (num--) {
			clk_register(&cl->clk);
			clkdev_add(cl);
			++cl;
		}
	}

? (The locking isn't optimal here, but I think you get the point.)


> +static struct clk_lookup usart_clocks_lookups[] = {
> +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck),
> +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk),
> +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk),
> +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk),
> +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk),
> +};
> [...]
> +struct clk* __init at91sam9rl_get_uart_clock(int id)
> +{
> +	if (id >= ARRAY_SIZE(usart_clocks_lookups))
> +		return NULL;
> +	return usart_clocks_lookups[id].clk;
Who is using this function? If the caller has access to the
atmel_usart.<id> device, just using clk_get looks better.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2011-04-20  8:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-20  3:59 [PATCH] at91: switch to CLKDEV_LOOKUP Jean-Christophe PLAGNIOL-VILLARD
2011-04-20  8:16 ` Uwe Kleine-König [this message]
2011-04-20 10:44   ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 19:22   ` Russell King - ARM Linux

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=20110420081624.GT31131@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).