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 E2607C4345F for ; Mon, 29 Apr 2024 15:20:36 +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:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GcRd+GCO+Hn3zFp6aX0PB4zbJsn/OUsF/AdgMQB471Q=; b=QK5y07nmzAlJEy 2vVPFfOiZXFNcU8MiEb5I02ISzgvEdWvxiGFO3ROEc0KBvsbFXP+2uwWDuU0xd/V7Qv8Hkc7yw1sA 1IuT5RcSEqFRuaPk20P1orRzWZWDJUffn68dYmT5Ix9qtHipmw1ZLQBZgTHSy7SlXBkCr9LalhlR5 Whfvc3T2VfBwQY6REkhOWGkkxO/Q9bZQE5hCFQ86uolWvKlAbI4V5+BxllT1kHgX/I66mRnQtiqFv Uly8j7EysvmVVa9Ij5ioGr8UuPSAdDW1uZimuNKXeoPO4G5AosJyvu+mVt6HmCBbjzLTQwy1OnqVt m1renPrR/sGNCyBwF74w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Snn-00000003N5u-3xhQ; Mon, 29 Apr 2024 15:20:23 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Snk-00000003N4B-2GUu for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:20:21 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a587831809eso547681466b.1 for ; Mon, 29 Apr 2024 08:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714404016; x=1715008816; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xestw1QNtEj/9cyE5NFVKambADQI6O/71HDnKGCInV8=; b=B2j3k+ecCbHD6tsXoLl9em8NIHH32REwK0FONNc2A240yom6/BYfJeTlXVL26lRGmp ikglA0uljRnHEapUw3n378GDMi3yFQzjOTAfeYUFSDQ6XcVx3Jlb8ImMbcyMteKTAVCp HxnPC6MBWNhj7JaML1xJhKqE55yEoeaiGlAUXNwxRA0OgWcbeWlbwc+lMCsMohwXSpPL Fhm7aPeKGs5hhVhpaQwAlBUZem0KNhpdXciFSwD/LwKMsFmM1E3GVNUNgKVWjiVBAaQP t2pKOyWjBkSNKvvF7yJXYwTt21Dhti8pDhvfpnfPIcUkVLfsbM2mslWYedRFnhX3QTmW +8IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714404016; x=1715008816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xestw1QNtEj/9cyE5NFVKambADQI6O/71HDnKGCInV8=; b=RIKaFtR6Eys5G9IDl2l0Qm9HHA7sH6QRatsr4kmhKR4ILzpO6i0I2NIMU89h+C23oE fAKojI4dSH2vW0JuoXTcZxepEmZNQIkXn8ZIBuYa68KKq6HgZir2GUbknEUIGRqAdFWW GEhmDf9jKsEWlWIV69dl/OLFICHbDFWPEy9zJGvxNgdtaVpTmEwi2C5YrnK1Lf0V/Pr8 RjbNtUemXJeOeYlLnpZeeOVRwbq0gU7bnpe5V86NFQL0vHd/ptLSTJh3ItbPnc6QOkfX UlyNCMEl+g3wAXZnqvCtKi514FQEHG0T7K9Go2iDBNqdVMfq/ZCLY9HlfvEwlMVhFj+n rQSg== X-Forwarded-Encrypted: i=1; AJvYcCXOBX2wkSqqWCA3KZVmDlr94yBH3uOwbpPPi0wUOFOseTnlT57W0fiJOOM5AottxfZqW6fxgdMXm/snlKiqlcE+7NijjeNtutRwp8JzHdVnvle0VYc= X-Gm-Message-State: AOJu0YxUsB0/evEqbHWzq5TBdI853Mq4A7d3Yml+MpBrm9cjPkYLQ1E4 fldDcTEgzq3eYfslx5Yoy5flNFkwAYbT0vDaNUMwKn3WFdawGv3R X-Google-Smtp-Source: AGHT+IFv2yQ+ISFsWoxWBWHT/F9qtbk97DzSDaqfb1LCDyJmZc2vAJwQngftmAeom2YpKJaF4blgng== X-Received: by 2002:a17:906:f9d6:b0:a58:f186:192 with SMTP id lj22-20020a170906f9d600b00a58f1860192mr3955858ejb.0.1714404016298; Mon, 29 Apr 2024 08:20:16 -0700 (PDT) Received: from jernej-laptop.localnet (86-58-6-171.dynamic.telemach.net. [86.58.6.171]) by smtp.gmail.com with ESMTPSA id s8-20020a170906500800b00a4e24d259edsm13916302ejj.167.2024.04.29.08.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:20:16 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: linux-spi@vger.kernel.org, Wolfram Sang Cc: Wolfram Sang , Mark Brown , Chen-Yu Tsai , 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() Date: Mon, 29 Apr 2024 17:20:14 +0200 Message-ID: <4885599.GXAFRqVoOG@jernej-laptop> 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_082020_618963_F834BF9C X-CRM114-Status: GOOD ( 21.85 ) 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 Dne ponedeljek, 29. april 2024 ob 13:28:40 GMT +2 je Wolfram Sang napisal(a): > 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 Acked-by: Jernej Skrabec Best regards, Jernej > --- > 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); > + 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