All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
@ 2011-04-20 19:55 Philipp Zabel
  2011-04-21 21:33 ` Robert Jarzmik
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Zabel @ 2011-04-20 19:55 UTC (permalink / raw)
  To: linux-arm-kernel

gpio_request_arrays() / gpio_free_arrays() are functional replacements for
mio_gpio_request() / mio_gpio_free(), which are now obsolete.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c |   66 +++++++-----------------------------------
 1 files changed, 11 insertions(+), 55 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 23925db..1ce6e5c 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -177,50 +177,6 @@ static unsigned long mioa701_pin_config[] = {
 	MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
 };
 
-#define MIO_GPIO_IN(num, _desc) \
-	{ .gpio = (num), .dir = 0, .desc = (_desc) }
-#define MIO_GPIO_OUT(num, _init, _desc) \
-	{ .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) }
-struct gpio_ress {
-	unsigned gpio : 8;
-	unsigned dir : 1;
-	unsigned init : 1;
-	char *desc;
-};
-
-static int mio_gpio_request(struct gpio_ress *gpios, int size)
-{
-	int i, rc = 0;
-	int gpio;
-	int dir;
-
-	for (i = 0; (!rc) && (i < size); i++) {
-		gpio = gpios[i].gpio;
-		dir = gpios[i].dir;
-		rc = gpio_request(gpio, gpios[i].desc);
-		if (rc) {
-			printk(KERN_ERR "Error requesting GPIO %d(%s) : %d\n",
-			       gpio, gpios[i].desc, rc);
-			continue;
-		}
-		if (dir)
-			gpio_direction_output(gpio, gpios[i].init);
-		else
-			gpio_direction_input(gpio);
-	}
-	while ((rc) && (--i >= 0))
-		gpio_free(gpios[i].gpio);
-	return rc;
-}
-
-static void mio_gpio_free(struct gpio_ress *gpios, int size)
-{
-	int i;
-
-	for (i = 0; i < size; i++)
-		gpio_free(gpios[i].gpio);
-}
-
 /* LCD Screen and Backlight */
 static struct platform_pwm_backlight_data mioa701_backlight_data = {
 	.pwm_id		= 0,
@@ -346,16 +302,16 @@ irqreturn_t gsm_on_irq(int irq, void *p)
 	return IRQ_HANDLED;
 }
 
-struct gpio_ress gsm_gpios[] = {
-	MIO_GPIO_IN(GPIO25_GSM_MOD_ON_STATE, "GSM state"),
-	MIO_GPIO_IN(GPIO113_GSM_EVENT, "GSM event"),
+static struct gpio gsm_gpios[] = {
+	{ GPIO25_GSM_MOD_ON_STATE, GPIOF_IN, "GSM state" },
+	{ GPIO113_GSM_EVENT, GPIOF_IN, "GSM event" },
 };
 
 static int __init gsm_init(void)
 {
 	int rc;
 
-	rc = mio_gpio_request(ARRAY_AND_SIZE(gsm_gpios));
+	rc = gpio_request_array(ARRAY_AND_SIZE(gsm_gpios));
 	if (rc)
 		goto err_gpio;
 	rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq,
@@ -369,7 +325,7 @@ static int __init gsm_init(void)
 
 err_irq:
 	printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n");
-	mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+	gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 err_gpio:
 	printk(KERN_ERR "Mioa701: gsm not available\n");
 	return rc;
@@ -378,7 +334,7 @@ err_gpio:
 static void gsm_exit(void)
 {
 	free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL);
-	mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+	gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 }
 
 /*
@@ -776,10 +732,10 @@ static void mioa701_restart(char c, const char *cmd)
 	arm_machine_restart('s', cmd);
 }
 
-static struct gpio_ress global_gpios[] = {
-	MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"),
-	MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"),
-	MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power"),
+static struct gpio global_gpios[] = {
+	{ GPIO9_CHARGE_EN, GPIOF_OUT_INIT_HIGH, "Charger enable" },
+	{ GPIO18_POWEROFF, GPIOF_OUT_INIT_LOW, "Power Off" },
+	{ GPIO87_LCD_POWER, GPIOF_OUT_INIT_LOW, "LCD Power" },
 };
 
 static void __init mioa701_machine_init(void)
@@ -793,7 +749,7 @@ static void __init mioa701_machine_init(void)
 	pxa_set_ffuart_info(NULL);
 	pxa_set_btuart_info(NULL);
 	pxa_set_stuart_info(NULL);
-	mio_gpio_request(ARRAY_AND_SIZE(global_gpios));
+	gpio_request_array(ARRAY_AND_SIZE(global_gpios));
 	bootstrap_init();
 	pxa_set_fb_info(NULL, &mioa701_pxafb_info);
 	pxa_set_mci_info(&mioa701_mci_info);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
  2011-04-20 19:55 [PATCH] pxa/mioa701: use gpio arrays for global and gsm gpio initialization Philipp Zabel
@ 2011-04-21 21:33 ` Robert Jarzmik
  2011-04-22 10:35   ` pHilipp Zabel
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Jarzmik @ 2011-04-21 21:33 UTC (permalink / raw)
  To: linux-arm-kernel

Philipp Zabel <philipp.zabel@gmail.com> writes:

> gpio_request_arrays() / gpio_free_arrays() are functional replacements for
> mio_gpio_request() / mio_gpio_free(), which are now obsolete.
>
> Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>

Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

--
Robert

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
  2011-04-21 21:33 ` Robert Jarzmik
