Message ID | 20240313072516.241106-17-sakari.ailus@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Generic line based metadata support, internal pads | expand |
Hi Sakari, Thank you for the patch. On Wed, Mar 13, 2024 at 09:24:54AM +0200, Sakari Ailus wrote: > On VIDIOC_SUBDEV_[GS]_ROUTING, only return as many routes back to the user > as there's room. Do not consider it an error if more routes existed. > Simply inform the user there are more routes. > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > --- > .../media/v4l/vidioc-subdev-g-routing.rst | 4 ---- > drivers/media/v4l2-core/v4l2-subdev.c | 10 +++------- > 2 files changed, 3 insertions(+), 11 deletions(-) > > diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst > index 6eb6a59570dc..08b8d17cef3f 100644 > --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst > +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst > @@ -147,10 +147,6 @@ On success 0 is returned, on error -1 and the ``errno`` variable is set > appropriately. The generic error codes are described at the > :ref:`Generic Error Codes <gen-errors>` chapter. > > -ENOSPC > - The application provided ``num_routes`` is not big enough to contain > - all the available routes the subdevice exposes. > - I wonder if this patch should be squashed with the previous two. You update the documentation in 14/38 already. > EINVAL > The sink or source pad identifiers reference a non-existing pad or reference > pads of different types (ie. the sink_pad identifiers refers to a source > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index a357ce318192..a6107e440ef0 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -964,7 +964,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, > > memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, > state->routing.routes, > - state->routing.num_routes * > + min(state->routing.num_routes, routing->len_routes) * > sizeof(*state->routing.routes)); > routing->num_routes = state->routing.num_routes; > > @@ -985,14 +985,10 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, > > krouting = &state->routing; > > - if (routing->len_routes < krouting->num_routes) { > - routing->num_routes = krouting->num_routes; > - return -ENOSPC; > - } > - > memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, > krouting->routes, > - krouting->num_routes * sizeof(*krouting->routes)); > + min(krouting->num_routes, routing->len_routes) * > + sizeof(*krouting->routes)); > routing->num_routes = krouting->num_routes; > > return 0;
On Wed, Mar 20, 2024 at 03:53:19AM +0200, Laurent Pinchart wrote: > Hi Sakari, > > Thank you for the patch. > > On Wed, Mar 13, 2024 at 09:24:54AM +0200, Sakari Ailus wrote: > > On VIDIOC_SUBDEV_[GS]_ROUTING, only return as many routes back to the user > > as there's room. Do not consider it an error if more routes existed. > > Simply inform the user there are more routes. > > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > > --- > > .../media/v4l/vidioc-subdev-g-routing.rst | 4 ---- > > drivers/media/v4l2-core/v4l2-subdev.c | 10 +++------- > > 2 files changed, 3 insertions(+), 11 deletions(-) > > > > diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst > > index 6eb6a59570dc..08b8d17cef3f 100644 > > --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst > > +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst > > @@ -147,10 +147,6 @@ On success 0 is returned, on error -1 and the ``errno`` variable is set > > appropriately. The generic error codes are described at the > > :ref:`Generic Error Codes <gen-errors>` chapter. > > > > -ENOSPC > > - The application provided ``num_routes`` is not big enough to contain > > - all the available routes the subdevice exposes. > > - > > I wonder if this patch should be squashed with the previous two. You > update the documentation in 14/38 already. I'll do that.
diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst index 6eb6a59570dc..08b8d17cef3f 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst @@ -147,10 +147,6 @@ On success 0 is returned, on error -1 and the ``errno`` variable is set appropriately. The generic error codes are described at the :ref:`Generic Error Codes <gen-errors>` chapter. -ENOSPC - The application provided ``num_routes`` is not big enough to contain - all the available routes the subdevice exposes. - EINVAL The sink or source pad identifiers reference a non-existing pad or reference pads of different types (ie. the sink_pad identifiers refers to a source diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index a357ce318192..a6107e440ef0 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -964,7 +964,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, state->routing.routes, - state->routing.num_routes * + min(state->routing.num_routes, routing->len_routes) * sizeof(*state->routing.routes)); routing->num_routes = state->routing.num_routes; @@ -985,14 +985,10 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, krouting = &state->routing; - if (routing->len_routes < krouting->num_routes) { - routing->num_routes = krouting->num_routes; - return -ENOSPC; - } - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, krouting->routes, - krouting->num_routes * sizeof(*krouting->routes)); + min(krouting->num_routes, routing->len_routes) * + sizeof(*krouting->routes)); routing->num_routes = krouting->num_routes; return 0;
On VIDIOC_SUBDEV_[GS]_ROUTING, only return as many routes back to the user as there's room. Do not consider it an error if more routes existed. Simply inform the user there are more routes. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- .../media/v4l/vidioc-subdev-g-routing.rst | 4 ---- drivers/media/v4l2-core/v4l2-subdev.c | 10 +++------- 2 files changed, 3 insertions(+), 11 deletions(-)