Commit 235a175c401ab2d79d63f08257acebe1558a0621

Authored by Marek Vasut
Committed by Eric Miao
1 parent ba38830794

ARM: pxa: Use gpio arrays in palmtx_pcmcia driver

Use gpio_request_array() / gpio_free_array(), this makes the code
cleaner and less error prone.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>

Showing 1 changed file with 11 additions and 44 deletions Side-by-side Diff

drivers/pcmcia/pxa2xx_palmtx.c
... ... @@ -13,67 +13,34 @@
13 13  
14 14 #include <linux/module.h>
15 15 #include <linux/platform_device.h>
  16 +#include <linux/gpio.h>
16 17  
17 18 #include <asm/mach-types.h>
18   -
19   -#include <mach/gpio.h>
20 19 #include <mach/palmtx.h>
21   -
22 20 #include "soc_common.h"
23 21  
  22 +static struct gpio palmtx_pcmcia_gpios[] = {
  23 + { GPIO_NR_PALMTX_PCMCIA_POWER1, GPIOF_INIT_LOW, "PCMCIA Power 1" },
  24 + { GPIO_NR_PALMTX_PCMCIA_POWER2, GPIOF_INIT_LOW, "PCMCIA Power 2" },
  25 + { GPIO_NR_PALMTX_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
  26 + { GPIO_NR_PALMTX_PCMCIA_READY, GPIOF_IN, "PCMCIA Ready" },
  27 +};
  28 +
24 29 static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25 30 {
26 31 int ret;
27 32  
28   - ret = gpio_request(GPIO_NR_PALMTX_PCMCIA_POWER1, "PCMCIA PWR1");
29   - if (ret)
30   - goto err1;
31   - ret = gpio_direction_output(GPIO_NR_PALMTX_PCMCIA_POWER1, 0);
32   - if (ret)
33   - goto err2;
  33 + ret = gpio_request_array(palmtx_pcmcia_gpios,
  34 + ARRAY_SIZE(palmtx_pcmcia_gpios));
34 35  
35   - ret = gpio_request(GPIO_NR_PALMTX_PCMCIA_POWER2, "PCMCIA PWR2");
36   - if (ret)
37   - goto err2;
38   - ret = gpio_direction_output(GPIO_NR_PALMTX_PCMCIA_POWER2, 0);
39   - if (ret)
40   - goto err3;
41   -
42   - ret = gpio_request(GPIO_NR_PALMTX_PCMCIA_RESET, "PCMCIA RST");
43   - if (ret)
44   - goto err3;
45   - ret = gpio_direction_output(GPIO_NR_PALMTX_PCMCIA_RESET, 1);
46   - if (ret)
47   - goto err4;
48   -
49   - ret = gpio_request(GPIO_NR_PALMTX_PCMCIA_READY, "PCMCIA RDY");
50   - if (ret)
51   - goto err4;
52   - ret = gpio_direction_input(GPIO_NR_PALMTX_PCMCIA_READY);
53   - if (ret)
54   - goto err5;
55   -
56 36 skt->socket.pci_irq = gpio_to_irq(GPIO_NR_PALMTX_PCMCIA_READY);
57   - return 0;
58 37  
59   -err5:
60   - gpio_free(GPIO_NR_PALMTX_PCMCIA_READY);
61   -err4:
62   - gpio_free(GPIO_NR_PALMTX_PCMCIA_RESET);
63   -err3:
64   - gpio_free(GPIO_NR_PALMTX_PCMCIA_POWER2);
65   -err2:
66   - gpio_free(GPIO_NR_PALMTX_PCMCIA_POWER1);
67   -err1:
68 38 return ret;
69 39 }
70 40  
71 41 static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
72 42 {
73   - gpio_free(GPIO_NR_PALMTX_PCMCIA_READY);
74   - gpio_free(GPIO_NR_PALMTX_PCMCIA_RESET);
75   - gpio_free(GPIO_NR_PALMTX_PCMCIA_POWER2);
76   - gpio_free(GPIO_NR_PALMTX_PCMCIA_POWER1);
  43 + gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios));
77 44 }
78 45  
79 46 static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,