@ 2011-04-22 10:35   ` pHilipp Zabel
  2011-04-25  3:31     ` Eric Miao
  0 siblings, 1 reply; 8+ messages in thread
From: pHilipp Zabel @ 2011-04-22 10:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 21, 2011 at 11:33 PM, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
> Philipp Zabel <philipp.zabel@gmail.com> writes:
>
>> gpio_request_arrays() / gpio_free_arrays() are functional replacements for
>> mio_gpio_request() / mio_gpio_free(), which are now obsolete.
>>
>> Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
>
> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Dmitry Artamonow pointed out that contrary to
hx4700/mio_gpio_request(), gpio_request_array() is silent when a
request fails. Would you prefer something like

int rc;
rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
if (rc)
    pr_err("MioA701: Failed to request GPIOs.\n");

in there?

regards
Philipp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
  2011-04-22 10:35   ` pHilipp Zabel
@ 2011-04-25  3:31     ` Eric Miao
  2011-04-27 18:50       ` [PATCH v2] " Philipp Zabel
  2011-04-28  7:10       ` [PATCH] " Robert Jarzmik
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Miao @ 2011-04-25  3:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 22, 2011 at 6:35 PM, pHilipp Zabel <philipp.zabel@gmail.com> wrote:
> On Thu, Apr 21, 2011 at 11:33 PM, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
>> Philipp Zabel <philipp.zabel@gmail.com> writes:
>>
>>> gpio_request_arrays() / gpio_free_arrays() are functional replacements for
>>> mio_gpio_request() / mio_gpio_free(), which are now obsolete.
>>>
>>> Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
>>
>> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
>
> Dmitry Artamonow pointed out that contrary to
> hx4700/mio_gpio_request(), gpio_request_array() is silent when a
> request fails. Would you prefer something like
>
> int rc;
> rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
> if (rc)
> ? ?pr_err("MioA701: Failed to request GPIOs.\n");
>
> in there?
>

That will always be good.

