All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Lu Guanqun <guanqun.lu@intel.com>
Cc: ALSA <alsa-devel@alsa-project.org>, clemens@ladisch.de
Subject: Re: [PATCH 3/3] ALSA: core: set kcontrol's count field correctly
Date: Wed, 24 Aug 2011 08:06:34 +0200	[thread overview]
Message-ID: <s5hy5yjpclx.wl%tiwai@suse.de> (raw)
In-Reply-To: <20110824031243.5279.93859.stgit@localhost6.localdomain6>

At Wed, 24 Aug 2011 11:12:43 +0800,
Lu Guanqun wrote:
> 
> I don't see how info's owner field relates to kcontrol's count field. It should
> assign to info's count instead.
> 
> Let's assume this scenario:
> 
> 1. user reads the control element from kernel (the owner field is set)
> 2. user changes some values
> 3. user issues 'SNDRV_CTL_IOCTL_ELEM_REPLACE' ioctl.
> 
> With the original code, 'kctl' here gets a large count number due to its
> non-empty owner field. Therefore it fails on subsequent call snd_ctl_new().

In IOCTL_ELEM_ADD and REPLACE, count and owner struct fields have
different meanings from others.  The count contains the array size,
not the number of identical elements.  And the owner contains the
number of elements to be created.  So, the current code is correct.

What we need is the documentation of this feature...


thanks,

Takashi


> This patch fixes this issue.
> 
> Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
> ---
>  sound/core/control.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/sound/core/control.c b/sound/core/control.c
> index 98b7fc7..30e1483 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -1099,7 +1099,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
>  	if (err < 0)
>  		return err;
>  	memcpy(&kctl.id, &info->id, sizeof(info->id));
> -	kctl.count = info->owner ? info->owner : 1;
> +	kctl.count = info->count;
>  	access |= SNDRV_CTL_ELEM_ACCESS_USER;
>  	kctl.info = snd_ctl_elem_user_info;
>  	if (access & SNDRV_CTL_ELEM_ACCESS_READ)
> 

  reply	other threads:[~2011-08-24  6:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24  3:12 [PATCH 1/3] ALSA: core: trivial code style fix Lu Guanqun
2011-08-24  3:12 ` [PATCH 2/3] ALSA: core: release the constraint check for replace ops Lu Guanqun
2011-08-24  6:01   ` Takashi Iwai
2011-08-24  6:08     ` Lu Guanqun
2011-08-24  6:45       ` [PATCH v2] " Lu Guanqun
2011-08-24  8:41         ` Takashi Iwai
2011-08-24  3:12 ` [PATCH 3/3] ALSA: core: set kcontrol's count field correctly Lu Guanqun
2011-08-24  6:06   ` Takashi Iwai [this message]
2011-08-24  6:17     ` Lu Guanqun
2011-08-24  6:26       ` Takashi Iwai
2011-08-24  8:42         ` Takashi Iwai
2011-08-24 11:46           ` Lu Guanqun
2011-08-24 12:05             ` Takashi Iwai
2011-08-24 12:46               ` Lu Guanqun
2011-08-24 13:06                 ` Takashi Iwai
2011-08-24  6:18     ` Takashi Iwai
2011-08-24  8:40 ` [PATCH 1/3] ALSA: core: trivial code style fix Takashi Iwai

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=s5hy5yjpclx.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=guanqun.lu@intel.com \
    /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.