Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8260425imu; Tue, 4 Dec 2018 05:43:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/VRVIiH4GwmmYheaAF3CEG7Ot5EGTx72YRuC2mrHB7ydwEitb3P8zeOaaEnrhV8JwvGXr+h X-Received: by 2002:a17:902:7d82:: with SMTP id a2mr20173498plm.163.1543931011763; Tue, 04 Dec 2018 05:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543931011; cv=none; d=google.com; s=arc-20160816; b=SiGVH8fJJntTdxs0bez2B2Dr0Av/7u5eDbL1v6ljyKLcDHAS8wHJKArZFkTo4PffMR vMq3NalfdN9td5pdRxxtyMmh3YxQnIAoa8j/WvOEGJAcLNMfnH/PheDrFkWkt/1FOdjl 7JozjXA4zIjvmpn7HAoPeWjxSdlxFvelJVwUFL/p1MaAv1n5jF82fTFuP0V1R0AQkUxR A/QweMMnVGONrs1qMC4tJafcfl9gUpzzB8XFgWjz6kGd5eU5sRaunBXhsS1gKly2UZuH 05kV+CgdP7xbZdfnnNLIdvwClngRIrKsnHa5fReDyoDdH5+qFJPyg+FK1HTRxt8DD6FR D8Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=2Wl6JhbY3w27kqFh8kKeoXmq2xfpFYXUfBNTAPNx+wY=; b=onEXoYGkJxfUcU1gaXMZvFPX6C3o7gMRNzSKzqKA7RN4MNr6zjwN5rVw3B6VoUyKF6 RkYaFjPq6FoSXhfW/AVAQ/oJaKJhkWsF9MN06g9GMrhmPtRzp1mr6KkUf4izfVmJTyUR UErqU6aPcv5eP8t/h16k7Xj8E5Jllj8TXRfp/2U7alxK5uVQwwYemgVKKHgzD4+gByt4 KLAsXVgfVM9SCsku4CTZG9CCrLpZ5/60M5VYFJYXHogpEJ/lxOGWMEB67yMUo/+SiG8r YVj84mVxzSJXYAk+9gghAK6pn6Nd4YbSaOLh+9SAolWBe7y46+MZSuXX08VV62sYO3bW hUkg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si18107571pfb.178.2018.12.04.05.43.06; Tue, 04 Dec 2018 05:43:31 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726470AbeLDNlM (ORCPT + 99 others); Tue, 4 Dec 2018 08:41:12 -0500 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:55838 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726165AbeLDNlL (ORCPT ); Tue, 4 Dec 2018 08:41:11 -0500 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id wB4DAcSu010699; Tue, 4 Dec 2018 15:10:38 +0200 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id 5D82E62DA6; Tue, 4 Dec 2018 15:40:36 +0200 (IST) From: Tomer Maimon To: broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, yuenn@google.com, venture@google.com, brendanhiggins@google.com, avifishman70@gmail.com, joel@jms.id.au Cc: linux-spi@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Tomer Maimon Subject: [PATCH v1] spi: npcm: Modify pspi send function Date: Tue, 4 Dec 2018 15:40:35 +0200 Message-Id: <20181204134035.124079-1-tmaimon77@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Align pspi send function code with the recieve function code, Also simplify the code a bit with early return. Signed-off-by: Tomer Maimon --- drivers/spi/spi-npcm-pspi.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c index dda91c19af93..e1dca79b9090 100644 --- a/drivers/spi/spi-npcm-pspi.c +++ b/drivers/spi/spi-npcm-pspi.c @@ -199,14 +199,22 @@ static void npcm_pspi_send(struct npcm_pspi *priv) wsize = min(bytes_per_word(priv->bits_per_word), priv->tx_bytes); priv->tx_bytes -= wsize; - if (priv->tx_buf) { - if (wsize == 1) - iowrite8(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); - if (wsize == 2) - iowrite16(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); + if (!priv->tx_buf) + return; - priv->tx_buf += wsize; + switch (wsize) { + case 1: + iowrite8(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); + break; + case 2: + iowrite16(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); + break; + default: + WARN_ON_ONCE(1); + return; } + + priv->tx_buf += wsize; } static void npcm_pspi_recv(struct npcm_pspi *priv) -- 2.14.1