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. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
@@ -993,13 +993,6 @@ static int atmel_spi_setup(struct spi_device *spi)
|
|||||||
|
|
||||||
as = spi_master_get_devdata(spi->master);
|
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 */
|
/* see notes above re chipselect */
|
||||||
if (!atmel_spi_is_v2(as)
|
if (!atmel_spi_is_v2(as)
|
||||||
&& spi->chip_select == 0
|
&& spi->chip_select == 0
|
||||||
|
|||||||
@@ -356,12 +356,6 @@ static int mcfqspi_transfer_one_message(struct spi_master *master,
|
|||||||
|
|
||||||
static int mcfqspi_setup(struct spi_device *spi)
|
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),
|
mcfqspi_cs_deselect(spi_master_get_devdata(spi->master),
|
||||||
spi->chip_select, spi->mode & SPI_CS_HIGH);
|
spi->chip_select, spi->mode & SPI_CS_HIGH);
|
||||||
|
|
||||||
|
|||||||
@@ -312,9 +312,6 @@ static int falcon_sflash_setup(struct spi_device *spi)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (spi->chip_select > 0)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&ebu_lock, flags);
|
spin_lock_irqsave(&ebu_lock, flags);
|
||||||
|
|
||||||
if (spi->max_speed_hz >= CLOCK_100M) {
|
if (spi->max_speed_hz >= CLOCK_100M) {
|
||||||
|
|||||||
@@ -365,9 +365,6 @@ static int mpc52xx_spi_setup(struct spi_device *spi)
|
|||||||
if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST))
|
if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (spi->chip_select >= spi->master->num_chipselect)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -332,12 +332,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
|
|||||||
|
|
||||||
uwire = spi_master_get_devdata(spi->master);
|
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;
|
bits = spi->bits_per_word;
|
||||||
if (t != NULL && t->bits_per_word)
|
if (t != NULL && t->bits_per_word)
|
||||||
bits = t->bits_per_word;
|
bits = t->bits_per_word;
|
||||||
|
|||||||
@@ -760,8 +760,6 @@ static int tegra_spi_setup(struct spi_device *spi)
|
|||||||
spi->mode & SPI_CPHA ? "" : "~",
|
spi->mode & SPI_CPHA ? "" : "~",
|
||||||
spi->max_speed_hz);
|
spi->max_speed_hz);
|
||||||
|
|
||||||
BUG_ON(spi->chip_select >= MAX_CHIP_SELECT);
|
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(tspi->dev);
|
ret = pm_runtime_get_sync(tspi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
|
dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
|
||||||
|
|||||||
@@ -760,8 +760,6 @@ static int tegra_slink_setup(struct spi_device *spi)
|
|||||||
spi->mode & SPI_CPHA ? "" : "~",
|
spi->mode & SPI_CPHA ? "" : "~",
|
||||||
spi->max_speed_hz);
|
spi->max_speed_hz);
|
||||||
|
|
||||||
BUG_ON(spi->chip_select >= MAX_CHIP_SELECT);
|
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(tspi->dev);
|
ret = pm_runtime_get_sync(tspi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
|
dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
|
||||||
|
|||||||
Reference in New Issue
Block a user