From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA836C4345F for ; Mon, 29 Apr 2024 12:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XUBu/cr4SKYleuc5bOm01VuNSw8yh7r8fFBrg8eRZ5g=; b=0NmC4ceqUe6mTp ehUmOlHQITP8wMjidQf2QAtwWGhn6l3TGZrdv7vezBZXvOJrnx79qODZQGxxFHVcBU9zpPNZe16ej dlx4IRVigP6vueANIa6rcqT+XRWk4G6lmTpCvRSMyo0X9/PC+Hyypg3DWKvgYV70/b1JjfpnVSBDN 9ym1dcqsWt16VmJ6zzfA7ZNzNGEoADNWqXSu7KOCVlnapSAtDAZYW5SpGk98Qf5DAEkTX3dtT6WxS 4UA7kln0IqFOirJ52RixraMXFRXqNtvGgdEXBKEli4bAjU9UBJehmCuJGQqLdd8RTIvbQWViZ72Aq cVLDSirSUBlZ1niPd4vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1PuD-00000002daH-0rBN; Mon, 29 Apr 2024 12:14:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Pu9-00000002dYg-1fMX for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 12:14:47 +0000 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) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_051445_634507_B8CCAB08 X-CRM114-Status: GOOD ( 18.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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, _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel