Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1958921lqa; Tue, 30 Apr 2024 04:44:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWw+T908eaN37ZrJUIR+4F7vX18WFgNDuQWtSgct71OulKlPZ3Z0r+Qbbcy+u3SVgSgIiI110YLvb5OriCoGPI3KuWsooA/8V/sOIGx4w== X-Google-Smtp-Source: AGHT+IE+D3xq/JMi27fy4jUy3hRR1rKhFnMuhhrQsmUoix1K2TT7oZjkjSEUq6nh505TzxZTbW6P X-Received: by 2002:a05:6a00:2451:b0:6ea:f05c:5c16 with SMTP id d17-20020a056a00245100b006eaf05c5c16mr3648748pfj.5.1714477449664; Tue, 30 Apr 2024 04:44:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714477449; cv=pass; d=google.com; s=arc-20160816; b=U7jMZSOrybUfSkP1XFzEptH33MSoTztjsvxHTvqqEil8kTiF7DjKoOMI1E5H9vuk6g PsAZD6uPzq4jYsGCWGk1g83pWo3KCznZmnpsW/iRflkkSf6yq9DNsaCJhvO+oS9pQ+Jr qZ4I5/5hwx+K4c3Yc4a2pvosVYrkSIXIeBIp9JO0dxZsgvsZraYe+nJip0abSA6SkbEW AMSrWrXHvdKS3zXpDm14m8WjrLYggSjYWqYOTno8zvUw8eHEbBnES93wa7I8UUawpNB8 r4VJekUz4OCco/OcrNSHPV66irx6/KIY5syKW8nKpZTSBbctFCBDDjSn4hjHmWuR82nG 7wLA== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LfhC74UTazCJF1AHQxec+FPBKj436LgBlykgn19Hkp8=; fh=DlgdcCpgGwGL1T2iBi1fxhNUXR5QutRhQ8XrI60jUAU=; b=ORQwJNJMhCg6A7VGqSn6Ud+IZoHoW6MtYic5Hezs2Wv9PnfA7NIHVYjbUbpQlSknwf vmjEgBGl1dcp/jJCzVyE66c/ZlNYFlIB+ye/DRevzsY4kL35HS647dpMpT9hsGgegtDJ d4RFc7oGI1v7Ova5pRnG9JGbXfwF3pS1BbTTa+UKnQKRLS8711kJn5Sw5N7jc4S6DpOA 8fXg3MCD/vMu0muT4Re+ztmqzDh13WEi0SbrEfkxFH2PSQnKnQMcxM0njdhhIYHIa+vB 2Q+5C72gJJr6o0k5fqOtXqyRUXskeQFPK53s+CtvwLtgf0Zpw2yxdNZQwtpGvXykrWKE zOOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=agg2mMQU; arc=pass (i=1 spf=pass spfdomain=sang-engineering.com dkim=pass dkdomain=sang-engineering.com); spf=pass (google.com: domain of linux-kernel+bounces-163861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163861-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ln22-20020a056a003cd600b006ecf4764fd7si22338751pfb.27.2024.04.30.04.44.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 04:44:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=agg2mMQU; arc=pass (i=1 spf=pass spfdomain=sang-engineering.com dkim=pass dkdomain=sang-engineering.com); spf=pass (google.com: domain of linux-kernel+bounces-163861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163861-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E7C532848EA for ; Tue, 30 Apr 2024 11:43:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08359133402; Tue, 30 Apr 2024 11:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="agg2mMQU" Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (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 7A7C91411DB for ; Tue, 30 Apr 2024 11:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714477319; cv=none; b=F9BSy7L70a+hjG7ywWHY9k1OXptt6DDIxMvdCDFKSyKssAV8BM7Tnf42qCZA9Haho4vEAszqTkSss2zVHVjreqRp3GP5K7NGPWtLGhyQkEL6tmLCiRGRWiyimuI1ONzN913/68oqWVwcvKK5Mpj5L4zLEQPM/nInt+aHwMeGXCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714477319; c=relaxed/simple; bh=hcbx56Y5k3mfmOycKnABdCI4HKZUNrDJD2fERcGh1U0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RJGj7veFQBCLJY5juyeFFrJn/gzmHrWwTkmnmtyYekmtGEUh1Z1Rjk1hKPh3cvfuAfr0AeusCJE1gINWCWr33iHU9WEP/opLJcMjoIFNswAum9p9qfQepHuOjwR3V7l3RVKTktGMoRpUE47N/kT3NqjI8Rr2UCgDAMkUiUBR8Fk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=agg2mMQU; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=LfhC74UTazCJF1AHQxec+FPBKj436LgBlykgn19Hkp8=; b=agg2mM QUq/qw/CPUMg3MUlGvabUhtC3Av3vJWr05yK4cm/qZbclwHuATMGEV444n04qDeM htXBcmEfA0ayOffXkVHPpBPKqP6O0aEL8e34tJ+EXgYgWmUbF7D0J+hpDA1FN5PW 1XUO22VdoP7TI+cG/fJGnIV0WQz5McR7UCUL4BL+KebYBpmcfzcDqs+UW1FqbiNC Xocud5Lobpl4xnSyIHwgGqodQo5T4ctEUpIdFVC7RDF1/pxDO/Q+ZW22o2tX+981 UURil3X0J5nEZRrmiLdBKEtjaSid9F6yh8EvVNU1GdUwUxhXnJBITijIKtG33Gt3 opmfO5UsXuEV2nEg== Received: (qmail 2617931 invoked from network); 30 Apr 2024 13:41:49 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 30 Apr 2024 13:41:49 +0200 X-UD-Smtp-Session: l3s3148p1@WnT/2k4X4Ohehhrb From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Jernej Skrabec , Andre Przywara , Mark Brown , Chen-Yu Tsai , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] spi: sun6i: use 'time_left' variable with wait_for_completion_timeout() Date: Tue, 30 Apr 2024 13:41:39 +0200 Message-ID: <20240430114142.28551-8-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240430114142.28551-1-wsa+renesas@sang-engineering.com> References: <20240430114142.28551-1-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-Transfer-Encoding: 8bit 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 Reviewed-by: Andre Przywara --- 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..5c26bf056293 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, -- 2.43.0