aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2012-05-20 01:42:08 -0400
committerGrant Likely <grant.likely@secretlab.ca>2012-05-20 01:42:08 -0400
commit1e8a52e18cfb381bc9cc1f0b720540364d2a6edd (patch)
treec10c014afe3e7cab09773b8af214a0c2e85aac2e /drivers/spi
parent71422f9e68d43f3fbc6c8939ca8d1b80aa2e4d1a (diff)
spi: By default setup spi_masters with 1 chipselect and dynamics bus number
Trivial simplification. Instead of requiring spi master drivers to always set the bus number (even when a dynamic number is desired), this patch modifies spi_alloc_master() to initialize num_chipselect to 1 (because there will always be at least one CS) and bus_num to -1 for dynamic allocation. This simplifies the code needed to be written for drivers. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-ath79.c3
-rw-r--r--drivers/spi/spi-lm70llp.c3
-rw-r--r--drivers/spi/spi-mpc52xx.c3
-rw-r--r--drivers/spi/spi-ppc4xx.c3
-rw-r--r--drivers/spi/spi-topcliff-pch.c1
-rw-r--r--drivers/spi/spi.c2
6 files changed, 2 insertions, 13 deletions
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c
index acc88b4d2869..249077e5cc48 100644
--- a/drivers/spi/spi-ath79.c
+++ b/drivers/spi/spi-ath79.c
@@ -216,9 +216,6 @@ static __devinit int ath79_spi_probe(struct platform_device *pdev)
216 if (pdata) { 216 if (pdata) {
217 master->bus_num = pdata->bus_num; 217 master->bus_num = pdata->bus_num;
218 master->num_chipselect = pdata->num_chipselect; 218 master->num_chipselect = pdata->num_chipselect;
219 } else {
220 master->bus_num = -1;
221 master->num_chipselect = 1;
222 } 219 }
223 220
224 sp->bitbang.master = spi_master_get(master); 221 sp->bitbang.master = spi_master_get(master);
diff --git a/drivers/spi/spi-lm70llp.c b/drivers/spi/spi-lm70llp.c
index 933eb9d9ddd4..0759b5db9883 100644
--- a/drivers/spi/spi-lm70llp.c
+++ b/drivers/spi/spi-lm70llp.c
@@ -219,9 +219,6 @@ static void spi_lm70llp_attach(struct parport *p)
219 } 219 }
220 pp = spi_master_get_devdata(master); 220 pp = spi_master_get_devdata(master);
221 221
222 master->bus_num = -1; /* dynamic alloc of a bus number */
223 master->num_chipselect = 1;
224
225 /* 222 /*
226 * SPI and bitbang hookup. 223 * SPI and bitbang hookup.
227 */ 224 */
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index 57633d963456..cb3a3830b0a5 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -433,7 +433,6 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op)
433 goto err_alloc; 433 goto err_alloc;
434 } 434 }
435 435
436 master->bus_num = -1;
437 master->setup = mpc52xx_spi_setup; 436 master->setup = mpc52xx_spi_setup;
438 master->transfer = mpc52xx_spi_transfer; 437 master->transfer = mpc52xx_spi_transfer;
439 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; 438 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
@@ -479,8 +478,6 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op)
479 gpio_direction_output(gpio_cs, 1); 478 gpio_direction_output(gpio_cs, 1);
480 ms->gpio_cs[i] = gpio_cs; 479 ms->gpio_cs[i] = gpio_cs;
481 } 480 }
482 } else {
483 master->num_chipselect = 1;
484 } 481 }
485 482
486 spin_lock_init(&ms->lock); 483 spin_lock_init(&ms->lock);
diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c
index d95d307a1100..75ac9d48ef46 100644
--- a/drivers/spi/spi-ppc4xx.c
+++ b/drivers/spi/spi-ppc4xx.c
@@ -466,9 +466,6 @@ static int __init spi_ppc4xx_of_probe(struct platform_device *op)
466 bbp->master->setup = spi_ppc4xx_setup; 466 bbp->master->setup = spi_ppc4xx_setup;
467 bbp->master->cleanup = spi_ppc4xx_cleanup; 467 bbp->master->cleanup = spi_ppc4xx_cleanup;
468 468
469 /* Allocate bus num dynamically. */
470 bbp->master->bus_num = -1;
471
472 /* the spi->mode bits understood by this driver: */ 469 /* the spi->mode bits understood by this driver: */
473 bbp->master->mode_bits = 470 bbp->master->mode_bits =
474 SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST; 471 SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST;
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 77c4562ac9d3..cd56dcf46320 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -1438,7 +1438,6 @@ static int __devinit pch_spi_pd_probe(struct platform_device *plat_dev)
1438 plat_dev->id, data->io_remap_addr); 1438 plat_dev->id, data->io_remap_addr);
1439 1439
1440 /* initialize members of SPI master */ 1440 /* initialize members of SPI master */
1441 master->bus_num = -1;
1442 master->num_chipselect = PCH_MAX_CS; 1441 master->num_chipselect = PCH_MAX_CS;
1443 master->setup = pch_spi_setup; 1442 master->setup = pch_spi_setup;
1444 master->transfer = pch_spi_transfer; 1443 master->transfer = pch_spi_transfer;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 2d65b1684cdc..1041cb83d67a 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -936,6 +936,8 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
936 return NULL; 936 return NULL;
937 937
938 device_initialize(&master->dev); 938 device_initialize(&master->dev);
939 master->bus_num = -1;
940 master->num_chipselect = 1;
939 master->dev.class = &spi_master_class; 941 master->dev.class = &spi_master_class;
940 master->dev.parent = get_device(dev); 942 master->dev.parent = get_device(dev);
941 spi_master_set_devdata(master, &master[1]); 943 spi_master_set_devdata(master, &master[1]);