Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: media requests: return EBADR instead of EACCES

If requests are used when they shouldn't, or not used when they should,
then return EBADR (Invalid request descriptor) instead of EACCES.

The reason for this change is that EACCES has more to do with permissions
(not being the owner of the resource), but in this case the request file
descriptor is just wrong for the current mode of the device.

Update the documentation accordingly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
e79c7159 ca0d1bd4

+12 -14
+1 -1
Documentation/media/uapi/mediactl/request-api.rst
··· 93 93 .. caution:: 94 94 For :ref:`memory-to-memory devices <mem2mem>` you can use requests only for 95 95 output buffers, not for capture buffers. Attempting to add a capture buffer 96 - to a request will result in an ``EACCES`` error. 96 + to a request will result in an ``EBADR`` error. 97 97 98 98 If the request contains configurations for multiple entities, individual drivers 99 99 may synchronize so the requested pipeline's topology is applied before the
+1 -1
Documentation/media/uapi/v4l/buffer.rst
··· 326 326 Applications should not set ``V4L2_BUF_FLAG_REQUEST_FD`` for any ioctls 327 327 other than :ref:`VIDIOC_QBUF <VIDIOC_QBUF>`. 328 328 329 - If the device does not support requests, then ``EACCES`` will be returned. 329 + If the device does not support requests, then ``EBADR`` will be returned. 330 330 If requests are supported but an invalid request file descriptor is 331 331 given, then ``EINVAL`` will be returned. 332 332
+5 -7
Documentation/media/uapi/v4l/vidioc-qbuf.rst
··· 111 111 until the request itself is queued. Also, the driver will apply any 112 112 settings associated with the request for this buffer. This field will 113 113 be ignored unless the ``V4L2_BUF_FLAG_REQUEST_FD`` flag is set. 114 - If the device does not support requests, then ``EACCES`` will be returned. 114 + If the device does not support requests, then ``EBADR`` will be returned. 115 115 If requests are supported but an invalid request file descriptor is given, 116 116 then ``EINVAL`` will be returned. 117 117 ··· 125 125 126 126 For :ref:`memory-to-memory devices <mem2mem>` you can specify the 127 127 ``request_fd`` only for output buffers, not for capture buffers. Attempting 128 - to specify this for a capture buffer will result in an ``EACCES`` error. 128 + to specify this for a capture buffer will result in an ``EBADR`` error. 129 129 130 130 Applications call the ``VIDIOC_DQBUF`` ioctl to dequeue a filled 131 131 (capturing) or displayed (output) buffer from the driver's outgoing ··· 185 185 codecs if a buffer with the ``V4L2_BUF_FLAG_LAST`` was already 186 186 dequeued and no new buffers are expected to become available. 187 187 188 - EACCES 189 - The ``V4L2_BUF_FLAG_REQUEST_FD`` flag was set but the device does not 190 - support requests for the given buffer type. 191 - 192 188 EBADR 193 - The ``V4L2_BUF_FLAG_REQUEST_FD`` flag was not set but the device requires 189 + The ``V4L2_BUF_FLAG_REQUEST_FD`` flag was set but the device does not 190 + support requests for the given buffer type, or 191 + the ``V4L2_BUF_FLAG_REQUEST_FD`` flag was not set but the device requires 194 192 that the buffer is part of a request. 195 193 196 194 EBUSY
+1 -1
drivers/media/common/videobuf2/videobuf2-v4l2.c
··· 392 392 return 0; 393 393 } else if (!q->supports_requests) { 394 394 dprintk(1, "%s: queue does not support requests\n", opname); 395 - return -EACCES; 395 + return -EBADR; 396 396 } else if (q->uses_qbuf) { 397 397 dprintk(1, "%s: queue does not use requests\n", opname); 398 398 return -EBUSY;
+2 -2
drivers/media/media-request.c
··· 251 251 252 252 if (!mdev || !mdev->ops || 253 253 !mdev->ops->req_validate || !mdev->ops->req_queue) 254 - return ERR_PTR(-EACCES); 254 + return ERR_PTR(-EBADR); 255 255 256 256 filp = fget(request_fd); 257 257 if (!filp) ··· 407 407 int ret = -EBUSY; 408 408 409 409 if (WARN_ON(!ops->release)) 410 - return -EACCES; 410 + return -EBADR; 411 411 412 412 spin_lock_irqsave(&req->lock, flags); 413 413
+2 -2
include/media/media-request.h
··· 198 198 * Get the request represented by @request_fd that is owned 199 199 * by the media device. 200 200 * 201 - * Return a -EACCES error pointer if requests are not supported 201 + * Return a -EBADR error pointer if requests are not supported 202 202 * by this driver. Return -EINVAL if the request was not found. 203 203 * Return the pointer to the request if found: the caller will 204 204 * have to call @media_request_put when it finished using the ··· 231 231 static inline struct media_request * 232 232 media_request_get_by_fd(struct media_device *mdev, int request_fd) 233 233 { 234 - return ERR_PTR(-EACCES); 234 + return ERR_PTR(-EBADR); 235 235 } 236 236 237 237 #endif