Message ID | 1429018817-18117-1-git-send-email-per.nilsson@xelmo.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 7d0ec8b6f40b356f780b79de63eeafd6b907d68c |
Headers | show |
On 04/14/2015 10:40 AM, Pelle Nilsson wrote: > 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: 30af9b558a56 ("spi/bitbang: Drop empty setup() functions") > Signed-off-by: Pelle Nilsson <per.nilsson@xelmo.com> Reviewed-by: Ezequiel Garcia <ezequiel.garcia@vanguardiasur.com.ar> Please note the merge window is open, so don't expect Mark to pick your change soon.
On Tue, Apr 14, 2015 at 03:40:17PM +0200, Pelle Nilsson wrote: > 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). I've applied this but really for something like this the commit message should be explaining *why* it's reasonable for the callback to be omitted.
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c index 5ef6638..840a498 100644 --- a/drivers/spi/spi-bitbang.c +++ b/drivers/spi/spi-bitbang.c @@ -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; }
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: 30af9b558a56 ("spi/bitbang: Drop empty setup() functions") Signed-off-by: Pelle Nilsson <per.nilsson@xelmo.com> --- drivers/spi/spi-bitbang.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)