Commit 7a5d8ca1 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mark Brown

spi: bitbang: simplify pointer arithmetics

Add a pointer variable to make spi_bitbang_start() look simpler.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 851bacf5
...@@ -427,40 +427,41 @@ EXPORT_SYMBOL_GPL(spi_bitbang_transfer); ...@@ -427,40 +427,41 @@ EXPORT_SYMBOL_GPL(spi_bitbang_transfer);
*/ */
int spi_bitbang_start(struct spi_bitbang *bitbang) int spi_bitbang_start(struct spi_bitbang *bitbang)
{ {
struct spi_master *master = bitbang->master;
int status; int status;
if (!bitbang->master || !bitbang->chipselect) if (!master || !bitbang->chipselect)
return -EINVAL; return -EINVAL;
INIT_WORK(&bitbang->work, bitbang_work); INIT_WORK(&bitbang->work, bitbang_work);
spin_lock_init(&bitbang->lock); spin_lock_init(&bitbang->lock);
INIT_LIST_HEAD(&bitbang->queue); INIT_LIST_HEAD(&bitbang->queue);
if (!bitbang->master->mode_bits) if (!master->mode_bits)
bitbang->master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags; master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags;
if (!bitbang->master->transfer) if (!master->transfer)
bitbang->master->transfer = spi_bitbang_transfer; master->transfer = spi_bitbang_transfer;
if (!bitbang->txrx_bufs) { if (!bitbang->txrx_bufs) {
bitbang->use_dma = 0; bitbang->use_dma = 0;
bitbang->txrx_bufs = spi_bitbang_bufs; bitbang->txrx_bufs = spi_bitbang_bufs;
if (!bitbang->master->setup) { if (!master->setup) {
if (!bitbang->setup_transfer) if (!bitbang->setup_transfer)
bitbang->setup_transfer = bitbang->setup_transfer =
spi_bitbang_setup_transfer; spi_bitbang_setup_transfer;
bitbang->master->setup = spi_bitbang_setup; master->setup = spi_bitbang_setup;
bitbang->master->cleanup = spi_bitbang_cleanup; master->cleanup = spi_bitbang_cleanup;
} }
} else if (!bitbang->master->setup) } else if (!master->setup)
return -EINVAL; return -EINVAL;
if (bitbang->master->transfer == spi_bitbang_transfer && if (master->transfer == spi_bitbang_transfer &&
!bitbang->setup_transfer) !bitbang->setup_transfer)
return -EINVAL; return -EINVAL;
/* this task is the only thing to touch the SPI bits */ /* this task is the only thing to touch the SPI bits */
bitbang->busy = 0; bitbang->busy = 0;
bitbang->workqueue = create_singlethread_workqueue( bitbang->workqueue = create_singlethread_workqueue(
dev_name(bitbang->master->dev.parent)); dev_name(master->dev.parent));
if (bitbang->workqueue == NULL) { if (bitbang->workqueue == NULL) {
status = -EBUSY; status = -EBUSY;
goto err1; goto err1;
...@@ -469,7 +470,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang) ...@@ -469,7 +470,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
/* driver may get busy before register() returns, especially /* driver may get busy before register() returns, especially
* if someone registered boardinfo for devices * if someone registered boardinfo for devices
*/ */
status = spi_register_master(bitbang->master); status = spi_register_master(master);
if (status < 0) if (status < 0)
goto err2; goto err2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment