Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5899465imd; Wed, 31 Oct 2018 03:59:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5f/sf6LKcyqlXr9ZHcKJqL1vR/lS4i4YSa+VjXTSm3Hwy20zdS0CfdEkMOoRFcjnv9QNqv0 X-Received: by 2002:a17:902:6113:: with SMTP id t19-v6mr2858208plj.84.1540983574071; Wed, 31 Oct 2018 03:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540983574; cv=none; d=google.com; s=arc-20160816; b=FLRrjw+/5Y80pQf4qtCRt0GYoZ4Zew7qoOpy5Yc3DVTdQoeRak25Eiaqjp23RQfqAC h20ai9KXsaE67+ZUUy0WXQ2aNmFN9WxkuYD5g8m2yvd54/kz54JAWmFmSt0foiMPxvNy T5tHjGZlufO1HUZOJUvB+35bUwOiZI2XJ4xtSxsFmsni8wY8hwEyabcH5gd+N0mlffUR XeXNiNW3kQzfFFLxHD/bkgx7+uQdkAC9UuDojmBN2LvyHeDpEOy0nILLIcTp/I2rFmJo TF9GnoOeTqtjjgIeSRZwMdsNhZAOakw50avhgydeWPG6O+dvcOC1NpzbXwZRgAG1/gq6 /blQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uG/xPakQDGOY9YPMCZ7pYvd1ZBnUY9UsEppY+TSPajo=; b=p1A7e5GDUkjULTW6arXFGrLPK019FROKaJ/NFRiDLU2v4rPUlvSS1vTkxpV7uAnjRF yVI1MSxK70XWMvDZ3EGxrqmVhC492Jg2eCUnww29/2oXsHfsZYmMbqFxf/hbDkaORWeX Mwu11NU54LOJfzgsdBKHh9MpHwZRaxzdoqeO2I0VatZm8RTc//6m1avusN/XRqiz6RCK /cNERrGSKREeqVKQpygJcxu32khHIasahptyriCscGVr+SEAECvHGt2/42yzISGI/V74 8FOGHTxcqLcBHOCWnDl30dRvTpLWTbQRS3ZBlFZxNC2dnR02pFeSiCQ8RTUFocgPpY75 IpfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XGx3WDoM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23-v6si18175949pfu.2.2018.10.31.03.59.19; Wed, 31 Oct 2018 03:59:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XGx3WDoM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729031AbeJaTzs (ORCPT + 99 others); Wed, 31 Oct 2018 15:55:48 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:36838 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727980AbeJaTzr (ORCPT ); Wed, 31 Oct 2018 15:55:47 -0400 Received: by mail-ed1-f68.google.com with SMTP id x2-v6so13218675eds.3; Wed, 31 Oct 2018 03:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uG/xPakQDGOY9YPMCZ7pYvd1ZBnUY9UsEppY+TSPajo=; b=XGx3WDoM4Rk+WhuH9O40Y4RRg8l3d4hd2P97Pj/GzVe1h189uWhlP6j0Y+NO6AABj+ DPylhXzQuxhMKu8vvp6HsANUxhBzptPwZhSarcm/s+2bzVEcYoc8sGWjmw8pUYf4k0gV 5WX/wsc6bL1CU7YrosTAHl2iyQyIXiHKngTUO5GugHFx4PFYfyZBzIwevanifmaziUbP cVDnu88e+0+zxbvV03VdeQCBTwRoJYgzIwyCEAs7nu03OmKlG8OysHdouI3Z9fvcv8xE 3kDJ9xM4+w6QQu913Gbk0IGxo183nFECkd4b2FOmnLdaEnopYYvqnDv6CDe7y9tAa4em rm9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=uG/xPakQDGOY9YPMCZ7pYvd1ZBnUY9UsEppY+TSPajo=; b=ecAICR9SAxAwhZDUdeOMzLCoY6MyGew/SapoxOhVdQLWC0fK76htMe6Z6rnUZfjH33 B2a2OZ79V3QMZVJXLgsBGYRzcmQ/rLn13a1oVFgDAaUreMn+X79giDUB1j2FFx0XCz1V C0g4oWKpzJXZjsteu1TOzwUAXHr6hxbGfOxPMZR3tI51TIlONQzlbxAwBDYofrllhf+8 v7No8PF2VPX84QGnG4HTTsdGLL2GSGEMeLVNEelNVdA9CGQW6mDroeSLxHQfW4CfpQHo p6uZhMqWAEMZbb93XDvasbIskMitR5m7VokU0a1Z4b60EKqYBSSUTLBiRNZYla4KeYAM fF1Q== X-Gm-Message-State: AGRZ1gIhknWnYwvFYMW9LRoAHkkMwgnoFPUXWD4L1SqtVhCwLx8HCDd1 RAZabwTE3cK2uigg8kf4OSKIfm+QWRU= X-Received: by 2002:a50:86ac:: with SMTP id r41-v6mr1626897eda.186.1540983489826; Wed, 31 Oct 2018 03:58:09 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id a40-v6sm9041108edd.61.2018.10.31.03.58.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 03:58:09 -0700 (PDT) From: Emil Renner Berthing To: linux-spi@vger.kernel.org Cc: Emil Renner Berthing , Addy Ke , Mark Brown , Heiko Stuebner , linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 09/14] spi: rockchip: simplify use_dma logic Date: Wed, 31 Oct 2018 11:57:06 +0100 Message-Id: <20181031105711.19575-10-esmil@mailme.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181031105711.19575-1-esmil@mailme.dk> References: <20181031105711.19575-1-esmil@mailme.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Emil Renner Berthing We only need to know if we're using dma when setting up the transfer, so just use a local variable for that. Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 45a1479c1a29..ba60cbcd45c2 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -184,8 +184,6 @@ struct rockchip_spi { void *rx_end; bool cs_asserted[ROCKCHIP_SPI_MAX_CS_NUM]; - - bool use_dma; }; static inline void spi_enable_chip(struct rockchip_spi *rs, bool enable) @@ -450,7 +448,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs, } static void rockchip_spi_config(struct rockchip_spi *rs, - struct spi_device *spi, struct spi_transfer *xfer) + struct spi_device *spi, struct spi_transfer *xfer, + bool use_dma) { u32 div = 0; u32 dmacr = 0; @@ -471,7 +470,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs, else cr0 |= CR0_XFM_TO << CR0_XFM_OFFSET; - if (rs->use_dma) { + if (use_dma) { if (xfer->tx_buf) dmacr |= TF_DMA_EN; if (xfer->rx_buf) @@ -537,6 +536,7 @@ static int rockchip_spi_transfer_one( struct spi_transfer *xfer) { struct rockchip_spi *rs = spi_master_get_devdata(master); + bool use_dma; WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) && (readl_relaxed(rs->regs + ROCKCHIP_SPI_SR) & SR_BUSY)); @@ -559,15 +559,11 @@ static int rockchip_spi_transfer_one( rs->rx = xfer->rx_buf; rs->rx_end = rs->rx + xfer->len; - /* we need prepare dma before spi was enabled */ - if (master->can_dma && master->can_dma(master, spi, xfer)) - rs->use_dma = true; - else - rs->use_dma = false; + use_dma = master->can_dma ? master->can_dma(master, spi, xfer) : false; - rockchip_spi_config(rs, spi, xfer); + rockchip_spi_config(rs, spi, xfer, use_dma); - if (rs->use_dma) + if (use_dma) return rockchip_spi_prepare_dma(rs, master, xfer); return rockchip_spi_pio_transfer(rs); -- 2.19.1