ar71xx: add initial support for 3.2
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-3.2 / 204-spi-ath79-use-gpio_request_one.patch
1 From c5bfb0c760a5d8de7ffc3a6acfb8c782be6af1a5 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 4/7] 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 @@ -93,6 +93,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 @@ -108,22 +109,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 + flags = GPIOF_DIR_OUT;
36 + if (spi->mode & SPI_CS_HIGH)
37 + flags |= GPIOF_INIT_HIGH;
38 + else
39 + flags |= GPIOF_INIT_LOW;
40
41 - status = gpio_direction_output(cdata->gpio,
42 - spi->mode & SPI_CS_HIGH);
43 - if (status) {
44 - gpio_free(cdata->gpio);
45 - return status;
46 - }
47 + status = gpio_request_one(cdata->gpio, flags,
48 + dev_name(&spi->dev));
49 }
50
51 - return 0;
52 + return status;
53 }
54
55 static void ath79_spi_cleanup_cs(struct spi_device *spi)