Re: [PATCH 13/13] clk: basic: improve parent_names & return errors

From: Shawn Guo
Date: Thu Apr 12 2012 - 02:49:36 EST


On Wed, Apr 11, 2012 at 06:02:51PM -0700, Mike Turquette wrote:
...
> @@ -175,23 +188,32 @@ struct clk *clk_register_divider(struct device *dev, const char *name,
> div->flags = clk_divider_flags;
> div->lock = lock;
>
> + /* allocate the temporary parent_names */
> if (parent_name) {
> - div->parent[0] = kstrdup(parent_name, GFP_KERNEL);
> - if (!div->parent[0])
> - goto out;
> + parent_names[0] = kstrdup(parent_name, GFP_KERNEL);
> + if (!parent_names[0]) {
> + pr_err("%s: could not allocate parent_names\n",
> + __func__);
> + goto fail_parent_names;
> + }
> }

Why do we need to copy the parent_names here at all? clk_register()
has done that for each basic clk.

Regards,
Shawn

>
> + /* register the clock */
> clk = clk_register(dev, name,
> &clk_divider_ops, &div->hw,
> - div->parent,
> + (parent_name ? parent_names: NULL),
> (parent_name ? 1 : 0),
> flags);
> - if (clk)
> - return clk;
>
> -out:
> - kfree(div->parent[0]);
> - kfree(div);
> + /* free the temporary parent_names */
> + if (parent_name)
> + kfree(parent_names[0]);
> +
> + if (!IS_ERR(clk))
> + goto out;
>
> - return NULL;
> +fail_parent_names:
> + kfree(div);
> +out:
> + return clk;
> }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/