Commit 90ed2311 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hdsp: Convert to generic PCM copy ops

This patch converts the hdsp 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.

Link: https://lore.kernel.org/r/20230815190136.8987-13-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c3abdf06
...@@ -3961,7 +3961,7 @@ static signed char *hdsp_channel_buffer_location(struct hdsp *hdsp, ...@@ -3961,7 +3961,7 @@ static signed char *hdsp_channel_buffer_location(struct hdsp *hdsp,
static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream,
int channel, unsigned long pos, int channel, unsigned long pos,
void __user *src, unsigned long count) struct iov_iter *src, unsigned long count)
{ {
struct hdsp *hdsp = snd_pcm_substream_chip(substream); struct hdsp *hdsp = snd_pcm_substream_chip(substream);
signed char *channel_buf; signed char *channel_buf;
...@@ -3972,28 +3972,14 @@ static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, ...@@ -3972,28 +3972,14 @@ static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream,
channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
if (snd_BUG_ON(!channel_buf)) if (snd_BUG_ON(!channel_buf))
return -EIO; return -EIO;
if (copy_from_user(channel_buf + pos, src, count)) if (copy_from_iter(channel_buf + pos, count, src) != count)
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
static int snd_hdsp_playback_copy_kernel(struct snd_pcm_substream *substream,
int channel, unsigned long pos,
void *src, unsigned long count)
{
struct hdsp *hdsp = snd_pcm_substream_chip(substream);
signed char *channel_buf;
channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel);
if (snd_BUG_ON(!channel_buf))
return -EIO;
memcpy(channel_buf + pos, src, count);
return 0;
}
static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream,
int channel, unsigned long pos, int channel, unsigned long pos,
void __user *dst, unsigned long count) struct iov_iter *dst, unsigned long count)
{ {
struct hdsp *hdsp = snd_pcm_substream_chip(substream); struct hdsp *hdsp = snd_pcm_substream_chip(substream);
signed char *channel_buf; signed char *channel_buf;
...@@ -4004,25 +3990,11 @@ static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, ...@@ -4004,25 +3990,11 @@ static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream,
channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
if (snd_BUG_ON(!channel_buf)) if (snd_BUG_ON(!channel_buf))
return -EIO; return -EIO;
if (copy_to_user(dst, channel_buf + pos, count)) if (copy_to_iter(channel_buf + pos, count, dst) != count)
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
static int snd_hdsp_capture_copy_kernel(struct snd_pcm_substream *substream,
int channel, unsigned long pos,
void *dst, unsigned long count)
{
struct hdsp *hdsp = snd_pcm_substream_chip(substream);
signed char *channel_buf;
channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel);
if (snd_BUG_ON(!channel_buf))
return -EIO;
memcpy(dst, channel_buf + pos, count);
return 0;
}
static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream, static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream,
int channel, unsigned long pos, int channel, unsigned long pos,
unsigned long count) unsigned long count)
...@@ -4950,8 +4922,7 @@ static const struct snd_pcm_ops snd_hdsp_playback_ops = { ...@@ -4950,8 +4922,7 @@ static const struct snd_pcm_ops snd_hdsp_playback_ops = {
.prepare = snd_hdsp_prepare, .prepare = snd_hdsp_prepare,
.trigger = snd_hdsp_trigger, .trigger = snd_hdsp_trigger,
.pointer = snd_hdsp_hw_pointer, .pointer = snd_hdsp_hw_pointer,
.copy_user = snd_hdsp_playback_copy, .copy = snd_hdsp_playback_copy,
.copy_kernel = snd_hdsp_playback_copy_kernel,
.fill_silence = snd_hdsp_hw_silence, .fill_silence = snd_hdsp_hw_silence,
}; };
...@@ -4963,8 +4934,7 @@ static const struct snd_pcm_ops snd_hdsp_capture_ops = { ...@@ -4963,8 +4934,7 @@ static const struct snd_pcm_ops snd_hdsp_capture_ops = {
.prepare = snd_hdsp_prepare, .prepare = snd_hdsp_prepare,
.trigger = snd_hdsp_trigger, .trigger = snd_hdsp_trigger,
.pointer = snd_hdsp_hw_pointer, .pointer = snd_hdsp_hw_pointer,
.copy_user = snd_hdsp_capture_copy, .copy = snd_hdsp_capture_copy,
.copy_kernel = snd_hdsp_capture_copy_kernel,
}; };
static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp) static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment