diff options
-rw-r--r-- | drivers/of/of_spi.c | 10 | ||||
-rw-r--r-- | drivers/spi/mpc512x_psc_spi.c | 1 | ||||
-rw-r--r-- | drivers/spi/mpc52xx_psc_spi.c | 10 | ||||
-rw-r--r-- | drivers/spi/mpc52xx_spi.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi.c | 4 | ||||
-rw-r--r-- | drivers/spi/spi_mpc8xxx.c | 4 | ||||
-rw-r--r-- | drivers/spi/spi_ppc4xx.c | 2 | ||||
-rw-r--r-- | drivers/spi/xilinx_spi.c | 3 | ||||
-rw-r--r-- | drivers/spi/xilinx_spi_of.c | 3 | ||||
-rw-r--r-- | include/linux/of_spi.h | 11 |
10 files changed, 27 insertions, 24 deletions
diff --git a/drivers/of/of_spi.c b/drivers/of/of_spi.c index d504f1d1324b..1dbce58a58b0 100644 --- a/drivers/of/of_spi.c +++ b/drivers/of/of_spi.c | |||
@@ -15,12 +15,11 @@ | |||
15 | /** | 15 | /** |
16 | * of_register_spi_devices - Register child devices onto the SPI bus | 16 | * of_register_spi_devices - Register child devices onto the SPI bus |
17 | * @master: Pointer to spi_master device | 17 | * @master: Pointer to spi_master device |
18 | * @np: parent node of SPI device nodes | ||
19 | * | 18 | * |
20 | * Registers an spi_device for each child node of 'np' which has a 'reg' | 19 | * Registers an spi_device for each child node of master node which has a 'reg' |
21 | * property. | 20 | * property. |
22 | */ | 21 | */ |
23 | void of_register_spi_devices(struct spi_master *master, struct device_node *np) | 22 | void of_register_spi_devices(struct spi_master *master) |
24 | { | 23 | { |
25 | struct spi_device *spi; | 24 | struct spi_device *spi; |
26 | struct device_node *nc; | 25 | struct device_node *nc; |
@@ -28,7 +27,10 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) | |||
28 | int rc; | 27 | int rc; |
29 | int len; | 28 | int len; |
30 | 29 | ||
31 | for_each_child_of_node(np, nc) { | 30 | if (!master->dev.of_node) |
31 | return; | ||
32 | |||
33 | for_each_child_of_node(master->dev.of_node, nc) { | ||
32 | /* Alloc an spi_device */ | 34 | /* Alloc an spi_device */ |
33 | spi = spi_alloc_device(master); | 35 | spi = spi_alloc_device(master); |
34 | if (!spi) { | 36 | if (!spi) { |
diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/mpc512x_psc_spi.c index 2534b1ec3edd..1bb4315f5f84 100644 --- a/drivers/spi/mpc512x_psc_spi.c +++ b/drivers/spi/mpc512x_psc_spi.c | |||
@@ -440,6 +440,7 @@ static int __init mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
440 | master->setup = mpc512x_psc_spi_setup; | 440 | master->setup = mpc512x_psc_spi_setup; |
441 | master->transfer = mpc512x_psc_spi_transfer; | 441 | master->transfer = mpc512x_psc_spi_transfer; |
442 | master->cleanup = mpc512x_psc_spi_cleanup; | 442 | master->cleanup = mpc512x_psc_spi_cleanup; |
443 | master->dev.of_node = dev->of_node; | ||
443 | 444 | ||
444 | tempp = ioremap(regaddr, size); | 445 | tempp = ioremap(regaddr, size); |
445 | if (!tempp) { | 446 | if (!tempp) { |
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 7104cb739da7..bd81ff90cfb3 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/of_platform.h> | 19 | #include <linux/of_platform.h> |
20 | #include <linux/of_spi.h> | ||
21 | #include <linux/workqueue.h> | 20 | #include <linux/workqueue.h> |
22 | #include <linux/completion.h> | 21 | #include <linux/completion.h> |
23 | #include <linux/io.h> | 22 | #include <linux/io.h> |
@@ -398,6 +397,7 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
398 | master->setup = mpc52xx_psc_spi_setup; | 397 | master->setup = mpc52xx_psc_spi_setup; |
399 | master->transfer = mpc52xx_psc_spi_transfer; | 398 | master->transfer = mpc52xx_psc_spi_transfer; |
400 | master->cleanup = mpc52xx_psc_spi_cleanup; | 399 | master->cleanup = mpc52xx_psc_spi_cleanup; |
400 | master->dev.of_node = dev->of_node; | ||
401 | 401 | ||
402 | mps->psc = ioremap(regaddr, size); | 402 | mps->psc = ioremap(regaddr, size); |
403 | if (!mps->psc) { | 403 | if (!mps->psc) { |
@@ -470,7 +470,6 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | |||
470 | const u32 *regaddr_p; | 470 | const u32 *regaddr_p; |
471 | u64 regaddr64, size64; | 471 | u64 regaddr64, size64; |
472 | s16 id = -1; | 472 | s16 id = -1; |
473 | int rc; | ||
474 | 473 | ||
475 | regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); | 474 | regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); |
476 | if (!regaddr_p) { | 475 | if (!regaddr_p) { |
@@ -491,13 +490,8 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | |||
491 | id = *psc_nump + 1; | 490 | id = *psc_nump + 1; |
492 | } | 491 | } |
493 | 492 | ||
494 | rc = mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, | 493 | return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, |
495 | irq_of_parse_and_map(op->dev.of_node, 0), id); | 494 | irq_of_parse_and_map(op->dev.of_node, 0), id); |
496 | if (rc == 0) | ||
497 | of_register_spi_devices(dev_get_drvdata(&op->dev), | ||
498 | op->dev.of_node); | ||
499 | |||
500 | return rc; | ||
501 | } | 495 | } |
502 | 496 | ||
503 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) | 497 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) |
diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c index b1a76bff775f..56136ff00e01 100644 --- a/drivers/spi/mpc52xx_spi.c +++ b/drivers/spi/mpc52xx_spi.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
21 | #include <linux/of_spi.h> | ||
22 | #include <linux/io.h> | 21 | #include <linux/io.h> |
23 | #include <linux/of_gpio.h> | 22 | #include <linux/of_gpio.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
@@ -439,6 +438,7 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op, | |||
439 | master->setup = mpc52xx_spi_setup; | 438 | master->setup = mpc52xx_spi_setup; |
440 | master->transfer = mpc52xx_spi_transfer; | 439 | master->transfer = mpc52xx_spi_transfer; |
441 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; | 440 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; |
441 | master->dev.of_node = op->dev.of_node; | ||
442 | 442 | ||
443 | dev_set_drvdata(&op->dev, master); | 443 | dev_set_drvdata(&op->dev, master); |
444 | 444 | ||
@@ -512,7 +512,6 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op, | |||
512 | if (rc) | 512 | if (rc) |
513 | goto err_register; | 513 | goto err_register; |
514 | 514 | ||
515 | of_register_spi_devices(master, op->dev.of_node); | ||
516 | dev_info(&ms->master->dev, "registered MPC5200 SPI bus\n"); | 515 | dev_info(&ms->master->dev, "registered MPC5200 SPI bus\n"); |
517 | 516 | ||
518 | return rc; | 517 | return rc; |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index b3a1f9259b62..1bb1b88780ce 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/mod_devicetable.h> | 27 | #include <linux/mod_devicetable.h> |
28 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
29 | #include <linux/of_spi.h> | ||
29 | 30 | ||
30 | 31 | ||
31 | /* SPI bustype and spi_master class are registered after board init code | 32 | /* SPI bustype and spi_master class are registered after board init code |
@@ -540,6 +541,9 @@ int spi_register_master(struct spi_master *master) | |||
540 | /* populate children from any spi device tables */ | 541 | /* populate children from any spi device tables */ |
541 | scan_boardinfo(master); | 542 | scan_boardinfo(master); |
542 | status = 0; | 543 | status = 0; |
544 | |||
545 | /* Register devices from the device tree */ | ||
546 | of_register_spi_devices(master); | ||
543 | done: | 547 | done: |
544 | return status; | 548 | return status; |
545 | } | 549 | } |
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c index 97ab0a81338a..aad9ae1b9c69 100644 --- a/drivers/spi/spi_mpc8xxx.c +++ b/drivers/spi/spi_mpc8xxx.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/of_platform.h> | 38 | #include <linux/of_platform.h> |
39 | #include <linux/gpio.h> | 39 | #include <linux/gpio.h> |
40 | #include <linux/of_gpio.h> | 40 | #include <linux/of_gpio.h> |
41 | #include <linux/of_spi.h> | ||
42 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
43 | 42 | ||
44 | #include <sysdev/fsl_soc.h> | 43 | #include <sysdev/fsl_soc.h> |
@@ -1009,6 +1008,7 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | |||
1009 | master->setup = mpc8xxx_spi_setup; | 1008 | master->setup = mpc8xxx_spi_setup; |
1010 | master->transfer = mpc8xxx_spi_transfer; | 1009 | master->transfer = mpc8xxx_spi_transfer; |
1011 | master->cleanup = mpc8xxx_spi_cleanup; | 1010 | master->cleanup = mpc8xxx_spi_cleanup; |
1011 | master->dev.of_node = dev->of_node; | ||
1012 | 1012 | ||
1013 | mpc8xxx_spi = spi_master_get_devdata(master); | 1013 | mpc8xxx_spi = spi_master_get_devdata(master); |
1014 | mpc8xxx_spi->dev = dev; | 1014 | mpc8xxx_spi->dev = dev; |
@@ -1299,8 +1299,6 @@ static int __devinit of_mpc8xxx_spi_probe(struct of_device *ofdev, | |||
1299 | goto err; | 1299 | goto err; |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | of_register_spi_devices(master, np); | ||
1303 | |||
1304 | return 0; | 1302 | return 0; |
1305 | 1303 | ||
1306 | err: | 1304 | err: |
diff --git a/drivers/spi/spi_ppc4xx.c b/drivers/spi/spi_ppc4xx.c index d53466a249d9..0f5fa7e2a550 100644 --- a/drivers/spi/spi_ppc4xx.c +++ b/drivers/spi/spi_ppc4xx.c | |||
@@ -407,6 +407,7 @@ static int __init spi_ppc4xx_of_probe(struct of_device *op, | |||
407 | master = spi_alloc_master(dev, sizeof *hw); | 407 | master = spi_alloc_master(dev, sizeof *hw); |
408 | if (master == NULL) | 408 | if (master == NULL) |
409 | return -ENOMEM; | 409 | return -ENOMEM; |
410 | master->dev.of_node = np; | ||
410 | dev_set_drvdata(dev, master); | 411 | dev_set_drvdata(dev, master); |
411 | hw = spi_master_get_devdata(master); | 412 | hw = spi_master_get_devdata(master); |
412 | hw->master = spi_master_get(master); | 413 | hw->master = spi_master_get(master); |
@@ -545,7 +546,6 @@ static int __init spi_ppc4xx_of_probe(struct of_device *op, | |||
545 | } | 546 | } |
546 | 547 | ||
547 | dev_info(dev, "driver initialized\n"); | 548 | dev_info(dev, "driver initialized\n"); |
548 | of_register_spi_devices(master, np); | ||
549 | 549 | ||
550 | return 0; | 550 | return 0; |
551 | 551 | ||
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 1b47363cb73f..80f2db5bcfd6 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c | |||
@@ -390,6 +390,9 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | |||
390 | 390 | ||
391 | master->bus_num = bus_num; | 391 | master->bus_num = bus_num; |
392 | master->num_chipselect = pdata->num_chipselect; | 392 | master->num_chipselect = pdata->num_chipselect; |
393 | #ifdef CONFIG_OF | ||
394 | master->dev.of_node = dev->of_node; | ||
395 | #endif | ||
393 | 396 | ||
394 | xspi->mem = *mem; | 397 | xspi->mem = *mem; |
395 | xspi->irq = irq; | 398 | xspi->irq = irq; |
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c index 4654805b08d8..87cda0956a83 100644 --- a/drivers/spi/xilinx_spi_of.c +++ b/drivers/spi/xilinx_spi_of.c | |||
@@ -80,9 +80,6 @@ static int __devinit xilinx_spi_of_probe(struct of_device *ofdev, | |||
80 | 80 | ||
81 | dev_set_drvdata(&ofdev->dev, master); | 81 | dev_set_drvdata(&ofdev->dev, master); |
82 | 82 | ||
83 | /* Add any subnodes on the SPI bus */ | ||
84 | of_register_spi_devices(master, ofdev->dev.of_node); | ||
85 | |||
86 | return 0; | 83 | return 0; |
87 | } | 84 | } |
88 | 85 | ||
diff --git a/include/linux/of_spi.h b/include/linux/of_spi.h index 5f71ee8c0868..9e3e70f78ae6 100644 --- a/include/linux/of_spi.h +++ b/include/linux/of_spi.h | |||
@@ -9,10 +9,15 @@ | |||
9 | #ifndef __LINUX_OF_SPI_H | 9 | #ifndef __LINUX_OF_SPI_H |
10 | #define __LINUX_OF_SPI_H | 10 | #define __LINUX_OF_SPI_H |
11 | 11 | ||
12 | #include <linux/of.h> | ||
13 | #include <linux/spi/spi.h> | 12 | #include <linux/spi/spi.h> |
14 | 13 | ||
15 | extern void of_register_spi_devices(struct spi_master *master, | 14 | #if defined(CONFIG_OF_SPI) || defined(CONFIG_OF_SPI_MODULE) |
16 | struct device_node *np); | 15 | extern void of_register_spi_devices(struct spi_master *master); |
16 | #else | ||
17 | static inline void of_register_spi_devices(struct spi_master *master) | ||
18 | { | ||
19 | return; | ||
20 | } | ||
21 | #endif /* CONFIG_OF_SPI */ | ||
17 | 22 | ||
18 | #endif /* __LINUX_OF_SPI */ | 23 | #endif /* __LINUX_OF_SPI */ |