aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-txx9.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-txx9.c')
-rw-r--r--drivers/spi/spi-txx9.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c
index adb853047926..cefd9568f098 100644
--- a/drivers/spi/spi-txx9.c
+++ b/drivers/spi/spi-txx9.c
@@ -116,17 +116,12 @@ static void txx9spi_cs_func(struct spi_device *spi, struct txx9spi *c,
116static int txx9spi_setup(struct spi_device *spi) 116static int txx9spi_setup(struct spi_device *spi)
117{ 117{
118 struct txx9spi *c = spi_master_get_devdata(spi->master); 118 struct txx9spi *c = spi_master_get_devdata(spi->master);
119 u8 bits_per_word;
120 119
121 if (!spi->max_speed_hz 120 if (!spi->max_speed_hz
122 || spi->max_speed_hz > c->max_speed_hz 121 || spi->max_speed_hz > c->max_speed_hz
123 || spi->max_speed_hz < c->min_speed_hz) 122 || spi->max_speed_hz < c->min_speed_hz)
124 return -EINVAL; 123 return -EINVAL;
125 124
126 bits_per_word = spi->bits_per_word;
127 if (bits_per_word != 8 && bits_per_word != 16)
128 return -EINVAL;
129
130 if (gpio_direction_output(spi->chip_select, 125 if (gpio_direction_output(spi->chip_select,
131 !(spi->mode & SPI_CS_HIGH))) { 126 !(spi->mode & SPI_CS_HIGH))) {
132 dev_err(&spi->dev, "Cannot setup GPIO for chipselect.\n"); 127 dev_err(&spi->dev, "Cannot setup GPIO for chipselect.\n");
@@ -319,8 +314,6 @@ static int txx9spi_transfer(struct spi_device *spi, struct spi_message *m)
319 314
320 if (!t->tx_buf && !t->rx_buf && t->len) 315 if (!t->tx_buf && !t->rx_buf && t->len)
321 return -EINVAL; 316 return -EINVAL;
322 if (bits_per_word != 8 && bits_per_word != 16)
323 return -EINVAL;
324 if (t->len & ((bits_per_word >> 3) - 1)) 317 if (t->len & ((bits_per_word >> 3) - 1))
325 return -EINVAL; 318 return -EINVAL;
326 if (speed_hz < c->min_speed_hz || speed_hz > c->max_speed_hz) 319 if (speed_hz < c->min_speed_hz || speed_hz > c->max_speed_hz)
@@ -411,6 +404,7 @@ static int txx9spi_probe(struct platform_device *dev)
411 master->setup = txx9spi_setup; 404 master->setup = txx9spi_setup;
412 master->transfer = txx9spi_transfer; 405 master->transfer = txx9spi_transfer;
413 master->num_chipselect = (u16)UINT_MAX; /* any GPIO numbers */ 406 master->num_chipselect = (u16)UINT_MAX; /* any GPIO numbers */
407 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
414 408
415 ret = spi_register_master(master); 409 ret = spi_register_master(master);
416 if (ret) 410 if (ret)