From patchwork Thu Jun 22 09:06:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13288807 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 C0996EB64D8 for ; Thu, 22 Jun 2023 09:07:20 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/74K7yVuzimdp+xQXpPLw1HU74UtfYVNY8F2vYUSJiA=; b=F2ZZs8CVOWuMdI HNDw16SdxzpCjy7z4jeV0osEGGsAyeBLJe/AlEj1GKzdUTqM08fa579AnWwKivmml9iP/yHCzQeDO hjLe468KZbZuCk6MrlQDSkpPXsX3yDWJJPyxbdyMAnyYN4XjT3zaYSbGb0g10gRYHpq0cK4wjbUTu w3urgdq/MpnWS3RHQ4SeB1uY37mAUoJ3q+IlB5EHPO/KdMrxb9xEifBFlVE+dsYsYBTQ407LhSrlX Py0OOowTh1oPFgPnCZgzOzubCi40jytljPZFW+3CdYGHkbEIDbidJ01YaDcv/hv2qN/H6YdebI4zu DDmpMgJkJc/16r+KGr3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCGHJ-00HXeX-2W; Thu, 22 Jun 2023 09:06:57 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCGH2-00HXYq-2u for linux-arm-kernel@lists.infradead.org; Thu, 22 Jun 2023 09:06:43 +0000 X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1687424799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uIrH6l6h4FVOlNSp29zZGkHu1wVR3pubO6q4OyhE0xo=; b=ZBuZQNF4lTle5ynALJZoxupoY97a6e2GchnIfLnvBQOypxDR5TAK2RbzZhykao/udWvOoQ zbOyDx3WXByizNLNVnxpJxbwIjEMRrJmKDX7qMGJmhBQ6MGPJH4AvCo+PNBdxHXz0niT/z g51ZXFdBuNQUFqDS3FUMpzFdtVhnLtStjNuFLjsYjP/PTnIBDSXTBqp6U/gi05DTL79NAW npWJN5Q+WeWeEYRUlSdgwoqaR81RfMR4IaPFXNkYUFSABdl3uHwg3/7c8Xj1EjTvJyMi0m ThE86jkW3WXQ0iploMiug+jiwagU9rQ/CD1c8jmP4Pw/ga3meGcI6Sgu6qGQ/Q== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 6F0D84000F; Thu, 22 Jun 2023 09:06:38 +0000 (UTC) From: Miquel Raynal To: Mark Brown , Subject: [PATCH v3 3/3] spi: sun6i: Use the new helper to derive the xfer timeout value Date: Thu, 22 Jun 2023 11:06:34 +0200 Message-Id: <20230622090634.3411468-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622090634.3411468-1-miquel.raynal@bootlin.com> References: <20230622090634.3411468-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_020641_087046_EDB27CA3 X-CRM114-Status: GOOD ( 12.46 ) 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: , Cc: Samuel Holland , Chen-Yu Tsai , Jernej Skrabec , Tudor Ambarus , Thomas Petazzoni , Miquel Raynal , Claudiu Beznea , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A helper was recently added to the core to factorize common code between drivers, like the amount of time a driver should wait for a transfer to happen. It is of course possible to use a default value (like eg. 1s) but it is way stronger to adapt this amount of time to the transfer. Indeed, long transfers (eg. 4MiB) on a slow single-spi bus might take more than the usual second of timeout and prevent lengthy transfers. The core helper was heavily inspired by the logic applied in this driver, the only difference being the minimum amount of time which was enlarged from 0.1s to 0.5s. Use this helper instead of open-coding it. Signed-off-by: Miquel Raynal --- drivers/spi/spi-sun6i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index 23ad052528db..180094dfae19 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -422,7 +422,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master, reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG); sun6i_spi_write(sspi, SUN6I_TFR_CTL_REG, reg | SUN6I_TFR_CTL_XCH); - tx_time = max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U); + tx_time = spi_controller_xfer_timeout(master, tfr); start = jiffies; timeout = wait_for_completion_timeout(&sspi->done, msecs_to_jiffies(tx_time));