aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorAddy Ke <addy.ke@rockchip.com>2014-07-10 22:07:56 -0400
committerMark Brown <broonie@linaro.org>2014-07-11 08:59:57 -0400
commit5dcc44ed911cadc7eb3db46e874a447848f3b340 (patch)
tree2143a44ddbbe14d62f765d812447662608817922 /drivers/spi
parentc15369087ae5c7db7f3e3604822eac6ab87429bd (diff)
spi/rockchip: cleanup some coding issues and uncessary output
Suggested-by: Mark Brown <broonie@kernel.org> Signed-off-by: Addy Ke <addy.ke@rockchip.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-rockchip.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 72fb287556d5..8c247086e520 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd 2 * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
3 * Author: addy ke <addy.ke@rock-chips.com> 3 * Author: Addy Ke <addy.ke@rock-chips.com>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License, 6 * under the terms and conditions of the GNU General Public License,
@@ -186,7 +186,7 @@ struct rockchip_spi {
186 void *rx_end; 186 void *rx_end;
187 187
188 u32 state; 188 u32 state;
189 189 /* protect state */
190 spinlock_t lock; 190 spinlock_t lock;
191 191
192 struct completion xfer_completion; 192 struct completion xfer_completion;
@@ -278,7 +278,7 @@ static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
278} 278}
279 279
280static int rockchip_spi_prepare_message(struct spi_master *master, 280static int rockchip_spi_prepare_message(struct spi_master *master,
281 struct spi_message *msg) 281 struct spi_message *msg)
282{ 282{
283 struct rockchip_spi *rs = spi_master_get_devdata(master); 283 struct rockchip_spi *rs = spi_master_get_devdata(master);
284 struct spi_device *spi = msg->spi; 284 struct spi_device *spi = msg->spi;
@@ -294,13 +294,19 @@ static int rockchip_spi_prepare_message(struct spi_master *master,
294} 294}
295 295
296static int rockchip_spi_unprepare_message(struct spi_master *master, 296static int rockchip_spi_unprepare_message(struct spi_master *master,
297 struct spi_message *msg) 297 struct spi_message *msg)
298{ 298{
299 unsigned long flags; 299 unsigned long flags;
300 struct rockchip_spi *rs = spi_master_get_devdata(master); 300 struct rockchip_spi *rs = spi_master_get_devdata(master);
301 301
302 spin_lock_irqsave(&rs->lock, flags); 302 spin_lock_irqsave(&rs->lock, flags);
303 303
304 /*
305 * For DMA mode, we need terminate DMA channel and flush
306 * fifo for the next transfer if DMA thansfer timeout.
307 * unprepare_message() was called by core if transfer complete
308 * or timeout. Maybe it is reasonable for error handling here.
309 */
304 if (rs->use_dma) { 310 if (rs->use_dma) {
305 if (rs->state & RXBUSY) { 311 if (rs->state & RXBUSY) {
306 dmaengine_terminate_all(rs->dma_rx.ch); 312 dmaengine_terminate_all(rs->dma_rx.ch);
@@ -344,7 +350,7 @@ static void rockchip_spi_pio_reader(struct rockchip_spi *rs)
344 else 350 else
345 *(u16 *)(rs->rx) = (u16)rxw; 351 *(u16 *)(rs->rx) = (u16)rxw;
346 rs->rx += rs->n_bytes; 352 rs->rx += rs->n_bytes;
347 }; 353 }
348} 354}
349 355
350static int rockchip_spi_pio_transfer(struct rockchip_spi *rs) 356static int rockchip_spi_pio_transfer(struct rockchip_spi *rs)
@@ -414,7 +420,8 @@ static int rockchip_spi_dma_transfer(struct rockchip_spi *rs)
414 rxconf.src_maxburst = rs->n_bytes; 420 rxconf.src_maxburst = rs->n_bytes;
415 dmaengine_slave_config(rs->dma_rx.ch, &rxconf); 421 dmaengine_slave_config(rs->dma_rx.ch, &rxconf);
416 422
417 rxdesc = dmaengine_prep_slave_sg(rs->dma_rx.ch, 423 rxdesc = dmaengine_prep_slave_sg(
424 rs->dma_rx.ch,
418 rs->rx_sg.sgl, rs->rx_sg.nents, 425 rs->rx_sg.sgl, rs->rx_sg.nents,
419 rs->dma_rx.direction, DMA_PREP_INTERRUPT); 426 rs->dma_rx.direction, DMA_PREP_INTERRUPT);
420 427
@@ -429,7 +436,8 @@ static int rockchip_spi_dma_transfer(struct rockchip_spi *rs)
429 txconf.dst_maxburst = rs->n_bytes; 436 txconf.dst_maxburst = rs->n_bytes;
430 dmaengine_slave_config(rs->dma_tx.ch, &txconf); 437 dmaengine_slave_config(rs->dma_tx.ch, &txconf);
431 438
432 txdesc = dmaengine_prep_slave_sg(rs->dma_tx.ch, 439 txdesc = dmaengine_prep_slave_sg(
440 rs->dma_tx.ch,
433 rs->tx_sg.sgl, rs->tx_sg.nents, 441 rs->tx_sg.sgl, rs->tx_sg.nents,
434 rs->dma_tx.direction, DMA_PREP_INTERRUPT); 442 rs->dma_tx.direction, DMA_PREP_INTERRUPT);
435 443
@@ -495,13 +503,13 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
495 503
496 spi_set_clk(rs, div); 504 spi_set_clk(rs, div);
497 505
498 dev_dbg(rs->dev, "cr0 0x%x, div %d\n", 506 dev_dbg(rs->dev, "cr0 0x%x, div %d\n", cr0, div);
499 cr0, div);
500 507
501 spi_enable_chip(rs, 1); 508 spi_enable_chip(rs, 1);
502} 509}
503 510
504static int rockchip_spi_transfer_one(struct spi_master *master, 511static int rockchip_spi_transfer_one(
512 struct spi_master *master,
505 struct spi_device *spi, 513 struct spi_device *spi,
506 struct spi_transfer *xfer) 514 struct spi_transfer *xfer)
507{ 515{
@@ -556,8 +564,8 @@ static int rockchip_spi_transfer_one(struct spi_master *master,
556} 564}
557 565
558static bool rockchip_spi_can_dma(struct spi_master *master, 566static bool rockchip_spi_can_dma(struct spi_master *master,
559 struct spi_device *spi, 567 struct spi_device *spi,
560 struct spi_transfer *xfer) 568 struct spi_transfer *xfer)
561{ 569{
562 struct rockchip_spi *rs = spi_master_get_devdata(master); 570 struct rockchip_spi *rs = spi_master_get_devdata(master);
563 571
@@ -572,10 +580,9 @@ static int rockchip_spi_probe(struct platform_device *pdev)
572 struct resource *mem; 580 struct resource *mem;
573 581
574 master = spi_alloc_master(&pdev->dev, sizeof(struct rockchip_spi)); 582 master = spi_alloc_master(&pdev->dev, sizeof(struct rockchip_spi));
575 if (!master) { 583 if (!master)
576 dev_err(&pdev->dev, "No memory for spi_master\n");
577 return -ENOMEM; 584 return -ENOMEM;
578 } 585
579 platform_set_drvdata(pdev, master); 586 platform_set_drvdata(pdev, master);
580 587
581 rs = spi_master_get_devdata(master); 588 rs = spi_master_get_devdata(master);
@@ -676,8 +683,6 @@ static int rockchip_spi_probe(struct platform_device *pdev)
676 goto err_register_master; 683 goto err_register_master;
677 } 684 }
678 685
679 dev_info(&pdev->dev, "Rockchip SPI controller initialized\n");
680
681 return 0; 686 return 0;
682 687
683err_register_master: 688err_register_master:
@@ -817,6 +822,6 @@ static struct platform_driver rockchip_spi_driver = {
817 822
818module_platform_driver(rockchip_spi_driver); 823module_platform_driver(rockchip_spi_driver);
819 824
820MODULE_AUTHOR("addy ke <addy.ke@rock-chips.com>"); 825MODULE_AUTHOR("Addy Ke <addy.ke@rock-chips.com>");
821MODULE_DESCRIPTION("ROCKCHIP SPI Controller Driver"); 826MODULE_DESCRIPTION("ROCKCHIP SPI Controller Driver");
822MODULE_LICENSE("GPL v2"); 827MODULE_LICENSE("GPL v2");