lkml.org 
[lkml]   [2015]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] spi: bitbang: Make setup_transfer callback optional
Date
spi-altera doesn't register this callback, and doesn't have a need for it,
but currently causes a NULL dereference when callback is called.
---
drivers/spi/spi-bitbang.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index 5ef6638..d02057d 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -180,7 +180,7 @@ int spi_bitbang_setup(struct spi_device *spi)
{
struct spi_bitbang_cs *cs = spi->controller_state;
struct spi_bitbang *bitbang;
- int retval;
+ int retval = 0;
unsigned long flags;

bitbang = spi_master_get_devdata(spi->master);
@@ -197,7 +197,8 @@ int spi_bitbang_setup(struct spi_device *spi)
if (!cs->txrx_word)
return -EINVAL;

- retval = bitbang->setup_transfer(spi, NULL);
+ if (bitbang->setup_transfer)
+ retval = bitbang->setup_transfer(spi, NULL);
if (retval < 0)
return retval;

@@ -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;
}
--
1.9.1


\
 
 \ /
  Last update: 2015-04-13 12:41    [W:0.097 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site