diff options
author | Mark Brown <broonie@linaro.org> | 2013-09-01 08:49:03 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-01 08:49:03 -0400 |
commit | 68aa4cb3374a5f47fe1f7b31e0b5893826c05c69 (patch) | |
tree | aa350fff2ef8ef496d46820487198e9bbfe2bf77 /drivers | |
parent | 11c28cfc1e4f32dc6d02373a1e80d7e83584ed21 (diff) | |
parent | b5f9a9d5113efe11a3b9dad600a6f833274da595 (diff) |
Merge remote-tracking branch 'spi/topic/pdata' into spi-next
Diffstat (limited to 'drivers')
30 files changed, 125 insertions, 160 deletions
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c index 156eb888655e..f38855f76536 100644 --- a/drivers/spi/spi-altera.c +++ b/drivers/spi/spi-altera.c | |||
@@ -200,7 +200,7 @@ static irqreturn_t altera_spi_irq(int irq, void *dev) | |||
200 | 200 | ||
201 | static int altera_spi_probe(struct platform_device *pdev) | 201 | static int altera_spi_probe(struct platform_device *pdev) |
202 | { | 202 | { |
203 | struct altera_spi_platform_data *platp = pdev->dev.platform_data; | 203 | struct altera_spi_platform_data *platp = dev_get_platdata(&pdev->dev); |
204 | struct altera_spi *hw; | 204 | struct altera_spi *hw; |
205 | struct spi_master *master; | 205 | struct spi_master *master; |
206 | struct resource *res; | 206 | struct resource *res; |
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index 0e06407a4670..37bad952ab38 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c | |||
@@ -221,7 +221,7 @@ static int ath79_spi_probe(struct platform_device *pdev) | |||
221 | sp = spi_master_get_devdata(master); | 221 | sp = spi_master_get_devdata(master); |
222 | platform_set_drvdata(pdev, sp); | 222 | platform_set_drvdata(pdev, sp); |
223 | 223 | ||
224 | pdata = pdev->dev.platform_data; | 224 | pdata = dev_get_platdata(&pdev->dev); |
225 | 225 | ||
226 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); | 226 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); |
227 | master->setup = ath79_spi_setup; | 227 | master->setup = ath79_spi_setup; |
diff --git a/drivers/spi/spi-au1550.c b/drivers/spi/spi-au1550.c index e1965553ab79..1d00d9b397dd 100644 --- a/drivers/spi/spi-au1550.c +++ b/drivers/spi/spi-au1550.c | |||
@@ -776,7 +776,7 @@ static int au1550_spi_probe(struct platform_device *pdev) | |||
776 | hw = spi_master_get_devdata(master); | 776 | hw = spi_master_get_devdata(master); |
777 | 777 | ||
778 | hw->master = spi_master_get(master); | 778 | hw->master = spi_master_get(master); |
779 | hw->pdata = pdev->dev.platform_data; | 779 | hw->pdata = dev_get_platdata(&pdev->dev); |
780 | hw->dev = &pdev->dev; | 780 | hw->dev = &pdev->dev; |
781 | 781 | ||
782 | if (hw->pdata == NULL) { | 782 | if (hw->pdata == NULL) { |
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index a21fef4a3bb1..de197f72e082 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c | |||
@@ -353,7 +353,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) | |||
353 | { | 353 | { |
354 | struct resource *r; | 354 | struct resource *r; |
355 | struct device *dev = &pdev->dev; | 355 | struct device *dev = &pdev->dev; |
356 | struct bcm63xx_spi_pdata *pdata = pdev->dev.platform_data; | 356 | struct bcm63xx_spi_pdata *pdata = dev_get_platdata(&pdev->dev); |
357 | int irq; | 357 | int irq; |
358 | struct spi_master *master; | 358 | struct spi_master *master; |
359 | struct clk *clk; | 359 | struct clk *clk; |
@@ -474,8 +474,7 @@ static int bcm63xx_spi_remove(struct platform_device *pdev) | |||
474 | #ifdef CONFIG_PM | 474 | #ifdef CONFIG_PM |
475 | static int bcm63xx_spi_suspend(struct device *dev) | 475 | static int bcm63xx_spi_suspend(struct device *dev) |
476 | { | 476 | { |
477 | struct spi_master *master = | 477 | struct spi_master *master = dev_get_drvdata(dev); |
478 | platform_get_drvdata(to_platform_device(dev)); | ||
479 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); | 478 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
480 | 479 | ||
481 | spi_master_suspend(master); | 480 | spi_master_suspend(master); |
@@ -487,8 +486,7 @@ static int bcm63xx_spi_suspend(struct device *dev) | |||
487 | 486 | ||
488 | static int bcm63xx_spi_resume(struct device *dev) | 487 | static int bcm63xx_spi_resume(struct device *dev) |
489 | { | 488 | { |
490 | struct spi_master *master = | 489 | struct spi_master *master = dev_get_drvdata(dev); |
491 | platform_get_drvdata(to_platform_device(dev)); | ||
492 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); | 490 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
493 | 491 | ||
494 | clk_prepare_enable(bs->clk); | 492 | clk_prepare_enable(bs->clk); |
diff --git a/drivers/spi/spi-bfin-sport.c b/drivers/spi/spi-bfin-sport.c index 07ec597f9732..91921b5f5817 100644 --- a/drivers/spi/spi-bfin-sport.c +++ b/drivers/spi/spi-bfin-sport.c | |||
@@ -756,7 +756,7 @@ static int bfin_sport_spi_probe(struct platform_device *pdev) | |||
756 | struct bfin_sport_spi_master_data *drv_data; | 756 | struct bfin_sport_spi_master_data *drv_data; |
757 | int status; | 757 | int status; |
758 | 758 | ||
759 | platform_info = dev->platform_data; | 759 | platform_info = dev_get_platdata(dev); |
760 | 760 | ||
761 | /* Allocate master with space for drv_data */ | 761 | /* Allocate master with space for drv_data */ |
762 | master = spi_alloc_master(dev, sizeof(*master) + 16); | 762 | master = spi_alloc_master(dev, sizeof(*master) + 16); |
diff --git a/drivers/spi/spi-bfin-v3.c b/drivers/spi/spi-bfin-v3.c index e4394ebf08f3..f4bf81347d68 100644 --- a/drivers/spi/spi-bfin-v3.c +++ b/drivers/spi/spi-bfin-v3.c | |||
@@ -773,7 +773,7 @@ static irqreturn_t bfin_spi_rx_dma_isr(int irq, void *dev_id) | |||
773 | static int bfin_spi_probe(struct platform_device *pdev) | 773 | static int bfin_spi_probe(struct platform_device *pdev) |
774 | { | 774 | { |
775 | struct device *dev = &pdev->dev; | 775 | struct device *dev = &pdev->dev; |
776 | struct bfin_spi3_master *info = dev->platform_data; | 776 | struct bfin_spi3_master *info = dev_get_platdata(dev); |
777 | struct spi_master *master; | 777 | struct spi_master *master; |
778 | struct bfin_spi_master *drv_data; | 778 | struct bfin_spi_master *drv_data; |
779 | struct resource *mem, *res; | 779 | struct resource *mem, *res; |
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c index 59a73424419c..45bdf73d6868 100644 --- a/drivers/spi/spi-bfin5xx.c +++ b/drivers/spi/spi-bfin5xx.c | |||
@@ -1271,7 +1271,7 @@ static int bfin_spi_probe(struct platform_device *pdev) | |||
1271 | struct resource *res; | 1271 | struct resource *res; |
1272 | int status = 0; | 1272 | int status = 0; |
1273 | 1273 | ||
1274 | platform_info = dev->platform_data; | 1274 | platform_info = dev_get_platdata(dev); |
1275 | 1275 | ||
1276 | /* Allocate master with space for drv_data */ | 1276 | /* Allocate master with space for drv_data */ |
1277 | master = spi_alloc_master(dev, sizeof(*drv_data)); | 1277 | master = spi_alloc_master(dev, sizeof(*drv_data)); |
diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c index 0631b9d4a5de..8e07928cadb3 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c | |||
@@ -400,7 +400,7 @@ static int mcfqspi_probe(struct platform_device *pdev) | |||
400 | struct mcfqspi_platform_data *pdata; | 400 | struct mcfqspi_platform_data *pdata; |
401 | int status; | 401 | int status; |
402 | 402 | ||
403 | pdata = pdev->dev.platform_data; | 403 | pdata = dev_get_platdata(&pdev->dev); |
404 | if (!pdata) { | 404 | if (!pdata) { |
405 | dev_dbg(&pdev->dev, "platform data is missing\n"); | 405 | dev_dbg(&pdev->dev, "platform data is missing\n"); |
406 | return -ENOENT; | 406 | return -ENOENT; |
@@ -558,7 +558,7 @@ static int mcfqspi_resume(struct device *dev) | |||
558 | #ifdef CONFIG_PM_RUNTIME | 558 | #ifdef CONFIG_PM_RUNTIME |
559 | static int mcfqspi_runtime_suspend(struct device *dev) | 559 | static int mcfqspi_runtime_suspend(struct device *dev) |
560 | { | 560 | { |
561 | struct mcfqspi *mcfqspi = platform_get_drvdata(to_platform_device(dev)); | 561 | struct mcfqspi *mcfqspi = dev_get_drvdata(dev); |
562 | 562 | ||
563 | clk_disable(mcfqspi->clk); | 563 | clk_disable(mcfqspi->clk); |
564 | 564 | ||
@@ -567,7 +567,7 @@ static int mcfqspi_runtime_suspend(struct device *dev) | |||
567 | 567 | ||
568 | static int mcfqspi_runtime_resume(struct device *dev) | 568 | static int mcfqspi_runtime_resume(struct device *dev) |
569 | { | 569 | { |
570 | struct mcfqspi *mcfqspi = platform_get_drvdata(to_platform_device(dev)); | 570 | struct mcfqspi *mcfqspi = dev_get_drvdata(dev); |
571 | 571 | ||
572 | clk_enable(mcfqspi->clk); | 572 | clk_enable(mcfqspi->clk); |
573 | 573 | ||
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 707966bd5610..8fbfe2483ffd 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c | |||
@@ -872,8 +872,8 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
872 | goto free_master; | 872 | goto free_master; |
873 | } | 873 | } |
874 | 874 | ||
875 | if (pdev->dev.platform_data) { | 875 | if (dev_get_platdata(&pdev->dev)) { |
876 | pdata = pdev->dev.platform_data; | 876 | pdata = dev_get_platdata(&pdev->dev); |
877 | dspi->pdata = *pdata; | 877 | dspi->pdata = *pdata; |
878 | } else { | 878 | } else { |
879 | /* update dspi pdata with that from the DT */ | 879 | /* update dspi pdata with that from the DT */ |
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index 31611f7d7be9..d22c00a227b6 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c | |||
@@ -874,7 +874,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev) | |||
874 | int irq; | 874 | int irq; |
875 | int error; | 875 | int error; |
876 | 876 | ||
877 | info = pdev->dev.platform_data; | 877 | info = dev_get_platdata(&pdev->dev); |
878 | 878 | ||
879 | irq = platform_get_irq(pdev, 0); | 879 | irq = platform_get_irq(pdev, 0); |
880 | if (irq < 0) { | 880 | if (irq < 0) { |
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 6a74d7848d93..b8f1103fe28e 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
@@ -584,7 +584,7 @@ static void fsl_espi_remove(struct mpc8xxx_spi *mspi) | |||
584 | static struct spi_master * fsl_espi_probe(struct device *dev, | 584 | static struct spi_master * fsl_espi_probe(struct device *dev, |
585 | struct resource *mem, unsigned int irq) | 585 | struct resource *mem, unsigned int irq) |
586 | { | 586 | { |
587 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 587 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
588 | struct spi_master *master; | 588 | struct spi_master *master; |
589 | struct mpc8xxx_spi *mpc8xxx_spi; | 589 | struct mpc8xxx_spi *mpc8xxx_spi; |
590 | struct fsl_espi_reg *reg_base; | 590 | struct fsl_espi_reg *reg_base; |
@@ -665,7 +665,7 @@ err: | |||
665 | static int of_fsl_espi_get_chipselects(struct device *dev) | 665 | static int of_fsl_espi_get_chipselects(struct device *dev) |
666 | { | 666 | { |
667 | struct device_node *np = dev->of_node; | 667 | struct device_node *np = dev->of_node; |
668 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 668 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
669 | const u32 *prop; | 669 | const u32 *prop; |
670 | int len; | 670 | int len; |
671 | 671 | ||
diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c index e947f2d1b2f5..0b75f26158ab 100644 --- a/drivers/spi/spi-fsl-lib.c +++ b/drivers/spi/spi-fsl-lib.c | |||
@@ -122,7 +122,7 @@ const char *mpc8xxx_spi_strmode(unsigned int flags) | |||
122 | int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, | 122 | int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, |
123 | unsigned int irq) | 123 | unsigned int irq) |
124 | { | 124 | { |
125 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 125 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
126 | struct spi_master *master; | 126 | struct spi_master *master; |
127 | struct mpc8xxx_spi *mpc8xxx_spi; | 127 | struct mpc8xxx_spi *mpc8xxx_spi; |
128 | int ret = 0; | 128 | int ret = 0; |
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 41e89c3e3edc..bbc94294891c 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c | |||
@@ -574,7 +574,7 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on) | |||
574 | 574 | ||
575 | static void fsl_spi_grlib_probe(struct device *dev) | 575 | static void fsl_spi_grlib_probe(struct device *dev) |
576 | { | 576 | { |
577 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 577 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
578 | struct spi_master *master = dev_get_drvdata(dev); | 578 | struct spi_master *master = dev_get_drvdata(dev); |
579 | struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(master); | 579 | struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(master); |
580 | struct fsl_spi_reg *reg_base = mpc8xxx_spi->reg_base; | 580 | struct fsl_spi_reg *reg_base = mpc8xxx_spi->reg_base; |
@@ -600,7 +600,7 @@ static void fsl_spi_grlib_probe(struct device *dev) | |||
600 | static struct spi_master * fsl_spi_probe(struct device *dev, | 600 | static struct spi_master * fsl_spi_probe(struct device *dev, |
601 | struct resource *mem, unsigned int irq) | 601 | struct resource *mem, unsigned int irq) |
602 | { | 602 | { |
603 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 603 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
604 | struct spi_master *master; | 604 | struct spi_master *master; |
605 | struct mpc8xxx_spi *mpc8xxx_spi; | 605 | struct mpc8xxx_spi *mpc8xxx_spi; |
606 | struct fsl_spi_reg *reg_base; | 606 | struct fsl_spi_reg *reg_base; |
@@ -700,7 +700,8 @@ err: | |||
700 | static void fsl_spi_cs_control(struct spi_device *spi, bool on) | 700 | static void fsl_spi_cs_control(struct spi_device *spi, bool on) |
701 | { | 701 | { |
702 | struct device *dev = spi->dev.parent->parent; | 702 | struct device *dev = spi->dev.parent->parent; |
703 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data); | 703 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
704 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); | ||
704 | u16 cs = spi->chip_select; | 705 | u16 cs = spi->chip_select; |
705 | int gpio = pinfo->gpios[cs]; | 706 | int gpio = pinfo->gpios[cs]; |
706 | bool alow = pinfo->alow_flags[cs]; | 707 | bool alow = pinfo->alow_flags[cs]; |
@@ -711,7 +712,7 @@ static void fsl_spi_cs_control(struct spi_device *spi, bool on) | |||
711 | static int of_fsl_spi_get_chipselects(struct device *dev) | 712 | static int of_fsl_spi_get_chipselects(struct device *dev) |
712 | { | 713 | { |
713 | struct device_node *np = dev->of_node; | 714 | struct device_node *np = dev->of_node; |
714 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 715 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
715 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); | 716 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); |
716 | int ngpios; | 717 | int ngpios; |
717 | int i = 0; | 718 | int i = 0; |
@@ -790,7 +791,7 @@ err_alloc_flags: | |||
790 | 791 | ||
791 | static int of_fsl_spi_free_chipselects(struct device *dev) | 792 | static int of_fsl_spi_free_chipselects(struct device *dev) |
792 | { | 793 | { |
793 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 794 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
794 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); | 795 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); |
795 | int i; | 796 | int i; |
796 | 797 | ||
@@ -889,7 +890,7 @@ static int plat_mpc8xxx_spi_probe(struct platform_device *pdev) | |||
889 | int irq; | 890 | int irq; |
890 | struct spi_master *master; | 891 | struct spi_master *master; |
891 | 892 | ||
892 | if (!pdev->dev.platform_data) | 893 | if (!dev_get_platdata(&pdev->dev)) |
893 | return -EINVAL; | 894 | return -EINVAL; |
894 | 895 | ||
895 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 896 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index a54524cf42cc..68b69fec13a9 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c | |||
@@ -420,7 +420,7 @@ static int spi_gpio_probe(struct platform_device *pdev) | |||
420 | if (status > 0) | 420 | if (status > 0) |
421 | use_of = 1; | 421 | use_of = 1; |
422 | 422 | ||
423 | pdata = pdev->dev.platform_data; | 423 | pdata = dev_get_platdata(&pdev->dev); |
424 | #ifdef GENERIC_BITBANG | 424 | #ifdef GENERIC_BITBANG |
425 | if (!pdata || !pdata->num_chipselect) | 425 | if (!pdata || !pdata->num_chipselect) |
426 | return -ENODEV; | 426 | return -ENODEV; |
@@ -506,7 +506,7 @@ static int spi_gpio_remove(struct platform_device *pdev) | |||
506 | int status; | 506 | int status; |
507 | 507 | ||
508 | spi_gpio = platform_get_drvdata(pdev); | 508 | spi_gpio = platform_get_drvdata(pdev); |
509 | pdata = pdev->dev.platform_data; | 509 | pdata = dev_get_platdata(&pdev->dev); |
510 | 510 | ||
511 | /* stop() unregisters child devices too */ | 511 | /* stop() unregisters child devices too */ |
512 | status = spi_bitbang_stop(&spi_gpio->bitbang); | 512 | status = spi_bitbang_stop(&spi_gpio->bitbang); |
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 85581f307945..dbc5e999a1f5 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c | |||
@@ -469,7 +469,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
469 | u32 size, unsigned int irq, | 469 | u32 size, unsigned int irq, |
470 | s16 bus_num) | 470 | s16 bus_num) |
471 | { | 471 | { |
472 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 472 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
473 | struct mpc512x_psc_spi *mps; | 473 | struct mpc512x_psc_spi *mps; |
474 | struct spi_master *master; | 474 | struct spi_master *master; |
475 | int ret; | 475 | int ret; |
diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c index fed0571d4dec..6e925dc34396 100644 --- a/drivers/spi/spi-mpc52xx-psc.c +++ b/drivers/spi/spi-mpc52xx-psc.c | |||
@@ -366,7 +366,7 @@ static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) | |||
366 | static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | 366 | static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, |
367 | u32 size, unsigned int irq, s16 bus_num) | 367 | u32 size, unsigned int irq, s16 bus_num) |
368 | { | 368 | { |
369 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 369 | struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); |
370 | struct mpc52xx_psc_spi *mps; | 370 | struct mpc52xx_psc_spi *mps; |
371 | struct spi_master *master; | 371 | struct spi_master *master; |
372 | int ret; | 372 | int ret; |
diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c index b21f8f20060a..47a68b43bcd5 100644 --- a/drivers/spi/spi-nuc900.c +++ b/drivers/spi/spi-nuc900.c | |||
@@ -350,7 +350,7 @@ static int nuc900_spi_probe(struct platform_device *pdev) | |||
350 | 350 | ||
351 | hw = spi_master_get_devdata(master); | 351 | hw = spi_master_get_devdata(master); |
352 | hw->master = spi_master_get(master); | 352 | hw->master = spi_master_get(master); |
353 | hw->pdata = pdev->dev.platform_data; | 353 | hw->pdata = dev_get_platdata(&pdev->dev); |
354 | hw->dev = &pdev->dev; | 354 | hw->dev = &pdev->dev; |
355 | 355 | ||
356 | if (hw->pdata == NULL) { | 356 | if (hw->pdata == NULL) { |
diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c index d36ba907743d..333cb1badcd7 100644 --- a/drivers/spi/spi-oc-tiny.c +++ b/drivers/spi/spi-oc-tiny.c | |||
@@ -285,7 +285,7 @@ static int tiny_spi_of_probe(struct platform_device *pdev) | |||
285 | 285 | ||
286 | static int tiny_spi_probe(struct platform_device *pdev) | 286 | static int tiny_spi_probe(struct platform_device *pdev) |
287 | { | 287 | { |
288 | struct tiny_spi_platform_data *platp = pdev->dev.platform_data; | 288 | struct tiny_spi_platform_data *platp = dev_get_platdata(&pdev->dev); |
289 | struct tiny_spi *hw; | 289 | struct tiny_spi *hw; |
290 | struct spi_master *master; | 290 | struct spi_master *master; |
291 | struct resource *res; | 291 | struct resource *res; |
diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c index cdcc72c5d380..69ecf05757dd 100644 --- a/drivers/spi/spi-omap-100k.c +++ b/drivers/spi/spi-omap-100k.c | |||
@@ -441,7 +441,7 @@ static int omap1_spi100k_probe(struct platform_device *pdev) | |||
441 | * You should allocate this with ioremap() before initializing | 441 | * You should allocate this with ioremap() before initializing |
442 | * the SPI. | 442 | * the SPI. |
443 | */ | 443 | */ |
444 | spi100k->base = (void __iomem *) pdev->dev.platform_data; | 444 | spi100k->base = (void __iomem *)dev_get_platdata(&pdev->dev); |
445 | 445 | ||
446 | spi100k->ick = devm_clk_get(&pdev->dev, "ick"); | 446 | spi100k->ick = devm_clk_get(&pdev->dev, "ick"); |
447 | if (IS_ERR(spi100k->ick)) { | 447 | if (IS_ERR(spi100k->ick)) { |
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 5994039758de..fc190a5a0bad 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -1340,7 +1340,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1340 | if (of_get_property(node, "ti,pindir-d0-out-d1-in", NULL)) | 1340 | if (of_get_property(node, "ti,pindir-d0-out-d1-in", NULL)) |
1341 | mcspi->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; | 1341 | mcspi->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; |
1342 | } else { | 1342 | } else { |
1343 | pdata = pdev->dev.platform_data; | 1343 | pdata = dev_get_platdata(&pdev->dev); |
1344 | master->num_chipselect = pdata->num_cs; | 1344 | master->num_chipselect = pdata->num_cs; |
1345 | if (pdev->id != -1) | 1345 | if (pdev->id != -1) |
1346 | master->bus_num = pdev->id; | 1346 | master->bus_num = pdev->id; |
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index abef061fb84a..4b564b74c99c 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
@@ -2091,7 +2091,8 @@ pl022_platform_data_dt_get(struct device *dev) | |||
2091 | static int pl022_probe(struct amba_device *adev, const struct amba_id *id) | 2091 | static int pl022_probe(struct amba_device *adev, const struct amba_id *id) |
2092 | { | 2092 | { |
2093 | struct device *dev = &adev->dev; | 2093 | struct device *dev = &adev->dev; |
2094 | struct pl022_ssp_controller *platform_info = adev->dev.platform_data; | 2094 | struct pl022_ssp_controller *platform_info = |
2095 | dev_get_platdata(&adev->dev); | ||
2095 | struct spi_master *master; | 2096 | struct spi_master *master; |
2096 | struct pl022 *pl022 = NULL; /*Data for this driver */ | 2097 | struct pl022 *pl022 = NULL; /*Data for this driver */ |
2097 | struct device_node *np = adev->dev.of_node; | 2098 | struct device_node *np = adev->dev.of_node; |
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index b44a6ac3cec9..57de139f76dc 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c | |||
@@ -564,8 +564,12 @@ static void rspi_work(struct work_struct *work) | |||
564 | unsigned long flags; | 564 | unsigned long flags; |
565 | int ret; | 565 | int ret; |
566 | 566 | ||
567 | spin_lock_irqsave(&rspi->lock, flags); | 567 | while (1) { |
568 | while (!list_empty(&rspi->queue)) { | 568 | spin_lock_irqsave(&rspi->lock, flags); |
569 | if (list_empty(&rspi->queue)) { | ||
570 | spin_unlock_irqrestore(&rspi->lock, flags); | ||
571 | break; | ||
572 | } | ||
569 | mesg = list_entry(rspi->queue.next, struct spi_message, queue); | 573 | mesg = list_entry(rspi->queue.next, struct spi_message, queue); |
570 | list_del_init(&mesg->queue); | 574 | list_del_init(&mesg->queue); |
571 | spin_unlock_irqrestore(&rspi->lock, flags); | 575 | spin_unlock_irqrestore(&rspi->lock, flags); |
@@ -595,8 +599,6 @@ static void rspi_work(struct work_struct *work) | |||
595 | 599 | ||
596 | mesg->status = 0; | 600 | mesg->status = 0; |
597 | mesg->complete(mesg->context); | 601 | mesg->complete(mesg->context); |
598 | |||
599 | spin_lock_irqsave(&rspi->lock, flags); | ||
600 | } | 602 | } |
601 | 603 | ||
602 | return; | 604 | return; |
@@ -664,12 +666,13 @@ static irqreturn_t rspi_irq(int irq, void *_sr) | |||
664 | static int rspi_request_dma(struct rspi_data *rspi, | 666 | static int rspi_request_dma(struct rspi_data *rspi, |
665 | struct platform_device *pdev) | 667 | struct platform_device *pdev) |
666 | { | 668 | { |
667 | struct rspi_plat_data *rspi_pd = pdev->dev.platform_data; | 669 | struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev); |
670 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
668 | dma_cap_mask_t mask; | 671 | dma_cap_mask_t mask; |
669 | struct dma_slave_config cfg; | 672 | struct dma_slave_config cfg; |
670 | int ret; | 673 | int ret; |
671 | 674 | ||
672 | if (!rspi_pd) | 675 | if (!res || !rspi_pd) |
673 | return 0; /* The driver assumes no error. */ | 676 | return 0; /* The driver assumes no error. */ |
674 | 677 | ||
675 | rspi->dma_width_16bit = rspi_pd->dma_width_16bit; | 678 | rspi->dma_width_16bit = rspi_pd->dma_width_16bit; |
@@ -683,6 +686,8 @@ static int rspi_request_dma(struct rspi_data *rspi, | |||
683 | if (rspi->chan_rx) { | 686 | if (rspi->chan_rx) { |
684 | cfg.slave_id = rspi_pd->dma_rx_id; | 687 | cfg.slave_id = rspi_pd->dma_rx_id; |
685 | cfg.direction = DMA_DEV_TO_MEM; | 688 | cfg.direction = DMA_DEV_TO_MEM; |
689 | cfg.dst_addr = 0; | ||
690 | cfg.src_addr = res->start + RSPI_SPDR; | ||
686 | ret = dmaengine_slave_config(rspi->chan_rx, &cfg); | 691 | ret = dmaengine_slave_config(rspi->chan_rx, &cfg); |
687 | if (!ret) | 692 | if (!ret) |
688 | dev_info(&pdev->dev, "Use DMA when rx.\n"); | 693 | dev_info(&pdev->dev, "Use DMA when rx.\n"); |
@@ -698,6 +703,8 @@ static int rspi_request_dma(struct rspi_data *rspi, | |||
698 | if (rspi->chan_tx) { | 703 | if (rspi->chan_tx) { |
699 | cfg.slave_id = rspi_pd->dma_tx_id; | 704 | cfg.slave_id = rspi_pd->dma_tx_id; |
700 | cfg.direction = DMA_MEM_TO_DEV; | 705 | cfg.direction = DMA_MEM_TO_DEV; |
706 | cfg.dst_addr = res->start + RSPI_SPDR; | ||
707 | cfg.src_addr = 0; | ||
701 | ret = dmaengine_slave_config(rspi->chan_tx, &cfg); | 708 | ret = dmaengine_slave_config(rspi->chan_tx, &cfg); |
702 | if (!ret) | 709 | if (!ret) |
703 | dev_info(&pdev->dev, "Use DMA when tx\n"); | 710 | dev_info(&pdev->dev, "Use DMA when tx\n"); |
diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c index 68910b310152..ce318d95a6ee 100644 --- a/drivers/spi/spi-s3c24xx.c +++ b/drivers/spi/spi-s3c24xx.c | |||
@@ -525,7 +525,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) | |||
525 | memset(hw, 0, sizeof(struct s3c24xx_spi)); | 525 | memset(hw, 0, sizeof(struct s3c24xx_spi)); |
526 | 526 | ||
527 | hw->master = spi_master_get(master); | 527 | hw->master = spi_master_get(master); |
528 | hw->pdata = pdata = pdev->dev.platform_data; | 528 | hw->pdata = pdata = dev_get_platdata(&pdev->dev); |
529 | hw->dev = &pdev->dev; | 529 | hw->dev = &pdev->dev; |
530 | 530 | ||
531 | if (pdata == NULL) { | 531 | if (pdata == NULL) { |
@@ -690,7 +690,7 @@ static int s3c24xx_spi_remove(struct platform_device *dev) | |||
690 | 690 | ||
691 | static int s3c24xx_spi_suspend(struct device *dev) | 691 | static int s3c24xx_spi_suspend(struct device *dev) |
692 | { | 692 | { |
693 | struct s3c24xx_spi *hw = platform_get_drvdata(to_platform_device(dev)); | 693 | struct s3c24xx_spi *hw = dev_get_drvdata(dev); |
694 | 694 | ||
695 | if (hw->pdata && hw->pdata->gpio_setup) | 695 | if (hw->pdata && hw->pdata->gpio_setup) |
696 | hw->pdata->gpio_setup(hw->pdata, 0); | 696 | hw->pdata->gpio_setup(hw->pdata, 0); |
@@ -701,7 +701,7 @@ static int s3c24xx_spi_suspend(struct device *dev) | |||
701 | 701 | ||
702 | static int s3c24xx_spi_resume(struct device *dev) | 702 | static int s3c24xx_spi_resume(struct device *dev) |
703 | { | 703 | { |
704 | struct s3c24xx_spi *hw = platform_get_drvdata(to_platform_device(dev)); | 704 | struct s3c24xx_spi *hw = dev_get_drvdata(dev); |
705 | 705 | ||
706 | s3c24xx_spi_initialsetup(hw); | 706 | s3c24xx_spi_initialsetup(hw); |
707 | return 0; | 707 | return 0; |
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 63e2070c6c14..2465d6d35b06 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c | |||
@@ -1275,7 +1275,7 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) | |||
1275 | #else | 1275 | #else |
1276 | static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) | 1276 | static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) |
1277 | { | 1277 | { |
1278 | return dev->platform_data; | 1278 | return dev_get_platdata(dev); |
1279 | } | 1279 | } |
1280 | #endif | 1280 | #endif |
1281 | 1281 | ||
@@ -1300,7 +1300,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) | |||
1300 | struct resource *mem_res; | 1300 | struct resource *mem_res; |
1301 | struct resource *res; | 1301 | struct resource *res; |
1302 | struct s3c64xx_spi_driver_data *sdd; | 1302 | struct s3c64xx_spi_driver_data *sdd; |
1303 | struct s3c64xx_spi_info *sci = pdev->dev.platform_data; | 1303 | struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev); |
1304 | struct spi_master *master; | 1304 | struct spi_master *master; |
1305 | int ret, irq; | 1305 | int ret, irq; |
1306 | char clk_name[16]; | 1306 | char clk_name[16]; |
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 2bc5a6b86300..cbc7f2216c16 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c | |||
@@ -645,7 +645,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) | |||
645 | if (pdev->dev.of_node) | 645 | if (pdev->dev.of_node) |
646 | p->info = sh_msiof_spi_parse_dt(&pdev->dev); | 646 | p->info = sh_msiof_spi_parse_dt(&pdev->dev); |
647 | else | 647 | else |
648 | p->info = pdev->dev.platform_data; | 648 | p->info = dev_get_platdata(&pdev->dev); |
649 | 649 | ||
650 | if (!p->info) { | 650 | if (!p->info) { |
651 | dev_err(&pdev->dev, "failed to obtain device info\n"); | 651 | dev_err(&pdev->dev, "failed to obtain device info\n"); |
diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c index 097e506042be..8eefeb6007df 100644 --- a/drivers/spi/spi-sh-sci.c +++ b/drivers/spi/spi-sh-sci.c | |||
@@ -130,7 +130,7 @@ static int sh_sci_spi_probe(struct platform_device *dev) | |||
130 | sp = spi_master_get_devdata(master); | 130 | sp = spi_master_get_devdata(master); |
131 | 131 | ||
132 | platform_set_drvdata(dev, sp); | 132 | platform_set_drvdata(dev, sp); |
133 | sp->info = dev->dev.platform_data; | 133 | sp->info = dev_get_platdata(&dev->dev); |
134 | 134 | ||
135 | /* setup spi bitbang adaptor */ | 135 | /* setup spi bitbang adaptor */ |
136 | sp->bitbang.master = spi_master_get(master); | 136 | sp->bitbang.master = spi_master_get(master); |
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index fc20bcfd90c3..fc5081ab3677 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c | |||
@@ -599,8 +599,7 @@ static int spi_sirfsoc_remove(struct platform_device *pdev) | |||
599 | #ifdef CONFIG_PM | 599 | #ifdef CONFIG_PM |
600 | static int spi_sirfsoc_suspend(struct device *dev) | 600 | static int spi_sirfsoc_suspend(struct device *dev) |
601 | { | 601 | { |
602 | struct platform_device *pdev = to_platform_device(dev); | 602 | struct spi_master *master = dev_get_drvdata(dev); |
603 | struct spi_master *master = platform_get_drvdata(pdev); | ||
604 | struct sirfsoc_spi *sspi = spi_master_get_devdata(master); | 603 | struct sirfsoc_spi *sspi = spi_master_get_devdata(master); |
605 | 604 | ||
606 | clk_disable(sspi->clk); | 605 | clk_disable(sspi->clk); |
@@ -609,8 +608,7 @@ static int spi_sirfsoc_suspend(struct device *dev) | |||
609 | 608 | ||
610 | static int spi_sirfsoc_resume(struct device *dev) | 609 | static int spi_sirfsoc_resume(struct device *dev) |
611 | { | 610 | { |
612 | struct platform_device *pdev = to_platform_device(dev); | 611 | struct spi_master *master = dev_get_drvdata(dev); |
613 | struct spi_master *master = platform_get_drvdata(pdev); | ||
614 | struct sirfsoc_spi *sspi = spi_master_get_devdata(master); | 612 | struct sirfsoc_spi *sspi = spi_master_get_devdata(master); |
615 | 613 | ||
616 | clk_enable(sspi->clk); | 614 | clk_enable(sspi->clk); |
diff --git a/drivers/spi/spi-ti-ssp.c b/drivers/spi/spi-ti-ssp.c index 10606fcc6efc..7d20e121e4c1 100644 --- a/drivers/spi/spi-ti-ssp.c +++ b/drivers/spi/spi-ti-ssp.c | |||
@@ -283,7 +283,7 @@ static int ti_ssp_spi_probe(struct platform_device *pdev) | |||
283 | struct device *dev = &pdev->dev; | 283 | struct device *dev = &pdev->dev; |
284 | int error = 0; | 284 | int error = 0; |
285 | 285 | ||
286 | pdata = dev->platform_data; | 286 | pdata = dev_get_platdata(dev); |
287 | if (!pdata) { | 287 | if (!pdata) { |
288 | dev_err(dev, "platform data not found\n"); | 288 | dev_err(dev, "platform data not found\n"); |
289 | return -EINVAL; | 289 | return -EINVAL; |
diff --git a/drivers/spi/spi-tle62x0.c b/drivers/spi/spi-tle62x0.c index 6b0874d782ed..b5a70e3fecb7 100644 --- a/drivers/spi/spi-tle62x0.c +++ b/drivers/spi/spi-tle62x0.c | |||
@@ -247,7 +247,7 @@ static int tle62x0_probe(struct spi_device *spi) | |||
247 | int ptr; | 247 | int ptr; |
248 | int ret; | 248 | int ret; |
249 | 249 | ||
250 | pdata = spi->dev.platform_data; | 250 | pdata = dev_get_platdata(&spi->dev); |
251 | if (pdata == NULL) { | 251 | if (pdata == NULL) { |
252 | dev_err(&spi->dev, "no device data specified\n"); | 252 | dev_err(&spi->dev, "no device data specified\n"); |
253 | return -EINVAL; | 253 | return -EINVAL; |
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index fb56fcfdf65e..0bf1b2c457a1 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c | |||
@@ -80,10 +80,9 @@ struct xilinx_spi { | |||
80 | /* bitbang has to be first */ | 80 | /* bitbang has to be first */ |
81 | struct spi_bitbang bitbang; | 81 | struct spi_bitbang bitbang; |
82 | struct completion done; | 82 | struct completion done; |
83 | struct resource mem; /* phys mem */ | ||
84 | void __iomem *regs; /* virt. address of the control registers */ | 83 | void __iomem *regs; /* virt. address of the control registers */ |
85 | 84 | ||
86 | u32 irq; | 85 | int irq; |
87 | 86 | ||
88 | u8 *rx_ptr; /* pointer in the Tx buffer */ | 87 | u8 *rx_ptr; /* pointer in the Tx buffer */ |
89 | const u8 *tx_ptr; /* pointer in the Rx buffer */ | 88 | const u8 *tx_ptr; /* pointer in the Rx buffer */ |
@@ -340,17 +339,34 @@ static const struct of_device_id xilinx_spi_of_match[] = { | |||
340 | }; | 339 | }; |
341 | MODULE_DEVICE_TABLE(of, xilinx_spi_of_match); | 340 | MODULE_DEVICE_TABLE(of, xilinx_spi_of_match); |
342 | 341 | ||
343 | struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | 342 | static int xilinx_spi_probe(struct platform_device *pdev) |
344 | u32 irq, s16 bus_num, int num_cs, int bits_per_word) | ||
345 | { | 343 | { |
346 | struct spi_master *master; | ||
347 | struct xilinx_spi *xspi; | 344 | struct xilinx_spi *xspi; |
348 | int ret; | 345 | struct xspi_platform_data *pdata; |
346 | struct resource *res; | ||
347 | int ret, num_cs = 0, bits_per_word = 8; | ||
348 | struct spi_master *master; | ||
349 | u32 tmp; | 349 | u32 tmp; |
350 | u8 i; | ||
351 | |||
352 | pdata = dev_get_platdata(&pdev->dev); | ||
353 | if (pdata) { | ||
354 | num_cs = pdata->num_chipselect; | ||
355 | bits_per_word = pdata->bits_per_word; | ||
356 | } else { | ||
357 | of_property_read_u32(pdev->dev.of_node, "xlnx,num-ss-bits", | ||
358 | &num_cs); | ||
359 | } | ||
350 | 360 | ||
351 | master = spi_alloc_master(dev, sizeof(struct xilinx_spi)); | 361 | if (!num_cs) { |
362 | dev_err(&pdev->dev, | ||
363 | "Missing slave select configuration data\n"); | ||
364 | return -EINVAL; | ||
365 | } | ||
366 | |||
367 | master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi)); | ||
352 | if (!master) | 368 | if (!master) |
353 | return NULL; | 369 | return -ENODEV; |
354 | 370 | ||
355 | /* the spi->mode bits understood by this driver: */ | 371 | /* the spi->mode bits understood by this driver: */ |
356 | master->mode_bits = SPI_CPOL | SPI_CPHA; | 372 | master->mode_bits = SPI_CPOL | SPI_CPHA; |
@@ -362,22 +378,16 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | |||
362 | xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs; | 378 | xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs; |
363 | init_completion(&xspi->done); | 379 | init_completion(&xspi->done); |
364 | 380 | ||
365 | if (!request_mem_region(mem->start, resource_size(mem), | 381 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
366 | XILINX_SPI_NAME)) | 382 | xspi->regs = devm_ioremap_resource(&pdev->dev, res); |
383 | if (IS_ERR(xspi->regs)) { | ||
384 | ret = PTR_ERR(xspi->regs); | ||
367 | goto put_master; | 385 | goto put_master; |
368 | |||
369 | xspi->regs = ioremap(mem->start, resource_size(mem)); | ||
370 | if (xspi->regs == NULL) { | ||
371 | dev_warn(dev, "ioremap failure\n"); | ||
372 | goto map_failed; | ||
373 | } | 386 | } |
374 | 387 | ||
375 | master->bus_num = bus_num; | 388 | master->bus_num = pdev->dev.id; |
376 | master->num_chipselect = num_cs; | 389 | master->num_chipselect = num_cs; |
377 | master->dev.of_node = dev->of_node; | 390 | master->dev.of_node = pdev->dev.of_node; |
378 | |||
379 | xspi->mem = *mem; | ||
380 | xspi->irq = irq; | ||
381 | 391 | ||
382 | /* | 392 | /* |
383 | * Detect endianess on the IP via loop bit in CR. Detection | 393 | * Detect endianess on the IP via loop bit in CR. Detection |
@@ -407,113 +417,63 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | |||
407 | } else if (xspi->bits_per_word == 32) { | 417 | } else if (xspi->bits_per_word == 32) { |
408 | xspi->tx_fn = xspi_tx32; | 418 | xspi->tx_fn = xspi_tx32; |
409 | xspi->rx_fn = xspi_rx32; | 419 | xspi->rx_fn = xspi_rx32; |
410 | } else | 420 | } else { |
411 | goto unmap_io; | 421 | ret = -EINVAL; |
412 | 422 | goto put_master; | |
423 | } | ||
413 | 424 | ||
414 | /* SPI controller initializations */ | 425 | /* SPI controller initializations */ |
415 | xspi_init_hw(xspi); | 426 | xspi_init_hw(xspi); |
416 | 427 | ||
428 | xspi->irq = platform_get_irq(pdev, 0); | ||
429 | if (xspi->irq < 0) { | ||
430 | ret = xspi->irq; | ||
431 | goto put_master; | ||
432 | } | ||
433 | |||
417 | /* Register for SPI Interrupt */ | 434 | /* Register for SPI Interrupt */ |
418 | ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); | 435 | ret = devm_request_irq(&pdev->dev, xspi->irq, xilinx_spi_irq, 0, |
436 | dev_name(&pdev->dev), xspi); | ||
419 | if (ret) | 437 | if (ret) |
420 | goto unmap_io; | 438 | goto put_master; |
421 | 439 | ||
422 | ret = spi_bitbang_start(&xspi->bitbang); | 440 | ret = spi_bitbang_start(&xspi->bitbang); |
423 | if (ret) { | 441 | if (ret) { |
424 | dev_err(dev, "spi_bitbang_start FAILED\n"); | 442 | dev_err(&pdev->dev, "spi_bitbang_start FAILED\n"); |
425 | goto free_irq; | 443 | goto put_master; |
426 | } | ||
427 | |||
428 | dev_info(dev, "at 0x%08llX mapped to 0x%p, irq=%d\n", | ||
429 | (unsigned long long)mem->start, xspi->regs, xspi->irq); | ||
430 | return master; | ||
431 | |||
432 | free_irq: | ||
433 | free_irq(xspi->irq, xspi); | ||
434 | unmap_io: | ||
435 | iounmap(xspi->regs); | ||
436 | map_failed: | ||
437 | release_mem_region(mem->start, resource_size(mem)); | ||
438 | put_master: | ||
439 | spi_master_put(master); | ||
440 | return NULL; | ||
441 | } | ||
442 | EXPORT_SYMBOL(xilinx_spi_init); | ||
443 | |||
444 | void xilinx_spi_deinit(struct spi_master *master) | ||
445 | { | ||
446 | struct xilinx_spi *xspi; | ||
447 | |||
448 | xspi = spi_master_get_devdata(master); | ||
449 | |||
450 | spi_bitbang_stop(&xspi->bitbang); | ||
451 | free_irq(xspi->irq, xspi); | ||
452 | iounmap(xspi->regs); | ||
453 | |||
454 | release_mem_region(xspi->mem.start, resource_size(&xspi->mem)); | ||
455 | spi_master_put(xspi->bitbang.master); | ||
456 | } | ||
457 | EXPORT_SYMBOL(xilinx_spi_deinit); | ||
458 | |||
459 | static int xilinx_spi_probe(struct platform_device *dev) | ||
460 | { | ||
461 | struct xspi_platform_data *pdata; | ||
462 | struct resource *r; | ||
463 | int irq, num_cs = 0, bits_per_word = 8; | ||
464 | struct spi_master *master; | ||
465 | u8 i; | ||
466 | |||
467 | pdata = dev->dev.platform_data; | ||
468 | if (pdata) { | ||
469 | num_cs = pdata->num_chipselect; | ||
470 | bits_per_word = pdata->bits_per_word; | ||
471 | } | ||
472 | |||
473 | #ifdef CONFIG_OF | ||
474 | if (dev->dev.of_node) { | ||
475 | const __be32 *prop; | ||
476 | int len; | ||
477 | |||
478 | /* number of slave select bits is required */ | ||
479 | prop = of_get_property(dev->dev.of_node, "xlnx,num-ss-bits", | ||
480 | &len); | ||
481 | if (prop && len >= sizeof(*prop)) | ||
482 | num_cs = __be32_to_cpup(prop); | ||
483 | } | ||
484 | #endif | ||
485 | |||
486 | if (!num_cs) { | ||
487 | dev_err(&dev->dev, "Missing slave select configuration data\n"); | ||
488 | return -EINVAL; | ||
489 | } | 444 | } |
490 | 445 | ||
491 | 446 | dev_info(&pdev->dev, "at 0x%08llX mapped to 0x%p, irq=%d\n", | |
492 | r = platform_get_resource(dev, IORESOURCE_MEM, 0); | 447 | (unsigned long long)res->start, xspi->regs, xspi->irq); |
493 | if (!r) | ||
494 | return -ENODEV; | ||
495 | |||
496 | irq = platform_get_irq(dev, 0); | ||
497 | if (irq < 0) | ||
498 | return -ENXIO; | ||
499 | |||
500 | master = xilinx_spi_init(&dev->dev, r, irq, dev->id, num_cs, | ||
501 | bits_per_word); | ||
502 | if (!master) | ||
503 | return -ENODEV; | ||
504 | 448 | ||
505 | if (pdata) { | 449 | if (pdata) { |
506 | for (i = 0; i < pdata->num_devices; i++) | 450 | for (i = 0; i < pdata->num_devices; i++) |
507 | spi_new_device(master, pdata->devices + i); | 451 | spi_new_device(master, pdata->devices + i); |
508 | } | 452 | } |
509 | 453 | ||
510 | platform_set_drvdata(dev, master); | 454 | platform_set_drvdata(pdev, master); |
511 | return 0; | 455 | return 0; |
456 | |||
457 | put_master: | ||
458 | spi_master_put(master); | ||
459 | |||
460 | return ret; | ||
512 | } | 461 | } |
513 | 462 | ||
514 | static int xilinx_spi_remove(struct platform_device *dev) | 463 | static int xilinx_spi_remove(struct platform_device *pdev) |
515 | { | 464 | { |
516 | xilinx_spi_deinit(platform_get_drvdata(dev)); | 465 | struct spi_master *master = platform_get_drvdata(pdev); |
466 | struct xilinx_spi *xspi = spi_master_get_devdata(master); | ||
467 | void __iomem *regs_base = xspi->regs; | ||
468 | |||
469 | spi_bitbang_stop(&xspi->bitbang); | ||
470 | |||
471 | /* Disable all the interrupts just in case */ | ||
472 | xspi->write_fn(0, regs_base + XIPIF_V123B_IIER_OFFSET); | ||
473 | /* Disable the global IPIF interrupt */ | ||
474 | xspi->write_fn(0, regs_base + XIPIF_V123B_DGIER_OFFSET); | ||
475 | |||
476 | spi_master_put(xspi->bitbang.master); | ||
517 | 477 | ||
518 | return 0; | 478 | return 0; |
519 | } | 479 | } |