From caae070c48f39b4f7312e7473f6d3576f426e7fb Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Fri, 9 Nov 2012 14:35:22 +0530 Subject: spi: Dont call master->setup if not populated Currently the master->setup() is called unconditionally. The assumption is that every driver need to implement this callback. This encourages drivers to populate empty functions to prevent crashing. This patch prevents the call of master->setup() if it is not populated. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/spi/spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/spi') diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 84c2861..619c7df 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1156,7 +1156,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master); int spi_setup(struct spi_device *spi) { unsigned bad_bits; - int status; + int status = 0; /* help drivers fail *cleanly* when they need options * that aren't supported with their current master @@ -1171,7 +1171,8 @@ int spi_setup(struct spi_device *spi) if (!spi->bits_per_word) spi->bits_per_word = 8; - status = spi->master->setup(spi); + if (spi->master->setup) + status = spi->master->setup(spi); dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s" "%u bits/w, %u Hz max --> %d\n", -- cgit v1.1