> regards
> Philipp
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
  2011-04-25  3:31     ` Eric Miao
@ 2011-04-27 18:50       ` Philipp Zabel
  2011-04-28  7:10       ` [PATCH] " Robert Jarzmik
  1 sibling, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2011-04-27 18:50 UTC (permalink / raw)
  To: linux-arm-kernel

gpio_request_array() / gpio_free_array() are functional replacements for
mio_gpio_request() / mio_gpio_free(), which are now obsolete.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c |   70 +++++++++---------------------------------
 1 files changed, 15 insertions(+), 55 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 23925db..0741e3b 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -177,50 +177,6 @@ static unsigned long mioa701_pin_config[] = {
 	MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
 };
 
-#define MIO_GPIO_IN(num, _desc) \
-	{ .gpio = (num), .dir = 0, .desc = (_desc) }
-#define MIO_GPIO_OUT(num, _init, _desc) \
-	{ .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) }
-struct gpio_ress {
-	unsigned gpio : 8;
-	unsigned dir : 1;
-	unsigned init : 1;
-	char *desc;
-};
-
-static int mio_gpio_request(struct gpio_ress *gpios, int size)
-{
-	int i, rc = 0;
-	int gpio;
-	int dir;
-
-	for (i = 0; (!rc) && (i < size); i++) {
-		gpio = gpios[i].gpio;
-		dir = gpios[i].dir;
-		rc = gpio_request(gpio, gpios[i].desc);
-		if (rc) {
-			printk(KERN_ERR "Error requesting GPIO %d(%s) : %d\n",
-			       gpio, gpios[i].desc, rc);
-			continue;
-		}
-		if (dir)
-			gpio_direction_output(gpio, gpios[i].init);
-		else
-			gpio_direction_input(gpio);
-	}
-	while ((rc) && (--i >= 0))
-		gpio_free(gpios[i].gpio);
-	return rc;
-}
-
-static void mio_gpio_free(struct gpio_ress *gpios, int size)
-{
-	int i;
-
-	for (i = 0; i < size; i++)
-		gpio_free(gpios[i].gpio);
-}
-
 /* LCD Screen and Backlight */
 static struct platform_pwm_backlight_data mioa701_backlight_data = {
 	.pwm_id		= 0,
@@ -346,16 +302,16 @@ irqreturn_t gsm_on_irq(int irq, void *p)
 	return IRQ_HANDLED;
 }
 
-struct gpio_ress gsm_gpios[] = {
-	MIO_GPIO_IN(GPIO25_GSM_MOD_ON_STATE, "GSM state"),
-	MIO_GPIO_IN(GPIO113_GSM_EVENT, "GSM event"),
+static struct gpio gsm_gpios[] = {
+	{ GPIO25_GSM_MOD_ON_STATE, GPIOF_IN, "GSM state" },
+	{ GPIO113_GSM_EVENT, GPIOF_IN, "GSM event" },
 };
 
 static int __init gsm_init(void)
 {
 	int rc;
 
-	rc = mio_gpio_request(ARRAY_AND_SIZE(gsm_gpios));
+	rc = gpio_request_array(ARRAY_AND_SIZE(gsm_gpios));
 	if (rc)
 		goto err_gpio;
 	rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq,
@@ -369,7 +325,7 @@ static int __init gsm_init(void)
 
 err_irq:
 	printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n");
-	mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+	gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 err_gpio:
 	printk(KERN_ERR "Mioa701: gsm not available\n");
 	return rc;
@@ -378,7 +334,7 @@ err_gpio:
 static void gsm_exit(void)
 {
 	free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL);
-	mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+	gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 }
 
 /*
@@ -776,14 +732,16 @@ static void mioa701_restart(char c, const char *cmd)
 	arm_machine_restart('s', cmd);
 }
 
-static struct gpio_ress global_gpios[] = {
-	MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"),
-	MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"),
-	MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power"),
+static struct gpio global_gpios[] = {
+	{ GPIO9_CHARGE_EN, GPIOF_OUT_INIT_HIGH, "Charger enable" },
+	{ GPIO18_POWEROFF, GPIOF_OUT_INIT_LOW, "Power Off" },
+	{ GPIO87_LCD_POWER, GPIOF_OUT_INIT_LOW, "LCD Power" },
 };
 
 static void __init mioa701_machine_init(void)
 {
+	int rc;
+
 	PSLR  = 0xff100000; /* SYSDEL=125ms, PWRDEL=125ms, PSLR_SL_ROD=1 */
 	PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE;
 	RTTR = 32768 - 1; /* Reset crazy WinCE value */
@@ -793,7 +751,9 @@ static void __init mioa701_machine_init(void)
 	pxa_set_ffuart_info(NULL);
 	pxa_set_btuart_info(NULL);
 	pxa_set_stuart_info(NULL);
-	mio_gpio_request(ARRAY_AND_SIZE(global_gpios));
+	rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
+	if (rc)
+		pr_err("MioA701: Failed to request GPIOs.");
 	bootstrap_init();
 	pxa_set_fb_info(NULL, &mioa701_pxafb_info);
 	pxa_set_mci_info(&mioa701_mci_info);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
  2011-04-25  3:31     ` Eric Miao
  2011-04-27 18:50       ` [PATCH v2] " Philipp Zabel
@ 2011-04-28  7:10       ` Robert Jarzmik
  2011-04-28 20:19         ` [PATCH v3] " Philipp Zabel
  1 sibling, 1 reply; 8+ messages in thread
From: Robert Jarzmik @ 2011-04-28  7:10 UTC (permalink / raw)
  To: linux-arm-kernel

Eric Miao <eric.y.miao@gmail.com> writes:

> On Fri, Apr 22, 2011 at 6:35 PM, pHilipp Zabel <philipp.zabel@gmail.com> wrote:
>> On Thu, Apr 21, 2011 at 11:33 PM, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
>>> Philipp Zabel <philipp.zabel@gmail.com> writes:
>>>
>>>> gpio_request_arrays() / gpio_free_arrays() are functional replacements for
>>>> mio_gpio_request() / mio_gpio_free(), which are now obsolete.
>>>>
>>>> Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
>>>
>>> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
>>
>> Dmitry Artamonow pointed out that contrary to
>> hx4700/mio_gpio_request(), gpio_request_array() is silent when a
>> request fails. Would you prefer something like
>>
>> int rc;
>> rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
>> if (rc)
>> ? ?pr_err("MioA701: Failed to request GPIOs.\n");
>>
>> in there?
>>
>
> That will always be good.
Indeed.

pHilipp, keep the ack, the usage of gpio_request_array() is a very good
idea. Reporting the error is even better than saying nothing.

Cheers.

-- 
Robert

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
  2011-04-28  7:10       ` [PATCH] " Robert Jarzmik
@ 2011-04-28 20:19         ` Philipp Zabel
  2011-07-05  7:55           ` Eric Miao
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Zabel @ 2011-04-28 20:19 UTC (permalink / raw)
  To: linux-arm-kernel

gpio_request_array() / gpio_free_array() are functional replacements for
mio_gpio_request() / mio_gpio_free(), which are now obsolete.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/mach-pxa/mioa701.c |   70 +++++++++---------------------------------
 1 files changed, 15 insertions(+), 55 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 23925db..403819c 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -177,50 +177,6 @@ static unsigned long mioa701_pin_config[] = {
 	MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
 };
 
-#define MIO_GPIO_IN(num, _desc) \
-	{ .gpio = (num), .dir = 0, .desc = (_desc) }
-#define MIO_GPIO_OUT(num, _init, _desc) \
-	{ .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) }
-struct gpio_ress {
-	unsigned gpio : 8;
-	unsigned dir : 1;
-	unsigned init : 1;
-	char *desc;
-};
-
-static int mio_gpio_request(struct gpio_ress *gpios, int size)
-{
-	int i, rc = 0;
-	int gpio;
-	int dir;
-
-	for (i = 0; (!rc) && (i < size); i++) {
-		gpio = gpios[i].gpio;
-		dir = gpios[i].dir;
-		rc = gpio_request(gpio, gpios[i].desc);
-		if (rc) {
-			printk(KERN_ERR "Error requesting GPIO %d(%s) : %d\n",
-			       gpio, gpios[i].desc, rc);
-			continue;
-		}
-		if (dir)
-			gpio_direction_output(gpio, gpios[i].init);
-		else
-			gpio_direction_input(gpio);
-	}
-	while ((rc) && (--i >= 0))
-		gpio_free(gpios[i].gpio);
-	return rc;
-}
-
-static void mio_gpio_free(struct gpio_ress *gpios, int size)
-{
-	int i;
-
-	for (i = 0; i < size; i++)
-		gpio_free(gpios[i].gpio);
-}
-
 /* LCD Screen and Backlight */
 static struct platform_pwm_backlight_data mioa701_backlight_data = {
 	.pwm_id		= 0,
@@ -346,16 +302,16 @@ irqreturn_t gsm_on_irq(int irq, void *p)
 	return IRQ_HANDLED;
 }
 
