Re: [PATCH 03/25] ALSA: core: Add memory copy helpers between iov_iter and iomem

From: Andy Shevchenko
Date: Tue Aug 15 2023 - 09:52:26 EST


On Mon, Aug 14, 2023 at 01:55:01PM +0200, Takashi Iwai wrote:
> Add two more helpers for copying memory between iov_iter and iomem,
> which will be used by the new PCM copy ops in a few drivers.
> The existing helpers became wrappers of those now.
>
> Note that copy_from/to_iter() returns the copied bytes, hence the
> error condition is inverted from copy_from/to_user().

...

> - return copy_to_user(dst, (const void __force*)src, count) ? -EFAULT : 0;
> + return !copy_to_iter((const void __force *)src, count, dst) ? -EFAULT : 0;

Inverted means, I believe, this

return copy_to_iter((const void __force *)src, count, dst) == count ? 0 : -EFAULT;

as far as I understand the idea behind the copy_to_user() return value.

Ditto for other cases.

--
With Best Regards,
Andy Shevchenko