Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp20522rdb; Sun, 17 Dec 2023 18:55:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPbsQmlZdprnaOCDQ6DRUssvnrgJn7HMnU5C/bG7SXkRJ0hOoQtx5dn1Qi+8AhUeST2/CX X-Received: by 2002:a05:6512:23a9:b0:50d:1a12:e357 with SMTP id c41-20020a05651223a900b0050d1a12e357mr9818349lfv.45.1702868103567; Sun, 17 Dec 2023 18:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702868103; cv=none; d=google.com; s=arc-20160816; b=XWQAstEp0SceFd86IuEZybyP+fnvNihauq2ifPu78CvYCPggWyA/ofcJ8EwCaIP05T zV7JZUyptMgkjk/CuVMDW7tdSRgQjui0BW2XdzijxCYGCFyoP8d6MSVduCs/kQY1aQaY uP8g9O9IIx6dJOdpIOYtUp3cgXjBb1PEvhlKpvxWfWXzepNrdSOMFmLE7RdlxPkeWVk7 myLyv7xfI1JEryBTgI4PFh54/U/6t6F2TMqMpz9JaY/Pls/Q2xyreWEf9cv8WNvAe+1C oHO7VpUqmwg3YEFPXQKNvCB5LZn5wRPp9wI5zgCYILSp3WkAr9vwMwJMk47v4Z0gfQOh Y8wA== 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=yM4YIpjuZjrjDL6u8VRHWK5vOaYgE96iUB6PkgjGeZ4=; fh=cqB3jvkIGLPqHYfnbOulxfH1CJnm8CVnas5gPCIFduU=; b=ySGpx/A5jBLsFe0LgWMH2yHs7wT4W92wQFhkl5WXx7D2cG3mnTLBthThjgGDEoMiPo EW3s5YocW5Ed9bqNXfQwsHoRcth8CWc2NjI+0vp+PsllO7KPs8bnoOrFnQr1nHjK2gIr PA2GyvZNkn0NgUHap33Cq7MPPFYHUZT+f4kva6n+lC8ZfbCfMGwXi/0S27JbBIICBqZL VOeqlw+aXRAPuUHIxIZq2eku/8qeRBA7XJ46bIo30+mEByiKUVhhmn3tPzndUamBUYFO 8xSOo57AipM5BW+cB49b/osyhmEwVcNUc/6kYdwAI2sYrrCEAtL4il759rv4vDxwWBEw iaYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=fdpgPzoE; spf=pass (google.com: domain of linux-kernel+bounces-2951-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2951-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m13-20020a1709066d0d00b00a2352fcd9a9si722424ejr.152.2023.12.17.18.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 18:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2951-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=fdpgPzoE; spf=pass (google.com: domain of linux-kernel+bounces-2951-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2951-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 024011F2199E for ; Mon, 18 Dec 2023 02:55:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EACB5691; Mon, 18 Dec 2023 02:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fdpgPzoE" 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 D9EBA525A; Mon, 18 Dec 2023 02:54:26 +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 144101583; Mon, 18 Dec 2023 03:53:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702868016; bh=ifP0i0WOxqYlJ9H1en/X9XPVzsiB06sLeUleJU3vF54=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fdpgPzoEUoD0FFoE3iVTgoals+XeJEqp2RaEpkXHV/gG1W4xQ7fNSWaNHnHyWaH40 dvVZyWK+a0S8zACTOwkPV4KJ7x2ceFKnyFwYagI0p4mfIfXLZkGEpnREOxaO14OY8R 62wPgvfnYLF9P6Z2/hXLwd31Gkw/PV95pz5xuchw= Date: Mon, 18 Dec 2023 04:54:30 +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: <20231218025430.GA9012@pendragon.ideasonboard.com> References: <20231215082452.1720481-1-tomm.merciai@gmail.com> <20231215082452.1720481-2-tomm.merciai@gmail.com> <20231218025044.GH5290@pendragon.ideasonboard.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: <20231218025044.GH5290@pendragon.ideasonboard.com> On Mon, Dec 18, 2023 at 04:50:46AM +0200, Laurent Pinchart wrote: > 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, This is also unrelated to this patch. > > + 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