| 1 | From 6bd876a46b977643f27d2cc63f49e1bc84b78134 Mon Sep 17 00:00:00 2001 |
| 2 | From: Gabor Juhos <juhosg@openwrt.org> |
| 3 | Date: Mon, 9 Jan 2012 15:04:21 +0100 |
| 4 | Subject: [PATCH 31/34] spi/ath79: use gpio_request_one |
| 5 | |
| 6 | Use gpio_request_one() instead of multiple gpiolib calls. |
| 7 | |
| 8 | Signed-off-by: Gabor Juhos <juhosg@openwrt.org> |
| 9 | --- |
| 10 | drivers/spi/spi-ath79.c | 26 +++++++++++++------------- |
| 11 | 1 files changed, 13 insertions(+), 13 deletions(-) |
| 12 | |
| 13 | --- a/drivers/spi/spi-ath79.c |
| 14 | +++ b/drivers/spi/spi-ath79.c |
| 15 | @@ -100,6 +100,7 @@ static int ath79_spi_setup_cs(struct spi |
| 16 | { |
| 17 | struct ath79_spi *sp = ath79_spidev_to_sp(spi); |
| 18 | struct ath79_spi_controller_data *cdata; |
| 19 | + int status; |
| 20 | |
| 21 | cdata = spi->controller_data; |
| 22 | if (spi->chip_select && !cdata) |
| 23 | @@ -115,22 +116,21 @@ static int ath79_spi_setup_cs(struct spi |
| 24 | /* TODO: setup speed? */ |
| 25 | ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, 0x43); |
| 26 | |
| 27 | + status = 0; |
| 28 | if (spi->chip_select) { |
| 29 | - int status = 0; |
| 30 | + unsigned long flags; |
| 31 | |
| 32 | - status = gpio_request(cdata->gpio, dev_name(&spi->dev)); |
| 33 | - if (status) |
| 34 | - return status; |
| 35 | - |
| 36 | - status = gpio_direction_output(cdata->gpio, |
| 37 | - spi->mode & SPI_CS_HIGH); |
| 38 | - if (status) { |
| 39 | - gpio_free(cdata->gpio); |
| 40 | - return status; |
| 41 | - } |
| 42 | + flags = GPIOF_DIR_OUT; |
| 43 | + if (spi->mode & SPI_CS_HIGH) |
| 44 | + flags |= GPIOF_INIT_HIGH; |
| 45 | + else |
| 46 | + flags |= GPIOF_INIT_LOW; |
| 47 | + |
| 48 | + status = gpio_request_one(cdata->gpio, flags, |
| 49 | + dev_name(&spi->dev)); |
| 50 | } |
| 51 | |
| 52 | - return 0; |
| 53 | + return status; |
| 54 | } |
| 55 | |
| 56 | static void ath79_spi_cleanup_cs(struct spi_device *spi) |
| 57 | |