From patchwork Wed Jun 28 19:25:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 9815229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C985860365 for ; Wed, 28 Jun 2017 19:26:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9F8D2018E for ; Wed, 28 Jun 2017 19:26:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD743262FF; Wed, 28 Jun 2017 19:26:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 296982018E for ; Wed, 28 Jun 2017 19:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Date: Message-Id:In-Reply-To:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: References:List-Owner; bh=z+SM+g/Dn4aFh7oKlO36oIegPWSs9YIk1GzhGzg5zGE=; b=CvA CK1VUAET5JTJt395WkeMFFLFIH3MjvJEBABrxFVKtpt0XL0rNukvqjncm4a9+o7neAS+nj63GqQfv gmGrZ1n1m2AGvFAjhcQEdPp54WGtGOwGP5t5F/Yk1uWrhZrVo4s/eARPAh/SSLlGwbHkfKUXwMExJ PioY0ppEh5ep3Bt6ZVDvmYz3ANkSJ5C1Kl3fb9GT9iDDJb/8p4dhU+oma1pdyC3Q/DkXlcJFOxXpc G5mEhnyP4oXFobeCSzA86ZlhGAaXAVDcFk/sJ+RlZAr4LwxoXHjnEp6J3+udDdvhN2T8S18bQJBdI qYaw5gjTY4wVl1Qjq4ecH6gZhMNv3/Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQIbl-0007Hs-1K; Wed, 28 Jun 2017 19:26:37 +0000 Received: from mezzanine.sirena.org.uk ([2400:8900::f03c:91ff:fedb:4f4]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQIaz-0006Na-82 for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 19:25:51 +0000 Received: from [176.12.107.140] (helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1dQIac-0001Zl-8m; Wed, 28 Jun 2017 19:25:28 +0000 Received: from broonie by finisterre with local (Exim 4.89) (envelope-from ) id 1dQIaY-0004dE-Sa; Wed, 28 Jun 2017 20:25:22 +0100 From: Mark Brown To: Amelie Delaunay In-Reply-To: <1498222550-19092-6-git-send-email-amelie.delaunay@st.com> Message-Id: Date: Wed, 28 Jun 2017 20:25:22 +0100 X-SA-Exim-Connect-IP: 176.12.107.140 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Applied "spi: stm32: use normal conditional statements instead of ternary operator" to the spi tree X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: No (on mezzanine.sirena.org.uk); Unknown failure X-Bad-Reply: In-Reply-To but no 'Re:' in Subject. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170628_122549_514586_6827303B X-CRM114-Status: GOOD ( 15.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Alexandre Torgue , linux-kernel@vger.kernel.org, Rob Herring , linux-spi@vger.kernel.org, Mark Brown , Maxime Coquelin , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The patch spi: stm32: use normal conditional statements instead of ternary operator has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 128ebb89c50e5452704de82d78845baeb3333c24 Mon Sep 17 00:00:00 2001 From: Amelie Delaunay Date: Tue, 27 Jun 2017 17:45:17 +0200 Subject: [PATCH] spi: stm32: use normal conditional statements instead of ternary operator This patch replace ternary operator use by normal condition statements to ease code reading. It also removes redundant !!. Signed-off-by: Amelie Delaunay Signed-off-by: Mark Brown --- drivers/spi/spi-stm32.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 3df4baa68d63..123529a1b40d 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -267,7 +267,10 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz) return -EINVAL; /* Determine the first power of 2 greater than or equal to div */ - mbrdiv = (div & (div - 1)) ? fls(div) : fls(div) - 1; + if (div & (div - 1)) + mbrdiv = fls(div); + else + mbrdiv = fls(div) - 1; spi->cur_speed = spi->clk_rate / (1 << mbrdiv); @@ -285,9 +288,12 @@ static u32 stm32_spi_prepare_fthlv(struct stm32_spi *spi) /* data packet should not exceed 1/2 of fifo space */ half_fifo = (spi->fifo_size / 2); - fthlv = (spi->cur_bpw <= 8) ? half_fifo : - (spi->cur_bpw <= 16) ? (half_fifo / 2) : - (half_fifo / 4); + if (spi->cur_bpw <= 8) + fthlv = half_fifo; + else if (spi->cur_bpw <= 16) + fthlv = half_fifo / 2; + else + fthlv = half_fifo / 4; /* align packet size with data registers access */ if (spi->cur_bpw > 8) @@ -462,9 +468,9 @@ static bool stm32_spi_can_dma(struct spi_master *master, struct stm32_spi *spi = spi_master_get_devdata(master); dev_dbg(spi->dev, "%s: %s\n", __func__, - (!!(transfer->len > spi->fifo_size)) ? "true" : "false"); + (transfer->len > spi->fifo_size) ? "true" : "false"); - return !!(transfer->len > spi->fifo_size); + return (transfer->len > spi->fifo_size); } /** @@ -493,7 +499,8 @@ static irqreturn_t stm32_spi_irq(int irq, void *dev_id) * Full-Duplex, need to poll RXP event to know if there are remaining * data, before disabling SPI. */ - mask |= ((spi->rx_buf && !spi->cur_usedma) ? SPI_SR_RXP : 0); + if (spi->rx_buf && !spi->cur_usedma) + mask |= SPI_SR_RXP; if (!(sr & mask)) { dev_dbg(spi->dev, "spurious IT (sr=0x%08x, ier=0x%08x)\n", @@ -656,12 +663,18 @@ static void stm32_spi_dma_config(struct stm32_spi *spi, enum dma_slave_buswidth buswidth; u32 maxburst; - buswidth = (spi->cur_bpw <= 8) ? DMA_SLAVE_BUSWIDTH_1_BYTE : - (spi->cur_bpw <= 16) ? DMA_SLAVE_BUSWIDTH_2_BYTES : - DMA_SLAVE_BUSWIDTH_4_BYTES; + if (spi->cur_bpw <= 8) + buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; + else if (spi->cur_bpw <= 16) + buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; + else + buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; /* Valid for DMA Half or Full Fifo threshold */ - maxburst = (spi->cur_fthlv == 2) ? 1 : spi->cur_fthlv; + if (spi->cur_fthlv == 2) + maxburst = 1; + else + maxburst = spi->cur_fthlv; memset(dma_conf, 0, sizeof(struct dma_slave_config)); dma_conf->direction = dir; @@ -920,9 +933,12 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, ~cfg2_clrb) | cfg2_setb, spi->base + STM32_SPI_CFG2); - nb_words = DIV_ROUND_UP(transfer->len * 8, - (spi->cur_bpw <= 8) ? 8 : - (spi->cur_bpw <= 16) ? 16 : 32); + if (spi->cur_bpw <= 8) + nb_words = transfer->len; + else if (spi->cur_bpw <= 16) + nb_words = DIV_ROUND_UP(transfer->len * 8, 16); + else + nb_words = DIV_ROUND_UP(transfer->len * 8, 32); nb_words <<= SPI_CR2_TSIZE_SHIFT; if (nb_words <= SPI_CR2_TSIZE) {