linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MMCI: use _cansleep GPIO functions
@ 2010-09-09 20:31 Linus Walleij
  2010-09-11  5:37 ` Rabin Vincent
  0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2010-09-09 20:31 UTC (permalink / raw)
  To: linux-arm-kernel

Currently the kernel is screaming about slowpath at me for the
wp/cd callbacks. Swicth to the _cansleep variants so as to silence
this. Also remove the double-negate in front of the cd GPIO read.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/mmc/host/mmci.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index f0c7313..082abad 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -614,7 +614,7 @@ static int mmci_get_ro(struct mmc_host *mmc)
 	if (host->gpio_wp == -ENOSYS)
 		return -ENOSYS;
 
-	return gpio_get_value(host->gpio_wp);
+	return gpio_get_value_cansleep(host->gpio_wp);
 }
 
 static int mmci_get_cd(struct mmc_host *mmc)
@@ -629,7 +629,8 @@ static int mmci_get_cd(struct mmc_host *mmc)
 
 		status = plat->status(mmc_dev(host->mmc));
 	} else
-		status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;
+		status = gpio_get_value_cansleep(host->gpio_cd) ^
+			plat->cd_invert;
 
 	/*
 	 * Use positive logic throughout - status is zero for no card,
-- 
1.6.3.3

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-09 20:31 [PATCH] MMCI: use _cansleep GPIO functions Linus Walleij
@ 2010-09-11  5:37 ` Rabin Vincent
  2010-09-11 11:22   ` Linus Walleij
  0 siblings, 1 reply; 9+ messages in thread
From: Rabin Vincent @ 2010-09-11  5:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 10, 2010 at 2:01 AM, Linus Walleij
<linus.walleij@stericsson.com> wrote:
> - ? ? ? ? ? ? ? status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;
> + ? ? ? ? ? ? ? status = gpio_get_value_cansleep(host->gpio_cd) ^
> + ? ? ? ? ? ? ? ? ? ? ? plat->cd_invert;

Why do you remove the double negation?  gpio_get_value*()
can return non-zero values, and we need to make it 1 for the
inversion xor to work.

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-11  5:37 ` Rabin Vincent
@ 2010-09-11 11:22   ` Linus Walleij
  2010-09-11 11:31     ` Linus Walleij
  2010-09-11 11:32     ` Russell King - ARM Linux
  0 siblings, 2 replies; 9+ messages in thread
From: Linus Walleij @ 2010-09-11 11:22 UTC (permalink / raw)
  To: linux-arm-kernel

2010/9/11 Rabin Vincent <rabin@rab.in>:
> On Fri, Sep 10, 2010 at 2:01 AM, Linus Walleij
> <linus.walleij@stericsson.com> wrote:
>> - ? ? ? ? ? ? ? status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;
>> + ? ? ? ? ? ? ? status = gpio_get_value_cansleep(host->gpio_cd) ^
>> + ? ? ? ? ? ? ? ? ? ? ? plat->cd_invert;
>
> Why do you remove the double negation? ?gpio_get_value*()
> can return non-zero values, and we need to make it 1 for the
> inversion xor to work.

Aha I get it. But !! is a bit hard to parse in head is it not...

Cast a non-zero to C internal bool type, negate it and then
negate the negation so the end result is bool, not just
non-zero. I never saw that idiom before.

I don't know if I'm particularly dumb but it makes my reading
take time.

I'll slam in some intermediate bool or something so it's super
clear what's happening, OK?

Yours,
Linus Walleij

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-11 11:22   ` Linus Walleij
@ 2010-09-11 11:31     ` Linus Walleij
  2010-09-11 11:32     ` Russell King - ARM Linux
  1 sibling, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2010-09-11 11:31 UTC (permalink / raw)
  To: linux-arm-kernel

2010/9/11 Linus Walleij <linus.ml.walleij@gmail.com>:

> I'll slam in some intermediate bool or something so it's super
> clear what's happening, OK?

Like this (untested):

From: Linus Walleij <linus.walleij@stericsson.com>
Date: Sat, 11 Sep 2010 13:29:04 +0200
Subject: [PATCH] MMCI: use _cansleep GPIO functions

