All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Russell King <rmk+kernel@armlinux.org.uk>,
	David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/7] drm/i2c: tda998x: fix error cleanup paths
Date: Wed, 6 Dec 2017 14:55:08 +0100	[thread overview]
Message-ID: <c414181e-7123-956a-ef8a-5eab0d85d627@xs4all.nl> (raw)
In-Reply-To: <E1eMYvG-0004Vh-0W@rmk-PC.armlinux.org.uk>

On 12/06/17 13:35, Russell King wrote:
> If tda998x_get_audio_ports() fails, and we requested the interrupt, we
> fail to free the interrupt before returning failure.  Rework the failure
> cleanup code and exit paths so that we always clean up properly after an
> error, and always propagate the error code.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 31 ++++++++++++++++++-------------
>  1 file changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
> index 4aeac2127974..661cb8915f2f 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -1499,10 +1499,15 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
>  
>  	/* read version: */
>  	rev_lo = reg_read(priv, REG_VERSION_LSB);
> +	if (rev_lo < 0) {
> +		dev_err(&client->dev, "failed to read version: %d\n", rev_lo);
> +		return rev_lo;
> +	}
> +
>  	rev_hi = reg_read(priv, REG_VERSION_MSB);
> -	if (rev_lo < 0 || rev_hi < 0) {
> -		ret = rev_lo < 0 ? rev_lo : rev_hi;
> -		goto fail;
> +	if (rev_hi < 0) {
> +		dev_err(&client->dev, "failed to read version: %d\n", rev_hi);
> +		return rev_hi;
>  	}
>  
>  	priv->rev = rev_lo | rev_hi << 8;
> @@ -1526,7 +1531,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
>  	default:
>  		dev_err(&client->dev, "found unsupported device: %04x\n",
>  			priv->rev);
> -		goto fail;
> +		return -ENXIO;
>  	}
>  
>  	/* after reset, enable DDC: */
> @@ -1568,7 +1573,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
>  			dev_err(&client->dev,
>  				"failed to request IRQ#%u: %d\n",
>  				client->irq, ret);
> -			goto fail;
> +			goto err_irq;
>  		}
>  
>  		/* enable HPD irq */
> @@ -1591,19 +1596,19 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
>  
>  	ret = tda998x_get_audio_ports(priv, np);
>  	if (ret)
> -		goto fail;
> +		goto err_audio;
>  
>  	if (priv->audio_port[0].format != AFMT_UNUSED)
>  		tda998x_audio_codec_init(priv, &client->dev);
>  
>  	return 0;
> -fail:
> -	/* if encoder_init fails, the encoder slave is never registered,
> -	 * so cleanup here:
> -	 */
> -	if (priv->cec)
> -		i2c_unregister_device(priv->cec);
> -	return -ENXIO;
> +
> +err_audio:
> +	if (client->irq)
> +		free_irq(client->irq, priv);
> +err_irq:
> +	i2c_unregister_device(priv->cec);
> +	return ret;
>  }
>  
>  static void tda998x_encoder_prepare(struct drm_encoder *encoder)
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-12-06 13:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06 12:34 [PATCH v2 0/7] TDA998x CEC support Russell King - ARM Linux
2017-12-06 12:35 ` [PATCH v2 1/7] drm/i2c: tda998x: move mutex/waitqueue/timer/work init early Russell King
2017-12-06 13:51   ` Hans Verkuil
2017-12-06 12:35 ` [PATCH v2 2/7] drm/i2c: tda998x: move CEC device initialisation later Russell King
2017-12-06 13:54   ` Hans Verkuil
2017-12-08 11:59     ` Russell King - ARM Linux
2017-12-12 14:37       ` Hans Verkuil
2017-12-12 14:50         ` Russell King - ARM Linux
2017-12-06 12:35 ` [PATCH v2 3/7] drm/i2c: tda998x: fix error cleanup paths Russell King
2017-12-06 13:55   ` Hans Verkuil [this message]
2017-12-06 12:35 ` [PATCH v2 4/7] drm/i2c: tda998x: always disable and clear interrupts at probe Russell King
2017-12-06 13:55   ` Hans Verkuil
2017-12-06 12:35 ` [PATCH v2 5/7] drm/i2c: tda9950: add CEC driver Russell King
2017-12-06 14:11   ` Hans Verkuil
2017-12-11 10:34     ` Russell King - ARM Linux
2017-12-06 12:35 ` [PATCH v2 6/7] drm/i2c: tda998x: add CEC support Russell King
2017-12-06 13:50   ` Hans Verkuil
2017-12-08 11:57     ` Russell King - ARM Linux
2017-12-08 12:14       ` Hans Verkuil
     [not found] ` <20171206123452.GA13127-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2017-12-06 12:35   ` [PATCH v2 7/7] dt-bindings: tda998x: add the calibration gpio Russell King
     [not found]     ` <E1eMYva-0004WA-Hf-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2017-12-06 20:41       ` Rob Herring

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=c414181e-7123-956a-ef8a-5eab0d85d627@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=rmk+kernel@armlinux.org.uk \
    /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.