From patchwork Mon Nov 21 05:54:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 9438799 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 16AED600BA for ; Mon, 21 Nov 2016 06:06:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 079C7286FC for ; Mon, 21 Nov 2016 06:06:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFE8C2898B; Mon, 21 Nov 2016 06:06:12 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 909C3286FC for ; Mon, 21 Nov 2016 06:06:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c8hig-0006qi-DO; Mon, 21 Nov 2016 06:04:46 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c8hhf-0006DF-8E for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2016 06:03:46 +0000 Received: by mail-pg0-x243.google.com with SMTP id x23so27557556pgx.3 for ; Sun, 20 Nov 2016 22:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=svRbHcDogjwSj3r19UYUrp2bE6m91RAxIxdl1VMAGSA=; b=lTLacfIFonGDRRw/uYnk6h/z2U/NQMwxDtVtNy7T3CKEiqQqed/0uTySeDt0m2qO+Y /MvVO6AodYLGr740ZVGkbM/fv3R2xEcDGwnmVokkOFN4nueKHI4vvqtibJwJOTTfD64f UzLKrVJYRzqugvIrzFLTQfSn1ua2/iYzRe2RDXzvLTFkcthqiWM7CZFYIJtxa4X6xpP3 7lEcv5dp4H5hsvi7p98c52rXf9swguhwRGcWuMHjLkfPVIkJ8JTduqZtfIR4i1BdldoQ 5f4QkxhT2u8UcnI6elvnBFZTS+801VR8n88YRKQp7lduQZmK0k/6mUAO9L9j7HxFsjtT xIjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=svRbHcDogjwSj3r19UYUrp2bE6m91RAxIxdl1VMAGSA=; b=m99S2ZrDCwuWCb78Z/vtt7XSspX0njTBMNXvSt4KWOGdfi2mwKbggbO3ETDB2ydtmV CyLAfKmZTMM8T3XDUyA6JJVhIZeFOp8McRgT6nbTc0KHWqJxfXVABTjJfisv4edGyU+u QoGeex9ORAaJO69PYymhW/spEr0SsI/UGahoNMFYKqmtlUNIkTf5RqnMTaFkmQcMnvnW DBLbkqfo4hGhJSYluGsEb8xWwGmqAVeOiPy/pu7+KKMtT0dysMcj7sjIQ90A8s+L8kyO jbXCDk9cRA1zqOtS5iFS0pmjPvgFVavwHMkHxBzv8OpcJF7VzYzfJSJhM/t5ZlyOkWEn JufA== X-Gm-Message-State: AKaTC01p6GqoIza/g7wXLEU6GDmQWdPMzJIJT9lA0oxYIjC/+cBC3bquL0hQoRRUg+msmg== X-Received: by 10.99.155.26 with SMTP id r26mr28437957pgd.165.1479708202302; Sun, 20 Nov 2016 22:03:22 -0800 (PST) Received: from localhost ([115.115.243.34]) by smtp.gmail.com with ESMTPSA id y89sm34011996pfk.83.2016.11.20.22.03.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Nov 2016 22:03:21 -0800 (PST) From: Sanchayan Maity To: broonie@kernel.org Subject: [PATCH v2 4/4] spi: spi-fsl-dspi: Minor code cleanup and error path fixes Date: Mon, 21 Nov 2016 11:24:04 +0530 Message-Id: <971874d8e662622c0cfe478adaa4c75b08388d0e.1479706671.git.maitysanchayan@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161120_220343_592998_7DD70CD8 X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sanchayan Maity , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, stefan@agner.ch, linux-kernel@vger.kernel.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 Code cleanup for improving code readability and error path fixes and cleanup removing use of devm_kfree. Signed-off-by: Sanchayan Maity --- drivers/spi/spi-fsl-dspi.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 08882f7..2987a16 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -226,8 +226,10 @@ static void dspi_rx_dma_callback(void *arg) if (!(dspi->dataflags & TRAN_STATE_RX_VOID)) { for (i = 0; i < dma->curr_xfer_len; i++) { d = dspi->dma->rx_dma_buf[i]; - rx_word ? (*(u16 *)dspi->rx = d) : - (*(u8 *)dspi->rx = d); + if (rx_word) + *(u16 *)dspi->rx = d; + else + *(u8 *)dspi->rx = d; dspi->rx += rx_word + 1; } } @@ -247,14 +249,20 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi) tx_word = is_double_byte_mode(dspi); for (i = 0; i < dma->curr_xfer_len - 1; i++) { - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx; + if (tx_word) + val = *(u16 *) dspi->tx; + else + val = *(u8 *) dspi->tx; dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT; dspi->tx += tx_word + 1; } - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx; + if (tx_word) + val = *(u16 *) dspi->tx; + else + val = *(u8 *) dspi->tx; dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) | SPI_PUSHR_CTAS(0); @@ -430,9 +438,11 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr) return 0; err_slave_config: - devm_kfree(dev, dma->rx_dma_buf); + dma_free_coherent(dev, DSPI_DMA_BUFSIZE, + dma->rx_dma_buf, dma->rx_dma_phys); err_rx_dma_buf: - devm_kfree(dev, dma->tx_dma_buf); + dma_free_coherent(dev, DSPI_DMA_BUFSIZE, + dma->tx_dma_buf, dma->tx_dma_phys); err_tx_dma_buf: dma_release_channel(dma->chan_tx); err_tx_channel: