Commit 7d0ec8b6 authored by Pelle Nilsson's avatar Pelle Nilsson Committed by Mark Brown

spi: bitbang: Make setup_transfer() callback optional

Some controller drivers have no need of this callback (spi-altera even
causes a NULL pointer dereference because it doesn't register the callback,
falsely assuming that it is already optional).

Fixes: 30af9b55 ("spi/bitbang: Drop empty setup() functions")
Signed-off-by: default avatarPelle Nilsson <per.nilsson@xelmo.com>
Reviewed-by: default avatarEzequiel Garcia <ezequiel.garcia@vanguardiasur.com.ar>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent c517d838
......@@ -180,7 +180,6 @@ int spi_bitbang_setup(struct spi_device *spi)
{
struct spi_bitbang_cs *cs = spi->controller_state;
struct spi_bitbang *bitbang;
int retval;
unsigned long flags;
bitbang = spi_master_get_devdata(spi->master);
......@@ -197,9 +196,11 @@ int spi_bitbang_setup(struct spi_device *spi)
if (!cs->txrx_word)
return -EINVAL;
retval = bitbang->setup_transfer(spi, NULL);
if (retval < 0)
return retval;
if (bitbang->setup_transfer) {
int retval = bitbang->setup_transfer(spi, NULL);
if (retval < 0)
return retval;
}
dev_dbg(&spi->dev, "%s, %u nsec/bit\n", __func__, 2 * cs->nsecs);
......@@ -295,9 +296,11 @@ static int spi_bitbang_transfer_one(struct spi_master *master,
/* init (-1) or override (1) transfer params */
if (do_setup != 0) {
status = bitbang->setup_transfer(spi, t);
if (status < 0)
break;
if (bitbang->setup_transfer) {
status = bitbang->setup_transfer(spi, t);
if (status < 0)
break;
}
if (do_setup == -1)
do_setup = 0;
}
......
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