Skip to contentSkip to conversation

spi: Remove duplicate code to check chip_select

PATCH Applied Axel Lin 2 participants 2 messages Feb 11, 2014 – Feb 12, 2014

Subsystems (5)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 spi: Remove duplicate code to check chip_select

In spi_add_device(), we have the code to validate spi->chip_select. So remove the duplicate code in various drivers.

Cc Wenyou Yang <[email protected]>
Cc Steven King <[email protected]>
Cc Thomas Langer <[email protected]>
Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Laxman Dewangan <[email protected]>
Cc Stephen Warren <[email protected]>
---
 drivers/spi/spi-atmel.c         | 7 -------
 drivers/spi/spi-coldfire-qspi.c | 6 ------
 drivers/spi/spi-falcon.c        | 3 ---
 drivers/spi/spi-mpc52xx.c       | 3 ---
 drivers/spi/spi-omap-uwire.c    | 6 ------
 drivers/spi/spi-tegra114.c      | 2 --
 drivers/spi/spi-tegra20-slink.c | 2 --
 7 files changed, 29 deletions(-)
drivers/spi/spi-atmel.c +0 -7
index 88796df..c3ed7ed 100644
@@ -992,13 +992,6 @@ static int atmel_spi_setup(struct spi_device *spi)
 
 	as = spi_master_get_devdata(spi->master);
 
-	if (spi->chip_select > spi->master->num_chipselect) {
-		dev_dbg(&spi->dev,
-				"setup: invalid chipselect %u (%u defined)\n",
-				spi->chip_select, spi->master->num_chipselect);
-		return -EINVAL;
-	}
-
 	/* see notes above re chipselect */
 	if (!atmel_spi_is_v2(as)
 			&& spi->chip_select == 0
drivers/spi/spi-coldfire-qspi.c +0 -6
index cabed8f..0ab2c55 100644
@@ -356,12 +356,6 @@ static int mcfqspi_transfer_one_message(struct spi_master *master,
 
 static int mcfqspi_setup(struct spi_device *spi)
 {
-	if (spi->chip_select >= spi->master->num_chipselect) {
-		dev_dbg(&spi->dev, "%d chip select is out of range\n",
-			spi->chip_select);
-		return -EINVAL;
-	}
-
 	mcfqspi_cs_deselect(spi_master_get_devdata(spi->master),
 			    spi->chip_select, spi->mode & SPI_CS_HIGH);
 
drivers/spi/spi-falcon.c +0 -3
index dd5bd46..0ae7f45 100644
@@ -312,9 +312,6 @@ static int falcon_sflash_setup(struct spi_device *spi)
 	unsigned int i;
 	unsigned long flags;
 
-	if (spi->chip_select > 0)
-		return -ENODEV;
-
 	spin_lock_irqsave(&ebu_lock, flags);
 
 	if (spi->max_speed_hz >= CLOCK_100M) {
drivers/spi/spi-mpc52xx.c +0 -3
index f573c3c..bd404c2 100644
@@ -364,9 +364,6 @@ static int mpc52xx_spi_setup(struct spi_device *spi)
 	if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST))
 		return -EINVAL;
 
-	if (spi->chip_select >= spi->master->num_chipselect)
-		return -EINVAL;
-
 	return 0;
 }
 
drivers/spi/spi-omap-uwire.c +0 -6
index 9313fd3..462ddd4 100644
@@ -332,12 +332,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 
 	uwire = spi_master_get_devdata(spi->master);
 
-	if (spi->chip_select > 3) {
-		pr_debug("%s: cs%d?\n", dev_name(&spi->dev), spi->chip_select);
-		status = -ENODEV;
-		goto done;
-	}
-
 	bits = spi->bits_per_word;
 	if (t != NULL && t->bits_per_word)
 		bits = t->bits_per_word;
drivers/spi/spi-tegra114.c +0 -2
index 2f8aba5..3d10ece 100644
@@ -759,8 +759,6 @@ static int tegra_spi_setup(struct spi_device *spi)
 		spi->mode & SPI_CPHA ? "" : "~",
 		spi->max_speed_hz);
 
-	BUG_ON(spi->chip_select >= MAX_CHIP_SELECT);
-
 	ret = pm_runtime_get_sync(tspi->dev);
 	if (ret < 0) {
 		dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
drivers/spi/spi-tegra20-slink.c +0 -2
index 9a060aa..8e21651 100644
@@ -759,8 +759,6 @@ static int tegra_slink_setup(struct spi_device *spi)
 		spi->mode & SPI_CPHA ? "" : "~",
 		spi->max_speed_hz);
 
-	BUG_ON(spi->chip_select >= MAX_CHIP_SELECT);
-
 	ret = pm_runtime_get_sync(tspi->dev);
 	if (ret < 0) {
 		dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
Signature · 8 lines
1.8.1.2



--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Applied
#1 lore raw
Quoted 2 lines · Axel Lin

In spi_add_device(), we have the code to validate spi->chip_select. So remove the duplicate code in various drivers.

Applied, thanks. With this sort of stuff it is a bit easier for me to split things up per driver - it's easier to judge what to do with acks and it works better with the forest of branches I keep.