linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean-Christophe Trotin <jean-christophe.trotin@st.com>
To: <linux-media@vger.kernel.org>, Hans Verkuil <hverkuil@xs4all.nl>
Cc: <kernel@stlinux.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Yannick Fertre <yannick.fertre@st.com>,
	Hugues Fruchet <hugues.fruchet@st.com>,
	Jean-Christophe Trotin <jean-christophe.trotin@st.com>
Subject: [PATCH v1] [media] v4l2-common: fix aligned value calculation
Date: Fri, 16 Dec 2016 14:32:15 +0100	[thread overview]
Message-ID: <1481895135-11055-1-git-send-email-jean-christophe.trotin@st.com> (raw)

Correct the calculation of the rounding to nearest aligned value in
the clamp_align() function. For example, clamp_align(1277, 1, 9600, 2)
returns 1276, while it should return 1280.

Signed-off-by: Jean-Christophe Trotin <jean-christophe.trotin@st.com>
---
 drivers/media/v4l2-core/v4l2-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 57cfe26a..2970ce7 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -315,7 +315,7 @@ static unsigned int clamp_align(unsigned int x, unsigned int min,
 
 	/* Round to nearest aligned value */
 	if (align)
-		x = (x + (1 << (align - 1))) & mask;
+		x = (x + ((1 << align) - 1)) & mask;
 
 	return x;
 }
-- 
1.9.1


             reply	other threads:[~2016-12-16 13:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 13:32 Jean-Christophe Trotin [this message]
2016-12-16 13:56 ` [PATCH v1] [media] v4l2-common: fix aligned value calculation Sakari Ailus
2017-01-03  9:12   ` Jean Christophe TROTIN

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=1481895135-11055-1-git-send-email-jean-christophe.trotin@st.com \
    --to=jean-christophe.trotin@st.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=hugues.fruchet@st.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@stlinux.com \
    --cc=linux-media@vger.kernel.org \
    --cc=yannick.fertre@st.com \
    /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 NNTP newsgroup(s).