From: Takashi Iwai Subject: Re: [PATCH v5 06/10] ALSA: core: pass audio tstamp config from userspace Date: Mon, 09 Feb 2015 16:08:48 +0100 Message-ID: References: <1423259759-4100-1-git-send-email-pierre-louis.bossart@linux.intel.com> <1423259759-4100-7-git-send-email-pierre-louis.bossart@linux.intel.com> 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 2A6F2260474 for ; Mon, 9 Feb 2015 16:08:49 +0100 (CET) In-Reply-To: <1423259759-4100-7-git-send-email-pierre-louis.bossart@linux.intel.com> 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: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 6 Feb 2015 15:55:55 -0600, Pierre-Louis Bossart wrote: > > Let userspace select audio timestamp config when the > STATUS_EXT ioctl is used, ignore and zero all > other fields > No change for the existing STATUS ioctl, parameters > are treated as read-only. > > Signed-off-by: Pierre-Louis Bossart > --- > sound/core/pcm_native.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c > index d50f3e6..40d2943 100644 > --- a/sound/core/pcm_native.c > +++ b/sound/core/pcm_native.c > @@ -753,12 +753,27 @@ int snd_pcm_status(struct snd_pcm_substream *substream, > } > > static int snd_pcm_status_user(struct snd_pcm_substream *substream, > - struct snd_pcm_status __user * _status) > + struct snd_pcm_status __user * _status, > + bool ext) > { > struct snd_pcm_status status; > int res; > - > - memset(&status, 0, sizeof(status)); > + u32 audio_tstamp_data; > + u32 __user *_audio_tstamp_data; > + > + if (ext == false) { > + memset(&status, 0, sizeof(status)); > + } else { > + /* > + * parameters are read/write, get audio_tstamp_data from user, > + * ignore rest of status structure > + */ > + _audio_tstamp_data = (u32 __user *)(&_status->audio_tstamp_data); > + if (get_user(audio_tstamp_data, _audio_tstamp_data)) > + return -EFAULT; > + memset(&status, 0, sizeof(status)); > + status.audio_tstamp_data = audio_tstamp_data; > + } It can be simplified a bit, e.g. memset(&status, 0, sizeof(status)); if (ext && get_user(status.audio_tstamp_data, &_status->audio_tstamp_data)) return -EFAULT; Takashi