mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tommaso Merciai <tomm.merciai@gmail.com>
Cc: linuxfancy@googlegroups.com, sakari.ailus@linux.intel.com,
	martin.hecht@avnet.eu, Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 5/5] media: i2c: alvium: fix req_fr check into alvium_s_frame_interval()
Date: Wed, 20 Dec 2023 15:02:36 +0200	[thread overview]
Message-ID: <20231220130236.GN29638@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20231220124023.2801417-6-tomm.merciai@gmail.com>

Hi Tommaso,

Thank you for the patch.

On Wed, Dec 20, 2023 at 01:40:23PM +0100, Tommaso Merciai wrote:
> Actually req_fr check into alvium_s_frame_interval() is wrong.
> In particular req_fr can't be >=max and <= min at the same time.
> Fix this using clamp and remove dft_fr parameter from
> alvium_get_frame_interval() not more used.

The commit message should have explained why clamping is better than
picking a default value, as that's a functional change. If you propose
an updated commit message in a reply, I think Sakari can update the
patch when applying the series to his tree, there's no need for a v4.

> Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/i2c/alvium-csi2.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c
> index 240bf991105e..01111a00902d 100644
> --- a/drivers/media/i2c/alvium-csi2.c
> +++ b/drivers/media/i2c/alvium-csi2.c
> @@ -1171,12 +1171,10 @@ static int alvium_set_bayer_pattern(struct alvium_dev *alvium,
>  }
>  
>  static int alvium_get_frame_interval(struct alvium_dev *alvium,
> -				     u64 *dft_fr, u64 *min_fr, u64 *max_fr)
> +				     u64 *min_fr, u64 *max_fr)
>  {
>  	int ret = 0;
>  
> -	alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW,
> -		    dft_fr, &ret);
>  	alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MIN_R,
>  		    min_fr, &ret);
>  	alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MAX_R,
> @@ -1647,7 +1645,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
>  {
>  	struct alvium_dev *alvium = sd_to_alvium(sd);
>  	struct device *dev = &alvium->i2c_client->dev;
> -	u64 req_fr, dft_fr, min_fr, max_fr;
> +	u64 req_fr, min_fr, max_fr;
>  	struct v4l2_fract *interval;
>  	int ret;
>  
> @@ -1657,7 +1655,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
>  	if (fi->interval.denominator == 0)
>  		return -EINVAL;
>  
> -	ret = alvium_get_frame_interval(alvium, &dft_fr, &min_fr, &max_fr);
> +	ret = alvium_get_frame_interval(alvium, &min_fr, &max_fr);
>  	if (ret) {
>  		dev_err(dev, "Fail to get frame interval\n");
>  		return ret;
> @@ -1670,9 +1668,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
>  
>  	req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) /
>  		       fi->interval.numerator);
> -
> -	if (req_fr >= max_fr && req_fr <= min_fr)
> -		req_fr = dft_fr;
> +	req_fr = clamp(req_fr, min_fr, max_fr);
>  
>  	interval = v4l2_subdev_state_get_interval(sd_state, 0);
>  

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-12-20 13:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 12:40 [PATCH v3 0/5] media: i2c: alvium: store frame interval in subdev Tommaso Merciai
2023-12-20 12:40 ` [PATCH v3 1/5] media: i2c: alvium: removal of dft_fr, min_fr and max_fr Tommaso Merciai
2023-12-20 12:40 ` [PATCH v3 2/5] media: i2c: alvium: remove the fr field of the alvium_dev structure Tommaso Merciai
2023-12-20 12:40 ` [PATCH v3 3/5] media: i2c: alvium: inline set_frame_interval into s_frame_interval Tommaso Merciai
2023-12-20 12:40 ` [PATCH v3 4/5] media: i2c: alvium: store frame interval in subdev state Tommaso Merciai
2023-12-20 12:40 ` [PATCH v3 5/5] media: i2c: alvium: fix req_fr check into alvium_s_frame_interval() Tommaso Merciai
2023-12-20 13:02   ` Laurent Pinchart [this message]
2023-12-20 13:52     ` Tommaso Merciai
2024-02-14 11:14       ` Sakari Ailus
2024-02-14 15:24         ` Tommaso Merciai

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=20231220130236.GN29638@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxfancy@googlegroups.com \
    --cc=martin.hecht@avnet.eu \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomm.merciai@gmail.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

all inboxes | Powered by JetHome®