Currently the kernel is screaming about slowpath at me for the
wp/cd callbacks. Swicth to the _cansleep variants so as to silence
this. Also rewrite the double-negate in front of the cd GPIO read
to make it more clear what is happening.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/mmc/host/mmci.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index f0c7313..603d4d5 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -614,7 +614,7 @@ static int mmci_get_ro(struct mmc_host *mmc)
 	if (host->gpio_wp == -ENOSYS)
 		return -ENOSYS;

-	return gpio_get_value(host->gpio_wp);
+	return gpio_get_value_cansleep(host->gpio_wp);
 }

 static int mmci_get_cd(struct mmc_host *mmc)
@@ -629,7 +629,9 @@ static int mmci_get_cd(struct mmc_host *mmc)

 		status = plat->status(mmc_dev(host->mmc));
 	} else
-		status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;
+		/* Convert the status to boolean and optionally invert */
+		status = (gpio_get_value_cansleep(host->gpio_cd) ? 1 : 0)
+			^ plat->cd_invert;

 	/*
 	 * Use positive logic throughout - status is zero for no card,
-- 
1.7.2.2

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-11 11:22   ` Linus Walleij
  2010-09-11 11:31     ` Linus Walleij
@ 2010-09-11 11:32     ` Russell King - ARM Linux
  2010-09-11 11:39       ` Linus Walleij
  1 sibling, 1 reply; 9+ messages in thread
From: Russell King - ARM Linux @ 2010-09-11 11:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Sep 11, 2010 at 01:22:04PM +0200, Linus Walleij wrote:
> I'll slam in some intermediate bool or something so it's super
> clear what's happening, OK?

No - once you've learnt that !! turns an int into a bool, there's
nothing more that needs to be done.

You'll find !! used throughout the kernel sources.

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-11 11:32     ` Russell King - ARM Linux
@ 2010-09-11 11:39       ` Linus Walleij
  2010-09-11 11:40         ` Russell King - ARM Linux
  2010-09-11 14:08         ` Sergei Shtylyov
  0 siblings, 2 replies; 9+ messages in thread
From: Linus Walleij @ 2010-09-11 11:39 UTC (permalink / raw)
  To: linux-arm-kernel

2010/9/11 Russell King - ARM Linux <linux@arm.linux.org.uk>:

> You'll find !! used throughout the kernel sources.

Aha it's a kernel idiom, OK!!

I'll just test it on hardware and I'll put it in the patch tracker.

From: Linus Walleij <linus.walleij@stericsson.com>
Date: Sat, 11 Sep 2010 13:36:20 +0200
Subject: [PATCH] MMCI: use _cansleep GPIO functions

Currently the kernel is screaming about slowpath at me for the
wp/cd callbacks. Swicth to the _cansleep variants so as to silence
this.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/mmc/host/mmci.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index f0c7313..c5fbf19 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -614,7 +614,7 @@ static int mmci_get_ro(struct mmc_host *mmc)
 	if (host->gpio_wp == -ENOSYS)
 		return -ENOSYS;

-	return gpio_get_value(host->gpio_wp);
+	return gpio_get_value_cansleep(host->gpio_wp);
 }

 static int mmci_get_cd(struct mmc_host *mmc)
@@ -629,7 +629,8 @@ static int mmci_get_cd(struct mmc_host *mmc)

 		status = plat->status(mmc_dev(host->mmc));
 	} else
-		status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;
+		status = !!gpio_get_value_cansleep(host->gpio_cd)
+			^ plat->cd_invert;

 	/*
 	 * Use positive logic throughout - status is zero for no card,
-- 
1.7.2.2

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-11 11:39       ` Linus Walleij
@ 2010-09-11 11:40         ` Russell King - ARM Linux
  2010-09-11 14:08         ` Sergei Shtylyov
  1 sibling, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2010-09-11 11:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Sep 11, 2010 at 01:39:04PM +0200, Linus Walleij wrote:
> 2010/9/11 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> 
> > You'll find !! used throughout the kernel sources.
> 
> Aha it's a kernel idiom, OK!!
> 
> I'll just test it on hardware and I'll put it in the patch tracker.
> 
> From: Linus Walleij <linus.walleij@stericsson.com>
> Date: Sat, 11 Sep 2010 13:36:20 +0200
> Subject: [PATCH] MMCI: use _cansleep GPIO functions
> 
> Currently the kernel is screaming about slowpath at me for the
> wp/cd callbacks. Swicth to the _cansleep variants so as to silence
> this.

You may wish to correct that spelling error.

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-11 11:39       ` Linus Walleij
  2010-09-11 11:40         ` Russell King - ARM Linux
@ 2010-09-11 14:08         ` Sergei Shtylyov
  2010-09-11 14:11           ` Sergei Shtylyov
  1 sibling, 1 reply; 9+ messages in thread
From: Sergei Shtylyov @ 2010-09-11 14:08 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

Linus Walleij wrote:

> From: Linus Walleij <linus.walleij@stericsson.com>
> Date: Sat, 11 Sep 2010 13:36:20 +0200
> Subject: [PATCH] MMCI: use _cansleep GPIO functions

> Currently the kernel is screaming about slowpath at me for the
> wp/cd callbacks. Swicth to the _cansleep variants so as to silence
> this.

> Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
> ---
>  drivers/mmc/host/mmci.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)

> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index f0c7313..c5fbf19 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
[...]
>  static int mmci_get_cd(struct mmc_host *mmc)
> @@ -629,7 +629,8 @@ static int mmci_get_cd(struct mmc_host *mmc)
> 
>  		status = plat->status(mmc_dev(host->mmc));
>  	} else
> -		status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;
> +		status = !!gpio_get_value_cansleep(host->gpio_cd)
> +			^ plat->cd_invert;

    Should be no space between ^ and operand, no?

WBR, Sergei

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

* [PATCH] MMCI: use _cansleep GPIO functions
  2010-09-11 14:08         ` Sergei Shtylyov
@ 2010-09-11 14:11           ` Sergei Shtylyov
  0 siblings, 0 replies; 9+ messages in thread
From: Sergei Shtylyov @ 2010-09-11 14:11 UTC (permalink / raw)
  To: linux-arm-kernel

I wrote:

>> From: Linus Walleij <linus.walleij@stericsson.com>
>> Date: Sat, 11 Sep 2010 13:36:20 +0200
>> Subject: [PATCH] MMCI: use _cansleep GPIO functions

>> Currently the kernel is screaming about slowpath at me for the
>> wp/cd callbacks. Swicth to the _cansleep variants so as to silence
>> this.

>> Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
>> ---
>>  drivers/mmc/host/mmci.c |    5 +++--
>>  1 files changed, 3 insertions(+), 2 deletions(-)

>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index f0c7313..c5fbf19 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
> [...]
>>  static int mmci_get_cd(struct mmc_host *mmc)
>> @@ -629,7 +629,8 @@ static int mmci_get_cd(struct mmc_host *mmc)
>>
>>          status = plat->status(mmc_dev(host->mmc));
>>      } else
>> -        status = !!gpio_get_value(host->gpio_cd) ^ plat->cd_invert;
>> +        status = !!gpio_get_value_cansleep(host->gpio_cd)
>> +            ^ plat->cd_invert;

>    Should be no space between ^ and operand, no?

    Oops, I've mixed it with ~. Still, I'd have left ^ on the first line.

WBR, Sergei

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

end of thread, other threads:[~2010-09-11 14:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-09 20:31 [PATCH] MMCI: use _cansleep GPIO functions Linus Walleij
2010-09-11  5:37 ` Rabin Vincent
2010-09-11 11:22   ` Linus Walleij
2010-09-11 11:31     ` Linus Walleij
2010-09-11 11:32     ` Russell King - ARM Linux
2010-09-11 11:39       ` Linus Walleij
2010-09-11 11:40         ` Russell King - ARM Linux
2010-09-11 14:08         ` Sergei Shtylyov
2010-09-11 14:11           ` Sergei Shtylyov

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).