Received: by 2002:ac8:5349:0:b0:427:7d78:cd45 with SMTP id d9csp819518qto; Wed, 20 Dec 2023 05:02:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IErirEEy5l8YCf2NgGrzMbE/lcARjsC0FfBEy3N4Wfmt17QGlHkJ4iJSnLOijIzyUTr6wUP X-Received: by 2002:a17:90a:a405:b0:28b:70e6:f6b3 with SMTP id y5-20020a17090aa40500b0028b70e6f6b3mr4245698pjp.6.1703077368199; Wed, 20 Dec 2023 05:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703077368; cv=none; d=google.com; s=arc-20160816; b=lcf5w5MFDMVOmOlQyA5YWUTI2DpiKbLIfLnz0/92uEFMj6ko3nPSMv1s+gQf0237OU th7D2oIUiB41fMqCdbZxbny5yF2f9tTjKp4fgpTq59cynpQ4i/2+MGaEG/WWG6K7fRaZ nHe5nFmfAx04N9oMLaOtYvuBZf+jk1g99CQCL/djcntiMjuExZRkWKtSefbltsuHzNeS OK9aohUuRp243VV0UjnmvrYgwqiQbLG9+1TZ0R7VjfytWgRThlgdbSPtyHMSSnUNKRu2 R7WikJXfjUhbW4Hkzqx2XWnmmckrqVQvas7d+ngBJ4O4HG/9vScwTj/JG2jRuU4nseid wguw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wwHnfbUwSKMsFeerthRKRssosFL5JzQUFW/ELAez6fM=; fh=2vd2rjvbNj479iSuIwaXZ/2EOj2BCCU77QD/Scj+DsA=; b=Y0ZlCtVWBaYY4kTYhQls2AhBeiGbITOIgnRGJopeCtHq8r6Q6Z+qzislvK4EatQWSA AnqPpbT3h2OhrDQgZaqtk4ymE4APKtngFw3Tn44Veu8zg7bSTf6frTxQDwt0BdzbXo3W 1HOEFYWO58uzdhi/awJjNSuTtp/EVTzIDuAJ/x3aTJPzp4iiD/GO6PM0uzbhasPqcuOy /fPLR+nOXuhmyfWfk2yVX2MLNRBRdbSDSqVK9SAcwZxJECXLPYZ6ZOwWgnKJ417rnJOo 2eAL889504dcY4a97WJHPlp6i3KTAz9nLHvXdZu8QUtkMivEIu4r9US3JHuDNLDSHA0Q xE1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=m8RpIy0C; spf=pass (google.com: domain of linux-kernel+bounces-6928-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6928-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l3-20020a17090ad10300b0028bc0456c51si2422013pju.70.2023.12.20.05.02.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:02:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6928-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=m8RpIy0C; spf=pass (google.com: domain of linux-kernel+bounces-6928-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6928-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C3C39B24639 for ; Wed, 20 Dec 2023 13:02:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF52325571; Wed, 20 Dec 2023 13:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="m8RpIy0C" X-Original-To: linux-kernel@vger.kernel.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59F8D25541; Wed, 20 Dec 2023 13:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 224E32B3; Wed, 20 Dec 2023 14:01:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1703077300; bh=MB0nR/heBhUV7y8E41acYk2PbnEPOOJDseKUnd5jXDw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m8RpIy0C4Dt6+20MsgoWNQ5s3PlEfxdt6kKpURHb4JqmUAzLQe/7kNGydVoi9jcR/ vch2OgKvR5oA9p/064oXtszZa6/Vc4oltEsDAVgGdENX76ik9v3U2AkCGkEkmdW/PM pM8gxcMQSSYKZxEMBJEdmKgVfmieG6jhD99/Ugmc= Date: Wed, 20 Dec 2023 15:02:36 +0200 From: Laurent Pinchart To: Tommaso Merciai Cc: linuxfancy@googlegroups.com, sakari.ailus@linux.intel.com, martin.hecht@avnet.eu, Mauro Carvalho Chehab , 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() Message-ID: <20231220130236.GN29638@pendragon.ideasonboard.com> References: <20231220124023.2801417-1-tomm.merciai@gmail.com> <20231220124023.2801417-6-tomm.merciai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 Reviewed-by: Laurent Pinchart > --- > 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