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 <ldewan...@nvidia.com>
---
When developing the driver for tegra20 sflash driver, found
that there is notung to do in setup and hence in palce of
adding the empty API, creating this patch.

 drivers/spi/spi.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 6891a03..37a8a2f 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1159,7 +1159,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
@@ -1174,7 +1174,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",
-- 
1.7.1.1


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

Reply via email to