diff mbox

ALSA: control: obsolete 'already present' messaging because it's caller's fault

Message ID 1423391348-2219-1-git-send-email-o-takashi@sakamocchi.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Sakamoto Feb. 8, 2015, 10:29 a.m. UTC
When drivers or userspace applications add a duplicated control, snd
module outputs error message and return -EBUSY.

This state is a bug in driver or application, therefore the messaging
should be done by them, not by snd module.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/core/control.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Comments

Takashi Iwai Feb. 8, 2015, 11:16 a.m. UTC | #1
At Sun,  8 Feb 2015 19:29:08 +0900,
Takashi Sakamoto wrote:
> 
> When drivers or userspace applications add a duplicated control, snd
> module outputs error message and return -EBUSY.
> 
> This state is a bug in driver or application, therefore the messaging
> should be done by them, not by snd module.

The message should be hidden for user-space actions, indeed, but it's
been very helpful for the driver developments, so I'm against the
unconditional removal.

Also, think what you really suggested: there are almost 500 calls of
snd_ctl_add() in the tree and you suggest to put the error message to
each of them.

Rather try to show the error only for the kernel snd_ctl_add() calls.


thanks,

Takashi

> 
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
>  sound/core/control.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/sound/core/control.c b/sound/core/control.c
> index d482997..8906b66 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -357,18 +357,10 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
>  
>  	down_write(&card->controls_rwsem);
>  	if (snd_ctl_find_id(card, &id)) {
> -		up_write(&card->controls_rwsem);
> -		dev_err(card->dev, "control %i:%i:%i:%s:%i is already present\n",
> -					id.iface,
> -					id.device,
> -					id.subdevice,
> -					id.name,
> -					id.index);
>  		err = -EBUSY;
>  		goto error;
>  	}
>  	if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
> -		up_write(&card->controls_rwsem);
>  		err = -ENOMEM;
>  		goto error;
>  	}
> @@ -388,6 +380,7 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
>  	return 0;
>  
>   error:
> +	up_write(&card->controls_rwsem);
>  	snd_ctl_free_one(kcontrol);
>  	return err;
>  }
> -- 
> 2.1.0
>
Takashi Iwai Feb. 8, 2015, 2:33 p.m. UTC | #2
At Sun, 08 Feb 2015 12:16:33 +0100,
Takashi Iwai wrote:
> 
> At Sun,  8 Feb 2015 19:29:08 +0900,
> Takashi Sakamoto wrote:
> > 
> > When drivers or userspace applications add a duplicated control, snd
> > module outputs error message and return -EBUSY.
> > 
> > This state is a bug in driver or application, therefore the messaging
> > should be done by them, not by snd module.
> 
> The message should be hidden for user-space actions, indeed, but it's
> been very helpful for the driver developments, so I'm against the
> unconditional removal.
> 
> Also, think what you really suggested: there are almost 500 calls of
> snd_ctl_add() in the tree and you suggest to put the error message to
> each of them.
> 
> Rather try to show the error only for the kernel snd_ctl_add() calls.

Alternatively, the easiest fix would be to change it to dev_dbg().


Takashi
diff mbox

Patch

diff --git a/sound/core/control.c b/sound/core/control.c
index d482997..8906b66 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -357,18 +357,10 @@  int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
 
 	down_write(&card->controls_rwsem);
 	if (snd_ctl_find_id(card, &id)) {
-		up_write(&card->controls_rwsem);
-		dev_err(card->dev, "control %i:%i:%i:%s:%i is already present\n",
-					id.iface,
-					id.device,
-					id.subdevice,
-					id.name,
-					id.index);
 		err = -EBUSY;
 		goto error;
 	}
 	if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
-		up_write(&card->controls_rwsem);
 		err = -ENOMEM;
 		goto error;
 	}
@@ -388,6 +380,7 @@  int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
 	return 0;
 
  error:
+	up_write(&card->controls_rwsem);
 	snd_ctl_free_one(kcontrol);
 	return err;
 }