From patchwork Sat Jan 20 17:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13524405 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 A7445C47258 for ; Sat, 20 Jan 2024 17:00: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: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:In-Reply-To:References: List-Owner; bh=V5t7td+H2NhQI1kxIX2OFpVKpMufi3LVmJlSlyDZWgU=; b=m+VrXzU5rDUOYx zeNaghkMixRdGsuye4qoi/RCBd59kSxtWvj5YL5Rnl9udiiz0eRWZyLZ10rZpUMg2E1iASn29G2Ez CrwIT1t9A1vWQuMpsxi1KI2M1hQ9TXh6RKi0IKn6SmDM9yp2otWsnD0EF2LTKqMJRNr9kK5u9W/ZM 06wYp4OOEa1zdzjKnHXn7JHez6lzARVx239gBD83FaM8S4J820sM9rOeWJIX982a1JmoYHjVHhxg+ M35wv7anLXJR2SKd+AAEEkINFArUHsWJfBx0qBDW7i3Kkdbkpwe7f/hQDg0H/+rGzSgan2IBHNWvj efaxHsP8MvGuTJFhYxLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rREhX-0087VD-33; Sat, 20 Jan 2024 17:00:11 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rREhS-0087UZ-1m for linux-arm-kernel@lists.infradead.org; Sat, 20 Jan 2024 17:00:10 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-595b3644acbso1373379eaf.1 for ; Sat, 20 Jan 2024 09:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705770004; x=1706374804; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=glGHg+SzqygO0Y5IbZ+h4Ne6PeGtd0PUMlqRFswKyG8=; b=OxMUdHVnitdjHdlXgUQFZmZ/GpWsBzwuDz/Axp6hiq2WEYch9vGK5w6m78czvKkoFo 62ADhSUSBVgobVdS18H7mDReIKxweE5apPSEq2k5pcFBBKCmdK3iRl1DcMiuLEkCmcrE 8l+oXqaLVCHg/hLB2pu0JTplwwsxUC7BuP3PAVy7N0xrgAaB2KJ1Hzjzum+Z+1VvhQd5 bl9VdfQviuPKfWArtkVFzToLdU0V0Vei4TbhvY8xWFjfB2UsUpnnd6uosaIDXRb8l3xv WD/DdxPJY6HQ4Jy7ygecjJdawdxT6UuoybA/AU9GWAN/VPEfw9MeB4OJIRoMF1TDvXDI lA6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705770004; x=1706374804; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=glGHg+SzqygO0Y5IbZ+h4Ne6PeGtd0PUMlqRFswKyG8=; b=IDpih84pyWBxs+8OqEhbA/Xxj4Bm5ORkrAzSLnxZ7RHTS3XoaCyin4GCFxDNhmbdKH MmsXj+nUavWmvFdhiecRcW4oAv2OP/MUruAQUnQvQdejD+3m6qeFex84ITYc9cCcF3tA fb0eyaLBTnQUZJ3E37PlQ24RV7Vwt5/GmEQI8V+wX6zT228dlP6h94o1p9tHE4fBRo0R fE7bYiiFWo4xTvCnuG9y9olKSz9slexYXmYyZxDt/72QbgKsXVtDYzsWMyxwoVpLKI7w pk01rdCeyC4/PkLaYr2mlgCuMtEQOaUp4JiUNKPwCtMG/vzhRS1ZmAK96z3h2WeC01Il QWzg== X-Gm-Message-State: AOJu0YyH1GAA/Q4bDgQ3gh1LDtUjIvWShTBmg2NLsnY4/3GTp/Qp8C2p NJMQFeT/gwRFRWh08vx8F6lOS7iK2WTfSW9Bg8OJEJiKC34KnMZkdzkiPZ7txOE= X-Google-Smtp-Source: AGHT+IFx52Mqg9UvAhyMZxSqoBm68J0eDSmn8idCjQbLNMt+HPNn3t9uPTN0PRxOWKxUjhl+YxVwhg== X-Received: by 2002:a05:6870:304a:b0:204:f46f:4ec9 with SMTP id u10-20020a056870304a00b00204f46f4ec9mr1191429oau.46.1705770002445; Sat, 20 Jan 2024 09:00:02 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id dt5-20020a0568705a8500b002142f74c5edsm236389oab.14.2024.01.20.09.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 09:00:01 -0800 (PST) From: Sam Protsenko To: Andi Shyti , Mark Brown , Krzysztof Kozlowski Cc: Alim Akhtar , linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: s3c64xx: Extract FIFO depth calculation to a dedicated macro Date: Sat, 20 Jan 2024 11:00:01 -0600 Message-Id: <20240120170001.3356-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240120_090006_662389_0BFA7707 X-CRM114-Status: GOOD ( 14.73 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplify the code by extracting all cases of FIFO depth calculation into a dedicated macro. No functional change. Signed-off-by: Sam Protsenko Reviewed-by: Andi Shyti --- drivers/spi/spi-s3c64xx.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index f7d623ad6ac3..7f7eb8f742e4 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -109,6 +109,7 @@ #define TX_FIFO_LVL(v, i) (((v) >> 6) & FIFO_LVL_MASK(i)) #define RX_FIFO_LVL(v, i) (((v) >> (i)->port_conf->rx_lvl_offset) & \ FIFO_LVL_MASK(i)) +#define FIFO_DEPTH(i) ((FIFO_LVL_MASK(i) >> 1) + 1) #define S3C64XX_SPI_MAX_TRAILCNT 0x3ff #define S3C64XX_SPI_TRAILCNT_OFF 19 @@ -406,7 +407,7 @@ static bool s3c64xx_spi_can_dma(struct spi_controller *host, struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host); if (sdd->rx_dma.ch && sdd->tx_dma.ch) { - return xfer->len > (FIFO_LVL_MASK(sdd) >> 1) + 1; + return xfer->len > FIFO_DEPTH(sdd); } else { return false; } @@ -495,9 +496,7 @@ static u32 s3c64xx_spi_wait_for_timeout(struct s3c64xx_spi_driver_data *sdd, void __iomem *regs = sdd->regs; unsigned long val = 1; u32 status; - - /* max fifo depth available */ - u32 max_fifo = (FIFO_LVL_MASK(sdd) >> 1) + 1; + u32 max_fifo = FIFO_DEPTH(sdd); if (timeout_ms) val = msecs_to_loops(timeout_ms); @@ -604,7 +603,7 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd, * For any size less than the fifo size the below code is * executed atleast once. */ - loops = xfer->len / ((FIFO_LVL_MASK(sdd) >> 1) + 1); + loops = xfer->len / FIFO_DEPTH(sdd); buf = xfer->rx_buf; do { /* wait for data to be received in the fifo */ @@ -741,7 +740,7 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host, struct spi_transfer *xfer) { struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host); - const unsigned int fifo_len = (FIFO_LVL_MASK(sdd) >> 1) + 1; + const unsigned int fifo_len = FIFO_DEPTH(sdd); const void *tx_buf = NULL; void *rx_buf = NULL; int target_len = 0, origin_len = 0; @@ -1280,7 +1279,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Targets attached\n", sdd->port_id, host->num_chipselect); dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\n", - mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1); + mem_res, FIFO_DEPTH(sdd)); pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev);