diff options
| -rw-r--r-- | drivers/spi/spi-ath79.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index f369174fbd88..3e9b928b563b 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c | |||
| @@ -78,14 +78,16 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active) | |||
| 78 | ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); | 78 | ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | if (spi->chip_select) { | 81 | if (gpio_is_valid(spi->cs_gpio)) { |
| 82 | /* SPI is normally active-low */ | 82 | /* SPI is normally active-low */ |
| 83 | gpio_set_value(spi->cs_gpio, cs_high); | 83 | gpio_set_value(spi->cs_gpio, cs_high); |
| 84 | } else { | 84 | } else { |
| 85 | u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select); | ||
| 86 | |||
| 85 | if (cs_high) | 87 | if (cs_high) |
| 86 | sp->ioc_base |= AR71XX_SPI_IOC_CS0; | 88 | sp->ioc_base |= cs_bit; |
| 87 | else | 89 | else |
| 88 | sp->ioc_base &= ~AR71XX_SPI_IOC_CS0; | 90 | sp->ioc_base &= ~cs_bit; |
| 89 | 91 | ||
| 90 | ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); | 92 | ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); |
| 91 | } | 93 | } |
| @@ -118,11 +120,8 @@ static int ath79_spi_setup_cs(struct spi_device *spi) | |||
| 118 | struct ath79_spi *sp = ath79_spidev_to_sp(spi); | 120 | struct ath79_spi *sp = ath79_spidev_to_sp(spi); |
| 119 | int status; | 121 | int status; |
| 120 | 122 | ||
| 121 | if (spi->chip_select && !gpio_is_valid(spi->cs_gpio)) | ||
| 122 | return -EINVAL; | ||
| 123 | |||
| 124 | status = 0; | 123 | status = 0; |
| 125 | if (spi->chip_select) { | 124 | if (gpio_is_valid(spi->cs_gpio)) { |
| 126 | unsigned long flags; | 125 | unsigned long flags; |
| 127 | 126 | ||
| 128 | flags = GPIOF_DIR_OUT; | 127 | flags = GPIOF_DIR_OUT; |
| @@ -134,10 +133,12 @@ static int ath79_spi_setup_cs(struct spi_device *spi) | |||
| 134 | status = gpio_request_one(spi->cs_gpio, flags, | 133 | status = gpio_request_one(spi->cs_gpio, flags, |
| 135 | dev_name(&spi->dev)); | 134 | dev_name(&spi->dev)); |
| 136 | } else { | 135 | } else { |
| 136 | u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select); | ||
| 137 | |||
| 137 | if (spi->mode & SPI_CS_HIGH) | 138 | if (spi->mode & SPI_CS_HIGH) |
| 138 | sp->ioc_base &= ~AR71XX_SPI_IOC_CS0; | 139 | sp->ioc_base &= ~cs_bit; |
| 139 | else | 140 | else |
| 140 | sp->ioc_base |= AR71XX_SPI_IOC_CS0; | 141 | sp->ioc_base |= cs_bit; |
| 141 | 142 | ||
| 142 | ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); | 143 | ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); |
| 143 | } | 144 | } |
| @@ -147,7 +148,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi) | |||
| 147 | 148 | ||
| 148 | static void ath79_spi_cleanup_cs(struct spi_device *spi) | 149 | static void ath79_spi_cleanup_cs(struct spi_device *spi) |
| 149 | { | 150 | { |
| 150 | if (spi->chip_select) { | 151 | if (gpio_is_valid(spi->cs_gpio)) { |
| 151 | gpio_free(spi->cs_gpio); | 152 | gpio_free(spi->cs_gpio); |
| 152 | } | 153 | } |
| 153 | } | 154 | } |
