aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2013-11-26 05:09:49 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2013-12-12 18:00:54 -0500
commit8bed576c1a81d620765ec96f7b4e80dedaef1bcf (patch)
tree7d55d1d3c1cde016e5d4fea88d611c6cb9483f7e
parent5f72d85e282e83db8eedb291aa89db9198470b38 (diff)
ARM: 7899/1: sa1100: h3600: refactor LCD GPIO handling
Use gpio_request_array to request all GPIOs at once. Also don't call gpio_free. There is little point freeing LCD gpios once they are requested. Instead guard them with bool variable. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-sa1100/h3600.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
index b8dc5bd22623..559c2a0a40d9 100644
--- a/arch/arm/mach-sa1100/h3600.c
+++ b/arch/arm/mach-sa1100/h3600.c
@@ -28,35 +28,39 @@
28/* 28/*
29 * helper for sa1100fb 29 * helper for sa1100fb
30 */ 30 */
31static struct gpio h3600_lcd_gpio[] = {
32 { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD power" },
33 { H3600_EGPIO_LCD_PCI, GPIOF_OUT_INIT_LOW, "LCD control" },
34 { H3600_EGPIO_LCD_5V_ON, GPIOF_OUT_INIT_LOW, "LCD 5v" },
35 { H3600_EGPIO_LVDD_ON, GPIOF_OUT_INIT_LOW, "LCD 9v/-6.5v" },
36};
37
38static bool h3600_lcd_request(void)
39{
40 static bool h3600_lcd_ok;
41 int rc;
42
43 if (h3600_lcd_ok)
44 return true;
45
46 rc = gpio_request_array(h3600_lcd_gpio, ARRAY_SIZE(h3600_lcd_gpio));
47 if (rc)
48 pr_err("%s: can't request GPIOs\n", __func__);
49 else
50 h3600_lcd_ok = true;
51
52 return h3600_lcd_ok;
53}
54
31static void h3600_lcd_power(int enable) 55static void h3600_lcd_power(int enable)
32{ 56{
33 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) { 57 if (!h3600_lcd_request())
34 pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__); 58 return;
35 goto err1;
36 }
37 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) {
38 pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__);
39 goto err2;
40 }
41 if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) {
42 pr_err("%s: can't request H3XXX_EGPIO_LCD_5V_ON\n", __func__);
43 goto err3;
44 }
45 if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) {
46 pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__);
47 goto err4;
48 }
49 59
50 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable); 60 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
51 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable); 61 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
52 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable); 62 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
53 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable); 63 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
54
55 gpio_free(H3600_EGPIO_LVDD_ON);
56err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
57err3: gpio_free(H3600_EGPIO_LCD_PCI);
58err2: gpio_free(H3XXX_EGPIO_LCD_ON);
59err1: return;
60} 64}
61 65
62static const struct sa1100fb_rgb h3600_rgb_16 = { 66static const struct sa1100fb_rgb h3600_rgb_16 = {