From: Tomasz Figa <tfiga@chromium.org>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Yunke Cao <yunkec@chromium.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org
Subject: Re: [PATCH v2 2/3] media: videobuf2-core: reverse the iteration order in __vb2_buf_dmabuf_put
Date: Fri, 17 May 2024 20:14:40 +0900 [thread overview]
Message-ID: <3zv3fq5w74frtrcoabtp7s24aob4lisehlwpr2uaj45g7oeoxl@qbz724nghogj> (raw)
In-Reply-To: <9431abcf-15d8-4a86-b824-1243114055a7@xs4all.nl>
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
next prev parent reply other threads:[~2024-05-17 11:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 9:13 [PATCH v2 0/3] media: videobuf2-core: attach once if multiple planes share the same dbuf Yunke Cao
2024-04-03 9:13 ` [PATCH v2 1/3] media: videobuf2-core: release all planes first in __prepare_dmabuf() Yunke Cao
2024-05-17 11:11 ` Tomasz Figa
2024-05-30 4:13 ` Yunke Cao
2024-04-03 9:13 ` [PATCH v2 2/3] media: videobuf2-core: reverse the iteration order in __vb2_buf_dmabuf_put Yunke Cao
2024-04-24 10:24 ` Hans Verkuil
2024-05-17 11:14 ` Tomasz Figa [this message]
2024-04-03 9:13 ` [PATCH v2 3/3] media: videobuf2-core: attach once if multiple planes share the same dbuf Yunke Cao
2024-05-17 11:23 ` Tomasz Figa
2024-05-20 2:19 ` Yunke Cao
2024-04-24 10:25 ` [PATCH v2 0/3] " Hans Verkuil
2024-05-08 16:02 ` Tomasz Figa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3zv3fq5w74frtrcoabtp7s24aob4lisehlwpr2uaj45g7oeoxl@qbz724nghogj \
--to=tfiga@chromium.org \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=yunkec@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).