diff mbox

[2/7] em28xx-audio: simplify error handling

Message ID 1389567649-26838-3-git-send-email-m.chehab@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Jan. 12, 2014, 11 p.m. UTC
Cleanup the error handling code at em28xx-audio init.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
---
 drivers/media/usb/em28xx/em28xx-audio.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

Comments

Frank Schäfer Jan. 13, 2014, 6:41 p.m. UTC | #1
On 13.01.2014 00:00, Mauro Carvalho Chehab wrote:
> Cleanup the error handling code at em28xx-audio init.
>
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> ---
>   drivers/media/usb/em28xx/em28xx-audio.c | 27 ++++++++++++++-------------
>   1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
> index 47766b796acb..97d9105e6830 100644
> --- a/drivers/media/usb/em28xx/em28xx-audio.c
> +++ b/drivers/media/usb/em28xx/em28xx-audio.c
> @@ -893,10 +893,8 @@ static int em28xx_audio_init(struct em28xx *dev)
>   	adev->udev = dev->udev;
>   
>   	err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm);
> -	if (err < 0) {
> -		snd_card_free(card);
> -		return err;
> -	}
> +	if (err < 0)
> +		goto card_free;
>   
>   	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_em28xx_pcm_capture);
>   	pcm->info_flags = 0;
> @@ -927,20 +925,23 @@ static int em28xx_audio_init(struct em28xx *dev)
>   	}
>   
>   	err = em28xx_audio_urb_init(dev);
> -	if (err) {
> -		snd_card_free(card);
> -		return -ENODEV;
> -	}
> +	if (err)
> +		goto card_free;
>   
>   	err = snd_card_register(card);
> -	if (err < 0) {
> -		em28xx_audio_free_urb(dev);
> -		snd_card_free(card);
> -		return err;
> -	}
> +	if (err < 0)
> +		goto urb_free;
>   
>   	em28xx_info("Audio extension successfully initialized\n");
>   	return 0;
> +
> +urb_free:
> +	em28xx_audio_free_urb(dev);
> +
> +card_free:
> +	snd_card_free(card);
> +
> +	return err;
>   }
>   
>   static int em28xx_audio_fini(struct em28xx *dev)
Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index 47766b796acb..97d9105e6830 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -893,10 +893,8 @@  static int em28xx_audio_init(struct em28xx *dev)
 	adev->udev = dev->udev;
 
 	err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto card_free;
 
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_em28xx_pcm_capture);
 	pcm->info_flags = 0;
@@ -927,20 +925,23 @@  static int em28xx_audio_init(struct em28xx *dev)
 	}
 
 	err = em28xx_audio_urb_init(dev);
-	if (err) {
-		snd_card_free(card);
-		return -ENODEV;
-	}
+	if (err)
+		goto card_free;
 
 	err = snd_card_register(card);
-	if (err < 0) {
-		em28xx_audio_free_urb(dev);
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto urb_free;
 
 	em28xx_info("Audio extension successfully initialized\n");
 	return 0;
+
+urb_free:
+	em28xx_audio_free_urb(dev);
+
+card_free:
+	snd_card_free(card);
+
+	return err;
 }
 
 static int em28xx_audio_fini(struct em28xx *dev)