Received: by 2002:a05:7208:c250:b0:86:f851:443 with SMTP id w16csp937142rbd; Thu, 13 Jun 2024 01:42:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7UinRHzWAoRNeMSbW7IaqMJy19mFhA11dZrgSbXx5YVPumNwJ37MOoMhVZhckdWx0Di9Isf5jJBh66LUex/u4CfO1HHU5T485e0qsZA== X-Google-Smtp-Source: AGHT+IFwDpTxvFqvrw8ayE0jA50jLlZX8pvLl04yRclXMI8YAW6T7eRscCZjbSBFk6utmjjKfRqQ X-Received: by 2002:a81:de48:0:b0:615:79df:e7ff with SMTP id 00721157ae682-62fbaf385f9mr41911927b3.29.1718268161621; Thu, 13 Jun 2024 01:42:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718268161; cv=pass; d=google.com; s=arc-20160816; b=vM0ULiHiwvxUeXyzlqbNmtD9E3dOjCwx8HJ+yt4jXhQvtwQv3PS2r53je51IZc0z0c 3MVDYJSDIpak08sxsaYvTbEjWV/q9FEhRPzEHvk+ETeAO0xga+RKOE7Lf5pkcnjpes2D dXdRIj5NSUK5iBE/HsaUy/5JnLVjK9ltj+KRHBa1FyvDAu5fBSkytT2LvciRKfvjOndm l1SW/AH/EoQXpmEt033gOwNcKKkooJQk7WSOs3MgNC41RujYETUf1fje+ufOJ6X4gJkm pbCkaXWcQH9gLnaLt8BXQbDCavkzqLChst5DQFU57DalimoEBJnrk2vfe/ZLENYf5nrn /OwA== 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:mail-followup-to :message-id:subject:cc:to:from:date; bh=p/xqHp2Y7Dquu+nr7qYRiJ5eu+ebLLJQiBei1RBggok=; fh=d2CIAFtwcAZjsuouIMspmoWtjeOQZOyg42WesqFoqZg=; b=QpzJTpJROlL9p1xR4nf6EROj2sMG7hQUgkGmM1k3ZS3a+IykJDUKGj/2BKrKJsbdzD i2SZLUDif+NfveQL1c6iRKgL76f8kgCX7Lf9buhgOmTs5hJc9yHYWJi3ICOXw0S9htrO PEdxl37Us7pRBOv4l+oSjE6cfDVw4BKO0V1Pt0VnbcM2zh0pC33wVbq4i4fagdszOHoG Myr7IB8orwWMX51p7gnbHsaMxNqrZ6PyrptmBKe/aGHkgSi0/0LvhC9wXBRoo0P1e6ER PmsusI9Hx4p/UY7rgxigoKvV0somvYiEj3g/ka6aB5dT3CePP80vgJdO9VmkJDU+4YJO Vz0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-212850-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212850-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-441f311cf14si10197911cf.784.2024.06.13.01.42.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 01:42:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212850-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-212850-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212850-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 587261C22552 for ; Thu, 13 Jun 2024 08:42:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B87FE142918; Thu, 13 Jun 2024 08:39:34 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 958C914291A for ; Thu, 13 Jun 2024 08:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718267974; cv=none; b=pu0HitY1LRSHbWOA5H4UFFz+VsdbLMQwUUNNK3Yz7vW7YIcxICslWWJDK7SsgXRALILjcPu5hV4N1ZeeGYCCh2N6iND3q7fGjYiSoGQ3AaS+ju2bWtl46Vr62K0R0pulKnwIYIVM/ob1P2IQP3vfscTkLIgbWdNzKasbA31Z3u0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718267974; c=relaxed/simple; bh=7ACeVZMYX61l7lQaZDCozpxXuPOFLEdwjRMo2FdSZf0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=r1F4JBhau05OgLpXBNXDDlCJH5sewMQFyDRmilVaVNMbHyhF0SGyuz2gnupITnVsmFv9NqWOCMw7m80+j8TJXqV6VJDQLJv3JoEo3TktGeEXosWOOql1A2VfbchRxOJ+RJGxxH5g4I3P+Q/DV7nu3CHdpTzOjIjQbP0jZ7C8DVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sHfzV-0005MD-Oq; Thu, 13 Jun 2024 10:39:29 +0200 Received: from [2a0a:edc0:2:b01:1d::c5] (helo=pty.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHfzV-001zED-9V; Thu, 13 Jun 2024 10:39:29 +0200 Received: from mtr by pty.whiteo.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1sHfzV-008R01-0d; Thu, 13 Jun 2024 10:39:29 +0200 Date: Thu, 13 Jun 2024 10:39:29 +0200 From: Michael Tretter To: Wolfram Sang Cc: linux-kernel@vger.kernel.org, Pengutronix Kernel Team , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: Re: [PATCH 1/8] media: allegro: use 'time_left' variable with wait_for_completion_timeout() Message-ID: Mail-Followup-To: Michael Tretter , Wolfram Sang , linux-kernel@vger.kernel.org, Pengutronix Kernel Team , Mauro Carvalho Chehab , linux-media@vger.kernel.org References: <20240603092841.9500-1-wsa+renesas@sang-engineering.com> <20240603092841.9500-2-wsa+renesas@sang-engineering.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: <20240603092841.9500-2-wsa+renesas@sang-engineering.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Hi Wolfram, On Mon, 03 Jun 2024 11:28:32 +0200, Wolfram Sang wrote: > There is a confusing pattern in the kernel to use a variable named 'timeout' to > store the result of wait_for_completion_timeout() causing patterns like: > > timeout = wait_for_completion_timeout(...) > if (!timeout) return -ETIMEDOUT; > > with all kinds of permutations. Use 'time_left' as a variable to make the code > self explaining. Thanks for the patch. There is another instance of wait_for_completion_timeout() in the driver, which uses tmo instead of timeout. Maybe this patch should change that, too. Michael > > Signed-off-by: Wolfram Sang > --- > .../media/platform/allegro-dvt/allegro-core.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c > index da61f9beb6b4..4016aef5fdb9 100644 > --- a/drivers/media/platform/allegro-dvt/allegro-core.c > +++ b/drivers/media/platform/allegro-dvt/allegro-core.c > @@ -2481,14 +2481,14 @@ static void allegro_mcu_interrupt(struct allegro_dev *dev) > static void allegro_destroy_channel(struct allegro_channel *channel) > { > struct allegro_dev *dev = channel->dev; > - unsigned long timeout; > + unsigned long time_left; > > if (channel_exists(channel)) { > reinit_completion(&channel->completion); > allegro_mcu_send_destroy_channel(dev, channel); > - timeout = wait_for_completion_timeout(&channel->completion, > - msecs_to_jiffies(5000)); > - if (timeout == 0) > + time_left = wait_for_completion_timeout(&channel->completion, > + msecs_to_jiffies(5000)); > + if (time_left == 0) > v4l2_warn(&dev->v4l2_dev, > "channel %d: timeout while destroying\n", > channel->mcu_channel_id); > @@ -2544,7 +2544,7 @@ static void allegro_destroy_channel(struct allegro_channel *channel) > static int allegro_create_channel(struct allegro_channel *channel) > { > struct allegro_dev *dev = channel->dev; > - unsigned long timeout; > + unsigned long time_left; > > if (channel_exists(channel)) { > v4l2_warn(&dev->v4l2_dev, > @@ -2595,9 +2595,9 @@ static int allegro_create_channel(struct allegro_channel *channel) > > reinit_completion(&channel->completion); > allegro_mcu_send_create_channel(dev, channel); > - timeout = wait_for_completion_timeout(&channel->completion, > - msecs_to_jiffies(5000)); > - if (timeout == 0) > + time_left = wait_for_completion_timeout(&channel->completion, > + msecs_to_jiffies(5000)); > + if (time_left == 0) > channel->error = -ETIMEDOUT; > if (channel->error) > goto err; > -- > 2.43.0 > >