Skip to content

Commit 9da85b2

Browse files
Yang Yinglianggregkh
authored andcommitted
spi: sun6i: switch to use modern name
[ Upstream commit 9f55bb7 ] Change legacy name master to modern name host or controller. No functional changed. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://msgid.link/r/20231128093031.3707034-8-yangyingliang@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org> Stable-dep-of: d874a1c ("spi: sun6i: fix controller deregistration") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7fd0c4f commit 9da85b2

1 file changed

Lines changed: 74 additions & 74 deletions

File tree

drivers/spi/spi-sun6i.c

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct sun6i_spi_cfg {
9797
};
9898

9999
struct sun6i_spi {
100-
struct spi_master *master;
100+
struct spi_controller *host;
101101
void __iomem *base_addr;
102102
dma_addr_t dma_addr_rx;
103103
dma_addr_t dma_addr_tx;
@@ -181,7 +181,7 @@ static inline void sun6i_spi_fill_fifo(struct sun6i_spi *sspi)
181181

182182
static void sun6i_spi_set_cs(struct spi_device *spi, bool enable)
183183
{
184-
struct sun6i_spi *sspi = spi_master_get_devdata(spi->master);
184+
struct sun6i_spi *sspi = spi_controller_get_devdata(spi->controller);
185185
u32 reg;
186186

187187
reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG);
@@ -212,7 +212,7 @@ static int sun6i_spi_prepare_dma(struct sun6i_spi *sspi,
212212
struct spi_transfer *tfr)
213213
{
214214
struct dma_async_tx_descriptor *rxdesc, *txdesc;
215-
struct spi_master *master = sspi->master;
215+
struct spi_controller *host = sspi->host;
216216

217217
rxdesc = NULL;
218218
if (tfr->rx_buf) {
@@ -223,9 +223,9 @@ static int sun6i_spi_prepare_dma(struct sun6i_spi *sspi,
223223
.src_maxburst = 8,
224224
};
225225

226-
dmaengine_slave_config(master->dma_rx, &rxconf);
226+
dmaengine_slave_config(host->dma_rx, &rxconf);
227227

228-
rxdesc = dmaengine_prep_slave_sg(master->dma_rx,
228+
rxdesc = dmaengine_prep_slave_sg(host->dma_rx,
229229
tfr->rx_sg.sgl,
230230
tfr->rx_sg.nents,
231231
DMA_DEV_TO_MEM,
@@ -245,38 +245,38 @@ static int sun6i_spi_prepare_dma(struct sun6i_spi *sspi,
245245
.dst_maxburst = 8,
246246
};
247247

248-
dmaengine_slave_config(master->dma_tx, &txconf);
248+
dmaengine_slave_config(host->dma_tx, &txconf);
249249

250-
txdesc = dmaengine_prep_slave_sg(master->dma_tx,
250+
txdesc = dmaengine_prep_slave_sg(host->dma_tx,
251251
tfr->tx_sg.sgl,
252252
tfr->tx_sg.nents,
253253
DMA_MEM_TO_DEV,
254254
DMA_PREP_INTERRUPT);
255255
if (!txdesc) {
256256
if (rxdesc)
257-
dmaengine_terminate_sync(master->dma_rx);
257+
dmaengine_terminate_sync(host->dma_rx);
258258
return -EINVAL;
259259
}
260260
}
261261

262262
if (tfr->rx_buf) {
263263
dmaengine_submit(rxdesc);
264-
dma_async_issue_pending(master->dma_rx);
264+
dma_async_issue_pending(host->dma_rx);
265265
}
266266

267267
if (tfr->tx_buf) {
268268
dmaengine_submit(txdesc);
269-
dma_async_issue_pending(master->dma_tx);
269+
dma_async_issue_pending(host->dma_tx);
270270
}
271271

272272
return 0;
273273
}
274274

275-
static int sun6i_spi_transfer_one(struct spi_master *master,
275+
static int sun6i_spi_transfer_one(struct spi_controller *host,
276276
struct spi_device *spi,
277277
struct spi_transfer *tfr)
278278
{
279-
struct sun6i_spi *sspi = spi_master_get_devdata(master);
279+
struct sun6i_spi *sspi = spi_controller_get_devdata(host);
280280
unsigned int div, div_cdr1, div_cdr2, timeout;
281281
unsigned int start, end, tx_time;
282282
unsigned int trig_level;
@@ -293,7 +293,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
293293
sspi->tx_buf = tfr->tx_buf;
294294
sspi->rx_buf = tfr->rx_buf;
295295
sspi->len = tfr->len;
296-
use_dma = master->can_dma ? master->can_dma(master, spi, tfr) : false;
296+
use_dma = host->can_dma ? host->can_dma(host, spi, tfr) : false;
297297

298298
/* Clear pending interrupts */
299299
sun6i_spi_write(sspi, SUN6I_INT_STA_REG, ~0);
@@ -463,7 +463,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
463463
} else {
464464
ret = sun6i_spi_prepare_dma(sspi, tfr);
465465
if (ret) {
466-
dev_warn(&master->dev,
466+
dev_warn(&host->dev,
467467
"%s: prepare DMA failed, ret=%d",
468468
dev_name(&spi->dev), ret);
469469
return ret;
@@ -486,7 +486,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
486486
reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG);
487487
sun6i_spi_write(sspi, SUN6I_TFR_CTL_REG, reg | SUN6I_TFR_CTL_XCH);
488488

489-
tx_time = spi_controller_xfer_timeout(master, tfr);
489+
tx_time = spi_controller_xfer_timeout(host, tfr);
490490
start = jiffies;
491491
timeout = wait_for_completion_timeout(&sspi->done,
492492
msecs_to_jiffies(tx_time));
@@ -502,13 +502,13 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
502502
timeout = wait_for_completion_timeout(&sspi->dma_rx_done,
503503
timeout);
504504
if (!timeout)
505-
dev_warn(&master->dev, "RX DMA timeout\n");
505+
dev_warn(&host->dev, "RX DMA timeout\n");
506506
}
507507
}
508508

509509
end = jiffies;
510510
if (!timeout) {
511-
dev_warn(&master->dev,
511+
dev_warn(&host->dev,
512512
"%s: timeout transferring %u bytes@%iHz for %i(%i)ms",
513513
dev_name(&spi->dev), tfr->len, tfr->speed_hz,
514514
jiffies_to_msecs(end - start), tx_time);
@@ -518,8 +518,8 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
518518
sun6i_spi_write(sspi, SUN6I_INT_CTL_REG, 0);
519519

520520
if (ret && use_dma) {
521-
dmaengine_terminate_sync(master->dma_rx);
522-
dmaengine_terminate_sync(master->dma_tx);
521+
dmaengine_terminate_sync(host->dma_rx);
522+
dmaengine_terminate_sync(host->dma_tx);
523523
}
524524

525525
return ret;
@@ -564,8 +564,8 @@ static irqreturn_t sun6i_spi_handler(int irq, void *dev_id)
564564

565565
static int sun6i_spi_runtime_resume(struct device *dev)
566566
{
567-
struct spi_master *master = dev_get_drvdata(dev);
568-
struct sun6i_spi *sspi = spi_master_get_devdata(master);
567+
struct spi_controller *host = dev_get_drvdata(dev);
568+
struct sun6i_spi *sspi = spi_controller_get_devdata(host);
569569
int ret;
570570

571571
ret = clk_prepare_enable(sspi->hclk);
@@ -601,8 +601,8 @@ static int sun6i_spi_runtime_resume(struct device *dev)
601601

602602
static int sun6i_spi_runtime_suspend(struct device *dev)
603603
{
604-
struct spi_master *master = dev_get_drvdata(dev);
605-
struct sun6i_spi *sspi = spi_master_get_devdata(master);
604+
struct spi_controller *host = dev_get_drvdata(dev);
605+
struct sun6i_spi *sspi = spi_controller_get_devdata(host);
606606

607607
reset_control_assert(sspi->rstc);
608608
clk_disable_unprepare(sspi->mclk);
@@ -611,11 +611,11 @@ static int sun6i_spi_runtime_suspend(struct device *dev)
611611
return 0;
612612
}
613613

614-
static bool sun6i_spi_can_dma(struct spi_master *master,
614+
static bool sun6i_spi_can_dma(struct spi_controller *host,
615615
struct spi_device *spi,
616616
struct spi_transfer *xfer)
617617
{
618-
struct sun6i_spi *sspi = spi_master_get_devdata(master);
618+
struct sun6i_spi *sspi = spi_controller_get_devdata(host);
619619

620620
/*
621621
* If the number of spi words to transfer is less or equal than
@@ -627,67 +627,67 @@ static bool sun6i_spi_can_dma(struct spi_master *master,
627627

628628
static int sun6i_spi_probe(struct platform_device *pdev)
629629
{
630-
struct spi_master *master;
630+
struct spi_controller *host;
631631
struct sun6i_spi *sspi;
632632
struct resource *mem;
633633
int ret = 0, irq;
634634

635-
master = spi_alloc_master(&pdev->dev, sizeof(struct sun6i_spi));
636-
if (!master) {
637-
dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
635+
host = spi_alloc_host(&pdev->dev, sizeof(struct sun6i_spi));
636+
if (!host) {
637+
dev_err(&pdev->dev, "Unable to allocate SPI Host\n");
638638
return -ENOMEM;
639639
}
640640

641-
platform_set_drvdata(pdev, master);
642-
sspi = spi_master_get_devdata(master);
641+
platform_set_drvdata(pdev, host);
642+
sspi = spi_controller_get_devdata(host);
643643

644644
sspi->base_addr = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
645645
if (IS_ERR(sspi->base_addr)) {
646646
ret = PTR_ERR(sspi->base_addr);
647-
goto err_free_master;
647+
goto err_free_host;
648648
}
649649

650650
irq = platform_get_irq(pdev, 0);
651651
if (irq < 0) {
652652
ret = -ENXIO;
653-
goto err_free_master;
653+
goto err_free_host;
654654
}
655655

656656
ret = devm_request_irq(&pdev->dev, irq, sun6i_spi_handler,
657657
0, "sun6i-spi", sspi);
658658
if (ret) {
659659
dev_err(&pdev->dev, "Cannot request IRQ\n");
660-
goto err_free_master;
660+
goto err_free_host;
661661
}
662662

663-
sspi->master = master;
663+
sspi->host = host;
664664
sspi->cfg = of_device_get_match_data(&pdev->dev);
665665

666-
master->max_speed_hz = 100 * 1000 * 1000;
667-
master->min_speed_hz = 3 * 1000;
668-
master->use_gpio_descriptors = true;
669-
master->set_cs = sun6i_spi_set_cs;
670-
master->transfer_one = sun6i_spi_transfer_one;
671-
master->num_chipselect = 4;
672-
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST |
673-
sspi->cfg->mode_bits;
674-
master->bits_per_word_mask = SPI_BPW_MASK(8);
675-
master->dev.of_node = pdev->dev.of_node;
676-
master->auto_runtime_pm = true;
677-
master->max_transfer_size = sun6i_spi_max_transfer_size;
666+
host->max_speed_hz = 100 * 1000 * 1000;
667+
host->min_speed_hz = 3 * 1000;
668+
host->use_gpio_descriptors = true;
669+
host->set_cs = sun6i_spi_set_cs;
670+
host->transfer_one = sun6i_spi_transfer_one;
671+
host->num_chipselect = 4;
672+
host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST |
673+
sspi->cfg->mode_bits;
674+
host->bits_per_word_mask = SPI_BPW_MASK(8);
675+
host->dev.of_node = pdev->dev.of_node;
676+
host->auto_runtime_pm = true;
677+
host->max_transfer_size = sun6i_spi_max_transfer_size;
678678

679679
sspi->hclk = devm_clk_get(&pdev->dev, "ahb");
680680
if (IS_ERR(sspi->hclk)) {
681681
dev_err(&pdev->dev, "Unable to acquire AHB clock\n");
682682
ret = PTR_ERR(sspi->hclk);
683-
goto err_free_master;
683+
goto err_free_host;
684684
}
685685

686686
sspi->mclk = devm_clk_get(&pdev->dev, "mod");
687687
if (IS_ERR(sspi->mclk)) {
688688
dev_err(&pdev->dev, "Unable to acquire module clock\n");
689689
ret = PTR_ERR(sspi->mclk);
690-
goto err_free_master;
690+
goto err_free_host;
691691
}
692692

693693
init_completion(&sspi->done);
@@ -697,34 +697,34 @@ static int sun6i_spi_probe(struct platform_device *pdev)
697697
if (IS_ERR(sspi->rstc)) {
698698
dev_err(&pdev->dev, "Couldn't get reset controller\n");
699699
ret = PTR_ERR(sspi->rstc);
700-
goto err_free_master;
700+
goto err_free_host;
701701
}
702702

703-
master->dma_tx = dma_request_chan(&pdev->dev, "tx");
704-
if (IS_ERR(master->dma_tx)) {
703+
host->dma_tx = dma_request_chan(&pdev->dev, "tx");
704+
if (IS_ERR(host->dma_tx)) {
705705
/* Check tx to see if we need defer probing driver */
706-
if (PTR_ERR(master->dma_tx) == -EPROBE_DEFER) {
706+
if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
707707
ret = -EPROBE_DEFER;
708-
goto err_free_master;
708+
goto err_free_host;
709709
}
710710
dev_warn(&pdev->dev, "Failed to request TX DMA channel\n");
711-
master->dma_tx = NULL;
711+
host->dma_tx = NULL;
712712
}
713713

714-
master->dma_rx = dma_request_chan(&pdev->dev, "rx");
715-
if (IS_ERR(master->dma_rx)) {
716-
if (PTR_ERR(master->dma_rx) == -EPROBE_DEFER) {
714+
host->dma_rx = dma_request_chan(&pdev->dev, "rx");
715+
if (IS_ERR(host->dma_rx)) {
716+
if (PTR_ERR(host->dma_rx) == -EPROBE_DEFER) {
717717
ret = -EPROBE_DEFER;
718718
goto err_free_dma_tx;
719719
}
720720
dev_warn(&pdev->dev, "Failed to request RX DMA channel\n");
721-
master->dma_rx = NULL;
721+
host->dma_rx = NULL;
722722
}
723723

724-
if (master->dma_tx && master->dma_rx) {
724+
if (host->dma_tx && host->dma_rx) {
725725
sspi->dma_addr_tx = mem->start + SUN6I_TXDATA_REG;
726726
sspi->dma_addr_rx = mem->start + SUN6I_RXDATA_REG;
727-
master->can_dma = sun6i_spi_can_dma;
727+
host->can_dma = sun6i_spi_can_dma;
728728
}
729729

730730
/*
@@ -742,9 +742,9 @@ static int sun6i_spi_probe(struct platform_device *pdev)
742742
pm_runtime_set_active(&pdev->dev);
743743
pm_runtime_enable(&pdev->dev);
744744

745-
ret = devm_spi_register_master(&pdev->dev, master);
745+
ret = devm_spi_register_controller(&pdev->dev, host);
746746
if (ret) {
747-
dev_err(&pdev->dev, "cannot register SPI master\n");
747+
dev_err(&pdev->dev, "cannot register SPI host\n");
748748
goto err_pm_disable;
749749
}
750750

@@ -754,26 +754,26 @@ static int sun6i_spi_probe(struct platform_device *pdev)
754754
pm_runtime_disable(&pdev->dev);
755755
sun6i_spi_runtime_suspend(&pdev->dev);
756756
err_free_dma_rx:
757-
if (master->dma_rx)
758-
dma_release_channel(master->dma_rx);
757+
if (host->dma_rx)
758+
dma_release_channel(host->dma_rx);
759759
err_free_dma_tx:
760-
if (master->dma_tx)
761-
dma_release_channel(master->dma_tx);
762-
err_free_master:
763-
spi_master_put(master);
760+
if (host->dma_tx)
761+
dma_release_channel(host->dma_tx);
762+
err_free_host:
763+
spi_controller_put(host);
764764
return ret;
765765
}
766766

767767
static void sun6i_spi_remove(struct platform_device *pdev)
768768
{
769-
struct spi_master *master = platform_get_drvdata(pdev);
769+
struct spi_controller *host = platform_get_drvdata(pdev);
770770

771771
pm_runtime_force_suspend(&pdev->dev);
772772

773-
if (master->dma_tx)
774-
dma_release_channel(master->dma_tx);
775-
if (master->dma_rx)
776-
dma_release_channel(master->dma_rx);
773+
if (host->dma_tx)
774+
dma_release_channel(host->dma_tx);
775+
if (host->dma_rx)
776+
dma_release_channel(host->dma_rx);
777777
}
778778

779779
static const struct sun6i_spi_cfg sun6i_a31_spi_cfg = {

0 commit comments

Comments
 (0)