From: Stephen Boyd <sboyd@codeaurora.org>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: linux-kernel@vger.kernel.org,
Mike Turquette <mturquette@linaro.org>,
Javier Martinez Canillas <javier.martinez@collabora.co.uk>,
Paul Walmsley <paul@pwsan.com>, Tony Lindgren <tony@atomide.com>,
Russell King <linux@arm.linux.org.uk>,
linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v11 2/4] clk: Make clk API return per-user struct clk instances
Date: Wed, 21 Jan 2015 17:01:36 -0800 [thread overview]
Message-ID: <20150122010136.GH27202@codeaurora.org> (raw)
In-Reply-To: <1421847039-29544-3-git-send-email-tomeu.vizoso@collabora.com>
On 01/21, Tomeu Vizoso wrote:
> @@ -2075,10 +2210,12 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
> }
> }
>
> - ret = __clk_init(dev, clk);
> + hw->clk = __clk_create_clk(hw, NULL, NULL);
> + ret = __clk_init(dev, hw->clk);
> if (!ret)
> - return clk;
> + return hw->clk;
>
> + kfree(hw->clk);
> fail_parent_names_copy:
> while (--i >= 0)
> kfree(clk->parent_names[i]);
Sigh, this patch is so huge I keep finding more things. Sorry. It
looks like __clk_create_clk() can return an error pointer, which
we then send directly to __clk_init. First off, we shouldn't
kfree() that pointer if it's an error pointer. Second, we
shouldn't crash in __clk_init() in such a situation so there
needs to be some sort of check somewhere.
BTW, please try and fixup checkpatch warnings.
> diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
> index da4bda8..fac3244 100644
> --- a/drivers/clk/clkdev.c
> +++ b/drivers/clk/clkdev.c
> @@ -69,20 +70,22 @@ struct clk *of_clk_get(struct device_node *np, int index)
[...]
> -struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
> +static struct clk *__of_clk_get_by_name(struct device_node *np, const char *name)
It would be nice if this returned an already __clk_create_clk()ed
pointer.
> {
> struct clk *clk = ERR_PTR(-ENOENT);
>
> @@ -119,7 +122,33 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
[...]
> +struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
> +{
> + struct clk *clk = __of_clk_get_by_name(np, name);
> +
> + if (!IS_ERR(clk))
> + clk = __clk_create_clk(__clk_get_hw(clk), np->full_name, name);
Because we do it here where we know we're CONFIG_COMMON_CLK=y.
> +
> + return clk;
> +}
> EXPORT_SYMBOL(of_clk_get_by_name);
> +
> +#else /* defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) */
> +
> +static struct clk *__of_clk_get_by_name(struct device_node *np, const char *name)
> +{
> + return ERR_PTR(-ENOENT);
> +}
> #endif
>
> /*
> @@ -185,9 +229,13 @@ struct clk *clk_get(struct device *dev, const char *con_id)
> struct clk *clk;
>
> if (dev) {
> - clk = of_clk_get_by_name(dev->of_node, con_id);
> - if (!IS_ERR(clk))
> + clk = __of_clk_get_by_name(dev->of_node, con_id);
> + if (!IS_ERR(clk)) {
> +#if defined(CONFIG_COMMON_CLK)
> + clk = __clk_create_clk(__clk_get_hw(clk), dev_id, con_id);
> +#endif
And we do it here where we could remove the #ifdef.
> return clk;
> + }
> if (PTR_ERR(clk) == -EPROBE_DEFER)
> return clk;
> }
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
WARNING: multiple messages have this Message-ID (diff)
From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v11 2/4] clk: Make clk API return per-user struct clk instances
Date: Wed, 21 Jan 2015 17:01:36 -0800 [thread overview]
Message-ID: <20150122010136.GH27202@codeaurora.org> (raw)
In-Reply-To: <1421847039-29544-3-git-send-email-tomeu.vizoso@collabora.com>
On 01/21, Tomeu Vizoso wrote:
> @@ -2075,10 +2210,12 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
> }
> }
>
> - ret = __clk_init(dev, clk);
> + hw->clk = __clk_create_clk(hw, NULL, NULL);
> + ret = __clk_init(dev, hw->clk);
> if (!ret)
> - return clk;
> + return hw->clk;
>
> + kfree(hw->clk);
> fail_parent_names_copy:
> while (--i >= 0)
> kfree(clk->parent_names[i]);
Sigh, this patch is so huge I keep finding more things. Sorry. It
looks like __clk_create_clk() can return an error pointer, which
we then send directly to __clk_init. First off, we shouldn't
kfree() that pointer if it's an error pointer. Second, we
shouldn't crash in __clk_init() in such a situation so there
needs to be some sort of check somewhere.
BTW, please try and fixup checkpatch warnings.
> diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
> index da4bda8..fac3244 100644
> --- a/drivers/clk/clkdev.c
> +++ b/drivers/clk/clkdev.c
> @@ -69,20 +70,22 @@ struct clk *of_clk_get(struct device_node *np, int index)
[...]
> -struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
> +static struct clk *__of_clk_get_by_name(struct device_node *np, const char *name)
It would be nice if this returned an already __clk_create_clk()ed
pointer.
> {
> struct clk *clk = ERR_PTR(-ENOENT);
>
> @@ -119,7 +122,33 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
[...]
> +struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
> +{
> + struct clk *clk = __of_clk_get_by_name(np, name);
> +
> + if (!IS_ERR(clk))
> + clk = __clk_create_clk(__clk_get_hw(clk), np->full_name, name);
Because we do it here where we know we're CONFIG_COMMON_CLK=y.
> +
> + return clk;
> +}
> EXPORT_SYMBOL(of_clk_get_by_name);
> +
> +#else /* defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) */
> +
> +static struct clk *__of_clk_get_by_name(struct device_node *np, const char *name)
> +{
> + return ERR_PTR(-ENOENT);
> +}
> #endif
>
> /*
> @@ -185,9 +229,13 @@ struct clk *clk_get(struct device *dev, const char *con_id)
> struct clk *clk;
>
> if (dev) {
> - clk = of_clk_get_by_name(dev->of_node, con_id);
> - if (!IS_ERR(clk))
> + clk = __of_clk_get_by_name(dev->of_node, con_id);
> + if (!IS_ERR(clk)) {
> +#if defined(CONFIG_COMMON_CLK)
> + clk = __clk_create_clk(__clk_get_hw(clk), dev_id, con_id);
> +#endif
And we do it here where we could remove the #ifdef.
> return clk;
> + }
> if (PTR_ERR(clk) == -EPROBE_DEFER)
> return clk;
> }
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2015-01-22 1:01 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-21 13:30 [PATCH v11 0/4] Per-user clock constraints Tomeu Vizoso
2015-01-21 13:30 ` [PATCH v11 1/4] clk: Remove unneeded NULL checks Tomeu Vizoso
2015-01-21 13:30 ` [PATCH v11 2/4] clk: Make clk API return per-user struct clk instances Tomeu Vizoso
2015-01-21 13:30 ` Tomeu Vizoso
2015-01-21 13:30 ` Tomeu Vizoso
2015-01-22 1:01 ` Stephen Boyd [this message]
2015-01-22 1:01 ` Stephen Boyd
2015-01-22 11:15 ` Tomeu Vizoso
2015-01-22 11:15 ` Tomeu Vizoso
2015-01-22 18:59 ` Stephen Boyd
2015-01-22 18:59 ` Stephen Boyd
2015-01-23 10:24 ` Tomeu Vizoso
2015-01-23 10:24 ` Tomeu Vizoso
2015-01-21 13:30 ` [PATCH v11 3/4] clk: Add rate constraints to clocks Tomeu Vizoso
2015-01-21 13:30 ` Tomeu Vizoso
2015-01-22 1:46 ` Stephen Boyd
2015-01-22 1:46 ` Stephen Boyd
2015-01-22 1:46 ` Stephen Boyd
2015-01-22 14:42 ` Tomeu Vizoso
2015-01-22 14:42 ` Tomeu Vizoso
2015-01-22 14:42 ` Tomeu Vizoso
2015-01-21 13:30 ` [PATCH v11 4/4] clk: Add module for unit tests Tomeu Vizoso
2015-01-22 2:23 ` Stephen Boyd
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=20150122010136.GH27202@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=javier.martinez@collabora.co.uk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mturquette@linaro.org \
--cc=paul@pwsan.com \
--cc=tomeu.vizoso@collabora.com \
--cc=tony@atomide.com \
/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.