All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] [media] v4l2-common: fix aligned value calculation
@ 2016-12-16 13:32 Jean-Christophe Trotin
  2016-12-16 13:56 ` Sakari Ailus
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Christophe Trotin @ 2016-12-16 13:32 UTC (permalink / raw)
  To: linux-media, Hans Verkuil
  Cc: kernel, Benjamin Gaignard, Yannick Fertre, Hugues Fruchet,
	Jean-Christophe Trotin

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-03  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 13:32 [PATCH v1] [media] v4l2-common: fix aligned value calculation Jean-Christophe Trotin
2016-12-16 13:56 ` Sakari Ailus
2017-01-03  9:12   ` Jean Christophe TROTIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.