From patchwork Fri Dec 16 13:32:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe Trotin X-Patchwork-Id: 9477905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2E56C601C2 for ; Fri, 16 Dec 2016 13:32:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FC4F287A8 for ; Fri, 16 Dec 2016 13:32:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11345287BA; Fri, 16 Dec 2016 13:32:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC53287A8 for ; Fri, 16 Dec 2016 13:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757596AbcLPNcl (ORCPT ); Fri, 16 Dec 2016 08:32:41 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:63172 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757498AbcLPNck (ORCPT ); Fri, 16 Dec 2016 08:32:40 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id uBGDVAtu004954; Fri, 16 Dec 2016 14:32:37 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 27bdmsydcc-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 16 Dec 2016 14:32:37 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 717FB31; Fri, 16 Dec 2016 13:32:36 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5B5792BE4; Fri, 16 Dec 2016 13:32:36 +0000 (GMT) Received: from localhost (10.201.23.70) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.294.0; Fri, 16 Dec 2016 14:32:36 +0100 From: Jean-Christophe Trotin To: , Hans Verkuil CC: , Benjamin Gaignard , Yannick Fertre , Hugues Fruchet , Jean-Christophe Trotin Subject: [PATCH v1] [media] v4l2-common: fix aligned value calculation Date: Fri, 16 Dec 2016 14:32:15 +0100 Message-ID: <1481895135-11055-1-git-send-email-jean-christophe.trotin@st.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.201.23.70] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-16_09:, , signatures=0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; }