From patchwork Tue Dec 24 09:49:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 3401371 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 818059F375 for ; Tue, 24 Dec 2013 09:49:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1DF1205F3 for ; Tue, 24 Dec 2013 09:49:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C62AB205F9 for ; Tue, 24 Dec 2013 09:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751797Ab3LXJtu (ORCPT ); Tue, 24 Dec 2013 04:49:50 -0500 Received: from juliette.telenet-ops.be ([195.130.137.74]:42335 "EHLO juliette.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751655Ab3LXJtu (ORCPT ); Tue, 24 Dec 2013 04:49:50 -0500 Received: from ayla.of.borg ([84.193.72.141]) by juliette.telenet-ops.be with bizsmtp id 5Mpl1n00932ts5g06MplvK; Tue, 24 Dec 2013 10:49:45 +0100 Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1VvOcS-0005ap-Ta; Tue, 24 Dec 2013 10:49:44 +0100 From: Geert Uytterhoeven To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/5] spi: rspi: Remove casts Date: Tue, 24 Dec 2013 10:49:31 +0100 Message-Id: <1387878574-21445-3-git-send-email-geert+renesas@linux-m68k.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1387878574-21445-1-git-send-email-geert+renesas@linux-m68k.org> References: <1387878574-21445-1-git-send-email-geert+renesas@linux-m68k.org> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove useless casts, and do not cast away const. Signed-off-by: Geert Uytterhoeven --- drivers/spi/spi-rspi.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 08861b5db893..a0038687a8fd 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -330,9 +330,7 @@ static int rspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg, struct spi_transfer *t) { int remain = t->len; - u8 *data; - - data = (u8 *)t->tx_buf; + const u8 *data = t->tx_buf; while (remain > 0) { rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD, RSPI_SPCR); @@ -358,12 +356,11 @@ static int qspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg, struct spi_transfer *t) { int remain = t->len; - u8 *data; + const u8 *data = t->tx_buf; rspi_write8(rspi, SPBFCR_TXRST, QSPI_SPBFCR); rspi_write8(rspi, 0x00, QSPI_SPBFCR); - data = (u8 *)t->tx_buf; while (remain > 0) { if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) { @@ -399,8 +396,8 @@ static void rspi_dma_complete(void *arg) wake_up_interruptible(&rspi->wait); } -static int rspi_dma_map_sg(struct scatterlist *sg, void *buf, unsigned len, - struct dma_chan *chan, +static int rspi_dma_map_sg(struct scatterlist *sg, const void *buf, + unsigned len, struct dma_chan *chan, enum dma_transfer_direction dir) { sg_init_table(sg, 1); @@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const void *data, unsigned len) static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t) { struct scatterlist sg; - void *buf = NULL; + const void *buf = NULL; struct dma_async_tx_descriptor *desc; unsigned len; int ret = 0; if (rspi->dma_width_16bit) { + void *tmp; /* * If DMAC bus width is 16-bit, the driver allocates a dummy * buffer. And, the driver converts original data into the @@ -454,13 +452,14 @@ static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t) * DMAC data: 1st byte, dummy, 2nd byte, dummy ... */ len = t->len * 2; - buf = kmalloc(len, GFP_KERNEL); - if (!buf) + tmp = kmalloc(len, GFP_KERNEL); + if (!tmp) return -ENOMEM; - rspi_memory_to_8bit(buf, t->tx_buf, t->len); + rspi_memory_to_8bit(tmp, t->tx_buf, t->len); + buf = tmp; } else { len = t->len; - buf = (void *)t->tx_buf; + buf = t->tx_buf; } if (!rspi_dma_map_sg(&sg, buf, len, rspi->chan_tx, DMA_TO_DEVICE)) { @@ -528,7 +527,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg, rspi_receive_init(rspi); - data = (u8 *)t->rx_buf; + data = t->rx_buf; while (remain > 0) { rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD, RSPI_SPCR); @@ -575,7 +574,7 @@ static int qspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg, qspi_receive_init(rspi); - data = (u8 *)t->rx_buf; + data = t->rx_buf; while (remain > 0) { if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) { @@ -802,7 +801,7 @@ static void rspi_cleanup(struct spi_device *spi) static irqreturn_t rspi_irq(int irq, void *_sr) { - struct rspi_data *rspi = (struct rspi_data *)_sr; + struct rspi_data *rspi = _sr; unsigned long spsr; irqreturn_t ret = IRQ_NONE; unsigned char disable_irq = 0;