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 1162AC4345F for ; Mon, 29 Apr 2024 12:16:22 +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=f+3xwFcyzkoHCDDMLTN5Zf784caePVuq0fLH1GIU8Yo=; b=w5qjJTPhkiJT3d ag49je2VQJiKOy2AJlOdK/UfyDQ7D5DS0vYXuS1tyP4h1z5zT4FKHHjDBYX2D0JCQGMWN+9guTUHG s3hayqrtInC7JS84ZCIvtKAABdfiA8/EzJqCHaAXYfSseuzH460c+ak2fG2nyIFK/W5fCxGsxYv6n pmGF6Hlz2WiwKaFJZXZYTXFOaowgFT0OKjZwc+iTU/pDSjaFPpElkqQcz9GLfbAGkXGLr/G22fAyJ xAOmptFk4wqWjT2Tvd/NiHW0rvCOpXxUFLNqBvP2KTNI/KSdvqdFvo9Hz2ir2dEEAyZEPOfa1f9C6 HoRnH9UF7EItS4NmttUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1PvU-00000002e5Y-2LSa; Mon, 29 Apr 2024 12:16:08 +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 1s1PvR-00000002e2q-13ae for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 12:16:06 +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 286752F4; Mon, 29 Apr 2024 05:16:31 -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 18BFB3F73F; Mon, 29 Apr 2024 05:16:02 -0700 (PDT) Date: Mon, 29 Apr 2024 13:16:00 +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 7/8] spi: sun6i: use 'time_left' variable with wait_for_completion_timeout() Message-ID: <20240429131600.4e910d8a@donnerap.manchester.arm.com> In-Reply-To: <20240429112843.67628-8-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> <20240429112843.67628-8-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_051605_383143_FCEF5724 X-CRM114-Status: GOOD ( 22.59 ) 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:40 +0200 Wolfram Sang wrote: Hi, > 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 > --- > drivers/spi/spi-sun6i.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c > index cd018ea1abf1..7bbe7ea0d66a 100644 > --- a/drivers/spi/spi-sun6i.c > +++ b/drivers/spi/spi-sun6i.c > @@ -277,7 +277,8 @@ static int sun6i_spi_transfer_one(struct spi_controller *host, > struct spi_transfer *tfr) > { > struct sun6i_spi *sspi = spi_controller_get_devdata(host); > - unsigned int div, div_cdr1, div_cdr2, timeout; > + unsigned int div, div_cdr1, div_cdr2; > + unsigned long time_left; > unsigned int start, end, tx_time; > unsigned int trig_level; > unsigned int tx_len = 0, rx_len = 0, nbits = 0; > @@ -488,26 +489,26 @@ static int sun6i_spi_transfer_one(struct spi_controller *host, > > tx_time = spi_controller_xfer_timeout(host, tfr); > 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)); > > if (!use_dma) { > sun6i_spi_drain_fifo(sspi); > } else { > - if (timeout && rx_len) { > + if (time_left && rx_len) { > /* > * Even though RX on the peripheral side has finished > * RX DMA might still be in flight > */ > - timeout = wait_for_completion_timeout(&sspi->dma_rx_done, > - timeout); > - if (!timeout) > + time_left = wait_for_completion_timeout(&sspi->dma_rx_done, > + time_left); Nit: indentation is off here. Regardless: Reviewed-by: Andre Przywara Cheers, Andre > + if (!time_left) > dev_warn(&host->dev, "RX DMA timeout\n"); > } > } > > 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