ARM: pxa: PalmTE2: Use gpio arrays in backlight init
Subsystems (5)
PATCH 1/8 ARM: pxa: PalmTE2: Use gpio arrays in backlight init
Use gpio_request_array() / gpio_free_array() in backlight init and exit functions. This makes the code cleaner and less error prone.
--- arch/arm/mach-pxa/palmte2.c | 31 +++++++------------------------ 1 files changed, 7 insertions(+), 24 deletions(-)
arch/arm/mach-pxa/palmte2.c +7 -24
@@ -136,30 +136,14 @@ static struct platform_device palmte2_pxa_keys = {/****************************************************************************** * Backlight ******************************************************************************/ +static struct gpio palmte_bl_gpios[] = { + {GPIO_NR_PALMTE2_BL_POWER ,GPIOF_INIT_LOW ,"Backlight power" }, + {GPIO_NR_PALMTE2_LCD_POWER ,GPIOF_INIT_LOW ,"LCD power" }, +}; +static int palmte2_backlight_init (struct device *dev) { -int ret; - - ret =gpio_request (GPIO_NR_PALMTE2_BL_POWER ,"BL POWER" ); -if (ret) - goto err; - ret =gpio_direction_output (GPIO_NR_PALMTE2_BL_POWER ,0 ); -if (ret) - goto err2; - ret =gpio_request (GPIO_NR_PALMTE2_LCD_POWER ,"LCD POWER" ); -if (ret) - goto err2; - ret =gpio_direction_output (GPIO_NR_PALMTE2_LCD_POWER ,0 ); -if (ret) - goto err3; - -return 0 ; -err3: -gpio_free (GPIO_NR_PALMTE2_LCD_POWER ); -err2: -gpio_free (GPIO_NR_PALMTE2_BL_POWER ); -err: -return ret; +return gpio_request_array (ARRAY_AND_SIZE (palmte_bl_gpios)); }static int palmte2_backlight_notify (struct device *dev,int brightness)
@@ -171,8 +155,7 @@ static int palmte2_backlight_notify(struct device *dev, int brightness)static void palmte2_backlight_exit (struct device *dev) { -gpio_free (GPIO_NR_PALMTE2_BL_POWER ); -gpio_free (GPIO_NR_PALMTE2_LCD_POWER ); +gpio_free_array (ARRAY_AND_SIZE (palmte_bl_gpios)); }static struct platform_pwm_backlight_data palmte2_backlight_data = {
Signature · 1 line
1.7.2.3
PATCH 2/8 ARM: pxa: Use gpio arrays in colibri_pcmcia driver
Use gpio_request_array() / gpio_free_array(), this makes the code cleaner and less error prone.
--- drivers/pcmcia/pxa2xx_colibri.c | 133 ++++++++++++++------------------------ 1 files changed, 49 insertions(+), 84 deletions(-)
drivers/pcmcia/pxa2xx_colibri.c +49 -84
@@ -34,14 +34,24 @@#define COLIBRI320_DETECT_GPIO 81#define COLIBRI320_READY_GPIO 29 -static struct { -int reset_gpio; -int ppen_gpio; -int bvd1_gpio; -int bvd2_gpio; -int detect_gpio; -int ready_gpio; -} colibri_pcmcia_gpio; +enum { +DETECT =0 , +READY =1 , +BVD1 =2 , +BVD2 =3 , +PPEN =4 , +RESET =5 , +}; + +/* Contents of this array are configured on-the-fly in init function */ +static struct gpio colibri_pcmcia_gpios[] = { + {0 ,GPIOF_IN ,"PCMCIA Detect" }, + {0 ,GPIOF_IN ,"PCMCIA Ready" }, + {0 ,GPIOF_IN ,"PCMCIA BVD1" }, + {0 ,GPIOF_IN ,"PCMCIA BVD2" }, + {0 ,GPIOF_INIT_LOW ,"PCMCIA PPEN" }, + {0 ,GPIOF_INIT_HIGH ,"PCMCIA Reset" }, +};static struct pcmcia_irqs colibri_irqs[] = { {
@@ -54,88 +64,42 @@ static int colibri_pcmcia_hw_init(struct soc_pcmcia_socket *skt) {int ret; - ret =gpio_request (colibri_pcmcia_gpio.detect_gpio,"DETECT" ); + ret =gpio_request_array (colibri_pcmcia_gpios, +ARRAY_SIZE (colibri_pcmcia_gpios));if (ret) goto err1; - ret =gpio_direction_input (colibri_pcmcia_gpio.detect_gpio); -if (ret) - goto err2; - - ret =gpio_request (colibri_pcmcia_gpio.ready_gpio,"READY" ); -if (ret) - goto err2; - ret =gpio_direction_input (colibri_pcmcia_gpio.ready_gpio); -if (ret) - goto err3; - ret =gpio_request (colibri_pcmcia_gpio.bvd1_gpio,"BVD1" ); -if (ret) - goto err3; - ret =gpio_direction_input (colibri_pcmcia_gpio.bvd1_gpio); -if (ret) - goto err4; + colibri_irqs[0 ].irq =gpio_to_irq (colibri_pcmcia_gpios[DETECT ].gpio); + skt->socket.pci_irq =gpio_to_irq (colibri_pcmcia_gpios[READY ].gpio); - ret =gpio_request (colibri_pcmcia_gpio.bvd2_gpio,"BVD2" ); -if (ret) - goto err4; - ret =gpio_direction_input (colibri_pcmcia_gpio.bvd2_gpio); -if (ret) - goto err5; - - ret =gpio_request (colibri_pcmcia_gpio.ppen_gpio,"PPEN" ); -if (ret) - goto err5; - ret =gpio_direction_output (colibri_pcmcia_gpio.ppen_gpio,0 ); -if (ret) - goto err6; - - ret =gpio_request (colibri_pcmcia_gpio.reset_gpio,"RESET" ); -if (ret) - goto err6; - ret =gpio_direction_output (colibri_pcmcia_gpio.reset_gpio,1 ); + ret =soc_pcmcia_request_irqs (skt, colibri_irqs, +ARRAY_SIZE (colibri_irqs));if (ret) - goto err7; - - colibri_irqs[0 ].irq =gpio_to_irq (colibri_pcmcia_gpio.detect_gpio); - skt->socket.pci_irq =gpio_to_irq (colibri_pcmcia_gpio.ready_gpio); + goto err2; -return soc_pcmcia_request_irqs (skt, colibri_irqs, -ARRAY_SIZE (colibri_irqs)); +return ret; -err7: -gpio_free (colibri_pcmcia_gpio.detect_gpio); -err6: -gpio_free (colibri_pcmcia_gpio.ready_gpio); -err5: -gpio_free (colibri_pcmcia_gpio.bvd1_gpio); -err4: -gpio_free (colibri_pcmcia_gpio.bvd2_gpio); -err3: -gpio_free (colibri_pcmcia_gpio.reset_gpio); err2: -gpio_free (colibri_pcmcia_gpio.ppen_gpio); +gpio_free_array (colibri_pcmcia_gpios, +ARRAY_SIZE (colibri_pcmcia_gpios)); err1:return ret; }static void colibri_pcmcia_hw_shutdown (struct soc_pcmcia_socket *skt) { -gpio_free (colibri_pcmcia_gpio.detect_gpio); -gpio_free (colibri_pcmcia_gpio.ready_gpio); -gpio_free (colibri_pcmcia_gpio.bvd1_gpio); -gpio_free (colibri_pcmcia_gpio.bvd2_gpio); -gpio_free (colibri_pcmcia_gpio.reset_gpio); -gpio_free (colibri_pcmcia_gpio.ppen_gpio); +gpio_free_array (colibri_pcmcia_gpios, +ARRAY_SIZE (colibri_pcmcia_gpios)); }static void colibri_pcmcia_socket_state (struct soc_pcmcia_socket *skt,struct pcmcia_state *state) { - state->detect = !!gpio_get_value (colibri_pcmcia_gpio.detect_gpio); - state->ready = !!gpio_get_value (colibri_pcmcia_gpio.ready_gpio); - state->bvd1 = !!gpio_get_value (colibri_pcmcia_gpio.bvd1_gpio); - state->bvd2 = !!gpio_get_value (colibri_pcmcia_gpio.bvd2_gpio); + state->detect = !!gpio_get_value (colibri_pcmcia_gpios[DETECT ].gpio); + state->ready = !!gpio_get_value (colibri_pcmcia_gpios[READY ].gpio); + state->bvd1 = !!gpio_get_value (colibri_pcmcia_gpios[BVD1 ].gpio); + state->bvd2 = !!gpio_get_value (colibri_pcmcia_gpios[BVD2 ].gpio); state->wrprot =0 ; state->vs_3v =1 ; state->vs_Xv =0 ;
@@ -145,9 +109,10 @@ static int colibri_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) { - gpio_set_value(colibri_pcmcia_gpio.ppen_gpio, + gpio_set_value(colibri_pcmcia_gpios[PPEN].gpio, !(state->Vcc == 33 && state->Vpp < 50)); -gpio_set_value (colibri_pcmcia_gpio.reset_gpio, state->flags &SS_RESET ); +gpio_set_value (colibri_pcmcia_gpios[RESET ].gpio, + state->flags &SS_RESET );return 0 ; }
@@ -187,20 +152,20 @@ static int __init colibri_pcmcia_init(void)/* Colibri PXA270 */ if (machine_is_colibri ()) { - colibri_pcmcia_gpio.reset_gpio =COLIBRI270_RESET_GPIO ; - colibri_pcmcia_gpio.ppen_gpio =COLIBRI270_PPEN_GPIO ; - colibri_pcmcia_gpio.bvd1_gpio =COLIBRI270_BVD1_GPIO ; - colibri_pcmcia_gpio.bvd2_gpio =COLIBRI270_BVD2_GPIO ; - colibri_pcmcia_gpio.detect_gpio =COLIBRI270_DETECT_GPIO ; - colibri_pcmcia_gpio.ready_gpio =COLIBRI270_READY_GPIO ; + colibri_pcmcia_gpios[RESET ].gpio =COLIBRI270_RESET_GPIO ; + colibri_pcmcia_gpios[PPEN ].gpio =COLIBRI270_PPEN_GPIO ; + colibri_pcmcia_gpios[BVD1 ].gpio =COLIBRI270_BVD1_GPIO ; + colibri_pcmcia_gpios[BVD2 ].gpio =COLIBRI270_BVD2_GPIO ; + colibri_pcmcia_gpios[DETECT ].gpio =COLIBRI270_DETECT_GPIO ; + colibri_pcmcia_gpios[READY ].gpio =COLIBRI270_READY_GPIO ;/* Colibri PXA320 */ }else if (machine_is_colibri320 ()) { - colibri_pcmcia_gpio.reset_gpio =COLIBRI320_RESET_GPIO ; - colibri_pcmcia_gpio.ppen_gpio =COLIBRI320_PPEN_GPIO ; - colibri_pcmcia_gpio.bvd1_gpio =COLIBRI320_BVD1_GPIO ; - colibri_pcmcia_gpio.bvd2_gpio =COLIBRI320_BVD2_GPIO ; - colibri_pcmcia_gpio.detect_gpio =COLIBRI320_DETECT_GPIO ; - colibri_pcmcia_gpio.ready_gpio =COLIBRI320_READY_GPIO ; + colibri_pcmcia_gpios[RESET ].gpio =COLIBRI320_RESET_GPIO ; + colibri_pcmcia_gpios[PPEN ].gpio =COLIBRI320_PPEN_GPIO ; + colibri_pcmcia_gpios[BVD1 ].gpio =COLIBRI320_BVD1_GPIO ; + colibri_pcmcia_gpios[BVD2 ].gpio =COLIBRI320_BVD2_GPIO ; + colibri_pcmcia_gpios[DETECT ].gpio =COLIBRI320_DETECT_GPIO ; + colibri_pcmcia_gpios[READY ].gpio =COLIBRI320_READY_GPIO ; } ret = platform_device_add_data(colibri_pcmcia_device,
Signature · 1 line
1.7.2.3
PATCH 3/8 ARM: pxa: Use gpio arrays in palmld_pcmcia driver
In reply to Marek VasutUse gpio_request_array() / gpio_free_array(), this makes the code cleaner and less error prone.
--- drivers/pcmcia/pxa2xx_palmld.c | 40 +++++++++------------------------------- 1 files changed, 9 insertions(+), 31 deletions(-)
drivers/pcmcia/pxa2xx_palmld.c +9 -31
@@ -20,49 +20,27 @@#include <mach/palmld.h> #include "soc_common.h" +static struct gpio palmld_pcmcia_gpios[] = { + {GPIO_NR_PALMLD_PCMCIA_POWER ,GPIOF_INIT_LOW ,"PCMCIA Power" }, + {GPIO_NR_PALMLD_PCMCIA_RESET ,GPIOF_INIT_HIGH ,"PCMCIA Reset" }, + {GPIO_NR_PALMLD_PCMCIA_READY ,GPIOF_IN ,"PCMCIA Ready" }, +}; +static int palmld_pcmcia_hw_init (struct soc_pcmcia_socket *skt) {int ret; - ret =gpio_request (GPIO_NR_PALMLD_PCMCIA_POWER ,"PCMCIA PWR" ); -if (ret) - goto err1; - ret =gpio_direction_output (GPIO_NR_PALMLD_PCMCIA_POWER ,0 ); -if (ret) - goto err2; - - ret =gpio_request (GPIO_NR_PALMLD_PCMCIA_RESET ,"PCMCIA RST" ); -if (ret) - goto err2; - ret =gpio_direction_output (GPIO_NR_PALMLD_PCMCIA_RESET ,1 ); -if (ret) - goto err3; - - ret =gpio_request (GPIO_NR_PALMLD_PCMCIA_READY ,"PCMCIA RDY" ); -if (ret) - goto err3; - ret =gpio_direction_input (GPIO_NR_PALMLD_PCMCIA_READY ); -if (ret) - goto err4; + ret =gpio_request_array (palmld_pcmcia_gpios, +ARRAY_SIZE (palmld_pcmcia_gpios)); skt->socket.pci_irq =IRQ_GPIO (GPIO_NR_PALMLD_PCMCIA_READY ); -return 0 ; -err4: -gpio_free (GPIO_NR_PALMLD_PCMCIA_READY ); -err3: -gpio_free (GPIO_NR_PALMLD_PCMCIA_RESET ); -err2: -gpio_free (GPIO_NR_PALMLD_PCMCIA_POWER ); -err1:return ret; }static void palmld_pcmcia_hw_shutdown (struct soc_pcmcia_socket *skt) { -gpio_free (GPIO_NR_PALMLD_PCMCIA_READY ); -gpio_free (GPIO_NR_PALMLD_PCMCIA_RESET ); -gpio_free (GPIO_NR_PALMLD_PCMCIA_POWER ); +gpio_free_array (palmld_pcmcia_gpios,ARRAY_SIZE (palmld_pcmcia_gpios)); } static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
Signature · 1 line
1.7.2.3
PATCH 4/8 ARM: pxa: Use gpio arrays in palmtc_pcmcia driver
In reply to Marek VasutUse gpio_request_array() / gpio_free_array(), this makes the code cleaner and less error prone.
--- drivers/pcmcia/pxa2xx_palmtc.c | 73 ++++++--------------------------------- 1 files changed, 12 insertions(+), 61 deletions(-)
drivers/pcmcia/pxa2xx_palmtc.c +12 -61
@@ -21,79 +21,30 @@#include <mach/palmtc.h> #include "soc_common.h" +static struct gpio palmtc_pcmcia_gpios[] = { + {GPIO_NR_PALMTC_PCMCIA_POWER1 ,GPIOF_INIT_LOW ,"PCMCIA Power 1" }, + {GPIO_NR_PALMTC_PCMCIA_POWER2 ,GPIOF_INIT_LOW ,"PCMCIA Power 2" }, + {GPIO_NR_PALMTC_PCMCIA_POWER3 ,GPIOF_INIT_LOW ,"PCMCIA Power 3" }, + {GPIO_NR_PALMTC_PCMCIA_RESET ,GPIOF_INIT_HIGH ,"PCMCIA Reset" }, + {GPIO_NR_PALMTC_PCMCIA_READY ,GPIOF_IN ,"PCMCIA Ready" }, + {GPIO_NR_PALMTC_PCMCIA_PWRREADY ,GPIOF_IN ,"PCMCIA Power Ready" }, +}; +static int palmtc_pcmcia_hw_init (struct soc_pcmcia_socket *skt) {int ret; - ret =gpio_request (GPIO_NR_PALMTC_PCMCIA_POWER1 ,"PCMCIA PWR1" ); -if (ret) - goto err1; - ret =gpio_direction_output (GPIO_NR_PALMTC_PCMCIA_POWER1 ,0 ); -if (ret) - goto err2; - - ret =gpio_request (GPIO_NR_PALMTC_PCMCIA_POWER2 ,"PCMCIA PWR2" ); -if (ret) - goto err2; - ret =gpio_direction_output (GPIO_NR_PALMTC_PCMCIA_POWER2 ,0 ); -if (ret) - goto err3; - - ret =gpio_request (GPIO_NR_PALMTC_PCMCIA_POWER3 ,"PCMCIA PWR3" ); -if (ret) - goto err3; - ret =gpio_direction_output (GPIO_NR_PALMTC_PCMCIA_POWER3 ,0 ); -if (ret) - goto err4; - - ret =gpio_request (GPIO_NR_PALMTC_PCMCIA_RESET ,"PCMCIA RST" ); -if (ret) - goto err4; - ret =gpio_direction_output (GPIO_NR_PALMTC_PCMCIA_RESET ,1 ); -if (ret) - goto err5; - - ret =gpio_request (GPIO_NR_PALMTC_PCMCIA_READY ,"PCMCIA RDY" ); -if (ret) - goto err5; - ret =gpio_direction_input (GPIO_NR_PALMTC_PCMCIA_READY ); -if (ret) - goto err6; - - ret =gpio_request (GPIO_NR_PALMTC_PCMCIA_PWRREADY ,"PCMCIA PWRRDY" ); -if (ret) - goto err6; - ret =gpio_direction_input (GPIO_NR_PALMTC_PCMCIA_PWRREADY ); -if (ret) - goto err7; + ret =gpio_request_array (palmtc_pcmcia_gpios, +ARRAY_SIZE (palmtc_pcmcia_gpios)); skt->socket.pci_irq =IRQ_GPIO (GPIO_NR_PALMTC_PCMCIA_READY ); -return 0 ; -err7: -gpio_free (GPIO_NR_PALMTC_PCMCIA_PWRREADY ); -err6: -gpio_free (GPIO_NR_PALMTC_PCMCIA_READY ); -err5: -gpio_free (GPIO_NR_PALMTC_PCMCIA_RESET ); -err4: -gpio_free (GPIO_NR_PALMTC_PCMCIA_POWER3 ); -err3: -gpio_free (GPIO_NR_PALMTC_PCMCIA_POWER2 ); -err2: -gpio_free (GPIO_NR_PALMTC_PCMCIA_POWER1 ); -err1:return ret; }static void palmtc_pcmcia_hw_shutdown (struct soc_pcmcia_socket *skt) { -gpio_free (GPIO_NR_PALMTC_PCMCIA_PWRREADY ); -gpio_free (GPIO_NR_PALMTC_PCMCIA_READY ); -gpio_free (GPIO_NR_PALMTC_PCMCIA_RESET ); -gpio_free (GPIO_NR_PALMTC_PCMCIA_POWER3 ); -gpio_free (GPIO_NR_PALMTC_PCMCIA_POWER2 ); -gpio_free (GPIO_NR_PALMTC_PCMCIA_POWER1 ); +gpio_free_array (palmtc_pcmcia_gpios,ARRAY_SIZE (palmtc_pcmcia_gpios)); } static void palmtc_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
Signature · 1 line
1.7.2.3
PATCH 5/8 ARM: pxa: Use gpio arrays in palmtx_pcmcia driver
In reply to Marek VasutUse gpio_request_array() / gpio_free_array(), this makes the code cleaner and less error prone.
--- drivers/pcmcia/pxa2xx_palmtx.c | 55 ++++++++-------------------------------- 1 files changed, 11 insertions(+), 44 deletions(-)
drivers/pcmcia/pxa2xx_palmtx.c +11 -44
@@ -13,67 +13,34 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <linux/gpio.h> #include <asm/mach-types.h> - -#include <mach/gpio.h> #include <mach/palmtx.h> -#include "soc_common.h" +static struct gpio palmtx_pcmcia_gpios[] = { + {GPIO_NR_PALMTX_PCMCIA_POWER1 ,GPIOF_INIT_LOW ,"PCMCIA Power 1" }, + {GPIO_NR_PALMTX_PCMCIA_POWER2 ,GPIOF_INIT_LOW ,"PCMCIA Power 2" }, + {GPIO_NR_PALMTX_PCMCIA_RESET ,GPIOF_INIT_HIGH ,"PCMCIA Reset" }, + {GPIO_NR_PALMTX_PCMCIA_READY ,GPIOF_IN ,"PCMCIA Ready" }, +}; +static int palmtx_pcmcia_hw_init (struct soc_pcmcia_socket *skt) {int ret; - ret =gpio_request (GPIO_NR_PALMTX_PCMCIA_POWER1 ,"PCMCIA PWR1" ); -if (ret) - goto err1; - ret =gpio_direction_output (GPIO_NR_PALMTX_PCMCIA_POWER1 ,0 ); -if (ret) - goto err2; - - ret =gpio_request (GPIO_NR_PALMTX_PCMCIA_POWER2 ,"PCMCIA PWR2" ); -if (ret) - goto err2; - ret =gpio_direction_output (GPIO_NR_PALMTX_PCMCIA_POWER2 ,0 ); -if (ret) - goto err3; - - ret =gpio_request (GPIO_NR_PALMTX_PCMCIA_RESET ,"PCMCIA RST" ); -if (ret) - goto err3; - ret =gpio_direction_output (GPIO_NR_PALMTX_PCMCIA_RESET ,1 ); -if (ret) - goto err4; - - ret =gpio_request (GPIO_NR_PALMTX_PCMCIA_READY ,"PCMCIA RDY" ); -if (ret) - goto err4; - ret =gpio_direction_input (GPIO_NR_PALMTX_PCMCIA_READY ); -if (ret) - goto err5; + ret =gpio_request_array (palmtx_pcmcia_gpios, +ARRAY_SIZE (palmtx_pcmcia_gpios)); skt->socket.pci_irq =gpio_to_irq (GPIO_NR_PALMTX_PCMCIA_READY ); -return 0 ; -err5: -gpio_free (GPIO_NR_PALMTX_PCMCIA_READY ); -err4: -gpio_free (GPIO_NR_PALMTX_PCMCIA_RESET ); -err3: -gpio_free (GPIO_NR_PALMTX_PCMCIA_POWER2 ); -err2: -gpio_free (GPIO_NR_PALMTX_PCMCIA_POWER1 ); -err1:return ret; }static void palmtx_pcmcia_hw_shutdown (struct soc_pcmcia_socket *skt) { -gpio_free (GPIO_NR_PALMTX_PCMCIA_READY ); -gpio_free (GPIO_NR_PALMTX_PCMCIA_RESET ); -gpio_free (GPIO_NR_PALMTX_PCMCIA_POWER2 ); -gpio_free (GPIO_NR_PALMTX_PCMCIA_POWER1 ); +gpio_free_array (palmtx_pcmcia_gpios,ARRAY_SIZE (palmtx_pcmcia_gpios)); } static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
Signature · 1 line
1.7.2.3
PATCH 6/8 ARM: pxa: Use gpio arrays in vpac270_pcmcia driver
In reply to Marek VasutUse gpio_request_array() / gpio_free_array(), this makes the code cleaner and less error prone.
--- drivers/pcmcia/pxa2xx_vpac270.c | 107 +++++++++++---------------------------- 1 files changed, 29 insertions(+), 78 deletions(-)
drivers/pcmcia/pxa2xx_vpac270.c +29 -78
@@ -22,6 +22,19 @@#include "soc_common.h" +static struct gpio vpac270_pcmcia_gpios[] = { + {GPIO84_VPAC270_PCMCIA_CD ,GPIOF_IN ,"PCMCIA Card Detect" }, + {GPIO35_VPAC270_PCMCIA_RDY ,GPIOF_IN ,"PCMCIA Ready" }, + {GPIO107_VPAC270_PCMCIA_PPEN ,GPIOF_INIT_LOW ,"PCMCIA PPEN" }, + {GPIO11_VPAC270_PCMCIA_RESET ,GPIOF_INIT_LOW ,"PCMCIA Reset" }, +}; + +static struct gpio vpac270_cf_gpios[] = { + {GPIO17_VPAC270_CF_CD ,GPIOF_IN ,"CF Card Detect" }, + {GPIO12_VPAC270_CF_RDY ,GPIOF_IN ,"CF Ready" }, + {GPIO16_VPAC270_CF_RESET ,GPIOF_INIT_LOW ,"CF Reset" }, +}; +static struct pcmcia_irqs cd_irqs[] = { { .sock =0 ,
@@ -40,96 +53,34 @@ static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)int ret;if (skt->nr ==0 ) { - ret =gpio_request (GPIO84_VPAC270_PCMCIA_CD ,"PCMCIA CD" ); -if (ret) - goto err1; - ret =gpio_direction_input (GPIO84_VPAC270_PCMCIA_CD ); -if (ret) - goto err2; - - ret =gpio_request (GPIO35_VPAC270_PCMCIA_RDY ,"PCMCIA RDY" ); -if (ret) - goto err2; - ret =gpio_direction_input (GPIO35_VPAC270_PCMCIA_RDY ); -if (ret) - goto err3; - - ret =gpio_request (GPIO107_VPAC270_PCMCIA_PPEN ,"PCMCIA PPEN" ); -if (ret) - goto err3; - ret =gpio_direction_output (GPIO107_VPAC270_PCMCIA_PPEN ,0 ); -if (ret) - goto err4; - - ret =gpio_request (GPIO11_VPAC270_PCMCIA_RESET ,"PCMCIA RESET" ); -if (ret) - goto err4; - ret =gpio_direction_output (GPIO11_VPAC270_PCMCIA_RESET ,0 ); -if (ret) - goto err5; + ret =gpio_request_array (vpac270_pcmcia_gpios, +ARRAY_SIZE (vpac270_pcmcia_gpios)); skt->socket.pci_irq =gpio_to_irq (GPIO35_VPAC270_PCMCIA_RDY ); -return soc_pcmcia_request_irqs (skt, &cd_irqs[0 ],1 ); - -err5: -gpio_free (GPIO11_VPAC270_PCMCIA_RESET ); -err4: -gpio_free (GPIO107_VPAC270_PCMCIA_PPEN ); -err3: -gpio_free (GPIO35_VPAC270_PCMCIA_RDY ); -err2: -gpio_free (GPIO84_VPAC270_PCMCIA_CD ); -err1: -return ret; - +if (!ret) + ret =soc_pcmcia_request_irqs (skt, &cd_irqs[0 ],1 ); }else { - ret =gpio_request (GPIO17_VPAC270_CF_CD ,"CF CD" ); -if (ret) - goto err6; - ret =gpio_direction_input (GPIO17_VPAC270_CF_CD ); -if (ret) - goto err7; - - ret =gpio_request (GPIO12_VPAC270_CF_RDY ,"CF RDY" ); -if (ret) - goto err7; - ret =gpio_direction_input (GPIO12_VPAC270_CF_RDY ); -if (ret) - goto err8; - - ret =gpio_request (GPIO16_VPAC270_CF_RESET ,"CF RESET" ); -if (ret) - goto err8; - ret =gpio_direction_output (GPIO16_VPAC270_CF_RESET ,0 ); -if (ret) - goto err9; + ret =gpio_request_array (vpac270_cf_gpios, +ARRAY_SIZE (vpac270_cf_gpios)); skt->socket.pci_irq =gpio_to_irq (GPIO12_VPAC270_CF_RDY ); -return soc_pcmcia_request_irqs (skt, &cd_irqs[1 ],1 ); - -err9: -gpio_free (GPIO16_VPAC270_CF_RESET ); -err8: -gpio_free (GPIO12_VPAC270_CF_RDY ); -err7: -gpio_free (GPIO17_VPAC270_CF_CD ); -err6: -return ret; - +if (!ret) + ret =soc_pcmcia_request_irqs (skt, &cd_irqs[1 ],1 ); } + +return ret; }static void vpac270_pcmcia_hw_shutdown (struct soc_pcmcia_socket *skt) { -gpio_free (GPIO11_VPAC270_PCMCIA_RESET ); -gpio_free (GPIO107_VPAC270_PCMCIA_PPEN ); -gpio_free (GPIO35_VPAC270_PCMCIA_RDY ); -gpio_free (GPIO84_VPAC270_PCMCIA_CD ); -gpio_free (GPIO16_VPAC270_CF_RESET ); -gpio_free (GPIO12_VPAC270_CF_RDY ); -gpio_free (GPIO17_VPAC270_CF_CD ); +if (skt->nr ==0 ) +gpio_request_array (vpac270_pcmcia_gpios, +ARRAY_SIZE (vpac270_pcmcia_gpios)); +else +gpio_request_array (vpac270_cf_gpios, +ARRAY_SIZE (vpac270_cf_gpios)); } static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
Signature · 1 line
1.7.2.3
PATCH 7/8 ARM: pxa: Use gpio arrays in palmld_hdd driver
In reply to Marek VasutUse gpio_request_array() / gpio_free_array(), this makes the code cleaner and less error prone.
This patch also properly frees GPIOs in case ata_host_activate() call fails.
--- drivers/ata/pata_palmld.c | 43 ++++++++++++++++++++++--------------------- 1 files changed, 22 insertions(+), 21 deletions(-)
drivers/ata/pata_palmld.c +22 -21
@@ -33,6 +33,11 @@#define DRV_NAME "pata_palmld" +static struct gpio palmld_hdd_gpios[] = { + {GPIO_NR_PALMLD_IDE_PWEN ,GPIOF_INIT_HIGH ,"HDD Power" }, + {GPIO_NR_PALMLD_IDE_RESET ,GPIOF_INIT_LOW ,"HDD Reset" }, +}; +static struct scsi_host_template palmld_sht = {ATA_PIO_SHT (DRV_NAME ), };
@@ -52,28 +57,23 @@ static __devinit int palmld_pata_probe(struct platform_device *pdev)/* allocate host */ host =ata_host_alloc (&pdev->dev,1 ); -if (!host) -return -ENOMEM ; +if (!host) { + ret = -ENOMEM ; + goto err1; + }/* remap drive's physical memory address */ mem =devm_ioremap (&pdev->dev,PALMLD_IDE_PHYS ,0x1000 ); -if (!mem) -return -ENOMEM ; +if (!mem) { + ret = -ENOMEM ; + goto err1; + }/* request and activate power GPIO, IRQ GPIO */ - ret =gpio_request (GPIO_NR_PALMLD_IDE_PWEN ,"HDD PWR" ); + ret =gpio_request_array (palmld_hdd_gpios, +ARRAY_SIZE (palmld_hdd_gpios));if (ret) goto err1; - ret =gpio_direction_output (GPIO_NR_PALMLD_IDE_PWEN ,1 ); -if (ret) - goto err2; - - ret =gpio_request (GPIO_NR_PALMLD_IDE_RESET ,"HDD RST" ); -if (ret) - goto err2; - ret =gpio_direction_output (GPIO_NR_PALMLD_IDE_RESET ,0 ); -if (ret) - goto err3;/* reset the drive */ gpio_set_value (GPIO_NR_PALMLD_IDE_RESET ,0 );
@@ -96,13 +96,15 @@ static __devinit int palmld_pata_probe(struct platform_device *pdev)ata_sff_std_ports (&ap->ioaddr);/* activate host */ -return ata_host_activate (host,0 ,NULL ,IRQF_TRIGGER_RISING , + ret =ata_host_activate (host,0 ,NULL ,IRQF_TRIGGER_RISING , &palmld_sht); +if (ret) + goto err2; + +return ret; -err3: -gpio_free (GPIO_NR_PALMLD_IDE_RESET ); err2: -gpio_free (GPIO_NR_PALMLD_IDE_PWEN ); +gpio_free_array (palmld_hdd_gpios,ARRAY_SIZE (palmld_hdd_gpios)); err1:return ret; }
@@ -116,8 +118,7 @@ static __devexit int palmld_pata_remove(struct platform_device *dev)/* power down the HDD */ gpio_set_value (GPIO_NR_PALMLD_IDE_PWEN ,0 ); -gpio_free (GPIO_NR_PALMLD_IDE_RESET ); -gpio_free (GPIO_NR_PALMLD_IDE_PWEN ); +gpio_free_array (palmld_hdd_gpios,ARRAY_SIZE (palmld_hdd_gpios));return 0 ; }
Signature · 1 line
1.7.2.3
PATCH 8/8 ARM: pxa: Update copyright notices for Palm devices
In reply to Marek Vasut--- arch/arm/mach-pxa/palm27x.c | 3 +-- drivers/pcmcia/pxa2xx_palmld.c | 2 +- drivers/pcmcia/pxa2xx_palmtc.c | 2 +- drivers/pcmcia/pxa2xx_palmtx.c | 2 +- drivers/pcmcia/pxa2xx_vpac270.c | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-)
arch/arm/mach-pxa/palm27x.c +1 -2
@@ -1,8 +1,7 @@/* * Common code for Palm LD, T5, TX, Z72 * -* Copyright (C) 2010 -* Marek Vasut <[email protected]> +* Copyright (C) 2010-2011 Marek Vasut <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
drivers/pcmcia/pxa2xx_palmld.c +1 -1
@@ -4,7 +4,7 @@* Driver for Palm LifeDrive PCMCIA * * Copyright (C) 2006 Alex Osborne <[email protected]> -* Copyright (C) 2007-2008 Marek Vasut <[email protected]> +* Copyright (C) 2007-2011 Marek Vasut <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
drivers/pcmcia/pxa2xx_palmtc.c +1 -1
@@ -4,7 +4,7 @@* Driver for Palm Tungsten|C PCMCIA * * Copyright (C) 2008 Alex Osborne <[email protected]> -* Copyright (C) 2009 Marek Vasut <[email protected]> +* Copyright (C) 2009-2011 Marek Vasut <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
drivers/pcmcia/pxa2xx_palmtx.c +1 -1
@@ -3,7 +3,7 @@* * Driver for Palm T|X PCMCIA * -* Copyright (C) 2007-2008 Marek Vasut <[email protected]> +* Copyright (C) 2007-2011 Marek Vasut <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
drivers/pcmcia/pxa2xx_vpac270.c +1 -2
@@ -3,8 +3,7 @@* * Driver for Voipac PXA270 PCMCIA and CF sockets * -* Copyright (C) 2010 -* Marek Vasut <[email protected]> +* Copyright (C) 2010-2011 Marek Vasut <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
Signature · 1 line
1.7.2.3