From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH 4/5] ALSA: control: improve returned value because of the rest Date: Wed, 11 Feb 2015 13:05:33 +0100 Message-ID: References: <1423651213-19829-1-git-send-email-o-takashi@sakamocchi.jp> <1423651213-19829-5-git-send-email-o-takashi@sakamocchi.jp> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 3D59326059B for ; Wed, 11 Feb 2015 13:05:36 +0100 (CET) In-Reply-To: <1423651213-19829-5-git-send-email-o-takashi@sakamocchi.jp> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Takashi Sakamoto Cc: alsa-devel@alsa-project.org, clemens@ladisch.de List-Id: alsa-devel@alsa-project.org At Wed, 11 Feb 2015 19:40:12 +0900, Takashi Sakamoto wrote: > When a character device doesn't have enough spaces for requested number > of controls or values, currently return -ENOMEM. This should be -ENOSPC > (No space left on device). > > This commit improves this behaviour. Well, if the error code is passed to user-space, we must not change the value now unless this change is mandatory. Otherwise this would break the user-space behavior. Takashi > > Signed-off-by: Takashi Sakamoto > --- > sound/core/control.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/sound/core/control.c b/sound/core/control.c > index bce4730..9944d75 100644 > --- a/sound/core/control.c > +++ b/sound/core/control.c > @@ -313,7 +313,7 @@ static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) > > /* this situation is very unlikely */ > dev_err(card->dev, "unable to allocate new control numid\n"); > - return -ENOMEM; > + return -ENOSPC; > } > return 0; > } > @@ -355,9 +355,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) > err = -EBUSY; > goto error; > } > - if (snd_ctl_find_hole(card, kcontrol->count) < 0) { > + err = snd_ctl_find_hole(card, kcontrol->count); > + if (err < 0) { > up_write(&card->controls_rwsem); > - err = -ENOMEM; > goto error; > } > list_add_tail(&kcontrol->list, &card->controls); > @@ -422,9 +422,9 @@ int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, > goto error; > } > add: > - if (snd_ctl_find_hole(card, kcontrol->count) < 0) { > + err = snd_ctl_find_hole(card, kcontrol->count); > + if (err < 0) { > up_write(&card->controls_rwsem); > - ret = -ENOMEM; > goto error; > } > list_add_tail(&kcontrol->list, &card->controls); > -- > 2.1.0 >