aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/spi-altera.c12
-rw-r--r--drivers/spi/spi-ath79.c4
-rw-r--r--drivers/spi/spi-atmel.c9
-rw-r--r--drivers/spi/spi-au1550.c12
-rw-r--r--drivers/spi/spi-bcm63xx.c20
-rw-r--r--drivers/spi/spi-bfin-sport.c10
-rw-r--r--drivers/spi/spi-bfin5xx.c21
-rw-r--r--drivers/spi/spi-clps711x.c7
-rw-r--r--drivers/spi/spi-coldfire-qspi.c11
-rw-r--r--drivers/spi/spi-davinci.c8
-rw-r--r--drivers/spi/spi-dw.c26
-rw-r--r--drivers/spi/spi-ep93xx.c11
-rw-r--r--drivers/spi/spi-fsl-espi.c9
-rw-r--r--drivers/spi/spi-gpio.c4
-rw-r--r--drivers/spi/spi-imx.c6
-rw-r--r--drivers/spi/spi-mxs.c7
-rw-r--r--drivers/spi/spi-nuc900.c13
-rw-r--r--drivers/spi/spi-omap-100k.c12
-rw-r--r--drivers/spi/spi-omap2-mcspi.c13
-rw-r--r--drivers/spi/spi-ppc4xx.c13
-rw-r--r--drivers/spi/spi-pxa2xx.c20
-rw-r--r--drivers/spi/spi-s3c64xx.c3
-rw-r--r--drivers/spi/spi-sirf.c6
-rw-r--r--drivers/spi/spi-ti-ssp.c16
-rw-r--r--drivers/spi/spi-topcliff-pch.c17
-rw-r--r--drivers/spi/spi-txx9.c8
-rw-r--r--drivers/spi/spi-xcomm.c12
-rw-r--r--drivers/spi/spi-xilinx.c16
28 files changed, 46 insertions, 280 deletions
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c
index a537f8dffc09..6b7096e0ad68 100644
--- a/drivers/spi/spi-altera.c
+++ b/drivers/spi/spi-altera.c
@@ -103,16 +103,6 @@ static void altera_spi_chipsel(struct spi_device *spi, int value)
103 } 103 }
104} 104}
105 105
106static int altera_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
107{
108 return 0;
109}
110
111static int altera_spi_setup(struct spi_device *spi)
112{
113 return 0;
114}
115
116static inline unsigned int hw_txbyte(struct altera_spi *hw, int count) 106static inline unsigned int hw_txbyte(struct altera_spi *hw, int count)
117{ 107{
118 if (hw->tx) { 108 if (hw->tx) {
@@ -231,7 +221,6 @@ static int altera_spi_probe(struct platform_device *pdev)
231 master->bus_num = pdev->id; 221 master->bus_num = pdev->id;
232 master->num_chipselect = 16; 222 master->num_chipselect = 16;
233 master->mode_bits = SPI_CS_HIGH; 223 master->mode_bits = SPI_CS_HIGH;
234 master->setup = altera_spi_setup;
235 224
236 hw = spi_master_get_devdata(master); 225 hw = spi_master_get_devdata(master);
237 platform_set_drvdata(pdev, hw); 226 platform_set_drvdata(pdev, hw);
@@ -240,7 +229,6 @@ static int altera_spi_probe(struct platform_device *pdev)
240 hw->bitbang.master = spi_master_get(master); 229 hw->bitbang.master = spi_master_get(master);
241 if (!hw->bitbang.master) 230 if (!hw->bitbang.master)
242 return err; 231 return err;
243 hw->bitbang.setup_transfer = altera_spi_setupxfer;
244 hw->bitbang.chipselect = altera_spi_chipsel; 232 hw->bitbang.chipselect = altera_spi_chipsel;
245 hw->bitbang.txrx_bufs = altera_spi_txrx; 233 hw->bitbang.txrx_bufs = altera_spi_txrx;
246 234
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c
index e504b7636058..5e2d52ce387f 100644
--- a/drivers/spi/spi-ath79.c
+++ b/drivers/spi/spi-ath79.c
@@ -155,9 +155,6 @@ static int ath79_spi_setup(struct spi_device *spi)
155{ 155{
156 int status = 0; 156 int status = 0;
157 157
158 if (spi->bits_per_word > 32)
159 return -EINVAL;
160
161 if (!spi->controller_state) { 158 if (!spi->controller_state) {
162 status = ath79_spi_setup_cs(spi); 159 status = ath79_spi_setup_cs(spi);
163 if (status) 160 if (status)
@@ -226,6 +223,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
226 223
227 pdata = pdev->dev.platform_data; 224 pdata = pdev->dev.platform_data;
228 225
226 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
229 master->setup = ath79_spi_setup; 227 master->setup = ath79_spi_setup;
230 master->cleanup = ath79_spi_cleanup; 228 master->cleanup = ath79_spi_cleanup;
231 if (pdata) { 229 if (pdata) {
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 380387a47b1d..31cfc8711547 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1268,13 +1268,6 @@ static int atmel_spi_setup(struct spi_device *spi)
1268 return -EINVAL; 1268 return -EINVAL;
1269 } 1269 }
1270 1270
1271 if (bits < 8 || bits > 16) {
1272 dev_dbg(&spi->dev,
1273 "setup: invalid bits_per_word %u (8 to 16)\n",
1274 bits);
1275 return -EINVAL;
1276 }
1277
1278 /* see notes above re chipselect */ 1271 /* see notes above re chipselect */
1279 if (!atmel_spi_is_v2(as) 1272 if (!atmel_spi_is_v2(as)
1280 && spi->chip_select == 0 1273 && spi->chip_select == 0
@@ -1515,7 +1508,7 @@ static int atmel_spi_probe(struct platform_device *pdev)
1515 1508
1516 /* the spi->mode bits understood by this driver: */ 1509 /* the spi->mode bits understood by this driver: */
1517 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1510 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1518 1511 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16);
1519 master->dev.of_node = pdev->dev.of_node; 1512 master->dev.of_node = pdev->dev.of_node;
1520 master->bus_num = pdev->id; 1513 master->bus_num = pdev->id;
1521 master->num_chipselect = master->dev.of_node ? 0 : 4; 1514 master->num_chipselect = master->dev.of_node ? 0 : 4;
diff --git a/drivers/spi/spi-au1550.c b/drivers/spi/spi-au1550.c
index 44dd34b6ad09..d736fa942020 100644
--- a/drivers/spi/spi-au1550.c
+++ b/drivers/spi/spi-au1550.c
@@ -248,11 +248,6 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
248 hz = t->speed_hz; 248 hz = t->speed_hz;
249 } 249 }
250 250
251 if (bpw < 4 || bpw > 24) {
252 dev_err(&spi->dev, "setupxfer: invalid bits_per_word=%d\n",
253 bpw);
254 return -EINVAL;
255 }
256 if (hz > spi->max_speed_hz || hz > hw->freq_max || hz < hw->freq_min) { 251 if (hz > spi->max_speed_hz || hz > hw->freq_max || hz < hw->freq_min) {
257 dev_err(&spi->dev, "setupxfer: clock rate=%d out of range\n", 252 dev_err(&spi->dev, "setupxfer: clock rate=%d out of range\n",
258 hz); 253 hz);
@@ -296,12 +291,6 @@ static int au1550_spi_setup(struct spi_device *spi)
296{ 291{
297 struct au1550_spi *hw = spi_master_get_devdata(spi->master); 292 struct au1550_spi *hw = spi_master_get_devdata(spi->master);
298 293
299 if (spi->bits_per_word < 4 || spi->bits_per_word > 24) {
300 dev_err(&spi->dev, "setup: invalid bits_per_word=%d\n",
301 spi->bits_per_word);
302 return -EINVAL;
303 }
304
305 if (spi->max_speed_hz == 0) 294 if (spi->max_speed_hz == 0)
306 spi->max_speed_hz = hw->freq_max; 295 spi->max_speed_hz = hw->freq_max;
307 if (spi->max_speed_hz > hw->freq_max 296 if (spi->max_speed_hz > hw->freq_max
@@ -782,6 +771,7 @@ static int au1550_spi_probe(struct platform_device *pdev)
782 771
783 /* the spi->mode bits understood by this driver: */ 772 /* the spi->mode bits understood by this driver: */
784 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; 773 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST;
774 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 24);
785 775
786 hw = spi_master_get_devdata(master); 776 hw = spi_master_get_devdata(master);
787 777
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index a4ec5f4ec817..270f09c071fb 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -124,17 +124,6 @@ static void bcm63xx_spi_setup_transfer(struct spi_device *spi,
124/* the spi->mode bits understood by this driver: */ 124/* the spi->mode bits understood by this driver: */
125#define MODEBITS (SPI_CPOL | SPI_CPHA) 125#define MODEBITS (SPI_CPOL | SPI_CPHA)
126 126
127static int bcm63xx_spi_setup(struct spi_device *spi)
128{
129 if (spi->bits_per_word != 8) {
130 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
131 __func__, spi->bits_per_word);
132 return -EINVAL;
133 }
134
135 return 0;
136}
137
138static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first, 127static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
139 unsigned int num_transfers) 128 unsigned int num_transfers)
140{ 129{
@@ -277,13 +266,6 @@ static int bcm63xx_spi_transfer_one(struct spi_master *master,
277 * full-duplex transfers. 266 * full-duplex transfers.
278 */ 267 */
279 list_for_each_entry(t, &m->transfers, transfer_list) { 268 list_for_each_entry(t, &m->transfers, transfer_list) {
280 if (t->bits_per_word != 8) {
281 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
282 __func__, t->bits_per_word);
283 status = -EINVAL;
284 goto exit;
285 }
286
287 if (!first) 269 if (!first)
288 first = t; 270 first = t;
289 271
@@ -430,11 +412,11 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
430 412
431 master->bus_num = pdata->bus_num; 413 master->bus_num = pdata->bus_num;
432 master->num_chipselect = pdata->num_chipselect; 414 master->num_chipselect = pdata->num_chipselect;
433 master->setup = bcm63xx_spi_setup;
434 master->prepare_transfer_hardware = bcm63xx_spi_prepare_transfer; 415 master->prepare_transfer_hardware = bcm63xx_spi_prepare_transfer;
435 master->unprepare_transfer_hardware = bcm63xx_spi_unprepare_transfer; 416 master->unprepare_transfer_hardware = bcm63xx_spi_unprepare_transfer;
436 master->transfer_one_message = bcm63xx_spi_transfer_one; 417 master->transfer_one_message = bcm63xx_spi_transfer_one;
437 master->mode_bits = MODEBITS; 418 master->mode_bits = MODEBITS;
419 master->bits_per_word_mask = SPI_BPW_MASK(8);
438 bs->msg_type_shift = pdata->msg_type_shift; 420 bs->msg_type_shift = pdata->msg_type_shift;
439 bs->msg_ctl_width = pdata->msg_ctl_width; 421 bs->msg_ctl_width = pdata->msg_ctl_width;
440 bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA)); 422 bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA));
diff --git a/drivers/spi/spi-bfin-sport.c b/drivers/spi/spi-bfin-sport.c
index 39b0d1711b4e..e4a858ad6ef6 100644
--- a/drivers/spi/spi-bfin-sport.c
+++ b/drivers/spi/spi-bfin-sport.c
@@ -417,7 +417,7 @@ bfin_sport_spi_pump_transfers(unsigned long data)
417 417
418 /* Bits per word setup */ 418 /* Bits per word setup */
419 bits_per_word = transfer->bits_per_word; 419 bits_per_word = transfer->bits_per_word;
420 if (bits_per_word % 16 == 0) 420 if (bits_per_word == 16)
421 drv_data->ops = &bfin_sport_transfer_ops_u16; 421 drv_data->ops = &bfin_sport_transfer_ops_u16;
422 else 422 else
423 drv_data->ops = &bfin_sport_transfer_ops_u8; 423 drv_data->ops = &bfin_sport_transfer_ops_u8;
@@ -600,13 +600,6 @@ bfin_sport_spi_setup(struct spi_device *spi)
600 } 600 }
601 } 601 }
602 602
603 if (spi->bits_per_word % 8) {
604 dev_err(&spi->dev, "%d bits_per_word is not supported\n",
605 spi->bits_per_word);
606 ret = -EINVAL;
607 goto error;
608 }
609
610 /* translate common spi framework into our register 603 /* translate common spi framework into our register
611 * following configure contents are same for tx and rx. 604 * following configure contents are same for tx and rx.
612 */ 605 */
@@ -778,6 +771,7 @@ static int bfin_sport_spi_probe(struct platform_device *pdev)
778 drv_data->pin_req = platform_info->pin_req; 771 drv_data->pin_req = platform_info->pin_req;
779 772
780 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; 773 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
774 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
781 master->bus_num = pdev->id; 775 master->bus_num = pdev->id;
782 master->num_chipselect = platform_info->num_chipselect; 776 master->num_chipselect = platform_info->num_chipselect;
783 master->cleanup = bfin_sport_spi_cleanup; 777 master->cleanup = bfin_sport_spi_cleanup;
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c
index 317f564c899c..e35c19cff9ca 100644
--- a/drivers/spi/spi-bfin5xx.c
+++ b/drivers/spi/spi-bfin5xx.c
@@ -643,21 +643,16 @@ static void bfin_spi_pump_transfers(unsigned long data)
643 643
644 /* Bits per word setup */ 644 /* Bits per word setup */
645 bits_per_word = transfer->bits_per_word; 645 bits_per_word = transfer->bits_per_word;
646 if (bits_per_word % 16 == 0) { 646 if (bits_per_word == 16) {
647 drv_data->n_bytes = bits_per_word/8; 647 drv_data->n_bytes = bits_per_word/8;
648 drv_data->len = (transfer->len) >> 1; 648 drv_data->len = (transfer->len) >> 1;
649 cr_width = BIT_CTL_WORDSIZE; 649 cr_width = BIT_CTL_WORDSIZE;
650 drv_data->ops = &bfin_bfin_spi_transfer_ops_u16; 650 drv_data->ops = &bfin_bfin_spi_transfer_ops_u16;
651 } else if (bits_per_word % 8 == 0) { 651 } else if (bits_per_word == 8) {
652 drv_data->n_bytes = bits_per_word/8; 652 drv_data->n_bytes = bits_per_word/8;
653 drv_data->len = transfer->len; 653 drv_data->len = transfer->len;
654 cr_width = 0; 654 cr_width = 0;
655 drv_data->ops = &bfin_bfin_spi_transfer_ops_u8; 655 drv_data->ops = &bfin_bfin_spi_transfer_ops_u8;
656 } else {
657 dev_err(&drv_data->pdev->dev, "transfer: unsupported bits_per_word\n");
658 message->status = -EINVAL;
659 bfin_spi_giveback(drv_data);
660 return;
661 } 656 }
662 cr = bfin_read(&drv_data->regs->ctl) & ~(BIT_CTL_TIMOD | BIT_CTL_WORDSIZE); 657 cr = bfin_read(&drv_data->regs->ctl) & ~(BIT_CTL_TIMOD | BIT_CTL_WORDSIZE);
663 cr |= cr_width; 658 cr |= cr_width;
@@ -808,13 +803,13 @@ static void bfin_spi_pump_transfers(unsigned long data)
808 bfin_write(&drv_data->regs->tdbr, chip->idle_tx_val); 803 bfin_write(&drv_data->regs->tdbr, chip->idle_tx_val);
809 else { 804 else {
810 int loop; 805 int loop;
811 if (bits_per_word % 16 == 0) { 806 if (bits_per_word == 16) {
812 u16 *buf = (u16 *)drv_data->tx; 807 u16 *buf = (u16 *)drv_data->tx;
813 for (loop = 0; loop < bits_per_word / 16; 808 for (loop = 0; loop < bits_per_word / 16;
814 loop++) { 809 loop++) {
815 bfin_write(&drv_data->regs->tdbr, *buf++); 810 bfin_write(&drv_data->regs->tdbr, *buf++);
816 } 811 }
817 } else if (bits_per_word % 8 == 0) { 812 } else if (bits_per_word == 8) {
818 u8 *buf = (u8 *)drv_data->tx; 813 u8 *buf = (u8 *)drv_data->tx;
819 for (loop = 0; loop < bits_per_word / 8; loop++) 814 for (loop = 0; loop < bits_per_word / 8; loop++)
820 bfin_write(&drv_data->regs->tdbr, *buf++); 815 bfin_write(&drv_data->regs->tdbr, *buf++);
@@ -1033,12 +1028,6 @@ static int bfin_spi_setup(struct spi_device *spi)
1033 chip->ctl_reg &= bfin_ctl_reg; 1028 chip->ctl_reg &= bfin_ctl_reg;
1034 } 1029 }
1035 1030
1036 if (spi->bits_per_word % 8) {
1037 dev_err(&spi->dev, "%d bits_per_word is not supported\n",
1038 spi->bits_per_word);
1039 goto error;
1040 }
1041
1042 /* translate common spi framework into our register */ 1031 /* translate common spi framework into our register */
1043 if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST)) { 1032 if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST)) {
1044 dev_err(&spi->dev, "unsupported spi modes detected\n"); 1033 dev_err(&spi->dev, "unsupported spi modes detected\n");
@@ -1299,7 +1288,7 @@ static int bfin_spi_probe(struct platform_device *pdev)
1299 1288
1300 /* the spi->mode bits supported by this driver: */ 1289 /* the spi->mode bits supported by this driver: */
1301 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; 1290 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
1302 1291 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
1303 master->bus_num = pdev->id; 1292 master->bus_num = pdev->id;
1304 master->num_chipselect = platform_info->num_chipselect; 1293 master->num_chipselect = platform_info->num_chipselect;
1305 master->cleanup = bfin_spi_cleanup; 1294 master->cleanup = bfin_spi_cleanup;
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c
index a11cbf02691a..e322b5bf9910 100644
--- a/drivers/spi/spi-clps711x.c
+++ b/drivers/spi/spi-clps711x.c
@@ -42,12 +42,6 @@ static int spi_clps711x_setup(struct spi_device *spi)
42{ 42{
43 struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); 43 struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master);
44 44
45 if (spi->bits_per_word != 8) {
46 dev_err(&spi->dev, "Unsupported master bus width %i\n",
47 spi->bits_per_word);
48 return -EINVAL;
49 }
50
51 /* We are expect that SPI-device is not selected */ 45 /* We are expect that SPI-device is not selected */
52 gpio_direction_output(hw->chipselect[spi->chip_select], 46 gpio_direction_output(hw->chipselect[spi->chip_select],
53 !(spi->mode & SPI_CS_HIGH)); 47 !(spi->mode & SPI_CS_HIGH));
@@ -190,6 +184,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
190 184
191 master->bus_num = pdev->id; 185 master->bus_num = pdev->id;
192 master->mode_bits = SPI_CPHA | SPI_CS_HIGH; 186 master->mode_bits = SPI_CPHA | SPI_CS_HIGH;
187 master->bits_per_word_mask = SPI_BPW_MASK(8);
193 master->num_chipselect = pdata->num_chipselect; 188 master->num_chipselect = pdata->num_chipselect;
194 master->setup = spi_clps711x_setup; 189 master->setup = spi_clps711x_setup;
195 master->transfer_one_message = spi_clps711x_transfer_one_message; 190 master->transfer_one_message = spi_clps711x_transfer_one_message;
diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c
index 7b5cc9e4e94d..9a7db9d1b4ca 100644
--- a/drivers/spi/spi-coldfire-qspi.c
+++ b/drivers/spi/spi-coldfire-qspi.c
@@ -312,10 +312,7 @@ static int mcfqspi_transfer_one_message(struct spi_master *master,
312 bool cs_high = spi->mode & SPI_CS_HIGH; 312 bool cs_high = spi->mode & SPI_CS_HIGH;
313 u16 qmr = MCFQSPI_QMR_MSTR; 313 u16 qmr = MCFQSPI_QMR_MSTR;
314 314
315 if (t->bits_per_word) 315 qmr |= t->bits_per_word << 10;
316 qmr |= t->bits_per_word << 10;
317 else
318 qmr |= spi->bits_per_word << 10;
319 if (spi->mode & SPI_CPHA) 316 if (spi->mode & SPI_CPHA)
320 qmr |= MCFQSPI_QMR_CPHA; 317 qmr |= MCFQSPI_QMR_CPHA;
321 if (spi->mode & SPI_CPOL) 318 if (spi->mode & SPI_CPOL)
@@ -377,11 +374,6 @@ static int mcfqspi_unprepare_transfer_hw(struct spi_master *master)
377 374
378static int mcfqspi_setup(struct spi_device *spi) 375static int mcfqspi_setup(struct spi_device *spi)
379{ 376{
380 if ((spi->bits_per_word < 8) || (spi->bits_per_word > 16)) {
381 dev_dbg(&spi->dev, "%d bits per word is not supported\n",
382 spi->bits_per_word);
383 return -EINVAL;
384 }
385 if (spi->chip_select >= spi->master->num_chipselect) { 377 if (spi->chip_select >= spi->master->num_chipselect) {
386 dev_dbg(&spi->dev, "%d chip select is out of range\n", 378 dev_dbg(&spi->dev, "%d chip select is out of range\n",
387 spi->chip_select); 379 spi->chip_select);
@@ -477,6 +469,7 @@ static int mcfqspi_probe(struct platform_device *pdev)
477 mcfqspi->dev = &pdev->dev; 469 mcfqspi->dev = &pdev->dev;
478 470
479 master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA; 471 master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA;
472 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16);
480 master->setup = mcfqspi_setup; 473 master->setup = mcfqspi_setup;
481 master->transfer_one_message = mcfqspi_transfer_one_message; 474 master->transfer_one_message = mcfqspi_transfer_one_message;
482 master->prepare_transfer_hardware = mcfqspi_prepare_transfer_hw; 475 master->prepare_transfer_hardware = mcfqspi_prepare_transfer_hw;
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 50b13c9b1ab6..b141ef221b14 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -299,16 +299,15 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
299 * Assign function pointer to appropriate transfer method 299 * Assign function pointer to appropriate transfer method
300 * 8bit, 16bit or 32bit transfer 300 * 8bit, 16bit or 32bit transfer
301 */ 301 */
302 if (bits_per_word <= 8 && bits_per_word >= 2) { 302 if (bits_per_word <= 8) {
303 dspi->get_rx = davinci_spi_rx_buf_u8; 303 dspi->get_rx = davinci_spi_rx_buf_u8;
304 dspi->get_tx = davinci_spi_tx_buf_u8; 304 dspi->get_tx = davinci_spi_tx_buf_u8;
305 dspi->bytes_per_word[spi->chip_select] = 1; 305 dspi->bytes_per_word[spi->chip_select] = 1;
306 } else if (bits_per_word <= 16 && bits_per_word >= 2) { 306 } else {
307 dspi->get_rx = davinci_spi_rx_buf_u16; 307 dspi->get_rx = davinci_spi_rx_buf_u16;
308 dspi->get_tx = davinci_spi_tx_buf_u16; 308 dspi->get_tx = davinci_spi_tx_buf_u16;
309 dspi->bytes_per_word[spi->chip_select] = 2; 309 dspi->bytes_per_word[spi->chip_select] = 2;
310 } else 310 }
311 return -EINVAL;
312 311
313 if (!hz) 312 if (!hz)
314 hz = spi->max_speed_hz; 313 hz = spi->max_speed_hz;
@@ -933,6 +932,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
933 master->dev.of_node = pdev->dev.of_node; 932 master->dev.of_node = pdev->dev.of_node;
934 master->bus_num = pdev->id; 933 master->bus_num = pdev->id;
935 master->num_chipselect = pdata->num_chipselect; 934 master->num_chipselect = pdata->num_chipselect;
935 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16);
936 master->setup = davinci_spi_setup; 936 master->setup = davinci_spi_setup;
937 937
938 dspi->bitbang.chipselect = davinci_spi_chipselect; 938 dspi->bitbang.chipselect = davinci_spi_chipselect;
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index c1abc06899e7..79c958e49f61 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -457,19 +457,7 @@ static void pump_transfers(unsigned long data)
457 } 457 }
458 if (transfer->bits_per_word) { 458 if (transfer->bits_per_word) {
459 bits = transfer->bits_per_word; 459 bits = transfer->bits_per_word;
460 460 dws->n_bytes = dws->dma_width = bits >> 3;
461 switch (bits) {
462 case 8:
463 case 16:
464 dws->n_bytes = dws->dma_width = bits >> 3;
465 break;
466 default:
467 printk(KERN_ERR "MRST SPI0: unsupported bits:"
468 "%db\n", bits);
469 message->status = -EIO;
470 goto early_exit;
471 }
472
473 cr0 = (bits - 1) 461 cr0 = (bits - 1)
474 | (chip->type << SPI_FRF_OFFSET) 462 | (chip->type << SPI_FRF_OFFSET)
475 | (spi->mode << SPI_MODE_OFFSET) 463 | (spi->mode << SPI_MODE_OFFSET)
@@ -629,9 +617,6 @@ static int dw_spi_setup(struct spi_device *spi)
629 struct dw_spi_chip *chip_info = NULL; 617 struct dw_spi_chip *chip_info = NULL;
630 struct chip_data *chip; 618 struct chip_data *chip;
631 619
632 if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
633 return -EINVAL;
634
635 /* Only alloc on first setup */ 620 /* Only alloc on first setup */
636 chip = spi_get_ctldata(spi); 621 chip = spi_get_ctldata(spi);
637 if (!chip) { 622 if (!chip) {
@@ -660,16 +645,12 @@ static int dw_spi_setup(struct spi_device *spi)
660 chip->enable_dma = chip_info->enable_dma; 645 chip->enable_dma = chip_info->enable_dma;
661 } 646 }
662 647
663 if (spi->bits_per_word <= 8) { 648 if (spi->bits_per_word == 8) {
664 chip->n_bytes = 1; 649 chip->n_bytes = 1;
665 chip->dma_width = 1; 650 chip->dma_width = 1;
666 } else if (spi->bits_per_word <= 16) { 651 } else if (spi->bits_per_word == 16) {
667 chip->n_bytes = 2; 652 chip->n_bytes = 2;
668 chip->dma_width = 2; 653 chip->dma_width = 2;
669 } else {
670 /* Never take >16b case for MRST SPIC */
671 dev_err(&spi->dev, "invalid wordsize\n");
672 return -EINVAL;
673 } 654 }
674 chip->bits_per_word = spi->bits_per_word; 655 chip->bits_per_word = spi->bits_per_word;
675 656
@@ -824,6 +805,7 @@ int dw_spi_add_host(struct dw_spi *dws)
824 } 805 }
825 806
826 master->mode_bits = SPI_CPOL | SPI_CPHA; 807 master->mode_bits = SPI_CPOL | SPI_CPHA;
808 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
827 master->bus_num = dws->bus_num; 809 master->bus_num = dws->bus_num;
828 master->num_chipselect = dws->num_cs; 810 master->num_chipselect = dws->num_cs;
829 master->cleanup = dw_spi_cleanup; 811 master->cleanup = dw_spi_cleanup;
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index d7bac60253c9..f1b14977abdf 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -296,12 +296,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
296 struct ep93xx_spi *espi = spi_master_get_devdata(spi->master); 296 struct ep93xx_spi *espi = spi_master_get_devdata(spi->master);
297 struct ep93xx_spi_chip *chip; 297 struct ep93xx_spi_chip *chip;
298 298
299 if (spi->bits_per_word < 4 || spi->bits_per_word > 16) {
300 dev_err(&espi->pdev->dev, "invalid bits per word %d\n",
301 spi->bits_per_word);
302 return -EINVAL;
303 }
304
305 chip = spi_get_ctldata(spi); 299 chip = spi_get_ctldata(spi);
306 if (!chip) { 300 if (!chip) {
307 dev_dbg(&espi->pdev->dev, "initial setup for %s\n", 301 dev_dbg(&espi->pdev->dev, "initial setup for %s\n",
@@ -365,10 +359,6 @@ static int ep93xx_spi_transfer(struct spi_device *spi, struct spi_message *msg)
365 359
366 /* first validate each transfer */ 360 /* first validate each transfer */
367 list_for_each_entry(t, &msg->transfers, transfer_list) { 361 list_for_each_entry(t, &msg->transfers, transfer_list) {
368 if (t->bits_per_word) {
369 if (t->bits_per_word < 4 || t->bits_per_word > 16)
370 return -EINVAL;
371 }
372 if (t->speed_hz && t->speed_hz < espi->min_rate) 362 if (t->speed_hz && t->speed_hz < espi->min_rate)
373 return -EINVAL; 363 return -EINVAL;
374 } 364 }
@@ -1046,6 +1036,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
1046 master->bus_num = pdev->id; 1036 master->bus_num = pdev->id;
1047 master->num_chipselect = info->num_chipselect; 1037 master->num_chipselect = info->num_chipselect;
1048 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1038 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1039 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
1049 1040
1050 platform_set_drvdata(pdev, master); 1041 platform_set_drvdata(pdev, master);
1051 1042
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 24610ca8955d..0ef05f198f22 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -144,10 +144,6 @@ static int fsl_espi_setup_transfer(struct spi_device *spi,
144 if (!bits_per_word) 144 if (!bits_per_word)
145 bits_per_word = spi->bits_per_word; 145 bits_per_word = spi->bits_per_word;
146 146
147 /* Make sure its a bit width we support [4..16] */
148 if ((bits_per_word < 4) || (bits_per_word > 16))
149 return -EINVAL;
150
151 if (!hz) 147 if (!hz)
152 hz = spi->max_speed_hz; 148 hz = spi->max_speed_hz;
153 149
@@ -157,12 +153,10 @@ static int fsl_espi_setup_transfer(struct spi_device *spi,
157 cs->get_tx = mpc8xxx_spi_tx_buf_u32; 153 cs->get_tx = mpc8xxx_spi_tx_buf_u32;
158 if (bits_per_word <= 8) { 154 if (bits_per_word <= 8) {
159 cs->rx_shift = 8 - bits_per_word; 155 cs->rx_shift = 8 - bits_per_word;
160 } else if (bits_per_word <= 16) { 156 } else
161 cs->rx_shift = 16 - bits_per_word; 157 cs->rx_shift = 16 - bits_per_word;
162 if (spi->mode & SPI_LSB_FIRST) 158 if (spi->mode & SPI_LSB_FIRST)
163 cs->get_tx = fsl_espi_tx_buf_lsb; 159 cs->get_tx = fsl_espi_tx_buf_lsb;
164 } else {
165 return -EINVAL;
166 } 160 }
167 161
168 mpc8xxx_spi->rx_shift = cs->rx_shift; 162 mpc8xxx_spi->rx_shift = cs->rx_shift;
@@ -609,6 +603,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
609 if (ret) 603 if (ret)
610 goto err_probe; 604 goto err_probe;
611 605
606 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
612 master->setup = fsl_espi_setup; 607 master->setup = fsl_espi_setup;
613 608
614 mpc8xxx_spi = spi_master_get_devdata(master); 609 mpc8xxx_spi = spi_master_get_devdata(master);
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 0021fc4c45bc..a7801a889ff9 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -239,9 +239,6 @@ static int spi_gpio_setup(struct spi_device *spi)
239 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); 239 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi);
240 struct device_node *np = spi->master->dev.of_node; 240 struct device_node *np = spi->master->dev.of_node;
241 241
242 if (spi->bits_per_word > 32)
243 return -EINVAL;
244
245 if (np) { 242 if (np) {
246 /* 243 /*
247 * In DT environments, the CS GPIOs have already been 244 * In DT environments, the CS GPIOs have already been
@@ -446,6 +443,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
446 if (pdata) 443 if (pdata)
447 spi_gpio->pdata = *pdata; 444 spi_gpio->pdata = *pdata;
448 445
446 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
449 master->flags = master_flags; 447 master->flags = master_flags;
450 master->bus_num = pdev->id; 448 master->bus_num = pdev->id;
451 master->num_chipselect = SPI_N_CHIPSEL; 449 master->num_chipselect = SPI_N_CHIPSEL;
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 0befeeb522f4..cb88eeb74cc4 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -698,11 +698,10 @@ static int spi_imx_setupxfer(struct spi_device *spi,
698 } else if (config.bpw <= 16) { 698 } else if (config.bpw <= 16) {
699 spi_imx->rx = spi_imx_buf_rx_u16; 699 spi_imx->rx = spi_imx_buf_rx_u16;
700 spi_imx->tx = spi_imx_buf_tx_u16; 700 spi_imx->tx = spi_imx_buf_tx_u16;
701 } else if (config.bpw <= 32) { 701 }
702 spi_imx->rx = spi_imx_buf_rx_u32; 702 spi_imx->rx = spi_imx_buf_rx_u32;
703 spi_imx->tx = spi_imx_buf_tx_u32; 703 spi_imx->tx = spi_imx_buf_tx_u32;
704 } else 704 }
705 BUG();
706 705
707 spi_imx->devtype_data->config(spi_imx, &config); 706 spi_imx->devtype_data->config(spi_imx, &config);
708 707
@@ -783,6 +782,7 @@ static int spi_imx_probe(struct platform_device *pdev)
783 782
784 platform_set_drvdata(pdev, master); 783 platform_set_drvdata(pdev, master);
785 784
785 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
786 master->bus_num = pdev->id; 786 master->bus_num = pdev->id;
787 master->num_chipselect = num_cs; 787 master->num_chipselect = num_cs;
788 788
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 84982768cd10..62b7e8ee1163 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -75,12 +75,6 @@ static int mxs_spi_setup_transfer(struct spi_device *dev,
75 if (t && t->bits_per_word) 75 if (t && t->bits_per_word)
76 bits_per_word = t->bits_per_word; 76 bits_per_word = t->bits_per_word;
77 77
78 if (bits_per_word != 8) {
79 dev_err(&dev->dev, "%s, unsupported bits_per_word=%d\n",
80 __func__, bits_per_word);
81 return -EINVAL;
82 }
83
84 hz = dev->max_speed_hz; 78 hz = dev->max_speed_hz;
85 if (t && t->speed_hz) 79 if (t && t->speed_hz)
86 hz = min(hz, t->speed_hz); 80 hz = min(hz, t->speed_hz);
@@ -548,6 +542,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
548 542
549 master->transfer_one_message = mxs_spi_transfer_one; 543 master->transfer_one_message = mxs_spi_transfer_one;
550 master->setup = mxs_spi_setup; 544 master->setup = mxs_spi_setup;
545 master->bits_per_word_mask = SPI_BPW_MASK(8);
551 master->mode_bits = SPI_CPOL | SPI_CPHA; 546 master->mode_bits = SPI_CPOL | SPI_CPHA;
552 master->num_chipselect = 3; 547 master->num_chipselect = 3;
553 master->dev.of_node = np; 548 master->dev.of_node = np;
diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c
index b3f9ec83ef73..94efa2c6298e 100644
--- a/drivers/spi/spi-nuc900.c
+++ b/drivers/spi/spi-nuc900.c
@@ -174,17 +174,6 @@ static void nuc900_spi_gobusy(struct nuc900_spi *hw)
174 spin_unlock_irqrestore(&hw->lock, flags); 174 spin_unlock_irqrestore(&hw->lock, flags);
175} 175}
176 176
177static int nuc900_spi_setupxfer(struct spi_device *spi,
178 struct spi_transfer *t)
179{
180 return 0;
181}
182
183static int nuc900_spi_setup(struct spi_device *spi)
184{
185 return 0;
186}
187
188static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count) 177static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count)
189{ 178{
190 return hw->tx ? hw->tx[count] : 0; 179 return hw->tx ? hw->tx[count] : 0;
@@ -377,10 +366,8 @@ static int nuc900_spi_probe(struct platform_device *pdev)
377 master->num_chipselect = hw->pdata->num_cs; 366 master->num_chipselect = hw->pdata->num_cs;
378 master->bus_num = hw->pdata->bus_num; 367 master->bus_num = hw->pdata->bus_num;
379 hw->bitbang.master = hw->master; 368 hw->bitbang.master = hw->master;
380 hw->bitbang.setup_transfer = nuc900_spi_setupxfer;
381 hw->bitbang.chipselect = nuc900_spi_chipsel; 369 hw->bitbang.chipselect = nuc900_spi_chipsel;
382 hw->bitbang.txrx_bufs = nuc900_spi_txrx; 370 hw->bitbang.txrx_bufs = nuc900_spi_txrx;
383 hw->bitbang.master->setup = nuc900_spi_setup;
384 371
385 hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 372 hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
386 if (hw->res == NULL) { 373 if (hw->res == NULL) {
diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
index 78d29a18dcc4..9137fcc4f99b 100644
--- a/drivers/spi/spi-omap-100k.c
+++ b/drivers/spi/spi-omap-100k.c
@@ -298,12 +298,6 @@ static int omap1_spi100k_setup(struct spi_device *spi)
298 struct omap1_spi100k *spi100k; 298 struct omap1_spi100k *spi100k;
299 struct omap1_spi100k_cs *cs = spi->controller_state; 299 struct omap1_spi100k_cs *cs = spi->controller_state;
300 300
301 if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
302 dev_dbg(&spi->dev, "setup: unsupported %d bit words\n",
303 spi->bits_per_word);
304 return -EINVAL;
305 }
306
307 spi100k = spi_master_get_devdata(spi->master); 301 spi100k = spi_master_get_devdata(spi->master);
308 302
309 if (!cs) { 303 if (!cs) {
@@ -451,10 +445,7 @@ static int omap1_spi100k_transfer(struct spi_device *spi, struct spi_message *m)
451 unsigned len = t->len; 445 unsigned len = t->len;
452 446
453 if (t->speed_hz > OMAP1_SPI100K_MAX_FREQ 447 if (t->speed_hz > OMAP1_SPI100K_MAX_FREQ
454 || (len && !(rx_buf || tx_buf)) 448 || (len && !(rx_buf || tx_buf))) {
455 || (t->bits_per_word &&
456 ( t->bits_per_word < 4
457 || t->bits_per_word > 32))) {
458 dev_dbg(&spi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n", 449 dev_dbg(&spi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
459 t->speed_hz, 450 t->speed_hz,
460 len, 451 len,
@@ -509,6 +500,7 @@ static int omap1_spi100k_probe(struct platform_device *pdev)
509 master->cleanup = NULL; 500 master->cleanup = NULL;
510 master->num_chipselect = 2; 501 master->num_chipselect = 2;
511 master->mode_bits = MODEBITS; 502 master->mode_bits = MODEBITS;
503 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
512 504
513 dev_set_drvdata(&pdev->dev, master); 505 dev_set_drvdata(&pdev->dev, master);
514 506
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 86d2158946bb..6246fb455774 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -857,12 +857,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
857 struct omap2_mcspi_dma *mcspi_dma; 857 struct omap2_mcspi_dma *mcspi_dma;
858 struct omap2_mcspi_cs *cs = spi->controller_state; 858 struct omap2_mcspi_cs *cs = spi->controller_state;
859 859
860 if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
861 dev_dbg(&spi->dev, "setup: unsupported %d bit words\n",
862 spi->bits_per_word);
863 return -EINVAL;
864 }
865
866 mcspi_dma = &mcspi->dma_channels[spi->chip_select]; 860 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
867 861
868 if (!cs) { 862 if (!cs) {
@@ -1072,10 +1066,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master,
1072 unsigned len = t->len; 1066 unsigned len = t->len;
1073 1067
1074 if (t->speed_hz > OMAP2_MCSPI_MAX_FREQ 1068 if (t->speed_hz > OMAP2_MCSPI_MAX_FREQ
1075 || (len && !(rx_buf || tx_buf)) 1069 || (len && !(rx_buf || tx_buf))) {
1076 || (t->bits_per_word &&
1077 ( t->bits_per_word < 4
1078 || t->bits_per_word > 32))) {
1079 dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n", 1070 dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
1080 t->speed_hz, 1071 t->speed_hz,
1081 len, 1072 len,
@@ -1196,7 +1187,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1196 1187
1197 /* the spi->mode bits understood by this driver: */ 1188 /* the spi->mode bits understood by this driver: */
1198 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1189 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1199 1190 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
1200 master->setup = omap2_mcspi_setup; 1191 master->setup = omap2_mcspi_setup;
1201 master->prepare_transfer_hardware = omap2_prepare_transfer; 1192 master->prepare_transfer_hardware = omap2_prepare_transfer;
1202 master->unprepare_transfer_hardware = omap2_unprepare_transfer; 1193 master->unprepare_transfer_hardware = omap2_unprepare_transfer;
diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c
index 357f183a4fb7..01df34bed2d0 100644
--- a/drivers/spi/spi-ppc4xx.c
+++ b/drivers/spi/spi-ppc4xx.c
@@ -190,12 +190,6 @@ static int spi_ppc4xx_setupxfer(struct spi_device *spi, struct spi_transfer *t)
190 speed = min(t->speed_hz, spi->max_speed_hz); 190 speed = min(t->speed_hz, spi->max_speed_hz);
191 } 191 }
192 192
193 if (bits_per_word != 8) {
194 dev_err(&spi->dev, "invalid bits-per-word (%d)\n",
195 bits_per_word);
196 return -EINVAL;
197 }
198
199 if (!speed || (speed > spi->max_speed_hz)) { 193 if (!speed || (speed > spi->max_speed_hz)) {
200 dev_err(&spi->dev, "invalid speed_hz (%d)\n", speed); 194 dev_err(&spi->dev, "invalid speed_hz (%d)\n", speed);
201 return -EINVAL; 195 return -EINVAL;
@@ -229,12 +223,6 @@ static int spi_ppc4xx_setup(struct spi_device *spi)
229{ 223{
230 struct spi_ppc4xx_cs *cs = spi->controller_state; 224 struct spi_ppc4xx_cs *cs = spi->controller_state;
231 225
232 if (spi->bits_per_word != 8) {
233 dev_err(&spi->dev, "invalid bits-per-word (%d)\n",
234 spi->bits_per_word);
235 return -EINVAL;
236 }
237
238 if (!spi->max_speed_hz) { 226 if (!spi->max_speed_hz) {
239 dev_err(&spi->dev, "invalid max_speed_hz (must be non-zero)\n"); 227 dev_err(&spi->dev, "invalid max_speed_hz (must be non-zero)\n");
240 return -EINVAL; 228 return -EINVAL;
@@ -465,6 +453,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
465 bbp->use_dma = 0; 453 bbp->use_dma = 0;
466 bbp->master->setup = spi_ppc4xx_setup; 454 bbp->master->setup = spi_ppc4xx_setup;
467 bbp->master->cleanup = spi_ppc4xx_cleanup; 455 bbp->master->cleanup = spi_ppc4xx_cleanup;
456 bbp->master->bits_per_word_mask = SPI_BPW_MASK(8);
468 457
469 /* the spi->mode bits understood by this driver: */ 458 /* the spi->mode bits understood by this driver: */
470 bbp->master->mode_bits = 459 bbp->master->mode_bits =
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index f5d84d6f8222..7de2ca1c4ee3 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -881,21 +881,6 @@ static int setup(struct spi_device *spi)
881 rx_thres = RX_THRESH_DFLT; 881 rx_thres = RX_THRESH_DFLT;
882 } 882 }
883 883
884 if (!pxa25x_ssp_comp(drv_data)
885 && (spi->bits_per_word < 4 || spi->bits_per_word > 32)) {
886 dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d "
887 "b/w not 4-32 for type non-PXA25x_SSP\n",
888 drv_data->ssp_type, spi->bits_per_word);
889 return -EINVAL;
890 } else if (pxa25x_ssp_comp(drv_data)
891 && (spi->bits_per_word < 4
892 || spi->bits_per_word > 16)) {
893 dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d "
894 "b/w not 4-16 for type PXA25x_SSP\n",
895 drv_data->ssp_type, spi->bits_per_word);
896 return -EINVAL;
897 }
898
899 /* Only alloc on first setup */ 884 /* Only alloc on first setup */
900 chip = spi_get_ctldata(spi); 885 chip = spi_get_ctldata(spi);
901 if (!chip) { 886 if (!chip) {
@@ -1011,9 +996,6 @@ static int setup(struct spi_device *spi)
1011 chip->n_bytes = 4; 996 chip->n_bytes = 4;
1012 chip->read = u32_reader; 997 chip->read = u32_reader;
1013 chip->write = u32_writer; 998 chip->write = u32_writer;
1014 } else {
1015 dev_err(&spi->dev, "invalid wordsize\n");
1016 return -ENODEV;
1017 } 999 }
1018 chip->bits_per_word = spi->bits_per_word; 1000 chip->bits_per_word = spi->bits_per_word;
1019 1001
@@ -1190,11 +1172,13 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
1190 drv_data->ioaddr = ssp->mmio_base; 1172 drv_data->ioaddr = ssp->mmio_base;
1191 drv_data->ssdr_physical = ssp->phys_base + SSDR; 1173 drv_data->ssdr_physical = ssp->phys_base + SSDR;
1192 if (pxa25x_ssp_comp(drv_data)) { 1174 if (pxa25x_ssp_comp(drv_data)) {
1175 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
1193 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE; 1176 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE;
1194 drv_data->dma_cr1 = 0; 1177 drv_data->dma_cr1 = 0;
1195 drv_data->clear_sr = SSSR_ROR; 1178 drv_data->clear_sr = SSSR_ROR;
1196 drv_data->mask_sr = SSSR_RFS | SSSR_TFS | SSSR_ROR; 1179 drv_data->mask_sr = SSSR_RFS | SSSR_TFS | SSSR_ROR;
1197 } else { 1180 } else {
1181 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
1198 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE | SSCR1_TINTE; 1182 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE | SSCR1_TINTE;
1199 drv_data->dma_cr1 = DEFAULT_DMA_CR1; 1183 drv_data->dma_cr1 = DEFAULT_DMA_CR1;
1200 drv_data->clear_sr = SSSR_ROR | SSSR_TINT; 1184 drv_data->clear_sr = SSSR_ROR | SSSR_TINT;
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 5000586cb98d..39a3824ec3d7 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1314,7 +1314,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1314 master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer; 1314 master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer;
1315 master->num_chipselect = sci->num_cs; 1315 master->num_chipselect = sci->num_cs;
1316 master->dma_alignment = 8; 1316 master->dma_alignment = 8;
1317 master->bits_per_word_mask = BIT(32 - 1) | BIT(16 - 1) | BIT(8 - 1); 1317 master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) |
1318 SPI_BPW_MASK(8);
1318 /* the spi->mode bits understood by this driver: */ 1319 /* the spi->mode bits understood by this driver: */
1319 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1320 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1320 1321
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index 0808cd56bf8d..77497be042a8 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -425,10 +425,6 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
425 rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | 425 rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) |
426 SIRFSOC_SPI_FIFO_WIDTH_DWORD; 426 SIRFSOC_SPI_FIFO_WIDTH_DWORD;
427 break; 427 break;
428 default:
429 dev_err(&spi->dev, "Bits per word %d not supported\n",
430 bits_per_word);
431 return -EINVAL;
432 } 428 }
433 429
434 if (!(spi->mode & SPI_CS_HIGH)) 430 if (!(spi->mode & SPI_CS_HIGH))
@@ -556,6 +552,8 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
556 sspi->bitbang.txrx_bufs = spi_sirfsoc_transfer; 552 sspi->bitbang.txrx_bufs = spi_sirfsoc_transfer;
557 sspi->bitbang.master->setup = spi_sirfsoc_setup; 553 sspi->bitbang.master->setup = spi_sirfsoc_setup;
558 master->bus_num = pdev->id; 554 master->bus_num = pdev->id;
555 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(12) |
556 SPI_BPW_MASK(16) | SPI_BPW_MASK(32);
559 sspi->bitbang.master->dev.of_node = pdev->dev.of_node; 557 sspi->bitbang.master->dev.of_node = pdev->dev.of_node;
560 558
561 sspi->p = pinctrl_get_select_default(&pdev->dev); 559 sspi->p = pinctrl_get_select_default(&pdev->dev);
diff --git a/drivers/spi/spi-ti-ssp.c b/drivers/spi/spi-ti-ssp.c
index 46992cab65f1..10606fcc6efc 100644
--- a/drivers/spi/spi-ti-ssp.c
+++ b/drivers/spi/spi-ti-ssp.c
@@ -237,14 +237,6 @@ static void ti_ssp_spi_work(struct work_struct *work)
237 spin_unlock(&hw->lock); 237 spin_unlock(&hw->lock);
238} 238}
239 239
240static int ti_ssp_spi_setup(struct spi_device *spi)
241{
242 if (spi->bits_per_word > 32)
243 return -EINVAL;
244
245 return 0;
246}
247
248static int ti_ssp_spi_transfer(struct spi_device *spi, struct spi_message *m) 240static int ti_ssp_spi_transfer(struct spi_device *spi, struct spi_message *m)
249{ 241{
250 struct ti_ssp_spi *hw; 242 struct ti_ssp_spi *hw;
@@ -269,12 +261,6 @@ static int ti_ssp_spi_transfer(struct spi_device *spi, struct spi_message *m)
269 dev_err(&spi->dev, "invalid xfer, full duplex\n"); 261 dev_err(&spi->dev, "invalid xfer, full duplex\n");
270 return -EINVAL; 262 return -EINVAL;
271 } 263 }
272
273 if (t->bits_per_word > 32) {
274 dev_err(&spi->dev, "invalid xfer width %d\n",
275 t->bits_per_word);
276 return -EINVAL;
277 }
278 } 264 }
279 265
280 spin_lock(&hw->lock); 266 spin_lock(&hw->lock);
@@ -337,8 +323,8 @@ static int ti_ssp_spi_probe(struct platform_device *pdev)
337 master->bus_num = pdev->id; 323 master->bus_num = pdev->id;
338 master->num_chipselect = pdata->num_cs; 324 master->num_chipselect = pdata->num_cs;
339 master->mode_bits = MODE_BITS; 325 master->mode_bits = MODE_BITS;
326 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
340 master->flags = SPI_MASTER_HALF_DUPLEX; 327 master->flags = SPI_MASTER_HALF_DUPLEX;
341 master->setup = ti_ssp_spi_setup;
342 master->transfer = ti_ssp_spi_transfer; 328 master->transfer = ti_ssp_spi_transfer;
343 329
344 error = spi_register_master(master); 330 error = spi_register_master(master);
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 35f60bd252dd..15cb39b0549e 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -472,11 +472,6 @@ static int pch_spi_setup(struct spi_device *pspi)
472 dev_dbg(&pspi->dev, "%s 8 bits per word\n", __func__); 472 dev_dbg(&pspi->dev, "%s 8 bits per word\n", __func__);
473 } 473 }
474 474
475 if ((pspi->bits_per_word != 8) && (pspi->bits_per_word != 16)) {
476 dev_err(&pspi->dev, "%s Invalid bits per word\n", __func__);
477 return -EINVAL;
478 }
479
480 /* Check baud rate setting */ 475 /* Check baud rate setting */
481 /* if baud rate of chip is greater than 476 /* if baud rate of chip is greater than
482 max we can support,return error */ 477 max we can support,return error */
@@ -537,17 +532,6 @@ static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg)
537 /* if baud rate has been specified validate the same */ 532 /* if baud rate has been specified validate the same */
538 if (transfer->speed_hz > PCH_MAX_BAUDRATE) 533 if (transfer->speed_hz > PCH_MAX_BAUDRATE)
539 transfer->speed_hz = PCH_MAX_BAUDRATE; 534 transfer->speed_hz = PCH_MAX_BAUDRATE;
540
541 /* if bits per word has been specified validate the same */
542 if (transfer->bits_per_word) {
543 if ((transfer->bits_per_word != 8)
544 && (transfer->bits_per_word != 16)) {
545 retval = -EINVAL;
546 dev_err(&pspi->dev,
547 "%s Invalid bits per word\n", __func__);
548 goto err_return_spinlock;
549 }
550 }
551 } 535 }
552 spin_unlock_irqrestore(&data->lock, flags); 536 spin_unlock_irqrestore(&data->lock, flags);
553 537
@@ -1442,6 +1426,7 @@ static int pch_spi_pd_probe(struct platform_device *plat_dev)
1442 master->setup = pch_spi_setup; 1426 master->setup = pch_spi_setup;
1443 master->transfer = pch_spi_transfer; 1427 master->transfer = pch_spi_transfer;
1444 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; 1428 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
1429 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
1445 1430
1446 data->board_dat = board_dat; 1431 data->board_dat = board_dat;
1447 data->plat_dev = plat_dev; 1432 data->plat_dev = plat_dev;
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)
diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c
index 4d3ec8b9f479..4258c712ad3c 100644
--- a/drivers/spi/spi-xcomm.c
+++ b/drivers/spi/spi-xcomm.c
@@ -76,7 +76,7 @@ static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm,
76{ 76{
77 unsigned int speed; 77 unsigned int speed;
78 78
79 if ((t->bits_per_word && t->bits_per_word != 8) || t->len > 62) 79 if (t->len > 62)
80 return -EINVAL; 80 return -EINVAL;
81 81
82 speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; 82 speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz;
@@ -209,14 +209,6 @@ static int spi_xcomm_transfer_one(struct spi_master *master,
209 return status; 209 return status;
210} 210}
211 211
212static int spi_xcomm_setup(struct spi_device *spi)
213{
214 if (spi->bits_per_word != 8)
215 return -EINVAL;
216
217 return 0;
218}
219
220static int spi_xcomm_probe(struct i2c_client *i2c, 212static int spi_xcomm_probe(struct i2c_client *i2c,
221 const struct i2c_device_id *id) 213 const struct i2c_device_id *id)
222{ 214{
@@ -233,8 +225,8 @@ static int spi_xcomm_probe(struct i2c_client *i2c,
233 225
234 master->num_chipselect = 16; 226 master->num_chipselect = 16;
235 master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_3WIRE; 227 master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_3WIRE;
228 master->bits_per_word_mask = SPI_BPW_MASK(8);
236 master->flags = SPI_MASTER_HALF_DUPLEX; 229 master->flags = SPI_MASTER_HALF_DUPLEX;
237 master->setup = spi_xcomm_setup;
238 master->transfer_one_message = spi_xcomm_transfer_one; 230 master->transfer_one_message = spi_xcomm_transfer_one;
239 master->dev.of_node = i2c->dev.of_node; 231 master->dev.of_node = i2c->dev.of_node;
240 i2c_set_clientdata(i2c, master); 232 i2c_set_clientdata(i2c, master);
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index e1d769607425..f321bf95d7c3 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -232,21 +232,6 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
232 return 0; 232 return 0;
233} 233}
234 234
235static int xilinx_spi_setup(struct spi_device *spi)
236{
237 /* always return 0, we can not check the number of bits.
238 * There are cases when SPI setup is called before any driver is
239 * there, in that case the SPI core defaults to 8 bits, which we
240 * do not support in some cases. But if we return an error, the
241 * SPI device would not be registered and no driver can get hold of it
242 * When the driver is there, it will call SPI setup again with the
243 * correct number of bits per transfer.
244 * If a driver setups with the wrong bit number, it will fail when
245 * it tries to do a transfer
246 */
247 return 0;
248}
249
250static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi) 235static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
251{ 236{
252 u8 sr; 237 u8 sr;
@@ -377,7 +362,6 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
377 xspi->bitbang.chipselect = xilinx_spi_chipselect; 362 xspi->bitbang.chipselect = xilinx_spi_chipselect;
378 xspi->bitbang.setup_transfer = xilinx_spi_setup_transfer; 363 xspi->bitbang.setup_transfer = xilinx_spi_setup_transfer;
379 xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs; 364 xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs;
380 xspi->bitbang.master->setup = xilinx_spi_setup;
381 init_completion(&xspi->done); 365 init_completion(&xspi->done);
382 366
383 if (!request_mem_region(mem->start, resource_size(mem), 367 if (!request_mem_region(mem->start, resource_size(mem),