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

Hi Jean-Christophe,

On Fri, Dec 16, 2016 at 02:32:15PM +0100, Jean-Christophe Trotin wrote:
> 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.

Why should the function return 1280 instead of 1276, which is closer to
1277?

> 
> 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;
>  }

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 13:32 [PATCH v1] [media] v4l2-common: fix aligned value calculation Jean-Christophe Trotin
2016-12-16 13:56 ` Sakari Ailus [this message]
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=20161216135626.GK16630@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=benjamin.gaignard@linaro.org \
    --cc=hugues.fruchet@st.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jean-christophe.trotin@st.com \
    --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).