lkml.org 
[lkml]   [2010]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] sound: push BKL into open functions
On Sat, 10 Jul 2010, Arnd Bergmann wrote:

> --- a/sound/core/hwdep.c
> +++ b/sound/core/hwdep.c
> @@ -94,13 +94,18 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
> hw = snd_lookup_oss_minor_data(iminor(inode),
> SNDRV_OSS_DEVICE_TYPE_DMFM);
> #endif
> - } else
> - return -ENXIO;
> + } else {
> + err = -ENXIO;
> + goto out;
> + }
> +
> + err = -ENODEV;
> if (hw == NULL)
> - return -ENODEV;
> + goto out;
>
> + err = -EFAULT;
> if (!try_module_get(hw->card->module))
> - return -EFAULT;
> + goto out;
>
> init_waitqueue_entry(&wait, current);
> add_wait_queue(&hw->open_wait, &wait);
> @@ -147,6 +152,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
> mutex_unlock(&hw->open_mutex);
> if (err < 0)
> module_put(hw->card->module);
> +out:
> return err;
> }
>
> diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
> index f50ebf2..c30b1f3 100644
> --- a/sound/core/oss/mixer_oss.c
> +++ b/sound/core/oss/mixer_oss.c
> @@ -49,17 +49,19 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
>
> card = snd_lookup_oss_minor_data(iminor(inode),
> SNDRV_OSS_DEVICE_TYPE_MIXER);
> - if (card == NULL)
> - return -ENODEV;
> - if (card->mixer_oss == NULL)
> - return -ENODEV;
> + err = -ENODEV;
> + if (card == NULL || card->mixer_oss == NULL)
> + goto out;
> +
> err = snd_card_file_add(card, file);
> if (err < 0)
> - return err;
> + goto out;
> +
> fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL);
> if (fmixer == NULL) {
> snd_card_file_remove(card, file);
> - return -ENOMEM;
> + err = -ENOMEM;
> + goto out;
> }
> fmixer->card = card;
> fmixer->mixer = card->mixer_oss;
> @@ -67,9 +69,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
> if (!try_module_get(card->module)) {
> kfree(fmixer);
> snd_card_file_remove(card, file);
> - return -EFAULT;
> + err = -EFAULT;
> }
> - return 0;
> +out:
> + return err;
> }
>

I don't see any reason (benefit) to add gotos to these two functions.

Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.


\
 
 \ /
  Last update: 2010-07-11 09:51    [W:0.095 / U:0.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site