mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-10 07:10:27 +00:00
spi/bitbang: check for setup_transfer during initialization
setup_transfer is mandatory if spi_bitbang_transfer is used, so check for it during initialization and not each time during runtime. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
This commit is contained in:
parent
1974eba605
commit
ea3065df7d
@ -259,10 +259,6 @@ static void bitbang_work(struct work_struct *work)
|
|||||||
struct spi_bitbang *bitbang =
|
struct spi_bitbang *bitbang =
|
||||||
container_of(work, struct spi_bitbang, work);
|
container_of(work, struct spi_bitbang, work);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int (*setup_transfer)(struct spi_device *,
|
|
||||||
struct spi_transfer *);
|
|
||||||
|
|
||||||
setup_transfer = bitbang->setup_transfer;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&bitbang->lock, flags);
|
spin_lock_irqsave(&bitbang->lock, flags);
|
||||||
bitbang->busy = 1;
|
bitbang->busy = 1;
|
||||||
@ -300,11 +296,7 @@ static void bitbang_work(struct work_struct *work)
|
|||||||
|
|
||||||
/* init (-1) or override (1) transfer params */
|
/* init (-1) or override (1) transfer params */
|
||||||
if (do_setup != 0) {
|
if (do_setup != 0) {
|
||||||
if (!setup_transfer) {
|
status = bitbang->setup_transfer(spi, t);
|
||||||
status = -ENOPROTOOPT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
status = setup_transfer(spi, t);
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
break;
|
break;
|
||||||
if (do_setup == -1)
|
if (do_setup == -1)
|
||||||
@ -465,6 +457,9 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
|
|||||||
}
|
}
|
||||||
} else if (!bitbang->master->setup)
|
} else if (!bitbang->master->setup)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
if (bitbang->master->transfer == spi_bitbang_transfer &&
|
||||||
|
!bitbang->setup_transfer)
|
||||||
|
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user