diff options
| -rw-r--r-- | drivers/spi/atmel_spi.c | 12 | ||||
| -rw-r--r-- | drivers/spi/au1550_spi.c | 12 | ||||
| -rw-r--r-- | drivers/spi/mpc52xx_psc_spi.c | 12 | ||||
| -rw-r--r-- | drivers/spi/omap2_mcspi.c | 12 | ||||
| -rw-r--r-- | drivers/spi/omap_uwire.c | 12 | ||||
| -rw-r--r-- | drivers/spi/orion_spi.c | 9 | ||||
| -rw-r--r-- | drivers/spi/pxa2xx_spi.c | 12 | ||||
| -rw-r--r-- | drivers/spi/spi.c | 11 | ||||
| -rw-r--r-- | drivers/spi/spi_bfin5xx.c | 9 | ||||
| -rw-r--r-- | drivers/spi/spi_bitbang.c | 9 | ||||
| -rw-r--r-- | drivers/spi/spi_imx.c | 12 | ||||
| -rw-r--r-- | drivers/spi/spi_mpc83xx.c | 14 | ||||
| -rw-r--r-- | drivers/spi/spi_s3c24xx.c | 12 | ||||
| -rw-r--r-- | drivers/spi/spi_txx9.c | 9 | ||||
| -rw-r--r-- | drivers/spi/xilinx_spi.c | 12 | ||||
| -rw-r--r-- | include/linux/spi/spi.h | 3 |
16 files changed, 57 insertions, 115 deletions
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 9f9ff3af72d7..f5b3fdbb1e27 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c | |||
| @@ -530,9 +530,6 @@ atmel_spi_interrupt(int irq, void *dev_id) | |||
| 530 | return ret; | 530 | return ret; |
| 531 | } | 531 | } |
| 532 | 532 | ||
| 533 | /* the spi->mode bits understood by this driver: */ | ||
| 534 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
| 535 | |||
| 536 | static int atmel_spi_setup(struct spi_device *spi) | 533 | static int atmel_spi_setup(struct spi_device *spi) |
| 537 | { | 534 | { |
| 538 | struct atmel_spi *as; | 535 | struct atmel_spi *as; |
| @@ -562,12 +559,6 @@ static int atmel_spi_setup(struct spi_device *spi) | |||
| 562 | return -EINVAL; | 559 | return -EINVAL; |
| 563 | } | 560 | } |
| 564 | 561 | ||
| 565 | if (spi->mode & ~MODEBITS) { | ||
| 566 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 567 | spi->mode & ~MODEBITS); | ||
| 568 | return -EINVAL; | ||
| 569 | } | ||
| 570 | |||
| 571 | /* see notes above re chipselect */ | 562 | /* see notes above re chipselect */ |
| 572 | if (!atmel_spi_is_v2() | 563 | if (!atmel_spi_is_v2() |
| 573 | && spi->chip_select == 0 | 564 | && spi->chip_select == 0 |
| @@ -773,6 +764,9 @@ static int __init atmel_spi_probe(struct platform_device *pdev) | |||
| 773 | if (!master) | 764 | if (!master) |
| 774 | goto out_free; | 765 | goto out_free; |
| 775 | 766 | ||
| 767 | /* the spi->mode bits understood by this driver: */ | ||
| 768 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
| 769 | |||
| 776 | master->bus_num = pdev->id; | 770 | master->bus_num = pdev->id; |
| 777 | master->num_chipselect = 4; | 771 | master->num_chipselect = 4; |
| 778 | master->setup = atmel_spi_setup; | 772 | master->setup = atmel_spi_setup; |
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c index 6a407e60f05b..76cbc1a66598 100644 --- a/drivers/spi/au1550_spi.c +++ b/drivers/spi/au1550_spi.c | |||
| @@ -284,9 +284,6 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t) | |||
| 284 | return 0; | 284 | return 0; |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | /* the spi->mode bits understood by this driver: */ | ||
| 288 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST) | ||
| 289 | |||
| 290 | static int au1550_spi_setup(struct spi_device *spi) | 287 | static int au1550_spi_setup(struct spi_device *spi) |
| 291 | { | 288 | { |
| 292 | struct au1550_spi *hw = spi_master_get_devdata(spi->master); | 289 | struct au1550_spi *hw = spi_master_get_devdata(spi->master); |
| @@ -297,12 +294,6 @@ static int au1550_spi_setup(struct spi_device *spi) | |||
| 297 | return -EINVAL; | 294 | return -EINVAL; |
| 298 | } | 295 | } |
| 299 | 296 | ||
| 300 | if (spi->mode & ~MODEBITS) { | ||
| 301 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 302 | spi->mode & ~MODEBITS); | ||
| 303 | return -EINVAL; | ||
| 304 | } | ||
| 305 | |||
| 306 | if (spi->max_speed_hz == 0) | 297 | if (spi->max_speed_hz == 0) |
| 307 | spi->max_speed_hz = hw->freq_max; | 298 | spi->max_speed_hz = hw->freq_max; |
| 308 | if (spi->max_speed_hz > hw->freq_max | 299 | if (spi->max_speed_hz > hw->freq_max |
| @@ -779,6 +770,9 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
| 779 | goto err_nomem; | 770 | goto err_nomem; |
| 780 | } | 771 | } |
| 781 | 772 | ||
| 773 | /* the spi->mode bits understood by this driver: */ | ||
| 774 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; | ||
| 775 | |||
| 782 | hw = spi_master_get_devdata(master); | 776 | hw = spi_master_get_devdata(master); |
| 783 | 777 | ||
| 784 | hw->master = spi_master_get(master); | 778 | hw->master = spi_master_get(master); |
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 68c77a911595..bdae9f908978 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
| @@ -261,9 +261,6 @@ static void mpc52xx_psc_spi_work(struct work_struct *work) | |||
| 261 | spin_unlock_irq(&mps->lock); | 261 | spin_unlock_irq(&mps->lock); |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | /* the spi->mode bits understood by this driver: */ | ||
| 265 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST) | ||
| 266 | |||
| 267 | static int mpc52xx_psc_spi_setup(struct spi_device *spi) | 264 | static int mpc52xx_psc_spi_setup(struct spi_device *spi) |
| 268 | { | 265 | { |
| 269 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | 266 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); |
| @@ -273,12 +270,6 @@ static int mpc52xx_psc_spi_setup(struct spi_device *spi) | |||
| 273 | if (spi->bits_per_word%8) | 270 | if (spi->bits_per_word%8) |
| 274 | return -EINVAL; | 271 | return -EINVAL; |
| 275 | 272 | ||
| 276 | if (spi->mode & ~MODEBITS) { | ||
| 277 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 278 | spi->mode & ~MODEBITS); | ||
| 279 | return -EINVAL; | ||
| 280 | } | ||
| 281 | |||
| 282 | if (!cs) { | 273 | if (!cs) { |
| 283 | cs = kzalloc(sizeof *cs, GFP_KERNEL); | 274 | cs = kzalloc(sizeof *cs, GFP_KERNEL); |
| 284 | if (!cs) | 275 | if (!cs) |
| @@ -385,6 +376,9 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
| 385 | dev_set_drvdata(dev, master); | 376 | dev_set_drvdata(dev, master); |
| 386 | mps = spi_master_get_devdata(master); | 377 | mps = spi_master_get_devdata(master); |
| 387 | 378 | ||
| 379 | /* the spi->mode bits understood by this driver: */ | ||
| 380 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; | ||
| 381 | |||
| 388 | mps->irq = irq; | 382 | mps->irq = irq; |
| 389 | if (pdata == NULL) { | 383 | if (pdata == NULL) { |
| 390 | dev_warn(dev, "probe called without platform data, no " | 384 | dev_warn(dev, "probe called without platform data, no " |
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index b4f3b753d0f4..eee4b6e0af2c 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c | |||
| @@ -603,9 +603,6 @@ static int omap2_mcspi_request_dma(struct spi_device *spi) | |||
| 603 | return 0; | 603 | return 0; |
| 604 | } | 604 | } |
| 605 | 605 | ||
| 606 | /* the spi->mode bits understood by this driver: */ | ||
| 607 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
| 608 | |||
| 609 | static int omap2_mcspi_setup(struct spi_device *spi) | 606 | static int omap2_mcspi_setup(struct spi_device *spi) |
| 610 | { | 607 | { |
| 611 | int ret; | 608 | int ret; |
| @@ -613,12 +610,6 @@ static int omap2_mcspi_setup(struct spi_device *spi) | |||
| 613 | struct omap2_mcspi_dma *mcspi_dma; | 610 | struct omap2_mcspi_dma *mcspi_dma; |
| 614 | struct omap2_mcspi_cs *cs = spi->controller_state; | 611 | struct omap2_mcspi_cs *cs = spi->controller_state; |
| 615 | 612 | ||
| 616 | if (spi->mode & ~MODEBITS) { | ||
| 617 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 618 | spi->mode & ~MODEBITS); | ||
| 619 | return -EINVAL; | ||
| 620 | } | ||
| 621 | |||
| 622 | if (spi->bits_per_word < 4 || spi->bits_per_word > 32) { | 613 | if (spi->bits_per_word < 4 || spi->bits_per_word > 32) { |
| 623 | dev_dbg(&spi->dev, "setup: unsupported %d bit words\n", | 614 | dev_dbg(&spi->dev, "setup: unsupported %d bit words\n", |
| 624 | spi->bits_per_word); | 615 | spi->bits_per_word); |
| @@ -982,6 +973,9 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
| 982 | return -ENOMEM; | 973 | return -ENOMEM; |
| 983 | } | 974 | } |
| 984 | 975 | ||
| 976 | /* the spi->mode bits understood by this driver: */ | ||
| 977 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
| 978 | |||
| 985 | if (pdev->id != -1) | 979 | if (pdev->id != -1) |
| 986 | master->bus_num = pdev->id; | 980 | master->bus_num = pdev->id; |
| 987 | 981 | ||
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c index 747d29be45d5..aa90ddb37066 100644 --- a/drivers/spi/omap_uwire.c +++ b/drivers/spi/omap_uwire.c | |||
| @@ -447,19 +447,10 @@ done: | |||
| 447 | return status; | 447 | return status; |
| 448 | } | 448 | } |
| 449 | 449 | ||
| 450 | /* the spi->mode bits understood by this driver: */ | ||
| 451 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
| 452 | |||
| 453 | static int uwire_setup(struct spi_device *spi) | 450 | static int uwire_setup(struct spi_device *spi) |
| 454 | { | 451 | { |
| 455 | struct uwire_state *ust = spi->controller_state; | 452 | struct uwire_state *ust = spi->controller_state; |
| 456 | 453 | ||
| 457 | if (spi->mode & ~MODEBITS) { | ||
| 458 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 459 | spi->mode & ~MODEBITS); | ||
| 460 | return -EINVAL; | ||
| 461 | } | ||
| 462 | |||
| 463 | if (ust == NULL) { | 454 | if (ust == NULL) { |
| 464 | ust = kzalloc(sizeof(*ust), GFP_KERNEL); | 455 | ust = kzalloc(sizeof(*ust), GFP_KERNEL); |
| 465 | if (ust == NULL) | 456 | if (ust == NULL) |
| @@ -520,6 +511,9 @@ static int __init uwire_probe(struct platform_device *pdev) | |||
| 520 | 511 | ||
| 521 | uwire_write_reg(UWIRE_SR3, 1); | 512 | uwire_write_reg(UWIRE_SR3, 1); |
| 522 | 513 | ||
| 514 | /* the spi->mode bits understood by this driver: */ | ||
| 515 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
| 516 | |||
| 523 | master->bus_num = 2; /* "official" */ | 517 | master->bus_num = 2; /* "official" */ |
| 524 | master->num_chipselect = 4; | 518 | master->num_chipselect = 4; |
| 525 | master->setup = uwire_setup; | 519 | master->setup = uwire_setup; |
diff --git a/drivers/spi/orion_spi.c b/drivers/spi/orion_spi.c index 6d5e33bb4b4a..3aea50da7b29 100644 --- a/drivers/spi/orion_spi.c +++ b/drivers/spi/orion_spi.c | |||
| @@ -358,12 +358,6 @@ static int orion_spi_setup(struct spi_device *spi) | |||
| 358 | 358 | ||
| 359 | orion_spi = spi_master_get_devdata(spi->master); | 359 | orion_spi = spi_master_get_devdata(spi->master); |
| 360 | 360 | ||
| 361 | if (spi->mode) { | ||
| 362 | dev_err(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 363 | spi->mode); | ||
| 364 | return -EINVAL; | ||
| 365 | } | ||
| 366 | |||
| 367 | /* Fix ac timing if required. */ | 361 | /* Fix ac timing if required. */ |
| 368 | if (orion_spi->spi_info->enable_clock_fix) | 362 | if (orion_spi->spi_info->enable_clock_fix) |
| 369 | orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG, | 363 | orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG, |
| @@ -473,6 +467,9 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
| 473 | if (pdev->id != -1) | 467 | if (pdev->id != -1) |
| 474 | master->bus_num = pdev->id; | 468 | master->bus_num = pdev->id; |
| 475 | 469 | ||
| 470 | /* we support only mode 0, and no options */ | ||
| 471 | master->mode_bits = 0; | ||
| 472 | |||
| 476 | master->setup = orion_spi_setup; | 473 | master->setup = orion_spi_setup; |
| 477 | master->transfer = orion_spi_transfer; | 474 | master->transfer = orion_spi_transfer; |
| 478 | master->num_chipselect = ORION_NUM_CHIPSELECTS; | 475 | master->num_chipselect = ORION_NUM_CHIPSELECTS; |
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index c7365e0b22dd..9c311dc4771d 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c | |||
| @@ -1185,9 +1185,6 @@ static int transfer(struct spi_device *spi, struct spi_message *msg) | |||
| 1185 | return 0; | 1185 | return 0; |
| 1186 | } | 1186 | } |
| 1187 | 1187 | ||
| 1188 | /* the spi->mode bits understood by this driver: */ | ||
| 1189 | #define MODEBITS (SPI_CPOL | SPI_CPHA) | ||
| 1190 | |||
| 1191 | static int setup_cs(struct spi_device *spi, struct chip_data *chip, | 1188 | static int setup_cs(struct spi_device *spi, struct chip_data *chip, |
| 1192 | struct pxa2xx_spi_chip *chip_info) | 1189 | struct pxa2xx_spi_chip *chip_info) |
| 1193 | { | 1190 | { |
| @@ -1252,12 +1249,6 @@ static int setup(struct spi_device *spi) | |||
| 1252 | return -EINVAL; | 1249 | return -EINVAL; |
| 1253 | } | 1250 | } |
| 1254 | 1251 | ||
| 1255 | if (spi->mode & ~MODEBITS) { | ||
| 1256 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 1257 | spi->mode & ~MODEBITS); | ||
| 1258 | return -EINVAL; | ||
| 1259 | } | ||
| 1260 | |||
| 1261 | /* Only alloc on first setup */ | 1252 | /* Only alloc on first setup */ |
| 1262 | chip = spi_get_ctldata(spi); | 1253 | chip = spi_get_ctldata(spi); |
| 1263 | if (!chip) { | 1254 | if (!chip) { |
| @@ -1493,6 +1484,9 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
| 1493 | drv_data->pdev = pdev; | 1484 | drv_data->pdev = pdev; |
| 1494 | drv_data->ssp = ssp; | 1485 | drv_data->ssp = ssp; |
| 1495 | 1486 | ||
| 1487 | /* the spi->mode bits understood by this driver: */ | ||
| 1488 | master->mode_bits = SPI_CPOL | SPI_CPHA; | ||
| 1489 | |||
| 1496 | master->bus_num = pdev->id; | 1490 | master->bus_num = pdev->id; |
| 1497 | master->num_chipselect = platform_info->num_chipselect; | 1491 | master->num_chipselect = platform_info->num_chipselect; |
| 1498 | master->dma_alignment = DMA_ALIGNMENT; | 1492 | master->dma_alignment = DMA_ALIGNMENT; |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 0276bc37e255..a525a3a848c1 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
| @@ -607,8 +607,19 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master); | |||
| 607 | */ | 607 | */ |
| 608 | int spi_setup(struct spi_device *spi) | 608 | int spi_setup(struct spi_device *spi) |
| 609 | { | 609 | { |
| 610 | unsigned bad_bits; | ||
| 610 | int status; | 611 | int status; |
| 611 | 612 | ||
| 613 | /* help drivers fail *cleanly* when they need options | ||
| 614 | * that aren't supported with their current master | ||
| 615 | */ | ||
| 616 | bad_bits = spi->mode & ~spi->master->mode_bits; | ||
| 617 | if (bad_bits) { | ||
| 618 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 619 | bad_bits); | ||
| 620 | return -EINVAL; | ||
| 621 | } | ||
| 622 | |||
| 612 | if (!spi->bits_per_word) | 623 | if (!spi->bits_per_word) |
| 613 | spi->bits_per_word = 8; | 624 | spi->bits_per_word = 8; |
| 614 | 625 | ||
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index d54058a903be..73e24ef5a2f9 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c | |||
| @@ -1010,12 +1010,6 @@ static int bfin_spi_setup(struct spi_device *spi) | |||
| 1010 | struct driver_data *drv_data = spi_master_get_devdata(spi->master); | 1010 | struct driver_data *drv_data = spi_master_get_devdata(spi->master); |
| 1011 | int ret; | 1011 | int ret; |
| 1012 | 1012 | ||
| 1013 | /* Abort device setup if requested features are not supported */ | ||
| 1014 | if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST)) { | ||
| 1015 | dev_err(&spi->dev, "requested mode not fully supported\n"); | ||
| 1016 | return -EINVAL; | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | if (spi->bits_per_word != 8 && spi->bits_per_word != 16) | 1013 | if (spi->bits_per_word != 8 && spi->bits_per_word != 16) |
| 1020 | return -EINVAL; | 1014 | return -EINVAL; |
| 1021 | 1015 | ||
| @@ -1283,6 +1277,9 @@ static int __init bfin_spi_probe(struct platform_device *pdev) | |||
| 1283 | drv_data->pdev = pdev; | 1277 | drv_data->pdev = pdev; |
| 1284 | drv_data->pin_req = platform_info->pin_req; | 1278 | drv_data->pin_req = platform_info->pin_req; |
| 1285 | 1279 | ||
| 1280 | /* the spi->mode bits supported by this driver: */ | ||
| 1281 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; | ||
| 1282 | |||
| 1286 | master->bus_num = pdev->id; | 1283 | master->bus_num = pdev->id; |
| 1287 | master->num_chipselect = platform_info->num_chipselect; | 1284 | master->num_chipselect = platform_info->num_chipselect; |
| 1288 | master->cleanup = bfin_spi_cleanup; | 1285 | master->cleanup = bfin_spi_cleanup; |
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c index 855b0b06e625..2a5abc08e857 100644 --- a/drivers/spi/spi_bitbang.c +++ b/drivers/spi/spi_bitbang.c | |||
| @@ -188,12 +188,6 @@ int spi_bitbang_setup(struct spi_device *spi) | |||
| 188 | 188 | ||
| 189 | bitbang = spi_master_get_devdata(spi->master); | 189 | bitbang = spi_master_get_devdata(spi->master); |
| 190 | 190 | ||
| 191 | /* Bitbangers can support SPI_CS_HIGH, SPI_3WIRE, and so on; | ||
| 192 | * add those to master->flags, and provide the other support. | ||
| 193 | */ | ||
| 194 | if ((spi->mode & ~(SPI_CPOL|SPI_CPHA|bitbang->flags)) != 0) | ||
| 195 | return -EINVAL; | ||
| 196 | |||
| 197 | if (!cs) { | 191 | if (!cs) { |
| 198 | cs = kzalloc(sizeof *cs, GFP_KERNEL); | 192 | cs = kzalloc(sizeof *cs, GFP_KERNEL); |
| 199 | if (!cs) | 193 | if (!cs) |
| @@ -452,6 +446,9 @@ int spi_bitbang_start(struct spi_bitbang *bitbang) | |||
| 452 | spin_lock_init(&bitbang->lock); | 446 | spin_lock_init(&bitbang->lock); |
| 453 | INIT_LIST_HEAD(&bitbang->queue); | 447 | INIT_LIST_HEAD(&bitbang->queue); |
| 454 | 448 | ||
| 449 | if (!bitbang->master->mode_bits) | ||
| 450 | bitbang->master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags; | ||
| 451 | |||
| 455 | if (!bitbang->master->transfer) | 452 | if (!bitbang->master->transfer) |
| 456 | bitbang->master->transfer = spi_bitbang_transfer; | 453 | bitbang->master->transfer = spi_bitbang_transfer; |
| 457 | if (!bitbang->txrx_bufs) { | 454 | if (!bitbang->txrx_bufs) { |
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c index 26d5ef06dbd9..c195e45f7f35 100644 --- a/drivers/spi/spi_imx.c +++ b/drivers/spi/spi_imx.c | |||
| @@ -1171,9 +1171,6 @@ msg_rejected: | |||
| 1171 | return -EINVAL; | 1171 | return -EINVAL; |
| 1172 | } | 1172 | } |
| 1173 | 1173 | ||
| 1174 | /* the spi->mode bits understood by this driver: */ | ||
| 1175 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
| 1176 | |||
| 1177 | /* On first setup bad values must free chip_data memory since will cause | 1174 | /* On first setup bad values must free chip_data memory since will cause |
| 1178 | spi_new_device to fail. Bad value setup from protocol driver are simply not | 1175 | spi_new_device to fail. Bad value setup from protocol driver are simply not |
| 1179 | applied and notified to the calling driver. */ | 1176 | applied and notified to the calling driver. */ |
| @@ -1186,12 +1183,6 @@ static int setup(struct spi_device *spi) | |||
| 1186 | u32 tmp; | 1183 | u32 tmp; |
| 1187 | int status = 0; | 1184 | int status = 0; |
| 1188 | 1185 | ||
| 1189 | if (spi->mode & ~MODEBITS) { | ||
| 1190 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 1191 | spi->mode & ~MODEBITS); | ||
| 1192 | return -EINVAL; | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | /* Get controller data */ | 1186 | /* Get controller data */ |
| 1196 | chip_info = spi->controller_data; | 1187 | chip_info = spi->controller_data; |
| 1197 | 1188 | ||
| @@ -1478,6 +1469,9 @@ static int __init spi_imx_probe(struct platform_device *pdev) | |||
| 1478 | drv_data->master_info = platform_info; | 1469 | drv_data->master_info = platform_info; |
| 1479 | drv_data->pdev = pdev; | 1470 | drv_data->pdev = pdev; |
| 1480 | 1471 | ||
| 1472 | /* the spi->mode bits understood by this driver: */ | ||
| 1473 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
| 1474 | |||
| 1481 | master->bus_num = pdev->id; | 1475 | master->bus_num = pdev->id; |
| 1482 | master->num_chipselect = platform_info->num_chipselect; | 1476 | master->num_chipselect = platform_info->num_chipselect; |
| 1483 | master->dma_alignment = DMA_ALIGNMENT; | 1477 | master->dma_alignment = DMA_ALIGNMENT; |
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index 0926a3e293e0..ce61be98e06d 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c | |||
| @@ -419,10 +419,6 @@ static void mpc83xx_spi_work(struct work_struct *work) | |||
| 419 | spin_unlock_irq(&mpc83xx_spi->lock); | 419 | spin_unlock_irq(&mpc83xx_spi->lock); |
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | /* the spi->mode bits understood by this driver: */ | ||
| 423 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ | ||
| 424 | | SPI_LSB_FIRST | SPI_LOOP) | ||
| 425 | |||
| 426 | static int mpc83xx_spi_setup(struct spi_device *spi) | 422 | static int mpc83xx_spi_setup(struct spi_device *spi) |
| 427 | { | 423 | { |
| 428 | struct mpc83xx_spi *mpc83xx_spi; | 424 | struct mpc83xx_spi *mpc83xx_spi; |
| @@ -430,12 +426,6 @@ static int mpc83xx_spi_setup(struct spi_device *spi) | |||
| 430 | u32 hw_mode; | 426 | u32 hw_mode; |
| 431 | struct spi_mpc83xx_cs *cs = spi->controller_state; | 427 | struct spi_mpc83xx_cs *cs = spi->controller_state; |
| 432 | 428 | ||
| 433 | if (spi->mode & ~MODEBITS) { | ||
| 434 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 435 | spi->mode & ~MODEBITS); | ||
| 436 | return -EINVAL; | ||
| 437 | } | ||
| 438 | |||
| 439 | if (!spi->max_speed_hz) | 429 | if (!spi->max_speed_hz) |
| 440 | return -EINVAL; | 430 | return -EINVAL; |
| 441 | 431 | ||
| @@ -562,6 +552,10 @@ mpc83xx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | |||
| 562 | 552 | ||
| 563 | dev_set_drvdata(dev, master); | 553 | dev_set_drvdata(dev, master); |
| 564 | 554 | ||
| 555 | /* the spi->mode bits understood by this driver: */ | ||
| 556 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | ||
| 557 | | SPI_LSB_FIRST | SPI_LOOP; | ||
| 558 | |||
| 565 | master->setup = mpc83xx_spi_setup; | 559 | master->setup = mpc83xx_spi_setup; |
| 566 | master->transfer = mpc83xx_spi_transfer; | 560 | master->transfer = mpc83xx_spi_transfer; |
| 567 | master->cleanup = mpc83xx_spi_cleanup; | 561 | master->cleanup = mpc83xx_spi_cleanup; |
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index 18a4c7f54380..e0d44af4745a 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c | |||
| @@ -146,19 +146,10 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi, | |||
| 146 | return 0; | 146 | return 0; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | /* the spi->mode bits understood by this driver: */ | ||
| 150 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
| 151 | |||
| 152 | static int s3c24xx_spi_setup(struct spi_device *spi) | 149 | static int s3c24xx_spi_setup(struct spi_device *spi) |
| 153 | { | 150 | { |
| 154 | int ret; | 151 | int ret; |
| 155 | 152 | ||
| 156 | if (spi->mode & ~MODEBITS) { | ||
| 157 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
| 158 | spi->mode & ~MODEBITS); | ||
| 159 | return -EINVAL; | ||
| 160 | } | ||
| 161 | |||
| 162 | ret = s3c24xx_spi_setupxfer(spi, NULL); | 153 | ret = s3c24xx_spi_setupxfer(spi, NULL); |
| 163 | if (ret < 0) { | 154 | if (ret < 0) { |
| 164 | dev_err(&spi->dev, "setupxfer returned %d\n", ret); | 155 | dev_err(&spi->dev, "setupxfer returned %d\n", ret); |
| @@ -283,6 +274,9 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev) | |||
| 283 | 274 | ||
| 284 | /* setup the master state. */ | 275 | /* setup the master state. */ |
| 285 | 276 | ||
| 277 | /* the spi->mode bits understood by this driver: */ | ||
| 278 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
| 279 | |||
| 286 | master->num_chipselect = hw->pdata->num_cs; | 280 | master->num_chipselect = hw->pdata->num_cs; |
| 287 | master->bus_num = pdata->bus_num; | 281 | master->bus_num = pdata->bus_num; |
| 288 | 282 | ||
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c index 8e36b2153d9a..96057de133ad 100644 --- a/drivers/spi/spi_txx9.c +++ b/drivers/spi/spi_txx9.c | |||
| @@ -110,17 +110,11 @@ static void txx9spi_cs_func(struct spi_device *spi, struct txx9spi *c, | |||
| 110 | ndelay(cs_delay); /* CS Setup Time / CS Recovery Time */ | 110 | ndelay(cs_delay); /* CS Setup Time / CS Recovery Time */ |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | /* the spi->mode bits understood by this driver: */ | ||
| 114 | #define MODEBITS (SPI_CS_HIGH|SPI_CPOL|SPI_CPHA) | ||
| 115 | |||
| 116 | static int txx9spi_setup(struct spi_device *spi) | 113 | static int txx9spi_setup(struct spi_device *spi) |
| 117 | { | 114 | { |
| 118 | struct txx9spi *c = spi_master_get_devdata(spi->master); | 115 | struct txx9spi *c = spi_master_get_devdata(spi->master); |
| 119 | u8 bits_per_word; | 116 | u8 bits_per_word; |
| 120 | 117 | ||
| 121 | if (spi->mode & ~MODEBITS) | ||
| 122 | return -EINVAL; | ||
| 123 | |||
| 124 | if (!spi->max_speed_hz | 118 | if (!spi->max_speed_hz |
| 125 | || spi->max_speed_hz > c->max_speed_hz | 119 | || spi->max_speed_hz > c->max_speed_hz |
| 126 | || spi->max_speed_hz < c->min_speed_hz) | 120 | || spi->max_speed_hz < c->min_speed_hz) |
| @@ -414,6 +408,9 @@ static int __init txx9spi_probe(struct platform_device *dev) | |||
| 414 | (unsigned long long)res->start, irq, | 408 | (unsigned long long)res->start, irq, |
| 415 | (c->baseclk + 500000) / 1000000); | 409 | (c->baseclk + 500000) / 1000000); |
| 416 | 410 | ||
| 411 | /* the spi->mode bits understood by this driver: */ | ||
| 412 | master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA; | ||
| 413 | |||
| 417 | master->bus_num = dev->id; | 414 | master->bus_num = dev->id; |
| 418 | master->setup = txx9spi_setup; | 415 | master->setup = txx9spi_setup; |
| 419 | master->transfer = txx9spi_transfer; | 416 | master->transfer = txx9spi_transfer; |
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 2d7e6b81fb4a..46b8c5c2f45e 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c | |||
| @@ -158,9 +158,6 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi, | |||
| 158 | return 0; | 158 | return 0; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | /* the spi->mode bits understood by this driver: */ | ||
| 162 | #define MODEBITS (SPI_CPOL | SPI_CPHA) | ||
| 163 | |||
| 164 | static int xilinx_spi_setup(struct spi_device *spi) | 161 | static int xilinx_spi_setup(struct spi_device *spi) |
| 165 | { | 162 | { |
| 166 | struct spi_bitbang *bitbang; | 163 | struct spi_bitbang *bitbang; |
| @@ -170,12 +167,6 @@ static int xilinx_spi_setup(struct spi_device *spi) | |||
| 170 | xspi = spi_master_get_devdata(spi->master); | 167 | xspi = spi_master_get_devdata(spi->master); |
| 171 | bitbang = &xspi->bitbang; | 168 | bitbang = &xspi->bitbang; |
| 172 | 169 | ||
| 173 | if (spi->mode & ~MODEBITS) { | ||
| 174 | dev_err(&spi->dev, "%s, unsupported mode bits %x\n", | ||
| 175 | __func__, spi->mode & ~MODEBITS); | ||
| 176 | return -EINVAL; | ||
| 177 | } | ||
| 178 | |||
| 179 | retval = xilinx_spi_setup_transfer(spi, NULL); | 170 | retval = xilinx_spi_setup_transfer(spi, NULL); |
| 180 | if (retval < 0) | 171 | if (retval < 0) |
| 181 | return retval; | 172 | return retval; |
| @@ -327,6 +318,9 @@ static int __init xilinx_spi_of_probe(struct of_device *ofdev, | |||
| 327 | goto put_master; | 318 | goto put_master; |
| 328 | } | 319 | } |
| 329 | 320 | ||
| 321 | /* the spi->mode bits understood by this driver: */ | ||
| 322 | master->mode_bits = SPI_CPOL | SPI_CPHA; | ||
| 323 | |||
| 330 | xspi = spi_master_get_devdata(master); | 324 | xspi = spi_master_get_devdata(master); |
| 331 | xspi->bitbang.master = spi_master_get(master); | 325 | xspi->bitbang.master = spi_master_get(master); |
| 332 | xspi->bitbang.chipselect = xilinx_spi_chipselect; | 326 | xspi->bitbang.chipselect = xilinx_spi_chipselect; |
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 0db5d64fc5e8..9c4cd27f4685 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h | |||
| @@ -245,6 +245,9 @@ struct spi_master { | |||
| 245 | */ | 245 | */ |
| 246 | u16 dma_alignment; | 246 | u16 dma_alignment; |
| 247 | 247 | ||
| 248 | /* spi_device.mode flags understood by this controller driver */ | ||
| 249 | u16 mode_bits; | ||
| 250 | |||
| 248 | /* Setup mode and clock, etc (spi driver may call many times). | 251 | /* Setup mode and clock, etc (spi driver may call many times). |
| 249 | * | 252 | * |
| 250 | * IMPORTANT: this may be called when transfers to another | 253 | * IMPORTANT: this may be called when transfers to another |
