Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1327279lqa; Mon, 29 Apr 2024 05:43:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgAsscIXaVJqD8HjVtxolotNaBoNeDnyiex6Vz36XP1AEjfdvo4wPWmDp21eS5Ud1Pu88Usd12Mvls7XWaFZi+vRPHM2uMBDYwZOeaBw== X-Google-Smtp-Source: AGHT+IGvCNclNKJqX+4dbI2jABJP9jGF1CeNyCtAc3sRWe2DdbN0qC9VEma7Amv8g7rt3hVmxhWj X-Received: by 2002:a17:903:245:b0:1e0:c0dd:c5eb with SMTP id j5-20020a170903024500b001e0c0ddc5ebmr12309047plh.9.1714394625289; Mon, 29 Apr 2024 05:43:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714394625; cv=pass; d=google.com; s=arc-20160816; b=j9VcG40FoPpFcN1DKLQGTbls3IO2vTAaYheAZz/GiAzS8tKqPRIfj+3YE9lULO41Kb stD8xDI81FDosI+/MyPQCSjmjbEefF3umS636S7o2ygZLiF3UONIMKmnQyrAQFzzPuqD CCxHir9V1ZrA63uETrERS+woZe56iNlGUmfI31Rhkn5ve2LhXeEVFLtOFyZDfNzSY3Wv K5gIhW32+9BcGzCt3TxVf4cGC6EsnO/88uKfRk4iZzQO67aKkEMsaVZkUtf76nk7SElx 4/bg0uVHD343r8CWM0185vXvSRd83dzepM3FqT8vWA7MUIyC1moz9EYN4MCPlw/eyvGg 2QPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=cOSVC/HsVZYjicV6vWoSCcJ+3anRv9AcshHm2Cc85M0=; fh=C7ZZ7hSUR7LkfociQhgKa5DkZ/zPwB04n62F9LRf+/A=; b=C9c0JiqtCezMhuEL7dWCDXmqgmEgg4ZobnTBCc0xGQQ8HmZhIkTJX4pq/OjRv6tYKL CUuP7e/OCRn73dvKlGsrVsU/A5dnHqdQqDv1X/OUVW6amVCOp1CklOmKZI2dxr+Ws7Dx WMtqyHAtlMe0NT/966F0so+vNy8Lyqq4gsSDwEBAkYuPhAOzikQh1oDjEeN6QmEx80Yz ckEyuKXsbjBBDNr7zhmeyYvgKyuK25Hf+qwrByVzXIA6YPH+BkES22pAzOLO4iaHQ2Qj kDGu3U3+qIn4SPTFC6Oj2QA6WkGZljiuUYVCuFBod/ZNs+v196M5artdrHNYxa9vJWYj 2asQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-162217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ix2-20020a170902f80200b001e4fe1ee5ddsi19235725plb.399.2024.04.29.05.43.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 05:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162217-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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-162217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 EFB88B2605C for ; Mon, 29 Apr 2024 12:15:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DED1548F1; Mon, 29 Apr 2024 12:14:45 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18502535A4; Mon, 29 Apr 2024 12:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714392884; cv=none; b=QayZPJi/TVGOQfHwwcCUM6L0KsEctDHzJAaioYDw7Xf/bpKtXtO7i4TkYIstHQbT1019/ZEhzo6FwwUzILrEMLEa98TYqYyb7ymcnbIp+cjMWpOXCUz+aZ2IKHngrXt5STXxugUfnQfdRbnTRv5nat3u3lpHggBsZaxAZDqt10k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714392884; c=relaxed/simple; bh=TY0BbP/ydR9gp4nj26TsMUiKKoe0SHMu2mZIdj/+l9c=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZzOAcpvHl9pRvdGK7+BRBP19qh1iOr2aLoYHf+URlTw47cjWxzHXyN8izK8cbNp0M1pdfOaCFxhIbzgHgvHtW2c3qU32DbyIoDN6yuOvx++qfI2i+7u7MKoh3jbnnBAL79ANsDKgp2d/ogJlUnwVdDn4V5svV4uL7NvdcfNYcd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4D8602F4; Mon, 29 Apr 2024 05:15:09 -0700 (PDT) Received: from donnerap.manchester.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 61A223F73F; Mon, 29 Apr 2024 05:14:41 -0700 (PDT) Date: Mon, 29 Apr 2024 13:14:38 +0100 From: Andre Przywara To: Wolfram Sang Cc: linux-spi@vger.kernel.org, Mark Brown , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/8] spi: sun4i: use 'time_left' variable with wait_for_completion_timeout() Message-ID: <20240429131438.1f036341@donnerap.manchester.arm.com> In-Reply-To: <20240429112843.67628-7-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> <20240429112843.67628-7-wsa+renesas@sang-engineering.com> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 29 Apr 2024 13:28:39 +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. > > Fix to the proper variable type 'unsigned long' while here. > > Signed-off-by: Wolfram Sang Reviewed-by: Andre Przywara Cheers, Andre > --- > drivers/spi/spi-sun4i.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c > index 11d8bd27b3e9..2ee6755b43f5 100644 > --- a/drivers/spi/spi-sun4i.c > +++ b/drivers/spi/spi-sun4i.c > @@ -206,7 +206,8 @@ static int sun4i_spi_transfer_one(struct spi_controller *host, > struct spi_transfer *tfr) > { > struct sun4i_spi *sspi = spi_controller_get_devdata(host); > - unsigned int mclk_rate, div, timeout; > + unsigned int mclk_rate, div; > + unsigned long time_left; > unsigned int start, end, tx_time; > unsigned int tx_len = 0; > int ret = 0; > @@ -327,10 +328,10 @@ static int sun4i_spi_transfer_one(struct spi_controller *host, > > tx_time = max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U); > start = jiffies; > - timeout = wait_for_completion_timeout(&sspi->done, > - msecs_to_jiffies(tx_time)); > + time_left = wait_for_completion_timeout(&sspi->done, > + msecs_to_jiffies(tx_time)); > end = jiffies; > - if (!timeout) { > + if (!time_left) { > dev_warn(&host->dev, > "%s: timeout transferring %u bytes@%iHz for %i(%i)ms", > dev_name(&spi->dev), tfr->len, tfr->speed_hz,