Skip to content

Commit 8e90859

Browse files
Nicolas Ferrealexandrebelloni
authored andcommitted
spi: atmel: remove the use of private channel fields
For DMA transfers, we now use the core DMA framework which provides channel fields in the spi_master structure. Remove the private channels from atmel_spi stucture which were located in a sub-structure. This last one (atmel_spi_dma) which is now empty is also removed. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fa82a56 commit 8e90859

1 file changed

Lines changed: 43 additions & 43 deletions

File tree

drivers/spi/spi-atmel.c

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,6 @@
265265

266266
#define AUTOSUSPEND_TIMEOUT 2000
267267

268-
struct atmel_spi_dma {
269-
struct dma_chan *chan_rx;
270-
struct dma_chan *chan_tx;
271-
};
272-
273268
struct atmel_spi_caps {
274269
bool is_spi2;
275270
bool has_wdrbt;
@@ -303,8 +298,6 @@ struct atmel_spi {
303298
bool use_dma;
304299
bool use_pdc;
305300
bool use_cs_gpios;
306-
/* dmaengine data */
307-
struct atmel_spi_dma dma;
308301

309302
bool keep_cs;
310303
bool cs_active;
@@ -461,6 +454,7 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as,
461454
struct dma_slave_config *slave_config,
462455
u8 bits_per_word)
463456
{
457+
struct spi_master *master = platform_get_drvdata(as->pdev);
464458
int err = 0;
465459

466460
if (bits_per_word > 8) {
@@ -492,7 +486,7 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as,
492486
* path works the same whether FIFOs are available (and enabled) or not.
493487
*/
494488
slave_config->direction = DMA_MEM_TO_DEV;
495-
if (dmaengine_slave_config(as->dma.chan_tx, slave_config)) {
489+
if (dmaengine_slave_config(master->dma_tx, slave_config)) {
496490
dev_err(&as->pdev->dev,
497491
"failed to configure tx dma channel\n");
498492
err = -EINVAL;
@@ -507,7 +501,7 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as,
507501
* enabled) or not.
508502
*/
509503
slave_config->direction = DMA_DEV_TO_MEM;
510-
if (dmaengine_slave_config(as->dma.chan_rx, slave_config)) {
504+
if (dmaengine_slave_config(master->dma_rx, slave_config)) {
511505
dev_err(&as->pdev->dev,
512506
"failed to configure rx dma channel\n");
513507
err = -EINVAL;
@@ -516,7 +510,8 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as,
516510
return err;
517511
}
518512

519-
static int atmel_spi_configure_dma(struct atmel_spi *as)
513+
static int atmel_spi_configure_dma(struct spi_master *master,
514+
struct atmel_spi *as)
520515
{
521516
struct dma_slave_config slave_config;
522517
struct device *dev = &as->pdev->dev;
@@ -526,26 +521,26 @@ static int atmel_spi_configure_dma(struct atmel_spi *as)
526521
dma_cap_zero(mask);
527522
dma_cap_set(DMA_SLAVE, mask);
528523

529-
as->dma.chan_tx = dma_request_slave_channel_reason(dev, "tx");
530-
if (IS_ERR(as->dma.chan_tx)) {
531-
err = PTR_ERR(as->dma.chan_tx);
524+
master->dma_tx = dma_request_slave_channel_reason(dev, "tx");
525+
if (IS_ERR(master->dma_tx)) {
526+
err = PTR_ERR(master->dma_tx);
532527
if (err == -EPROBE_DEFER) {
533528
dev_warn(dev, "no DMA channel available at the moment\n");
534-
return err;
529+
goto error_clear;
535530
}
536531
dev_err(dev,
537532
"DMA TX channel not available, SPI unable to use DMA\n");
538533
err = -EBUSY;
539-
goto error;
534+
goto error_clear;
540535
}
541536

542537
/*
543538
* No reason to check EPROBE_DEFER here since we have already requested
544539
* tx channel. If it fails here, it's for another reason.
545540
*/
546-
as->dma.chan_rx = dma_request_slave_channel(dev, "rx");
541+
master->dma_rx = dma_request_slave_channel(dev, "rx");
547542

548-
if (!as->dma.chan_rx) {
543+
if (!master->dma_rx) {
549544
dev_err(dev,
550545
"DMA RX channel not available, SPI unable to use DMA\n");
551546
err = -EBUSY;
@@ -558,31 +553,38 @@ static int atmel_spi_configure_dma(struct atmel_spi *as)
558553

559554
dev_info(&as->pdev->dev,
560555
"Using %s (tx) and %s (rx) for DMA transfers\n",
561-
dma_chan_name(as->dma.chan_tx),
562-
dma_chan_name(as->dma.chan_rx));
556+
dma_chan_name(master->dma_tx),
557+
dma_chan_name(master->dma_rx));
558+
563559
return 0;
564560
error:
565-
if (as->dma.chan_rx)
566-
dma_release_channel(as->dma.chan_rx);
567-
if (!IS_ERR(as->dma.chan_tx))
568-
dma_release_channel(as->dma.chan_tx);
561+
if (master->dma_rx)
562+
dma_release_channel(master->dma_rx);
563+
if (!IS_ERR(master->dma_tx))
564+
dma_release_channel(master->dma_tx);
565+
error_clear:
566+
master->dma_tx = master->dma_rx = NULL;
569567
return err;
570568
}
571569

572-
static void atmel_spi_stop_dma(struct atmel_spi *as)
570+
static void atmel_spi_stop_dma(struct spi_master *master)
573571
{
574-
if (as->dma.chan_rx)
575-
dmaengine_terminate_all(as->dma.chan_rx);
576-
if (as->dma.chan_tx)
577-
dmaengine_terminate_all(as->dma.chan_tx);
572+
if (master->dma_rx)
573+
dmaengine_terminate_all(master->dma_rx);
574+
if (master->dma_tx)
575+
dmaengine_terminate_all(master->dma_tx);
578576
}
579577

580-
static void atmel_spi_release_dma(struct atmel_spi *as)
578+
static void atmel_spi_release_dma(struct spi_master *master)
581579
{
582-
if (as->dma.chan_rx)
583-
dma_release_channel(as->dma.chan_rx);
584-
if (as->dma.chan_tx)
585-
dma_release_channel(as->dma.chan_tx);
580+
if (master->dma_rx) {
581+
dma_release_channel(master->dma_rx);
582+
master->dma_rx = NULL;
583+
}
584+
if (master->dma_tx) {
585+
dma_release_channel(master->dma_tx);
586+
master->dma_tx = NULL;
587+
}
586588
}
587589

588590
/* This function is called by the DMA driver from tasklet context */
@@ -718,8 +720,8 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,
718720
u32 *plen)
719721
{
720722
struct atmel_spi *as = spi_master_get_devdata(master);
721-
struct dma_chan *rxchan = as->dma.chan_rx;
722-
struct dma_chan *txchan = as->dma.chan_tx;
723+
struct dma_chan *rxchan = master->dma_rx;
724+
struct dma_chan *txchan = master->dma_tx;
723725
struct dma_async_tx_descriptor *rxdesc;
724726
struct dma_async_tx_descriptor *txdesc;
725727
struct dma_slave_config slave_config;
@@ -783,7 +785,7 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,
783785

784786
err_dma:
785787
spi_writel(as, IDR, SPI_BIT(OVRES));
786-
atmel_spi_stop_dma(as);
788+
atmel_spi_stop_dma(master);
787789
err_exit:
788790
atmel_spi_lock(as);
789791
return -ENOMEM;
@@ -1311,7 +1313,7 @@ static int atmel_spi_one_transfer(struct spi_master *master,
13111313
spi_readl(as, SR);
13121314

13131315
} else if (atmel_spi_use_dma(as, xfer)) {
1314-
atmel_spi_stop_dma(as);
1316+
atmel_spi_stop_dma(master);
13151317
}
13161318

13171319
if (!msg->is_dma_mapped
@@ -1540,10 +1542,8 @@ static int atmel_spi_probe(struct platform_device *pdev)
15401542
as->use_dma = false;
15411543
as->use_pdc = false;
15421544
if (as->caps.has_dma_support) {
1543-
ret = atmel_spi_configure_dma(as);
1545+
ret = atmel_spi_configure_dma(master, as);
15441546
if (ret == 0) {
1545-
master->dma_tx = as->dma.chan_tx;
1546-
master->dma_rx = as->dma.chan_rx;
15471547
as->use_dma = true;
15481548
} else if (ret == -EPROBE_DEFER) {
15491549
return ret;
@@ -1612,7 +1612,7 @@ static int atmel_spi_probe(struct platform_device *pdev)
16121612
pm_runtime_set_suspended(&pdev->dev);
16131613

16141614
if (as->use_dma)
1615-
atmel_spi_release_dma(as);
1615+
atmel_spi_release_dma(master);
16161616

16171617
spi_writel(as, CR, SPI_BIT(SWRST));
16181618
spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
@@ -1634,8 +1634,8 @@ static int atmel_spi_remove(struct platform_device *pdev)
16341634
/* reset the hardware and block queue progress */
16351635
spin_lock_irq(&as->lock);
16361636
if (as->use_dma) {
1637-
atmel_spi_stop_dma(as);
1638-
atmel_spi_release_dma(as);
1637+
atmel_spi_stop_dma(master);
1638+
atmel_spi_release_dma(master);
16391639
}
16401640

16411641
spi_writel(as, CR, SPI_BIT(SWRST));

0 commit comments

Comments
 (0)