[PATCH 10/10] clk: copy parent_names in clk-mux registration

Turquette, Mike mturquette at ti.com
Mon Apr 9 18:00:53 EDT 2012


On Tue, Mar 27, 2012 at 12:23 AM, Shawn Guo <shawn.guo at linaro.org> wrote:
> Just like what all other basic clks do, copy parent_names in clk-mux
> registration, so that clock driver can mark the parent_names
> __initconst.
>
> Signed-off-by: Shawn Guo <shawn.guo at linaro.org>

Hi Shawn,

As discussed in the other thread, I've moved the parent string copies
into clk_register; that makes this patch unnecessary (and you can
still mark the parent_names as __initdata).

I'll publish my fixes either today or tomorrow.

Regards,
Mike

> ---
>  drivers/clk/clk-mux.c |   29 +++++++++++++++++++++++++++--
>  1 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
> index 1ff90a6..353fcb7 100644
> --- a/drivers/clk/clk-mux.c
> +++ b/drivers/clk/clk-mux.c
> @@ -94,6 +94,9 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
>                u8 clk_mux_flags, spinlock_t *lock)
>  {
>        struct clk_mux *mux;
> +       struct clk *clk;
> +       const char **parents = NULL;
> +       int i = 0;
>
>        mux = kzalloc(sizeof(struct clk_mux), GFP_KERNEL);
>
> @@ -109,6 +112,28 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
>        mux->flags = clk_mux_flags;
>        mux->lock = lock;
>
> -       return clk_register(dev, name, &clk_mux_ops, &mux->hw,
> -                       parent_names, num_parents, flags);
> +       if (num_parents) {
> +               parents = kzalloc(sizeof(char *) * num_parents, GFP_KERNEL);
> +               if (!parents)
> +                       goto out;
> +
> +               for (i = 0; i < num_parents; i++) {
> +                       parents[i] = kstrdup(parent_names[i], GFP_KERNEL);
> +                       if (!parents[i])
> +                               goto out;
> +               }
> +       }
> +
> +       clk =  clk_register(dev, name, &clk_mux_ops, &mux->hw,
> +                       parents, num_parents, flags);
> +       if (clk)
> +               return clk;
> +
> +out:
> +       for (i--; i >= 0; i--)
> +               kfree(parents[i]);
> +       kfree(parents);
> +       kfree(mux);
> +
> +       return NULL;
>  }
> --
> 1.7.5.4
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



More information about the linux-arm-kernel mailing list