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.tro...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to