forked from Minki/linux
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>
This commit is contained in:
parent
71422f9e68
commit
1e8a52e18c
@ -216,9 +216,6 @@ static __devinit int ath79_spi_probe(struct platform_device *pdev)
|
|||||||
if (pdata) {
|
if (pdata) {
|
||||||
master->bus_num = pdata->bus_num;
|
master->bus_num = pdata->bus_num;
|
||||||
master->num_chipselect = pdata->num_chipselect;
|
master->num_chipselect = pdata->num_chipselect;
|
||||||
} else {
|
|
||||||
master->bus_num = -1;
|
|
||||||
master->num_chipselect = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sp->bitbang.master = spi_master_get(master);
|
sp->bitbang.master = spi_master_get(master);
|
||||||
|
@ -219,9 +219,6 @@ static void spi_lm70llp_attach(struct parport *p)
|
|||||||
}
|
}
|
||||||
pp = spi_master_get_devdata(master);
|
pp = spi_master_get_devdata(master);
|
||||||
|
|
||||||
master->bus_num = -1; /* dynamic alloc of a bus number */
|
|
||||||
master->num_chipselect = 1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SPI and bitbang hookup.
|
* SPI and bitbang hookup.
|
||||||
*/
|
*/
|
||||||
|
@ -433,7 +433,6 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op)
|
|||||||
goto err_alloc;
|
goto err_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
master->bus_num = -1;
|
|
||||||
master->setup = mpc52xx_spi_setup;
|
master->setup = mpc52xx_spi_setup;
|
||||||
master->transfer = mpc52xx_spi_transfer;
|
master->transfer = mpc52xx_spi_transfer;
|
||||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
|
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
|
||||||
@ -479,8 +478,6 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op)
|
|||||||
gpio_direction_output(gpio_cs, 1);
|
gpio_direction_output(gpio_cs, 1);
|
||||||
ms->gpio_cs[i] = gpio_cs;
|
ms->gpio_cs[i] = gpio_cs;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
master->num_chipselect = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_init(&ms->lock);
|
spin_lock_init(&ms->lock);
|
||||||
|
@ -466,9 +466,6 @@ static int __init spi_ppc4xx_of_probe(struct platform_device *op)
|
|||||||
bbp->master->setup = spi_ppc4xx_setup;
|
bbp->master->setup = spi_ppc4xx_setup;
|
||||||
bbp->master->cleanup = spi_ppc4xx_cleanup;
|
bbp->master->cleanup = spi_ppc4xx_cleanup;
|
||||||
|
|
||||||
/* Allocate bus num dynamically. */
|
|
||||||
bbp->master->bus_num = -1;
|
|
||||||
|
|
||||||
/* the spi->mode bits understood by this driver: */
|
/* the spi->mode bits understood by this driver: */
|
||||||
bbp->master->mode_bits =
|
bbp->master->mode_bits =
|
||||||
SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST;
|
SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST;
|
||||||
|
@ -1438,7 +1438,6 @@ static int __devinit pch_spi_pd_probe(struct platform_device *plat_dev)
|
|||||||
plat_dev->id, data->io_remap_addr);
|
plat_dev->id, data->io_remap_addr);
|
||||||
|
|
||||||
/* initialize members of SPI master */
|
/* initialize members of SPI master */
|
||||||
master->bus_num = -1;
|
|
||||||
master->num_chipselect = PCH_MAX_CS;
|
master->num_chipselect = PCH_MAX_CS;
|
||||||
master->setup = pch_spi_setup;
|
master->setup = pch_spi_setup;
|
||||||
master->transfer = pch_spi_transfer;
|
master->transfer = pch_spi_transfer;
|
||||||
|
@ -936,6 +936,8 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
device_initialize(&master->dev);
|
device_initialize(&master->dev);
|
||||||
|
master->bus_num = -1;
|
||||||
|
master->num_chipselect = 1;
|
||||||
master->dev.class = &spi_master_class;
|
master->dev.class = &spi_master_class;
|
||||||
master->dev.parent = get_device(dev);
|
master->dev.parent = get_device(dev);
|
||||||
spi_master_set_devdata(master, &master[1]);
|
spi_master_set_devdata(master, &master[1]);
|
||||||
|
Loading…
Reference in New Issue
Block a user