mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
ALSA: xen: Convert to generic PCM copy ops
This patch converts the xen frontend driver code to use the new unified PCM copy callback. It's a straightforward conversion from *_user() to *_iter() variants. Note that copy_from/to_iter() returns the copied bytes, hence the error condition is adjusted accordingly. Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Cc: xen-devel@lists.xenproject.org Link: https://lore.kernel.org/r/20230815190136.8987-16-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2f432f4702
commit
390244f5ba
1 changed files with 11 additions and 45 deletions
|
@ -602,8 +602,8 @@ static snd_pcm_uframes_t alsa_pointer(struct snd_pcm_substream *substream)
|
||||||
return (snd_pcm_uframes_t)atomic_read(&stream->hw_ptr);
|
return (snd_pcm_uframes_t)atomic_read(&stream->hw_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alsa_pb_copy_user(struct snd_pcm_substream *substream,
|
static int alsa_pb_copy(struct snd_pcm_substream *substream,
|
||||||
int channel, unsigned long pos, void __user *src,
|
int channel, unsigned long pos, struct iov_iter *src,
|
||||||
unsigned long count)
|
unsigned long count)
|
||||||
{
|
{
|
||||||
struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
|
struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
|
||||||
|
@ -611,28 +611,14 @@ static int alsa_pb_copy_user(struct snd_pcm_substream *substream,
|
||||||
if (unlikely(pos + count > stream->buffer_sz))
|
if (unlikely(pos + count > stream->buffer_sz))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(stream->buffer + pos, src, count))
|
if (copy_from_iter(stream->buffer + pos, count, src) != count)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count);
|
return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alsa_pb_copy_kernel(struct snd_pcm_substream *substream,
|
static int alsa_cap_copy(struct snd_pcm_substream *substream,
|
||||||
int channel, unsigned long pos, void *src,
|
int channel, unsigned long pos, struct iov_iter *dst,
|
||||||
unsigned long count)
|
|
||||||
{
|
|
||||||
struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
|
|
||||||
|
|
||||||
if (unlikely(pos + count > stream->buffer_sz))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
memcpy(stream->buffer + pos, src, count);
|
|
||||||
|
|
||||||
return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int alsa_cap_copy_user(struct snd_pcm_substream *substream,
|
|
||||||
int channel, unsigned long pos, void __user *dst,
|
|
||||||
unsigned long count)
|
unsigned long count)
|
||||||
{
|
{
|
||||||
struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
|
struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
|
||||||
|
@ -645,26 +631,8 @@ static int alsa_cap_copy_user(struct snd_pcm_substream *substream,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return copy_to_user(dst, stream->buffer + pos, count) ?
|
if (copy_to_iter(stream->buffer + pos, count, dst) != count)
|
||||||
-EFAULT : 0;
|
return -EFAULT;
|
||||||
}
|
|
||||||
|
|
||||||
static int alsa_cap_copy_kernel(struct snd_pcm_substream *substream,
|
|
||||||
int channel, unsigned long pos, void *dst,
|
|
||||||
unsigned long count)
|
|
||||||
{
|
|
||||||
struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (unlikely(pos + count > stream->buffer_sz))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
ret = xen_snd_front_stream_read(&stream->evt_pair->req, pos, count);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
memcpy(dst, stream->buffer + pos, count);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,8 +665,7 @@ static const struct snd_pcm_ops snd_drv_alsa_playback_ops = {
|
||||||
.prepare = alsa_prepare,
|
.prepare = alsa_prepare,
|
||||||
.trigger = alsa_trigger,
|
.trigger = alsa_trigger,
|
||||||
.pointer = alsa_pointer,
|
.pointer = alsa_pointer,
|
||||||
.copy_user = alsa_pb_copy_user,
|
.copy = alsa_pb_copy,
|
||||||
.copy_kernel = alsa_pb_copy_kernel,
|
|
||||||
.fill_silence = alsa_pb_fill_silence,
|
.fill_silence = alsa_pb_fill_silence,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -710,8 +677,7 @@ static const struct snd_pcm_ops snd_drv_alsa_capture_ops = {
|
||||||
.prepare = alsa_prepare,
|
.prepare = alsa_prepare,
|
||||||
.trigger = alsa_trigger,
|
.trigger = alsa_trigger,
|
||||||
.pointer = alsa_pointer,
|
.pointer = alsa_pointer,
|
||||||
.copy_user = alsa_cap_copy_user,
|
.copy = alsa_cap_copy,
|
||||||
.copy_kernel = alsa_cap_copy_kernel,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int new_pcm_instance(struct xen_snd_front_card_info *card_info,
|
static int new_pcm_instance(struct xen_snd_front_card_info *card_info,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue