Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp19673rdb; Sun, 17 Dec 2023 18:51:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzIkZYxLqyFjLOizPt94UTOINTmC8V8tHmC0Q217Mn2Mz3vonhRCWFPgA7TRZaEOWiH6Wc X-Received: by 2002:a50:9983:0:b0:553:39e3:879a with SMTP id m3-20020a509983000000b0055339e3879amr1201193edb.41.1702867872436; Sun, 17 Dec 2023 18:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702867872; cv=none; d=google.com; s=arc-20160816; b=i0TqQwfMPXDrN+I1u5OA+LAxKM05oepZFdZ5vM+3f6O1RhU7vhNTbmipOB8KPnLQEy /B+JBC4h97khywsjGQ/GDa+OURf/oJLqhO/fzO1CdCVrPM0wUQlYA14GG9OuBaZOcocs CWmbsI+hH99rK3HJgHlEZ5vq8lcRLlPk1esVvOf4oou22TqS6Zj7iCYxDVJIXRb/jP2P c6EpqQvnP3piwOs+5GjJ1WAhC/v2OgSYElW55wEfaiwQB+p+isaXKg3Rdlear/Gt5ixR JeCJ7m8SYut0SVMtxq/mM01OpiDBGkwoEWmqKisG/bYWF06hSwFn0+HJzbw16KfMMQrr rn7A== 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=E2aD10EjYhDN2l+uBwQTmcZpPej3M7j85SXAU/ZeHNY=; fh=cqB3jvkIGLPqHYfnbOulxfH1CJnm8CVnas5gPCIFduU=; b=pK1kuvFE347Hx78PfKB9ZoUxOfJjRa+MOi+zjfB19bFQr6TUXkbNbvQwjTueGiJQWR HFlBFXsAdM5PxgaEBzH40oQf7liiD7F9+iwPgYgzVIZoFjM16Z7w7jxzDPLOAJJ7jeQa g5RU6xueh5wTxccYT4Dt6JFRz9v3Xo4OnOje1XwiE72lCvqo19viMCvk0LonVVx8aBZs 3QJAH9rxON1ckHgLzoYgvzP5/MfnaKU2fq+MDzoo9vuBV9i5es04vkvNjzhVUvmZlGC+ PvUx9UyBW3IcBJx25Pj4qK4Gsun7Qm23G57XuOpAxYVQSt6Od+ldoj4hcgVFBhag5bDD gM9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="q/P1wkyU"; spf=pass (google.com: domain of linux-kernel+bounces-2946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2946-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q15-20020a50cc8f000000b00551f4310ef7si4934773edi.195.2023.12.17.18.51.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 18:51:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="q/P1wkyU"; spf=pass (google.com: domain of linux-kernel+bounces-2946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2946-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C02DF1F21455 for ; Mon, 18 Dec 2023 02:51:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2C6946B8; Mon, 18 Dec 2023 02:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="q/P1wkyU" 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 0E2CE5238; Mon, 18 Dec 2023 02:50:39 +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 B9CD11583; Mon, 18 Dec 2023 03:49:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702867789; bh=kAjfKX0BWMBTowti17qTSb6dTKjTkYpWap0QOJvxxgA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q/P1wkyUPgR+EY9tRz3uDkV2GItpL/j1dfhB+M4ED3RiN0I3EvrSArBwWjtVf7ibK TJ0pa3B4IGUQpPG5v+gYXRek4zVjFImLE5fIG9YeIFx1EU72TPpy1eKXzT+8/sDBaK 8UAAxRRtaamUYS2Px9nqKOcKaiQVIhamKWQYoK7c= Date: Mon, 18 Dec 2023 04:50:44 +0200 From: Laurent Pinchart To: Tommaso Merciai Cc: linuxfancy@googlegroups.com, sakari.ailus@linux.intel.com, Martin Hecht , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] media: i2c: alvium: removal of dft_fr, min_fr and max_fr Message-ID: <20231218025044.GH5290@pendragon.ideasonboard.com> References: <20231215082452.1720481-1-tomm.merciai@gmail.com> <20231215082452.1720481-2-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: <20231215082452.1720481-2-tomm.merciai@gmail.com> Hi Tommaso, Thank you for the patch. On Fri, Dec 15, 2023 at 09:24:50AM +0100, Tommaso Merciai wrote: > Remove driver private data dft_fr, min_fr and max_fr. > Those are used only in alvium_set_frame_interval function. > Use local ones instead. The fields are used to pass data from alvium_get_frame_interval() to its caller, not just in alvium_get_frame_interval(). You can write The dft_fr, min_fr and max_fr fields of the alvium_dev structure are only used to pass results from alvium_get_frame_interval() to its caller. Replace them with function parameters. > Signed-off-by: Tommaso Merciai > --- > drivers/media/i2c/alvium-csi2.c | 45 +++++++++++++++------------------ > drivers/media/i2c/alvium-csi2.h | 3 --- > 2 files changed, 21 insertions(+), 27 deletions(-) > > diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c > index 34ff7fad3877..c4b7851045a1 100644 > --- a/drivers/media/i2c/alvium-csi2.c > +++ b/drivers/media/i2c/alvium-csi2.c > @@ -1170,40 +1170,36 @@ static int alvium_set_bayer_pattern(struct alvium_dev *alvium, > return 0; > } > > -static int alvium_get_frame_interval(struct alvium_dev *alvium) > +static int alvium_get_frame_interval(struct alvium_dev *alvium, > + u64 *dft_fr, u64 *min_fr, u64 *max_fr) > { > - u64 dft_fr, min_fr, max_fr; > int ret = 0; > > alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW, > - &dft_fr, &ret); > + dft_fr, &ret); > alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MIN_R, > - &min_fr, &ret); > + min_fr, &ret); > alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MAX_R, > - &max_fr, &ret); > + max_fr, &ret); > if (ret) > return ret; You can just return ret; > > - alvium->dft_fr = dft_fr; > - alvium->min_fr = min_fr; > - alvium->max_fr = max_fr; > - > return 0; > } > > -static int alvium_set_frame_rate(struct alvium_dev *alvium) > +static int alvium_set_frame_rate(struct alvium_dev *alvium, u64 fr) > { > struct device *dev = &alvium->i2c_client->dev; > int ret; > > ret = alvium_write_hshake(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW, > - alvium->fr); > + fr); This is unrelated to the commit message. Please split handling of the fr field to a separate patch. One change, one patch. > if (ret) { > dev_err(dev, "Fail to set frame rate lanes reg\n"); > return ret; > } > > - dev_dbg(dev, "set frame rate: %llu us\n", alvium->fr); > + dev_dbg(dev, "set frame rate: %llu us\n", fr); > > return 0; > } > @@ -1667,36 +1663,36 @@ static int alvium_g_frame_interval(struct v4l2_subdev *sd, > } > > static int alvium_set_frame_interval(struct alvium_dev *alvium, > - struct v4l2_subdev_frame_interval *fi) > + struct v4l2_subdev *sd, > + struct v4l2_subdev_state *sd_state, > + struct v4l2_subdev_frame_interval *fi, > + u64 *req_fr) > { > struct device *dev = &alvium->i2c_client->dev; > - u64 req_fr, min_fr, max_fr; > + u64 dft_fr, min_fr, max_fr; > int ret; > > if (fi->interval.denominator == 0) > return -EINVAL; > > - ret = alvium_get_frame_interval(alvium); > + ret = alvium_get_frame_interval(alvium, &dft_fr, &min_fr, &max_fr); > if (ret) { > dev_err(dev, "Fail to get frame interval\n"); > return ret; > } > > - min_fr = alvium->min_fr; > - max_fr = alvium->max_fr; > - > dev_dbg(dev, "fi->interval.numerator = %d\n", > fi->interval.numerator); > dev_dbg(dev, "fi->interval.denominator = %d\n", > fi->interval.denominator); > > - req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) / > + *req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) / > fi->interval.numerator); > > - if (req_fr >= max_fr && req_fr <= min_fr) > - req_fr = alvium->dft_fr; > + if (*req_fr >= max_fr && *req_fr <= min_fr) > + *req_fr = dft_fr; > > - alvium->fr = req_fr; > + alvium->fr = *req_fr; > alvium->frame_interval.numerator = fi->interval.numerator; > alvium->frame_interval.denominator = fi->interval.denominator; > > @@ -1708,6 +1704,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, > struct v4l2_subdev_frame_interval *fi) > { > struct alvium_dev *alvium = sd_to_alvium(sd); > + u64 req_fr; > int ret; > > /* > @@ -1720,9 +1717,9 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, > if (alvium->streaming) > return -EBUSY; > > - ret = alvium_set_frame_interval(alvium, fi); > + ret = alvium_set_frame_interval(alvium, sd, sd_state, fi, &req_fr); > if (!ret) > - ret = alvium_set_frame_rate(alvium); > + ret = alvium_set_frame_rate(alvium, req_fr); > > return ret; > } > diff --git a/drivers/media/i2c/alvium-csi2.h b/drivers/media/i2c/alvium-csi2.h > index 8b554bffdc39..a6529b28e7dd 100644 > --- a/drivers/media/i2c/alvium-csi2.h > +++ b/drivers/media/i2c/alvium-csi2.h > @@ -443,9 +443,6 @@ struct alvium_dev { > > struct alvium_mode mode; > struct v4l2_fract frame_interval; > - u64 dft_fr; > - u64 min_fr; > - u64 max_fr; > u64 fr; > > u8 h_sup_csi_lanes; -- Regards, Laurent Pinchart