Re: [PATCH 21/25] ASoC: dmaengine: Convert to generic PCM copy ops
From: Andy Shevchenko
Date: Tue Aug 15 2023 - 10:01:07 EST
On Mon, Aug 14, 2023 at 01:55:19PM +0200, Takashi Iwai wrote:
> This patch converts the ASoC dmaenging driver code to use the new
> unified PCM copy callback. It's a straightforward conversion from
> *_user() to *_iter() variants.
>
> The process callback is still using the direct pointer as of now, but
> it'll be converted in the next patch.
>
> Note that copy_from/to_iter() returns the copied bytes, hence the
> error condition is inverted from copy_from/to_user().
...
> if (is_playback)
> - if (copy_from_user(dma_ptr, buf, bytes))
> + if (!copy_from_iter(dma_ptr, bytes, buf))
!= bytes ?
> return -EFAULT;
Can be compressed to a single conditional:
if (is_playback && copy_from_iter(dma_ptr, bytes, buf) != bytes)
...
> if (!is_playback)
> - if (copy_to_user(buf, dma_ptr, bytes))
> + if (!copy_to_iter(dma_ptr, bytes, buf))
> return -EFAULT;
As per above.
--
With Best Regards,
Andy Shevchenko