Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] usb: typec: hd3ss3220: hd3ss3220_probe() warn: passing zero to 'PTR_ERR'
@ 2019-10-07 15:38 Biju Das
  2019-10-08 12:32 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Biju Das @ 2019-10-07 15:38 UTC (permalink / raw)
  To: Heikki Krogerus, Dan Carpenter
  Cc: Biju Das, Greg Kroah-Hartman, linux-usb, Geert Uytterhoeven,
	Simon Horman, Chris Paterson, Fabrizio Castro, linux-renesas-soc

This patch fixes the warning passing zero to 'PTR_ERR' by changing the
check from 'IS_ERR_OR_NULL' to 'IS_ERR'. Also improved the error handling
on probe function.

Fixes: 1c48c759ef4b ("usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller")
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/usb/typec/hd3ss3220.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
index 1900910..7e5f3f7 100644
--- a/drivers/usb/typec/hd3ss3220.c
+++ b/drivers/usb/typec/hd3ss3220.c
@@ -178,7 +178,7 @@ static int hd3ss3220_probe(struct i2c_client *client,
 
 	hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
 	fwnode_handle_put(connector);
-	if (IS_ERR_OR_NULL(hd3ss3220->role_sw))
+	if (IS_ERR(hd3ss3220->role_sw))
 		return PTR_ERR(hd3ss3220->role_sw);
 
 	hd3ss3220->typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE;
@@ -188,20 +188,22 @@ static int hd3ss3220_probe(struct i2c_client *client,
 
 	hd3ss3220->port = typec_register_port(&client->dev,
 					      &hd3ss3220->typec_cap);
-	if (IS_ERR(hd3ss3220->port))
-		return PTR_ERR(hd3ss3220->port);
+	if (IS_ERR(hd3ss3220->port)) {
+		ret = PTR_ERR(hd3ss3220->port);
+		goto err_put_role;
+	}
 
 	hd3ss3220_set_role(hd3ss3220);
 	ret = regmap_read(hd3ss3220->regmap, HD3SS3220_REG_CN_STAT_CTRL, &data);
 	if (ret < 0)
-		goto error;
+		goto err_unreg_port;
 
 	if (data & HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS) {
 		ret = regmap_write(hd3ss3220->regmap,
 				HD3SS3220_REG_CN_STAT_CTRL,
 				data | HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS);
 		if (ret < 0)
-			goto error;
+			goto err_unreg_port;
 	}
 
 	if (client->irq > 0) {
@@ -210,18 +212,19 @@ static int hd3ss3220_probe(struct i2c_client *client,
 					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 					"hd3ss3220", &client->dev);
 		if (ret)
-			goto error;
+			goto err_unreg_port;
 	}
 
 	ret = i2c_smbus_read_byte_data(client, HD3SS3220_REG_DEV_REV);
 	if (ret < 0)
-		goto error;
+		goto err_unreg_port;
 
 	dev_info(&client->dev, "probed revision=0x%x\n", ret);
 
 	return 0;
-error:
+err_unreg_port:
 	typec_unregister_port(hd3ss3220->port);
+err_put_role:
 	usb_role_switch_put(hd3ss3220->role_sw);
 
 	return ret;
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: typec: hd3ss3220: hd3ss3220_probe() warn: passing zero to 'PTR_ERR'
  2019-10-07 15:38 [PATCH] usb: typec: hd3ss3220: hd3ss3220_probe() warn: passing zero to 'PTR_ERR' Biju Das
@ 2019-10-08 12:32 ` Heikki Krogerus
  0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2019-10-08 12:32 UTC (permalink / raw)
  To: Biju Das
  Cc: Dan Carpenter, Greg Kroah-Hartman, linux-usb, Geert Uytterhoeven,
	Simon Horman, Chris Paterson, Fabrizio Castro, linux-renesas-soc

On Mon, Oct 07, 2019 at 04:38:49PM +0100, Biju Das wrote:
> This patch fixes the warning passing zero to 'PTR_ERR' by changing the
> check from 'IS_ERR_OR_NULL' to 'IS_ERR'. Also improved the error handling
> on probe function.
> 
> Fixes: 1c48c759ef4b ("usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller")
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>

OK by me. FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/hd3ss3220.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
> index 1900910..7e5f3f7 100644
> --- a/drivers/usb/typec/hd3ss3220.c
> +++ b/drivers/usb/typec/hd3ss3220.c
> @@ -178,7 +178,7 @@ static int hd3ss3220_probe(struct i2c_client *client,
>  
>  	hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
>  	fwnode_handle_put(connector);
> -	if (IS_ERR_OR_NULL(hd3ss3220->role_sw))
> +	if (IS_ERR(hd3ss3220->role_sw))
>  		return PTR_ERR(hd3ss3220->role_sw);
>  
>  	hd3ss3220->typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE;
> @@ -188,20 +188,22 @@ static int hd3ss3220_probe(struct i2c_client *client,
>  
>  	hd3ss3220->port = typec_register_port(&client->dev,
>  					      &hd3ss3220->typec_cap);
> -	if (IS_ERR(hd3ss3220->port))
> -		return PTR_ERR(hd3ss3220->port);
> +	if (IS_ERR(hd3ss3220->port)) {
> +		ret = PTR_ERR(hd3ss3220->port);
> +		goto err_put_role;
> +	}
>  
>  	hd3ss3220_set_role(hd3ss3220);
>  	ret = regmap_read(hd3ss3220->regmap, HD3SS3220_REG_CN_STAT_CTRL, &data);
>  	if (ret < 0)
> -		goto error;
> +		goto err_unreg_port;
>  
>  	if (data & HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS) {
>  		ret = regmap_write(hd3ss3220->regmap,
>  				HD3SS3220_REG_CN_STAT_CTRL,
>  				data | HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS);
>  		if (ret < 0)
> -			goto error;
> +			goto err_unreg_port;
>  	}
>  
>  	if (client->irq > 0) {
> @@ -210,18 +212,19 @@ static int hd3ss3220_probe(struct i2c_client *client,
>  					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
>  					"hd3ss3220", &client->dev);
>  		if (ret)
> -			goto error;
> +			goto err_unreg_port;
>  	}
>  
>  	ret = i2c_smbus_read_byte_data(client, HD3SS3220_REG_DEV_REV);
>  	if (ret < 0)
> -		goto error;
> +		goto err_unreg_port;
>  
>  	dev_info(&client->dev, "probed revision=0x%x\n", ret);
>  
>  	return 0;
> -error:
> +err_unreg_port:
>  	typec_unregister_port(hd3ss3220->port);
> +err_put_role:
>  	usb_role_switch_put(hd3ss3220->role_sw);
>  
>  	return ret;
> -- 
> 2.7.4

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 15:38 [PATCH] usb: typec: hd3ss3220: hd3ss3220_probe() warn: passing zero to 'PTR_ERR' Biju Das
2019-10-08 12:32 ` Heikki Krogerus

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org linux-usb@archiver.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/ public-inbox