[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 14/24] 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 *_sockptr() variants.

Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
 sound/xen/xen_snd_front_alsa.c | 55 +++++++---------------------------
 1 file changed, 10 insertions(+), 45 deletions(-)

diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
index 7a3dfce97c15..a7e2cba3ff4e 100644
--- a/sound/xen/xen_snd_front_alsa.c
+++ b/sound/xen/xen_snd_front_alsa.c
@@ -602,38 +602,24 @@ static snd_pcm_uframes_t alsa_pointer(struct 
snd_pcm_substream *substream)
        return (snd_pcm_uframes_t)atomic_read(&stream->hw_ptr);
 }
 
-static int alsa_pb_copy_user(struct snd_pcm_substream *substream,
-                            int channel, unsigned long pos, void __user *src,
-                            unsigned long count)
+static int alsa_pb_copy(struct snd_pcm_substream *substream,
+                       int channel, unsigned long pos, sockptr_t src,
+                       unsigned long count)
 {
        struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
 
        if (unlikely(pos + count > stream->buffer_sz))
                return -EINVAL;
 
-       if (copy_from_user(stream->buffer + pos, src, count))
+       if (copy_from_sockptr(stream->buffer + pos, src, count))
                return -EFAULT;
 
        return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count);
 }
 
-static int alsa_pb_copy_kernel(struct snd_pcm_substream *substream,
-                              int channel, unsigned long pos, void *src,
-                              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)
+static int alsa_cap_copy(struct snd_pcm_substream *substream,
+                        int channel, unsigned long pos, sockptr_t dst,
+                        unsigned long count)
 {
        struct xen_snd_front_pcm_stream_info *stream = stream_get(substream);
        int ret;
@@ -645,29 +631,10 @@ static int alsa_cap_copy_user(struct snd_pcm_substream 
*substream,
        if (ret < 0)
                return ret;
 
-       return copy_to_user(dst, stream->buffer + pos, count) ?
+       return copy_to_sockptr(dst, stream->buffer + pos, count) ?
                -EFAULT : 0;
 }
 
-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;
-}
-
 static int alsa_pb_fill_silence(struct snd_pcm_substream *substream,
                                int channel, unsigned long pos,
                                unsigned long count)
@@ -697,8 +664,7 @@ static const struct snd_pcm_ops snd_drv_alsa_playback_ops = 
{
        .prepare        = alsa_prepare,
        .trigger        = alsa_trigger,
        .pointer        = alsa_pointer,
-       .copy_user      = alsa_pb_copy_user,
-       .copy_kernel    = alsa_pb_copy_kernel,
+       .copy           = alsa_pb_copy,
        .fill_silence   = alsa_pb_fill_silence,
 };
 
@@ -710,8 +676,7 @@ static const struct snd_pcm_ops snd_drv_alsa_capture_ops = {
        .prepare        = alsa_prepare,
        .trigger        = alsa_trigger,
        .pointer        = alsa_pointer,
-       .copy_user      = alsa_cap_copy_user,
-       .copy_kernel    = alsa_cap_copy_kernel,
+       .copy           = alsa_cap_copy,
 };
 
 static int new_pcm_instance(struct xen_snd_front_card_info *card_info,
-- 
2.35.3




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.