-struct gpio_ress gsm_gpios[] = {
-	MIO_GPIO_IN(GPIO25_GSM_MOD_ON_STATE, "GSM state"),
-	MIO_GPIO_IN(GPIO113_GSM_EVENT, "GSM event"),
+static struct gpio gsm_gpios[] = {
+	{ GPIO25_GSM_MOD_ON_STATE, GPIOF_IN, "GSM state" },
+	{ GPIO113_GSM_EVENT, GPIOF_IN, "GSM event" },
 };
 
 static int __init gsm_init(void)
 {
 	int rc;
 
-	rc = mio_gpio_request(ARRAY_AND_SIZE(gsm_gpios));
+	rc = gpio_request_array(ARRAY_AND_SIZE(gsm_gpios));
 	if (rc)
 		goto err_gpio;
 	rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq,
@@ -369,7 +325,7 @@ static int __init gsm_init(void)
 
 err_irq:
 	printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n");
-	mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+	gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 err_gpio:
 	printk(KERN_ERR "Mioa701: gsm not available\n");
 	return rc;
@@ -378,7 +334,7 @@ err_gpio:
 static void gsm_exit(void)
 {
 	free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL);
-	mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+	gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 }
 
 /*
@@ -776,14 +732,16 @@ static void mioa701_restart(char c, const char *cmd)
 	arm_machine_restart('s', cmd);
 }
 
-static struct gpio_ress global_gpios[] = {
-	MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"),
-	MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"),
-	MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power"),
+static struct gpio global_gpios[] = {
+	{ GPIO9_CHARGE_EN, GPIOF_OUT_INIT_HIGH, "Charger enable" },
+	{ GPIO18_POWEROFF, GPIOF_OUT_INIT_LOW, "Power Off" },
+	{ GPIO87_LCD_POWER, GPIOF_OUT_INIT_LOW, "LCD Power" },
 };
 
 static void __init mioa701_machine_init(void)
 {
+	int rc;
+
 	PSLR  = 0xff100000; /* SYSDEL=125ms, PWRDEL=125ms, PSLR_SL_ROD=1 */
 	PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE;
 	RTTR = 32768 - 1; /* Reset crazy WinCE value */
@@ -793,7 +751,9 @@ static void __init mioa701_machine_init(void)
 	pxa_set_ffuart_info(NULL);
 	pxa_set_btuart_info(NULL);
 	pxa_set_stuart_info(NULL);
-	mio_gpio_request(ARRAY_AND_SIZE(global_gpios));
+	rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
+	if (rc)
+		pr_err("MioA701: Failed to request GPIOs: %d", rc);
 	bootstrap_init();
 	pxa_set_fb_info(NULL, &mioa701_pxafb_info);
 	pxa_set_mci_info(&mioa701_mci_info);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3] pxa/mioa701: use gpio arrays for global and gsm gpio initialization
  2011-04-28 20:19         ` [PATCH v3] " Philipp Zabel
@ 2011-07-05  7:55           ` Eric Miao
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Miao @ 2011-07-05  7:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 29, 2011 at 4:19 AM, Philipp Zabel <philipp.zabel@gmail.com> wrote:
> gpio_request_array() / gpio_free_array() are functional replacements for
> mio_gpio_request() / mio_gpio_free(), which are now obsolete.
>
> Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Applied.

