aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-imx.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2012-07-27 10:45:04 -0400
committerAndrew Lunn <andrew@lunn.ch>2012-07-27 10:45:04 -0400
commit4297103560b4c5aba904e4711e982a039619f1f6 (patch)
tree772c527706c8d7677d79390ac3336af11bcc34e2 /drivers/spi/spi-imx.c
parent84a1caf1453c3d44050bd22db958af4a7f99315c (diff)
parent8ceffa7c4a4c378d8e371fe2f444656e75390b34 (diff)
Merge tag 'spi-3.6' into v3.5-rc7-dt-v3
spi: Updates for 3.6 Since Grant is even more specacularly busy than usual for the time being I've been collecting SPI patches for him for this release - probably things will revert back to Grant before the next release. There's nothing too exciting here, mostly it's simple driver specific stuff: - Add spi: to the modaliases of SPI devices to provide namespacing. - A driver for AD-FMCOMMS1-EBZ. - DT binding for Orion. - Fixes and cleanups for i.MX, PL0022, OMAP and bitbang drivers. There may be a few more fixes I've missed, people keep sending me new things.
Diffstat (limited to 'drivers/spi/spi-imx.c')
-rw-r--r--drivers/spi/spi-imx.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 47877d687614..e834ff8c0188 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -626,7 +626,7 @@ static void spi_imx_chipselect(struct spi_device *spi, int is_active)
626 int active = is_active != BITBANG_CS_INACTIVE; 626 int active = is_active != BITBANG_CS_INACTIVE;
627 int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH); 627 int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);
628 628
629 if (gpio < 0) 629 if (!gpio_is_valid(gpio))
630 return; 630 return;
631 631
632 gpio_set_value(gpio, dev_is_lowactive ^ active); 632 gpio_set_value(gpio, dev_is_lowactive ^ active);
@@ -688,8 +688,6 @@ static int spi_imx_setupxfer(struct spi_device *spi,
688 config.speed_hz = spi->max_speed_hz; 688 config.speed_hz = spi->max_speed_hz;
689 if (!config.bpw) 689 if (!config.bpw)
690 config.bpw = spi->bits_per_word; 690 config.bpw = spi->bits_per_word;
691 if (!config.speed_hz)
692 config.speed_hz = spi->max_speed_hz;
693 691
694 /* Initialize the functions for transfer */ 692 /* Initialize the functions for transfer */
695 if (config.bpw <= 8) { 693 if (config.bpw <= 8) {
@@ -738,7 +736,7 @@ static int spi_imx_setup(struct spi_device *spi)
738 dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__, 736 dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
739 spi->mode, spi->bits_per_word, spi->max_speed_hz); 737 spi->mode, spi->bits_per_word, spi->max_speed_hz);
740 738
741 if (gpio >= 0) 739 if (gpio_is_valid(gpio))
742 gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1); 740 gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
743 741
744 spi_imx_chipselect(spi, BITBANG_CS_INACTIVE); 742 spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
@@ -791,11 +789,11 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
791 789
792 for (i = 0; i < master->num_chipselect; i++) { 790 for (i = 0; i < master->num_chipselect; i++) {
793 int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); 791 int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
794 if (cs_gpio < 0 && mxc_platform_info) 792 if (!gpio_is_valid(cs_gpio) && mxc_platform_info)
795 cs_gpio = mxc_platform_info->chipselect[i]; 793 cs_gpio = mxc_platform_info->chipselect[i];
796 794
797 spi_imx->chipselect[i] = cs_gpio; 795 spi_imx->chipselect[i] = cs_gpio;
798 if (cs_gpio < 0) 796 if (!gpio_is_valid(cs_gpio))
799 continue; 797 continue;
800 798
801 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME); 799 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
@@ -897,7 +895,7 @@ out_release_mem:
897 release_mem_region(res->start, resource_size(res)); 895 release_mem_region(res->start, resource_size(res));
898out_gpio_free: 896out_gpio_free:
899 while (--i >= 0) { 897 while (--i >= 0) {
900 if (spi_imx->chipselect[i] >= 0) 898 if (gpio_is_valid(spi_imx->chipselect[i]))
901 gpio_free(spi_imx->chipselect[i]); 899 gpio_free(spi_imx->chipselect[i]);
902 } 900 }
903 spi_master_put(master); 901 spi_master_put(master);
@@ -922,7 +920,7 @@ static int __devexit spi_imx_remove(struct platform_device *pdev)
922 iounmap(spi_imx->base); 920 iounmap(spi_imx->base);
923 921
924 for (i = 0; i < master->num_chipselect; i++) 922 for (i = 0; i < master->num_chipselect; i++)
925 if (spi_imx->chipselect[i] >= 0) 923 if (gpio_is_valid(spi_imx->chipselect[i]))
926 gpio_free(spi_imx->chipselect[i]); 924 gpio_free(spi_imx->chipselect[i]);
927 925
928 spi_master_put(master); 926 spi_master_put(master);