aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-11-09 04:05:22 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-11-09 11:46:48 -0500
commitcaae070c48f39b4f7312e7473f6d3576f426e7fb (patch)
tree09afeaeb4cd7b26fa2345f883889d87191575a1b /drivers/spi/spi.c
parent3d70f8c617a436c7146ecb81df2265b4626dfe89 (diff)
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 <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 84c2861d6f4d..619c7df0d27f 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1156,7 +1156,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master);
1156int spi_setup(struct spi_device *spi) 1156int spi_setup(struct spi_device *spi)
1157{ 1157{
1158 unsigned bad_bits; 1158 unsigned bad_bits;
1159 int status; 1159 int status = 0;
1160 1160
1161 /* help drivers fail *cleanly* when they need options 1161 /* help drivers fail *cleanly* when they need options
1162 * that aren't supported with their current master 1162 * that aren't supported with their current master
@@ -1171,7 +1171,8 @@ int spi_setup(struct spi_device *spi)
1171 if (!spi->bits_per_word) 1171 if (!spi->bits_per_word)
1172 spi->bits_per_word = 8; 1172 spi->bits_per_word = 8;
1173 1173
1174 status = spi->master->setup(spi); 1174 if (spi->master->setup)
1175 status = spi->master->setup(spi);
1175 1176
1176 dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s" 1177 dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s"
1177 "%u bits/w, %u Hz max --> %d\n", 1178 "%u bits/w, %u Hz max --> %d\n",