> ---
> ?arch/arm/mach-pxa/mioa701.c | ? 70 +++++++++---------------------------------
> ?1 files changed, 15 insertions(+), 55 deletions(-)
>
> diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
> index 23925db..403819c 100644
> --- a/arch/arm/mach-pxa/mioa701.c
> +++ b/arch/arm/mach-pxa/mioa701.c
> @@ -177,50 +177,6 @@ static unsigned long mioa701_pin_config[] = {
> ? ? ? ?MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
> ?};
>
> -#define MIO_GPIO_IN(num, _desc) \
> - ? ? ? { .gpio = (num), .dir = 0, .desc = (_desc) }
> -#define MIO_GPIO_OUT(num, _init, _desc) \
> - ? ? ? { .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) }
> -struct gpio_ress {
> - ? ? ? unsigned gpio : 8;
> - ? ? ? unsigned dir : 1;
> - ? ? ? unsigned init : 1;
> - ? ? ? char *desc;
> -};
> -
> -static int mio_gpio_request(struct gpio_ress *gpios, int size)
> -{
> - ? ? ? int i, rc = 0;
> - ? ? ? int gpio;
> - ? ? ? int dir;
> -
> - ? ? ? for (i = 0; (!rc) && (i < size); i++) {
> - ? ? ? ? ? ? ? gpio = gpios[i].gpio;
> - ? ? ? ? ? ? ? dir = gpios[i].dir;
> - ? ? ? ? ? ? ? rc = gpio_request(gpio, gpios[i].desc);
> - ? ? ? ? ? ? ? if (rc) {
> - ? ? ? ? ? ? ? ? ? ? ? printk(KERN_ERR "Error requesting GPIO %d(%s) : %d\n",
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?gpio, gpios[i].desc, rc);
> - ? ? ? ? ? ? ? ? ? ? ? continue;
> - ? ? ? ? ? ? ? }
> - ? ? ? ? ? ? ? if (dir)
> - ? ? ? ? ? ? ? ? ? ? ? gpio_direction_output(gpio, gpios[i].init);
> - ? ? ? ? ? ? ? else
> - ? ? ? ? ? ? ? ? ? ? ? gpio_direction_input(gpio);
> - ? ? ? }
> - ? ? ? while ((rc) && (--i >= 0))
> - ? ? ? ? ? ? ? gpio_free(gpios[i].gpio);
> - ? ? ? return rc;
> -}
> -
> -static void mio_gpio_free(struct gpio_ress *gpios, int size)
> -{
> - ? ? ? int i;
> -
> - ? ? ? for (i = 0; i < size; i++)
> - ? ? ? ? ? ? ? gpio_free(gpios[i].gpio);
> -}
> -
> ?/* LCD Screen and Backlight */
> ?static struct platform_pwm_backlight_data mioa701_backlight_data = {
> ? ? ? ?.pwm_id ? ? ? ? = 0,
> @@ -346,16 +302,16 @@ irqreturn_t gsm_on_irq(int irq, void *p)
> ? ? ? ?return IRQ_HANDLED;
> ?}
>
> -struct gpio_ress gsm_gpios[] = {
> - ? ? ? MIO_GPIO_IN(GPIO25_GSM_MOD_ON_STATE, "GSM state"),
> - ? ? ? MIO_GPIO_IN(GPIO113_GSM_EVENT, "GSM event"),
> +static struct gpio gsm_gpios[] = {
> + ? ? ? { GPIO25_GSM_MOD_ON_STATE, GPIOF_IN, "GSM state" },
> + ? ? ? { GPIO113_GSM_EVENT, GPIOF_IN, "GSM event" },
> ?};
>
> ?static int __init gsm_init(void)
> ?{
> ? ? ? ?int rc;
>
> - ? ? ? rc = mio_gpio_request(ARRAY_AND_SIZE(gsm_gpios));
> + ? ? ? rc = gpio_request_array(ARRAY_AND_SIZE(gsm_gpios));
> ? ? ? ?if (rc)
> ? ? ? ? ? ? ? ?goto err_gpio;
> ? ? ? ?rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq,
> @@ -369,7 +325,7 @@ static int __init gsm_init(void)
>
> ?err_irq:
> ? ? ? ?printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n");
> - ? ? ? mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
> + ? ? ? gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
> ?err_gpio:
> ? ? ? ?printk(KERN_ERR "Mioa701: gsm not available\n");
> ? ? ? ?return rc;
> @@ -378,7 +334,7 @@ err_gpio:
> ?static void gsm_exit(void)
> ?{
> ? ? ? ?free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL);
> - ? ? ? mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
> + ? ? ? gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
> ?}
>
> ?/*
> @@ -776,14 +732,16 @@ static void mioa701_restart(char c, const char *cmd)
> ? ? ? ?arm_machine_restart('s', cmd);
> ?}
>
> -static struct gpio_ress global_gpios[] = {
> - ? ? ? MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"),
> - ? ? ? MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"),
> - ? ? ? MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power"),
> +static struct gpio global_gpios[] = {
> + ? ? ? { GPIO9_CHARGE_EN, GPIOF_OUT_INIT_HIGH, "Charger enable" },
> + ? ? ? { GPIO18_POWEROFF, GPIOF_OUT_INIT_LOW, "Power Off" },
> + ? ? ? { GPIO87_LCD_POWER, GPIOF_OUT_INIT_LOW, "LCD Power" },
> ?};
>
> ?static void __init mioa701_machine_init(void)
> ?{
> + ? ? ? int rc;
> +
> ? ? ? ?PSLR ?= 0xff100000; /* SYSDEL=125ms, PWRDEL=125ms, PSLR_SL_ROD=1 */
> ? ? ? ?PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE;
> ? ? ? ?RTTR = 32768 - 1; /* Reset crazy WinCE value */
> @@ -793,7 +751,9 @@ static void __init mioa701_machine_init(void)
> ? ? ? ?pxa_set_ffuart_info(NULL);
> ? ? ? ?pxa_set_btuart_info(NULL);
> ? ? ? ?pxa_set_stuart_info(NULL);
> - ? ? ? mio_gpio_request(ARRAY_AND_SIZE(global_gpios));
> + ? ? ? rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
> + ? ? ? if (rc)
> + ? ? ? ? ? ? ? pr_err("MioA701: Failed to request GPIOs: %d", rc);
> ? ? ? ?bootstrap_init();
> ? ? ? ?pxa_set_fb_info(NULL, &mioa701_pxafb_info);
> ? ? ? ?pxa_set_mci_info(&mioa701_mci_info);
> --
> 1.7.4.4
>
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-07-05  7:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 19:55 [PATCH] pxa/mioa701: use gpio arrays for global and gsm gpio initialization Philipp Zabel
2011-04-21 21:33 ` Robert Jarzmik
2011-04-22 10:35   ` pHilipp Zabel
2011-04-25  3:31     ` Eric Miao
2011-04-27 18:50       ` [PATCH v2] " Philipp Zabel
2011-04-28  7:10       ` [PATCH] " Robert Jarzmik
2011-04-28 20:19         ` [PATCH v3] " Philipp Zabel
2011-07-05  7:55           ` Eric Miao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.