Received: by 2002:ab2:78c:0:b0:1ec:b906:25e5 with SMTP id h12csp260448lqe; Fri, 23 Feb 2024 03:48:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXZWre1FuijdKfrXSJF8LF6Q/NY+MmkPuYCauvzQLgCMxwkjahIRs6YPP/g7FCm66PFuAB5tMgDL2wPbX0ZtacPEgsL2ofC8F2OR3wi3g== X-Google-Smtp-Source: AGHT+IG4CeFZ5OAkP1MmENmvZ1xC5BKMZZ/l3Bm5abyMyzlNZ78Eir9ijuBbgYTOKJK0VngXEYTs X-Received: by 2002:a17:902:c38c:b0:1d9:a91b:778 with SMTP id g12-20020a170902c38c00b001d9a91b0778mr1411525plg.30.1708688936624; Fri, 23 Feb 2024 03:48:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708688936; cv=pass; d=google.com; s=arc-20160816; b=McBY0ts/PfGIuDOFx2R1JKTqtJ1LS9h69E3hOOt3LaKpbzazzwv1yFcS72nPiMndtE BSEo7S9F9tpt8/f8JDcpTIcQr3gCR6h5AHI0lHM15x2LNxRR4wtrml3uolLfc60kdbS6 7UIMrPUVXZJgApyo8nOdODIz/hG/7fmTniAhhBYd2ArCGhmMoe/npb4Y9cMrpffpP9ps GS8oNcMC13sdtDQMd5Xyd7wFkBOA1oExpICPONNbY3hEGAinKIlya27YuWjSXQLNoaVF kmyeJqt87oN87iGObzOaNZNo7QCCN0vO4DIXSx32wDN+HG2sXSBjwKZ5JerCaQr5jCUD PIog== ARC-Message-Signature: i=2; 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=d4yUYj+03oC2x/Nvf6DHMf4qcQJjU5GDQ0T5v09Q4wQ=; fh=QT+iGvNcZeaNbQRUR4DJ7wLtNyZTa5ZJCEL+R9E9tc8=; b=PRd5FmJw4S8DvgjVi7bxtlvYwLQT5qSYipVp+AIFmq0Tlxkw8cwNDXPcRU5DCm4LrA v1kinG2pZVSDFlx78mKUNxzQ+Q8O1oAYyveDKmTUlx5mc7pmZAUnb+hCvQW5Ua4TZUM+ QvmBCuaLSaJnuVecnMyGPcdaiusE9ZdBsUWDK3YQDgEQFcC6t1ONtKcttsriGN1Gk8HE n4JmevvwAoX4cjKCrQVuh+8KMccQgY97g3eXUw8r78yLbWtOyuRnIBTK2izsLRqD21yP NAAYdO4Xl46rOAXBzxOwBcCYZvVudCRdLIMC+4/fLJFk56y1jkoDF9i1NjCo2tx18ywj cbxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=WoI1QGtb; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-78248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78248-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n16-20020a170903111000b001db2d82e7f1si12187734plh.137.2024.02.23.03.48.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 03:48:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=WoI1QGtb; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-78248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78248-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4DADE287083 for ; Fri, 23 Feb 2024 11:48:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E0577AE65; Fri, 23 Feb 2024 11:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WoI1QGtb" 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 D98D2D29B; Fri, 23 Feb 2024 11:48:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708688929; cv=none; b=B3X/u2R9Z7kwrW+rhu8uDIS6P1Hg5wDGnmmCb8AY2p8W+jc+cGDREO065JhwX0DzL8Uinti5fNlZrCW5fSyXMaQbBz+bRtam3hUzXufSYe3f7hycVOfU5TDqbUbIndGX1H6qvtbqX5lWqsnmgrTTy/F0yk5hiVUFl/7AOKDhjv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708688929; c=relaxed/simple; bh=bWXU1JOJOzHsStAX81T5OTAuXcnBcBLeIwRKasby7p0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZR0kKYGaCI1qRdwoasQ7cn5X/DHVVvvb1ejbslufthw10bfedAldmZN9c4nW9KVLmWhL0k8kKeuoZULy1hBEJDkfYW3nBuGT2OUTV6jZBBmmRwdeQN9NPM+dlAG8uetYVQtwkO+jFLXSnVO1IQHI4UsfAUTHiWKSDOYfzRZKyP0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=WoI1QGtb; arc=none smtp.client-ip=213.167.242.64 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 (89-27-53-110.bb.dnainternet.fi [89.27.53.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E9D872E7; Fri, 23 Feb 2024 12:48:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708688917; bh=bWXU1JOJOzHsStAX81T5OTAuXcnBcBLeIwRKasby7p0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WoI1QGtbFy8UgiimLlRY0M15+GZS+Ei9nWBH3ZJNQBGfFB756JpG6VCISJX3tosSK OBcwCzQu0rD6jxnXzYP/53w8HLa4PJN7v8zyxo63bemRty7gNnn61gP+Mg7FCfIIVF /ji6ZA1YXVVG4yXqXtROhrrBY8QsOFMzI5GA0qe4= Date: Fri, 23 Feb 2024 13:48:49 +0200 From: Laurent Pinchart To: Mikhail Rudenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sakari Ailus , Jacopo Mondi , Tommaso Merciai , Christophe JAILLET , Dave Stevenson , Mauro Carvalho Chehab Subject: Re: [PATCH v2 19/20] media: i2c: ov4689: Refactor ov4689_s_stream Message-ID: <20240223114849.GU31348@pendragon.ideasonboard.com> References: <20231218174042.794012-1-mike.rudenko@gmail.com> <20231218174042.794012-20-mike.rudenko@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: <20231218174042.794012-20-mike.rudenko@gmail.com> Hi Mikhail, Thank you for the patch. On Mon, Dec 18, 2023 at 08:40:40PM +0300, Mikhail Rudenko wrote: > Remove repetitive pm_runtime_put calls in ov4689_s_stream function, > and call pm_runtime_put once at the end of the "on" branch if any > error occurred. > > Signed-off-by: Mikhail Rudenko > --- > drivers/media/i2c/ov4689.c | 29 ++++++++++------------------- > 1 file changed, 10 insertions(+), 19 deletions(-) > > diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c > index e997c3231e85..884761d02119 100644 > --- a/drivers/media/i2c/ov4689.c > +++ b/drivers/media/i2c/ov4689.c > @@ -555,35 +555,26 @@ static int ov4689_s_stream(struct v4l2_subdev *sd, int on) > ov4689_common_regs, > ARRAY_SIZE(ov4689_common_regs), > NULL); > - if (ret) { > - pm_runtime_put_sync(dev); > - goto unlock_and_return; > - } > + if (ret) > + goto cleanup_pm; > > ret = ov4689_setup_timings(ov4689, sd_state); > - if (ret) { > - pm_runtime_put(dev); > - goto unlock_and_return; > - } > + if (ret) > + goto cleanup_pm; > > ret = ov4689_setup_blc_anchors(ov4689, sd_state); > - if (ret) { > - pm_runtime_put(dev); > - goto unlock_and_return; > - } > + if (ret) > + goto cleanup_pm; > > ret = __v4l2_ctrl_handler_setup(&ov4689->ctrl_handler); > - if (ret) { > - pm_runtime_put_sync(dev); > - goto unlock_and_return; > - } > + if (ret) > + goto cleanup_pm; > > ret = cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, > OV4689_MODE_STREAMING, NULL); > - if (ret) { > +cleanup_pm: A label within an if branch isn't great, readability-wise :-S Could we maybe split the ov4687_s_stream() function in two (streamon and streamoff, or similar names) ? You would then have a single pm_runtime_put_sync() call in ov4689_s_stream(), in the error handling path for the streamon function call. > + if (ret) > pm_runtime_put_sync(dev); > - goto unlock_and_return; > - } > } else { > cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, > OV4689_MODE_SW_STANDBY, NULL); -- Regards, Laurent Pinchart