linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 08/11] ARM: pxa: use generic gpio operation instead of gpio register
Date: Thu, 27 Oct 2011 10:23:24 +0100	[thread overview]
Message-ID: <20111027092324.GG19187@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1318858517-22494-9-git-send-email-haojian.zhuang@marvell.com>

On Mon, Oct 17, 2011 at 09:35:14PM +0800, Haojian Zhuang wrote:
> Remove the code of accessing gpio register. Use the generic read
> operation instead.

This patch looks buggy.

> @@ -90,7 +92,7 @@ static int corgi_should_wakeup(unsigned int resume_on_alarm)
>  {
>  	int is_resume = 0;
>  
> -	dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR);
> +	dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", charger_gpios[4].gpio, PEDR);

This code used to read the GPLR0 register and report its value.  With
this change, it how reads the GPIO number and prints that instead.  So
formerly it reported the current state of a set of GPIO signals and
now it reports a gpio number.

>  
>  	if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) {
>  		if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) {
> @@ -124,14 +126,18 @@ static int corgi_should_wakeup(unsigned int resume_on_alarm)
>  
>  static unsigned long corgi_charger_wakeup(void)
>  {
> -	return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) );
> +	unsigned long gplr0;
> +	gplr0 = gpio_get_value(charger_gpios[3].gpio);
> +	return ~gplr0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) );

This also looks very wrong.  gpio_get_value() can return a boolean 0 or 1
value, but you're treating it as a bitmask.

>  }
>  
>  unsigned long corgipm_read_devdata(int type)
>  {
> +	unsigned long gplr0 = 0;
>  	switch(type) {
>  	case SHARPSL_STATUS_ACIN:
> -		return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0);
> +		gplr0 = gpio_get_value(charger_gpios[3].gpio);
> +		return ((gplr0 & GPIO_bit(CORGI_GPIO_AC_IN)) != 0);

Ditto.

>  	case SHARPSL_STATUS_LOCK:
>  		return gpio_get_value(sharpsl_pm.machinfo->gpio_batlock);
>  	case SHARPSL_STATUS_CHRGFULL:
> diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
> index 094279a..adf87ed 100644
> --- a/arch/arm/mach-pxa/spitz_pm.c
> +++ b/arch/arm/mach-pxa/spitz_pm.c
> @@ -41,6 +41,7 @@ static int spitz_last_ac_status;
>  static struct gpio spitz_charger_gpios[] = {
>  	{ SPITZ_GPIO_KEY_INT,	GPIOF_IN, "Keyboard Interrupt" },
>  	{ SPITZ_GPIO_SYNC,	GPIOF_IN, "Sync" },
> +	{ SPITZ_GPIO_AC_IN,     GPIOF_IN, "Charger Detection" },
>  	{ SPITZ_GPIO_ADC_TEMP_ON, GPIOF_OUT_INIT_LOW, "ADC Temp On" },
>  	{ SPITZ_GPIO_JK_B,	  GPIOF_OUT_INIT_LOW, "JK B" },
>  	{ SPITZ_GPIO_CHRG_ON,	  GPIOF_OUT_INIT_LOW, "Charger On" },
> @@ -169,14 +170,18 @@ static int spitz_should_wakeup(unsigned int resume_on_alarm)
>  
>  static unsigned long spitz_charger_wakeup(void)
>  {
> -	return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC));
> +	unsigned long gplr0;
> +	gplr0 = gpio_get_value(spitz_charger_gpios[0].gpio);
> +	return (~gplr0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (gplr0 & GPIO_bit(SPITZ_GPIO_SYNC));

Ditto.

>  }
>  
>  unsigned long spitzpm_read_devdata(int type)
>  {
> +	unsigned long gplr = 0;
>  	switch (type) {
>  	case SHARPSL_STATUS_ACIN:
> -		return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);
> +		gplr = gpio_get_value(spitz_charger_gpios[2].gpio);
> +		return ((~gplr & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);

Ditto.

>  	case SHARPSL_STATUS_LOCK:
>  		return gpio_get_value(sharpsl_pm.machinfo->gpio_batlock);
>  	case SHARPSL_STATUS_CHRGFULL:
> -- 
> 1.7.2.5
> 

  reply	other threads:[~2011-10-27  9:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17 13:35 [PATCH v5 00/11] change gpio as platform driver Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 01/11] ARM: pxa: rename IRQ_GPIO to PXA_GPIO_TO_IRQ Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 02/11] ARM: pxa: use chained interrupt for GPIO0 and GPIO1 Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 03/11] ARM: pxa: rename gpio_to_irq and irq_to_gpio Haojian Zhuang
2011-10-27  9:17   ` Russell King - ARM Linux
2011-11-07  7:14     ` Haojian Zhuang
2011-11-07  8:49       ` Russell King - ARM Linux
2011-10-17 13:35 ` [PATCH v5 04/11] ARM: pxa: recognize gpio number and type Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 05/11] ARM: pxa: rename NR_BUILTIN_GPIO Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 06/11] ARM: pxa: remove head file in plat-pxa Haojian Zhuang
2011-10-27  9:20   ` Russell King - ARM Linux
2011-10-17 13:35 ` [PATCH v5 07/11] ARM: pxa: use little endian read write in gpio driver Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 08/11] ARM: pxa: use generic gpio operation instead of gpio register Haojian Zhuang
2011-10-27  9:23   ` Russell King - ARM Linux [this message]
2011-10-17 13:35 ` [PATCH v5 09/11] ARM: pxa: change gpio to platform device Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 10/11] ARM: mmp: clear gpio edge detect Haojian Zhuang
2011-10-17 13:35 ` [PATCH v5 11/11] ARM: pxa: add clk support in gpio driver Haojian Zhuang
2011-10-27  9:25   ` Russell King - ARM Linux
2011-10-25  7:13 ` [PATCH v5 00/11] change gpio as platform driver Haojian Zhuang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111027092324.GG19187@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).