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: 30af9b558a
("spi/bitbang: Drop empty setup() functions")
Signed-off-by: Pelle Nilsson <per.nilsson@xelmo.com>
Reviewed-by: Ezequiel Garcia <ezequiel.garcia@vanguardiasur.com.ar>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
c517d838eb
Коммит
7d0ec8b6f4
|
@ -180,7 +180,6 @@ int spi_bitbang_setup(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct spi_bitbang_cs *cs = spi->controller_state;
|
struct spi_bitbang_cs *cs = spi->controller_state;
|
||||||
struct spi_bitbang *bitbang;
|
struct spi_bitbang *bitbang;
|
||||||
int retval;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
bitbang = spi_master_get_devdata(spi->master);
|
bitbang = spi_master_get_devdata(spi->master);
|
||||||
|
@ -197,9 +196,11 @@ int spi_bitbang_setup(struct spi_device *spi)
|
||||||
if (!cs->txrx_word)
|
if (!cs->txrx_word)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
retval = bitbang->setup_transfer(spi, NULL);
|
if (bitbang->setup_transfer) {
|
||||||
|
int retval = bitbang->setup_transfer(spi, NULL);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
dev_dbg(&spi->dev, "%s, %u nsec/bit\n", __func__, 2 * cs->nsecs);
|
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 */
|
/* init (-1) or override (1) transfer params */
|
||||||
if (do_setup != 0) {
|
if (do_setup != 0) {
|
||||||
|
if (bitbang->setup_transfer) {
|
||||||
status = bitbang->setup_transfer(spi, t);
|
status = bitbang->setup_transfer(spi, t);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (do_setup == -1)
|
if (do_setup == -1)
|
||||||
do_setup = 0;
|
do_setup = 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче