Message ID | 20240403091306.1308878-3-yunkec@chromium.org |
---|---|
State | New |
Headers | show |
Series | media: videobuf2-core: attach once if multiple planes share the same dbuf | expand |
On 03/04/2024 11:13, Yunke Cao wrote: > Release the planes from num_planes - 1 to 0. > > Signed-off-by: Yunke Cao <yunkec@chromium.org> > --- > drivers/media/common/videobuf2/videobuf2-core.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c > index 702f7b6f783a..a5368cef73bb 100644 > --- a/drivers/media/common/videobuf2/videobuf2-core.c > +++ b/drivers/media/common/videobuf2/videobuf2-core.c > @@ -320,10 +320,10 @@ static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p) > */ > static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) > { > - unsigned int plane; > + unsigned int i; > > - for (plane = 0; plane < vb->num_planes; ++plane) > - __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); > + for (i = 0; i < vb->num_planes; ++i) > + __vb2_plane_dmabuf_put(vb, &vb->planes[vb->num_planes - 1 - i]); This is a bit ugly. Why not just do: for (plane = vb->num_planes; plane; plane--) __vb2_plane_dmabuf_put(vb, &vb->planes[plane - 1]); Regards, Hans > } > > /*
On Wed, Apr 24, 2024 at 12:24:24PM +0200, Hans Verkuil wrote: > On 03/04/2024 11:13, Yunke Cao wrote: > > Release the planes from num_planes - 1 to 0. > > > > Signed-off-by: Yunke Cao <yunkec@chromium.org> > > --- > > drivers/media/common/videobuf2/videobuf2-core.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c > > index 702f7b6f783a..a5368cef73bb 100644 > > --- a/drivers/media/common/videobuf2/videobuf2-core.c > > +++ b/drivers/media/common/videobuf2/videobuf2-core.c > > @@ -320,10 +320,10 @@ static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p) > > */ > > static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) > > { > > - unsigned int plane; > > + unsigned int i; > > > > - for (plane = 0; plane < vb->num_planes; ++plane) > > - __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); > > + for (i = 0; i < vb->num_planes; ++i) > > + __vb2_plane_dmabuf_put(vb, &vb->planes[vb->num_planes - 1 - i]); > > This is a bit ugly. Why not just do: > > for (plane = vb->num_planes; plane; plane--) > __vb2_plane_dmabuf_put(vb, &vb->planes[plane - 1]); How about making plane signed (since it's just a local variable) and avoiding any weird additions or subtractions? Best regards, Tomasz
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 702f7b6f783a..a5368cef73bb 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -320,10 +320,10 @@ static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p) */ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) { - unsigned int plane; + unsigned int i; - for (plane = 0; plane < vb->num_planes; ++plane) - __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); + for (i = 0; i < vb->num_planes; ++i) + __vb2_plane_dmabuf_put(vb, &vb->planes[vb->num_planes - 1 - i]); } /*
Release the planes from num_planes - 1 to 0. Signed-off-by: Yunke Cao <yunkec@chromium.org> --- drivers/media/common/videobuf2/videobuf2-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)