From e6811d1d7a6a38ee637fe219c3b67dbfe17e8b3f Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Fri, 9 Nov 2012 14:36:45 +0530 Subject: spi: make sure all transfer has bits_per_word set When spi client does the spi transfer and does not sets the bits_per_word for each transfer then set it as default of spi device in spi core before calling low level transfer. Removing the similar code from spi-tegra20-slink driver as it is not required. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c index b8985be..07dc735 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c @@ -727,8 +727,7 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi, unsigned long command; unsigned long command2; - bits_per_word = t->bits_per_word ? t->bits_per_word : - spi->bits_per_word; + bits_per_word = t->bits_per_word; speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; if (!speed) speed = tspi->spi_max_frequency; diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 84c2861..518e595 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1190,6 +1190,7 @@ EXPORT_SYMBOL_GPL(spi_setup); static int __spi_async(struct spi_device *spi, struct spi_message *message) { struct spi_master *master = spi->master; + struct spi_transfer *xfer; /* Half-duplex links include original MicroWire, and ones with * only one data pin like SPI_3WIRE (switches direction) or where @@ -1198,7 +1199,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) */ if ((master->flags & SPI_MASTER_HALF_DUPLEX) || (spi->mode & SPI_3WIRE)) { - struct spi_transfer *xfer; unsigned flags = master->flags; list_for_each_entry(xfer, &message->transfers, transfer_list) { @@ -1211,6 +1211,15 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) } } + /** + * Set transfer bits_per_word as spi device default if it is not + * set for this transfer. + */ + list_for_each_entry(xfer, &message->transfers, transfer_list) { + if (!xfer->bits_per_word) + xfer->bits_per_word = spi->bits_per_word; + } + message->spi = spi; message->status = -EINPROGRESS; return master->transfer(spi, message); -- cgit v0.10.2 From 24bc89716163b4e30c1b71c9f4bd020387b13c96 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Fri, 9 Nov 2012 14:37:32 +0530 Subject: spi: tegra: sequence compatible strings as per preference Sequence compatible list for tegra20-slink driver to first look for Tegra30 and then Tegra20. Tegra30 have additional feature in HW which need to be utilize if it is provided from DT. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c index 07dc735..7882b50 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c @@ -1109,8 +1109,8 @@ const struct tegra_slink_chip_data tegra20_spi_cdata = { }; static struct of_device_id tegra_slink_of_match[] __devinitconst = { - { .compatible = "nvidia,tegra20-slink", .data = &tegra20_spi_cdata, }, { .compatible = "nvidia,tegra30-slink", .data = &tegra30_spi_cdata, }, + { .compatible = "nvidia,tegra20-slink", .data = &tegra20_spi_cdata, }, {} }; MODULE_DEVICE_TABLE(of, tegra_slink_of_match); -- cgit v0.10.2 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 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 v0.10.2