diff mbox

clk: tegra: fix return value check in tegra_clk_register_pllc()

Message ID CAPgLHd-wYa3Z7J93LmC0rvRPKsrjK+8DEZR+2f+e14RN+p_fPg@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Yongjun Oct. 29, 2013, 2:07 a.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

In case of error, the function __clk_lookup() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should
be replaced with NULL test.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/clk/tegra/clk-pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Warren Oct. 29, 2013, 7:40 p.m. UTC | #1
On 10/28/2013 08:07 PM, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, the function __clk_lookup() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should
> be replaced with NULL test.

>  	parent = __clk_lookup(parent_name);
> -	if (IS_ERR(parent)) {
> +	if (!parent) {

clk_get() returns an error-value. It'd be nice if the internal clk APIs
all did the same for consistency... Otherwise, the clock subsystem is
essentially using both NULL and error-values as errors, which is rather
frowned upon.
Peter De Schrijver Nov. 28, 2013, 1:10 p.m. UTC | #2
On Tue, Oct 29, 2013 at 03:07:57AM +0100, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, the function __clk_lookup() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should
> be replaced with NULL test.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>  drivers/clk/tegra/clk-pll.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
> index 197074a..a99bef7 100644
> --- a/drivers/clk/tegra/clk-pll.c
> +++ b/drivers/clk/tegra/clk-pll.c
> @@ -1507,7 +1507,7 @@ struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
>  		return ERR_PTR(-EINVAL);
>  
>  	parent = __clk_lookup(parent_name);
> -	if (IS_ERR(parent)) {
> +	if (!parent) {
>  		WARN(1, "parent clk %s of %s must be registered first\n",
>  			name, parent_name);
>  		return ERR_PTR(-EINVAL);
> 

Ah :( There are a few more instances of this. I will fix them all.
diff mbox

Patch

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 197074a..a99bef7 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -1507,7 +1507,7 @@  struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
 		return ERR_PTR(-EINVAL);
 
 	parent = __clk_lookup(parent_name);
-	if (IS_ERR(parent)) {
+	if (!parent) {
 		WARN(1, "parent clk %s of %s must be registered first\n",
 			name, parent_name);
 		return ERR_PTR(-EINVAL);