linux/drivers/media/common/videobuf2
Zile Xiong a562d6dc86 media: vb2: use ssize_t for vb2_read/vb2_write
vb2_read() and vb2_write() return size_t, but propagate
negative errno values from __vb2_perform_fileio().

This relies on implicit signed/unsigned conversions in callers
(e.g. vb2_fop_read()) to recover error codes:

    __vb2_perform_fileio() -> -EINVAL
    vb2_read()             -> (size_t)-EINVAL
    vb2_fop_read()         -> -EINVAL

This relies on implicit conversions that are not obvious.

These helpers are exported (EXPORT_SYMBOL_GPL) and part of the
vb2 API, so changing their return type may affect existing users.

However, they conceptually follow read/write semantics, where
ssize_t is typically used to return either a byte count or a
negative error code.

Switch vb2_read() and vb2_write() to ssize_t, and update
__vb2_perform_fileio() accordingly.

Signed-off-by: Zile Xiong <xiongzile99@gmail.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Fixes: b25748fe61 ("[media] v4l: videobuf2: add read() and write() emulator")
Cc: stable@vger.kernel.org
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
History 2026-05-06 09:05:56 +02:00
..
frame_vector.c media: use struct_size() helper 2023-09-27 09:40:01 +02:00
Kconfig media: videobuf2: Move frame_vector into media subsystem 2021-01-12 14:15:31 +01:00
Makefile media: Makefiles: sort entries where it fits 2022-03-14 09:42:59 +01:00
vb2-trace.c media: videobuf2: fix build issues with vb2-trace 2018-02-23 05:13:53 -05:00
videobuf2-core.c media: vb2: use ssize_t for vb2_read/vb2_write 2026-05-06 09:05:56 +02:00
videobuf2-dma-contig.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
videobuf2-dma-sg.c media: videobuf2: Set vma_flags in vb2_dma_sg_mmap 2026-03-16 11:51:55 +01:00
videobuf2-dvb.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
videobuf2-memops.c media: videobuf2: revert "get_userptr: buffers are always writable" 2022-12-06 07:14:31 +00:00
videobuf2-v4l2.c media: vb2: remove vb2_ops_wait_prepare/finish helpers 2025-12-18 11:14:57 +01:00
videobuf2-vmalloc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00