[PATCH 08/18] CLK: Check and do not allow to register clock twice.

Sascha Hauer s.hauer at pengutronix.de
Tue Mar 3 01:03:34 PST 2015


On Mon, Mar 02, 2015 at 11:21:52PM +0300, Andrey Panov wrote:
> Signed-off-by: Andrey Panov <rockford at yandex.ru>
> ---
>  drivers/clk/clk.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 584e2f3..5f78c9c 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -212,8 +212,17 @@ struct clk *clk_get_parent(struct clk *clk)
>  
>  int clk_register(struct clk *clk)
>  {
> +	struct clk *c;
> +
>  	clk->parents = xzalloc(sizeof(struct clk *) * clk->num_parents);
>  
> +	list_for_each_entry(c, &clks, list) {
> +		if (!strcmp(c->name, clk->name)){
> +			pr_err("%s clk %s is already registered, skipping!\n", __func__, clk->name);
> +			return 0;
> +		}
> +	}

Why return 0 here? This should return -EBUSY. Also please move this
check above the memory allocation.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list