SUPERH platform development
 help / color / mirror / Atom feed
* Re: [PATCH 2/2 v3] net/smsc911x: Add regulator support
From: Mike Frysinger @ 2011-10-27 20:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Linus Walleij, netdev, Steve Glendinning, Mathieu Poirer,
	Robert Marklund, Paul Mundt, linux-sh, Sascha Hauer,
	Tony Lindgren, linux-omap, uclinux-dist-devel, Linus Walleij
In-Reply-To: <20111027154638.GA16946@sirena.org.uk>

On Thu, Oct 27, 2011 at 17:46, Mark Brown wrote:
> On Thu, Oct 27, 2011 at 03:21:47PM +0200, Mike Frysinger wrote:
>> my gut reaction: smsc911x is working just fine without regulator
>> support for many people, so why do we suddenly need to make it a
>> requirement ?  this is a fairly small amount of code, so adding a
>> smsc911x Kconfig symbol to control the regulator support seems like
>> overkill.  only other option would be to change the patch to not make
>> missing regulators non-fatal.  so i'd probably lean towards the latter
>> (and it sounds like you changed this with earlier versions).
>
> The regulator API contains a series of generic facilities for stubbing
> itself out when not in use - there's no need for individual drivers to
> worry about this stuff, they should just rely on the framework.  The
> main one at the minute is REGULATOR_DUMMY which does what you suggest
> and makes regulator_get() never fail.

i saw that !CONFIG_REGULATOR works great.  my concern is that these
boards don't define any regulators for smsc resources, so if
CONFIG_REGULATOR is enabled to test out unrelated daughter cards, i
don't want the network driver suddenly failing.  Linus' comments
suggest that this is what would happen unless each board file has its
smsc platform resources extended.  maybe i misunderstood what he was saying ?
-mike

^ permalink raw reply

* Re: [PATCH 2/2 v3] net/smsc911x: Add regulator support
From: Mark Brown @ 2011-10-27 15:46 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: Linus Walleij, netdev, Steve Glendinning, Mathieu Poirer,
	Robert Marklund, Paul Mundt, linux-sh, Sascha Hauer,
	Tony Lindgren, linux-omap, uclinux-dist-devel, Linus Walleij
In-Reply-To: <CAJaTeTrzFwxsn22U-NHQ8iCiaUM+mj8PyicavR-DN0HgE08ZEQ@mail.gmail.com>

On Thu, Oct 27, 2011 at 03:21:47PM +0200, Mike Frysinger wrote:

> my gut reaction: smsc911x is working just fine without regulator
> support for many people, so why do we suddenly need to make it a
> requirement ?  this is a fairly small amount of code, so adding a
> smsc911x Kconfig symbol to control the regulator support seems like
> overkill.  only other option would be to change the patch to not make
> missing regulators non-fatal.  so i'd probably lean towards the latter
> (and it sounds like you changed this with earlier versions).

The regulator API contains a series of generic facilities for stubbing
itself out when not in use - there's no need for individual drivers to
worry about this stuff, they should just rely on the framework.  The
main one at the minute is REGULATOR_DUMMY which does what you suggest
and makes regulator_get() never fail.

^ permalink raw reply

* Re: [PATCH 2/2 v3] net/smsc911x: Add regulator support
From: Mike Frysinger @ 2011-10-27 13:21 UTC (permalink / raw)
  To: Linus Walleij
  Cc: netdev, Steve Glendinning, Mathieu Poirer, Robert Marklund,
	Paul Mundt, linux-sh, Sascha Hauer, Tony Lindgren, linux-omap,
	uclinux-dist-devel, Linus Walleij
In-Reply-To: <1319719691-15799-1-git-send-email-linus.walleij@stericsson.com>

On Thu, Oct 27, 2011 at 14:48, Linus Walleij wrote:
> Platforms that use regulators and the smsc911x and have no defined
> regulator for the smsc911x and claim complete regulator
> constraints with no dummy regulators will need to provide it, for
> example using a fixed voltage regulator. It appears that this may
> affect (apart from Ux500 Snowball) possibly these archs/machines
> that from some grep:s appear to define both CONFIG_SMSC911X and
> CONFIG_REGULATOR:
>
> - ARM Freescale mx3 and OMAP 2 plus, Raumfeld machines
> - Blackfin
> - Super-H

no Blackfin board in the tree uses regulators by default.  we do list
regulator resources with some boards so people can rebuild the
development system to support addon daughter cards.

my gut reaction: smsc911x is working just fine without regulator
support for many people, so why do we suddenly need to make it a
requirement ?  this is a fairly small amount of code, so adding a
smsc911x Kconfig symbol to control the regulator support seems like
overkill.  only other option would be to change the patch to not make
missing regulators non-fatal.  so i'd probably lean towards the latter
(and it sounds like you changed this with earlier versions).

> --- a/drivers/net/ethernet/smsc/smsc911x.c
> +++ b/drivers/net/ethernet/smsc/smsc911x.c
>
> +#define SMSC911X_NUM_SUPPLIES 2

this gets used once (to define the array), so i wonder if it shouldn't
just be inlined

> +static int smsc911x_enable_disable_resources(struct platform_device *pdev,
> +                                            bool enable)
> +{
> ...
> +       if (enable) {
> +               ret = regulator_bulk_enable(ARRAY_SIZE(pdata->supplies),
> +                               pdata->supplies);
> +               if (ret)
> +                       netdev_err(ndev, "failed to enable regulators %d\n",
> +                                       ret);
> ...
> static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
> ...
> +       retval = smsc911x_request_free_resources(pdev, true);
> +       if (retval) {
> +               pr_err("Could request regulators needed aborting\n");

you warn twice here, and the grammar in the later error is broken, and
uses pr_err() instead of netdev_err().  i would simply drop the latter
pr_err().

> +static int smsc911x_request_free_resources(struct platform_device *pdev,
> +               bool request)
> +{
> ...
> +       if (request) {
> +               ret = regulator_bulk_get(&pdev->dev,
> +                               ARRAY_SIZE(pdata->supplies),
> +                               pdata->supplies);
> +               if (ret)
> +                       netdev_err(ndev, "couldn't get regulators %d\n",
> +                                       ret);
> static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
> ...
> +       retval = smsc911x_enable_disable_resources(pdev, true);
> +       if (retval) {
> +               pr_err("Could enable regulators needed aborting\n");

same exact issues with the request/free helper

> +       retval = smsc911x_request_free_resources(pdev, false);
> +       /* ignore not all have regulators */

old comment ?
-mike

^ permalink raw reply

* [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers
From: Mike Frysinger @ 2011-10-27 13:01 UTC (permalink / raw)
  To: Grant Likely, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Haavard Skinnemoen <hskin>
  Cc: linux-alpha, linux-arch, linux-ia64, microblaze-uclinux,
	linux-mips, linux-sh, linux, linuxppc-dev, sparclinux, x86,
	linux-arm-kernel, uclinux-dist-devel, linux-kernel,
	Mike Frysinger, linux-m68k
In-Reply-To: <1319528012-19006-1-git-send-email-broonie@opensource.wolfsonmicro.com>

Rather than requiring architectures that use gpiolib but don't have
any need to define anything custom to copy an asm/gpio.h, merge this
code into the asm-generic/gpio.h.  We add ifdef checks so that arches
can still override things while using the asm-generic/gpio.h, but on
a more fine grained per-func approach.

I've compile tested these guys (with & without GPIOLIB), but don't
have the hardware to boot:
	- alpha defconfig
	- arm defconfig
	- blackfin defconfig
	- ia64 defconfig
	- mips: ar7 & ath79 & bcm47xx & bcm63xx & ip22 defconfig
	- powerpc: mpc85xx & ppc64 defconfig
	- sh: kfr2r09 defconfig
	- sparc defconfig
	- x86_64 defconfig

I don't have any toolchains for avr32, microblaze, openrisc, unicore32,
or xtensa.  So they lose :x.

I don't see m68k supporting gpoilib, so I've just ignored it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/alpha/include/asm/Kbuild                   |    2 +
 arch/alpha/include/asm/gpio.h                   |   55 -------------------
 arch/arm/include/asm/gpio.h                     |   13 +++--
 arch/avr32/mach-at32ap/include/mach/gpio.h      |   19 +------
 arch/blackfin/include/asm/gpio.h                |   16 ++----
 arch/ia64/include/asm/Kbuild                    |    2 +
 arch/ia64/include/asm/gpio.h                    |   55 -------------------
 arch/microblaze/include/asm/Kbuild              |    2 +
 arch/microblaze/include/asm/gpio.h              |   53 ------------------
 arch/mips/include/asm/mach-ar7/gpio.h           |    5 --
 arch/mips/include/asm/mach-ath79/gpio.h         |    8 ++-
 arch/mips/include/asm/mach-bcm47xx/gpio.h       |    3 +
 arch/mips/include/asm/mach-bcm63xx/gpio.h       |    5 --
 arch/mips/include/asm/mach-generic/gpio.h       |    8 +--
 arch/mips/include/asm/mach-loongson/gpio.h      |    7 +--
 arch/mips/include/asm/mach-rc32434/gpio.h       |   10 +---
 arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h |   12 +---
 arch/openrisc/include/asm/Kbuild                |    1 +
 arch/openrisc/include/asm/gpio.h                |   65 -----------------------
 arch/powerpc/include/asm/Kbuild                 |    2 +
 arch/powerpc/include/asm/gpio.h                 |   53 ------------------
 arch/sh/include/asm/gpio.h                      |   32 +-----------
 arch/sparc/include/asm/Kbuild                   |    1 +
 arch/sparc/include/asm/gpio.h                   |   36 -------------
 arch/unicore32/include/asm/gpio.h               |    8 ++-
 arch/x86/include/asm/Kbuild                     |    2 +
 arch/x86/include/asm/gpio.h                     |   53 ------------------
 arch/xtensa/include/asm/Kbuild                  |    2 +
 arch/xtensa/include/asm/gpio.h                  |   56 -------------------
 include/asm-generic/gpio.h                      |   23 ++++++++
 30 files changed, 81 insertions(+), 528 deletions(-)
 delete mode 100644 arch/alpha/include/asm/gpio.h
 delete mode 100644 arch/ia64/include/asm/gpio.h
 delete mode 100644 arch/microblaze/include/asm/gpio.h
 delete mode 100644 arch/openrisc/include/asm/gpio.h
 delete mode 100644 arch/powerpc/include/asm/gpio.h
 delete mode 100644 arch/sparc/include/asm/gpio.h
 delete mode 100644 arch/x86/include/asm/gpio.h
 delete mode 100644 arch/xtensa/include/asm/gpio.h

diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index e423def..0bcff1a 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -1,5 +1,7 @@
 include include/asm-generic/Kbuild.asm
 
+generic-y += gpio.h
+
 header-y += compiler.h
 header-y += console.h
 header-y += fpu.h
diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h
deleted file mode 100644
index 7dc6a63..0000000
--- a/arch/alpha/include/asm/gpio.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Generic GPIO API implementation for Alpha.
- *
- * A stright copy of that for PowerPC which was:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_ALPHA_GPIO_H
-#define _ASM_ALPHA_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_ALPHA_GPIO_H */
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
index 11ad0bf..741efb2 100644
--- a/arch/arm/include/asm/gpio.h
+++ b/arch/arm/include/asm/gpio.h
@@ -5,14 +5,15 @@
 #include <mach/gpio.h>
 
 #ifndef __ARM_GPIOLIB_COMPLEX
+/* assume the mach has defined this */
+#ifndef irq_to_gpio
+#define irq_to_gpio irq_to_gpio
+#endif
+
 /* Note: this may rely upon the value of ARCH_NR_GPIOS set in mach/gpio.h */
 #include <asm-generic/gpio.h>
 
-/* The trivial gpiolib dispatchers */
-#define gpio_get_value  __gpio_get_value
-#define gpio_set_value  __gpio_set_value
-#define gpio_cansleep   __gpio_cansleep
-#endif
+#else
 
 /*
  * Provide a default gpio_to_irq() which should satisfy every case.
@@ -23,4 +24,6 @@
 #define gpio_to_irq	__gpio_to_irq
 #endif
 
+#endif
+
 #endif /* _ARCH_ARM_GPIO_H */
diff --git a/arch/avr32/mach-at32ap/include/mach/gpio.h b/arch/avr32/mach-at32ap/include/mach/gpio.h
index 0180f58..f2ff962 100644
--- a/arch/avr32/mach-at32ap/include/mach/gpio.h
+++ b/arch/avr32/mach-at32ap/include/mach/gpio.h
@@ -10,26 +10,13 @@
  */
 #define ARCH_NR_GPIOS	(NR_GPIO_IRQS + 2 * 32)
 
+/* We implement a few ourself */
+#define gpio_to_irq gpio_to_irq
+#define irq_to_gpio irq_to_gpio
 
 /* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */
 #include <asm-generic/gpio.h>
 
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-
 static inline int gpio_to_irq(unsigned int gpio)
 {
 	if (gpio < NR_GPIO_IRQS)
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h
index 5a25856..6e25dcc 100644
--- a/arch/blackfin/include/asm/gpio.h
+++ b/arch/blackfin/include/asm/gpio.h
@@ -189,6 +189,12 @@ void bfin_gpio_set_value(unsigned gpio, int value);
 #include <asm/errno.h>
 
 #ifdef CONFIG_GPIOLIB
+
+/* We implement a few ourself */
+#define gpio_get_value gpio_get_value
+#define gpio_set_value gpio_set_value
+#define irq_to_gpio irq_to_gpio
+
 #include <asm-generic/gpio.h>		/* cansleep wrappers */
 
 static inline int gpio_get_value(unsigned int gpio)
@@ -207,16 +213,6 @@ static inline void gpio_set_value(unsigned int gpio, int value)
 		__gpio_set_value(gpio, value);
 }
 
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
 #else /* !CONFIG_GPIOLIB */
 
 static inline int gpio_request(unsigned gpio, const char *label)
diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild
index 241d1c5..d0fdd2d 100644
--- a/arch/ia64/include/asm/Kbuild
+++ b/arch/ia64/include/asm/Kbuild
@@ -1,5 +1,7 @@
 include include/asm-generic/Kbuild.asm
 
+generic-y += gpio.h
+
 header-y += break.h
 header-y += fpu.h
 header-y += gcc_intrin.h
diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h
deleted file mode 100644
index 590a20d..0000000
--- a/arch/ia64/include/asm/gpio.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Generic GPIO API implementation for IA-64.
- *
- * A stright copy of that for PowerPC which was:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_IA64_GPIO_H
-#define _ASM_IA64_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_IA64_GPIO_H */
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild
index db5294c..5bf1ca7 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -1,3 +1,5 @@
 include include/asm-generic/Kbuild.asm
 
+generic-y += gpio.h
+
 header-y  += elf.h
diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h
deleted file mode 100644
index 2b2c18b..0000000
--- a/arch/microblaze/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for PowerPC.
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_MICROBLAZE_GPIO_H
-#define _ASM_MICROBLAZE_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_MICROBLAZE_GPIO_H */
diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h
index c177cd1..78f40c2 100644
--- a/arch/mips/include/asm/mach-ar7/gpio.h
+++ b/arch/mips/include/asm/mach-ar7/gpio.h
@@ -27,11 +27,6 @@
 
 #define gpio_to_irq(gpio)	-1
 
-#define gpio_get_value __gpio_get_value
-#define gpio_set_value __gpio_set_value
-
-#define gpio_cansleep __gpio_cansleep
-
 /* Board specific GPIO functions */
 int ar7_gpio_enable(unsigned gpio);
 int ar7_gpio_disable(unsigned gpio);
diff --git a/arch/mips/include/asm/mach-ath79/gpio.h b/arch/mips/include/asm/mach-ath79/gpio.h
index 60dcb62..2c570a0 100644
--- a/arch/mips/include/asm/mach-ath79/gpio.h
+++ b/arch/mips/include/asm/mach-ath79/gpio.h
@@ -13,6 +13,12 @@
 #ifndef __ASM_MACH_ATH79_GPIO_H
 #define __ASM_MACH_ATH79_GPIO_H
 
+/* We implement a few ourself */
+#define gpio_get_value gpio_get_value
+#define gpio_set_value gpio_set_value
+#define gpio_to_irq gpio_to_irq
+#define irq_to_gpio irq_to_gpio
+
 #define ARCH_NR_GPIOS	64
 #include <asm-generic/gpio.h>
 
@@ -21,6 +27,4 @@ int irq_to_gpio(unsigned irq);
 int gpio_get_value(unsigned gpio);
 void gpio_set_value(unsigned gpio, int value);
 
-#define gpio_cansleep	__gpio_cansleep
-
 #endif /* __ASM_MACH_ATH79_GPIO_H */
diff --git a/arch/mips/include/asm/mach-bcm47xx/gpio.h b/arch/mips/include/asm/mach-bcm47xx/gpio.h
index 76961ca..d678316 100644
--- a/arch/mips/include/asm/mach-bcm47xx/gpio.h
+++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h
@@ -19,6 +19,7 @@
 extern int gpio_request(unsigned gpio, const char *label);
 extern void gpio_free(unsigned gpio);
 extern int gpio_to_irq(unsigned gpio);
+#define gpio_to_irq gpio_to_irq
 
 static inline int gpio_get_value(unsigned gpio)
 {
@@ -35,6 +36,7 @@ static inline int gpio_get_value(unsigned gpio)
 	}
 	return -EINVAL;
 }
+#define gpio_get_value gpio_get_value
 
 static inline void gpio_set_value(unsigned gpio, int value)
 {
@@ -53,6 +55,7 @@ static inline void gpio_set_value(unsigned gpio, int value)
 #endif
 	}
 }
+#define gpio_set_value gpio_set_value
 
 static inline int gpio_direction_input(unsigned gpio)
 {
diff --git a/arch/mips/include/asm/mach-bcm63xx/gpio.h b/arch/mips/include/asm/mach-bcm63xx/gpio.h
index 1eb534d..c71bf66 100644
--- a/arch/mips/include/asm/mach-bcm63xx/gpio.h
+++ b/arch/mips/include/asm/mach-bcm63xx/gpio.h
@@ -5,11 +5,6 @@
 
 #define gpio_to_irq(gpio)	-1
 
-#define gpio_get_value __gpio_get_value
-#define gpio_set_value __gpio_set_value
-
-#define gpio_cansleep __gpio_cansleep
-
 #include <asm-generic/gpio.h>
 
 #endif /* __ASM_MIPS_MACH_BCM63XX_GPIO_H */
diff --git a/arch/mips/include/asm/mach-generic/gpio.h b/arch/mips/include/asm/mach-generic/gpio.h
index b4e7020..e8a89c5 100644
--- a/arch/mips/include/asm/mach-generic/gpio.h
+++ b/arch/mips/include/asm/mach-generic/gpio.h
@@ -1,11 +1,7 @@
 #ifndef __ASM_MACH_GENERIC_GPIO_H
 #define __ASM_MACH_GENERIC_GPIO_H
 
-#ifdef CONFIG_GPIOLIB
-#define gpio_get_value	__gpio_get_value
-#define gpio_set_value	__gpio_set_value
-#define gpio_cansleep	__gpio_cansleep
-#else
+#ifndef CONFIG_GPIOLIB
 int gpio_request(unsigned gpio, const char *label);
 void gpio_free(unsigned gpio);
 int gpio_direction_input(unsigned gpio);
@@ -14,7 +10,9 @@ int gpio_get_value(unsigned gpio);
 void gpio_set_value(unsigned gpio, int value);
 #endif
 int gpio_to_irq(unsigned gpio);
+#define gpio_to_irq gpio_to_irq
 int irq_to_gpio(unsigned irq);
+#define irq_to_gpio irq_to_gpio
 
 #include <asm-generic/gpio.h>		/* cansleep wrappers */
 
diff --git a/arch/mips/include/asm/mach-loongson/gpio.h b/arch/mips/include/asm/mach-loongson/gpio.h
index e30e73d..df6efc0 100644
--- a/arch/mips/include/asm/mach-loongson/gpio.h
+++ b/arch/mips/include/asm/mach-loongson/gpio.h
@@ -13,6 +13,8 @@
 #ifndef	__STLS2F_GPIO_H
 #define	__STLS2F_GPIO_H
 
+#define gpio_to_irq gpio_to_irq
+
 #include <asm-generic/gpio.h>
 
 extern void gpio_set_value(unsigned gpio, int value);
@@ -27,9 +29,4 @@ static inline int gpio_to_irq(int gpio)
 	return -EINVAL;
 }
 
-static inline int irq_to_gpio(int gpio)
-{
-	return -EINVAL;
-}
-
 #endif				/* __STLS2F_GPIO_H */
diff --git a/arch/mips/include/asm/mach-rc32434/gpio.h b/arch/mips/include/asm/mach-rc32434/gpio.h
index 12ee8d5..8b0815b 100644
--- a/arch/mips/include/asm/mach-rc32434/gpio.h
+++ b/arch/mips/include/asm/mach-rc32434/gpio.h
@@ -13,18 +13,14 @@
 #ifndef _RC32434_GPIO_H_
 #define _RC32434_GPIO_H_
 
+#define gpio_to_irq(gpio)	(8 + 4 * 32 + gpio)
+#define irq_to_gpio(irq)	(irq - (8 + 4 * 32))
+
 #include <linux/types.h>
 #include <asm-generic/gpio.h>
 
 #define NR_BUILTIN_GPIO		32
 
-#define gpio_get_value	__gpio_get_value
-#define gpio_set_value	__gpio_set_value
-#define gpio_cansleep	__gpio_cansleep
-
-#define gpio_to_irq(gpio)	(8 + 4 * 32 + gpio)
-#define irq_to_gpio(irq)	(irq - (8 + 4 * 32))
-
 struct rb532_gpio_reg {
 	u32   gpiofunc;   /* GPIO Function Register
 			   * gpiofunc[x]=0 bit = gpio
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h
index ebdbab9..8356a8e 100644
--- a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h
@@ -11,16 +11,15 @@
 #ifndef __PMC_MSP71XX_GPIO_H
 #define __PMC_MSP71XX_GPIO_H
 
+/* We implement a few ourself */
+#define gpio_to_irq gpio_to_irq
+
 /* Max number of gpio's is 28 on chip plus 3 banks of I2C IO Expanders */
 #define ARCH_NR_GPIOS (28 + (3 * 8))
 
 /* new generic GPIO API - see Documentation/gpio.txt */
 #include <asm-generic/gpio.h>
 
-#define gpio_get_value	__gpio_get_value
-#define gpio_set_value	__gpio_set_value
-#define gpio_cansleep	__gpio_cansleep
-
 /* Setup calls for the gpio and gpio extended */
 extern void msp71xx_init_gpio(void);
 extern void msp71xx_init_gpio_extended(void);
@@ -38,9 +37,4 @@ static inline int gpio_to_irq(unsigned gpio)
 	return -EINVAL;
 }
 
-static inline int irq_to_gpio(unsigned irq)
-{
-	return -EINVAL;
-}
-
 #endif /* __PMC_MSP71XX_GPIO_H */
diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild
index 11162e6..03f0823 100644
--- a/arch/openrisc/include/asm/Kbuild
+++ b/arch/openrisc/include/asm/Kbuild
@@ -23,6 +23,7 @@ generic-y += fb.h
 generic-y += fcntl.h
 generic-y += ftrace.h
 generic-y += futex.h
+generic-y += gpio.h
 generic-y += hardirq.h
 generic-y += hw_irq.h
 generic-y += ioctl.h
diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h
deleted file mode 100644
index 0b0d174..0000000
--- a/arch/openrisc/include/asm/gpio.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * OpenRISC Linux
- *
- * Linux architectural port borrowing liberally from similar works of
- * others.  All original copyrights apply as per the original source
- * declaration.
- *
- * OpenRISC implementation:
- * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
- * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
- * et al.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __ASM_OPENRISC_GPIO_H
-#define __ASM_OPENRISC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * OpenRISC (or1k) does not have on-chip GPIO's so there is not really
- * any standardized implementation that makes sense here.  If passing
- * through gpiolib becomes a bottleneck then it may make sense, on a
- * case-by-case basis, to implement these inlined/rapid versions.
- *
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-/*
- * Not implemented, yet.
- */
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return -ENOSYS;
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_OPENRISC_GPIO_H */
diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
index d51df17..9cf0632 100644
--- a/arch/powerpc/include/asm/Kbuild
+++ b/arch/powerpc/include/asm/Kbuild
@@ -1,5 +1,7 @@
 include include/asm-generic/Kbuild.asm
 
+generic-y += gpio.h
+
 header-y += auxvec.h
 header-y += bootx.h
 header-y += byteorder.h
diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
deleted file mode 100644
index 38762ed..0000000
--- a/arch/powerpc/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for PowerPC.
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __ASM_POWERPC_GPIO_H
-#define __ASM_POWERPC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_POWERPC_GPIO_H */
diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h
index 04f53d3..44fee05 100644
--- a/arch/sh/include/asm/gpio.h
+++ b/arch/sh/include/asm/gpio.h
@@ -12,9 +12,6 @@
 #ifndef __ASM_SH_GPIO_H
 #define __ASM_SH_GPIO_H
 
-#include <linux/kernel.h>
-#include <linux/errno.h>
-
 #if defined(CONFIG_CPU_SH3)
 #include <cpu/gpio.h>
 #endif
@@ -22,33 +19,6 @@
 #define ARCH_NR_GPIOS 512
 #include <linux/sh_pfc.h>
 
-#ifdef CONFIG_GPIOLIB
-
-static inline int gpio_get_value(unsigned gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -ENOSYS;
-}
-
-#endif /* CONFIG_GPIOLIB */
+#include <asm-generic/gpio.h>
 
 #endif /* __ASM_SH_GPIO_H */
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index 2c2e388..6d27595 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -18,6 +18,7 @@ header-y += utrap.h
 header-y += watchdog.h
 
 generic-y += div64.h
+generic-y += gpio.h
 generic-y += local64.h
 generic-y += irq_regs.h
 generic-y += local.h
diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h
deleted file mode 100644
index a0e3ac0..0000000
--- a/arch/sparc/include/asm/gpio.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __ASM_SPARC_GPIO_H
-#define __ASM_SPARC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return -ENOSYS;
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_SPARC_GPIO_H */
diff --git a/arch/unicore32/include/asm/gpio.h b/arch/unicore32/include/asm/gpio.h
index 2716f14..437f4e8 100644
--- a/arch/unicore32/include/asm/gpio.h
+++ b/arch/unicore32/include/asm/gpio.h
@@ -13,6 +13,12 @@
 #ifndef __UNICORE_GPIO_H__
 #define __UNICORE_GPIO_H__
 
+/* We implement a few ourself */
+#define gpio_get_value gpio_get_value
+#define gpio_set_value gpio_set_value
+#define gpio_to_irq gpio_to_irq
+#define irq_to_gpio irq_to_gpio
+
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <mach/hardware.h>
@@ -83,8 +89,6 @@ static inline void gpio_set_value(unsigned gpio, int value)
 		__gpio_set_value(gpio, value);
 }
 
-#define gpio_cansleep	__gpio_cansleep
-
 static inline unsigned gpio_to_irq(unsigned gpio)
 {
 	if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & readl(GPIO_GPIR)))
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 6fa90a8..99d44ce 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -1,5 +1,7 @@
 include include/asm-generic/Kbuild.asm
 
+generic-y += gpio.h
+
 header-y += boot.h
 header-y += bootparam.h
 header-y += debugreg.h
diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h
deleted file mode 100644
index 91d915a..0000000
--- a/arch/x86/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for x86.
- *
- * Derived from the generic GPIO API for powerpc:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_X86_GPIO_H
-#define _ASM_X86_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_X86_GPIO_H */
diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild
index c68e168..7d52c50 100644
--- a/arch/xtensa/include/asm/Kbuild
+++ b/arch/xtensa/include/asm/Kbuild
@@ -1 +1,3 @@
 include include/asm-generic/Kbuild.asm
+
+generic-y += gpio.h
diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h
deleted file mode 100644
index a8c9fc4..0000000
--- a/arch/xtensa/include/asm/gpio.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Generic GPIO API implementation for xtensa.
- *
- * Stolen from x86, which is derived from the generic GPIO API for powerpc:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_XTENSA_GPIO_H
-#define _ASM_XTENSA_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-/*
- * Not implemented, yet.
- */
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_XTENSA_GPIO_H */
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d494001..622851c 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -170,6 +170,29 @@ extern int __gpio_cansleep(unsigned gpio);
 
 extern int __gpio_to_irq(unsigned gpio);
 
+#ifndef gpio_get_value
+#define gpio_get_value(gpio) __gpio_get_value(gpio)
+#endif
+
+#ifndef gpio_set_value
+#define gpio_set_value(gpio, value) __gpio_set_value(gpio, value)
+#endif
+
+#ifndef gpio_cansleep
+#define gpio_cansleep(gpio) __gpio_cansleep(gpio)
+#endif
+
+#ifndef gpio_to_irq
+#define gpio_to_irq(gpio) __gpio_to_irq(gpio)
+#endif
+
+#ifndef irq_to_gpio
+static inline int irq_to_gpio(unsigned int irq)
+{
+	return -EINVAL;
+}
+#endif
+
 /**
  * struct gpio - a structure describing a GPIO with configuration
  * @gpio:	the GPIO number
-- 
1.7.6.1


^ permalink raw reply related

* [PATCH 2/2 v3] net/smsc911x: Add regulator support
From: Linus Walleij @ 2011-10-27 12:48 UTC (permalink / raw)
  To: netdev, Steve Glendinning
  Cc: Mathieu Poirer, Robert Marklund, Paul Mundt, linux-sh,
	Sascha Hauer, Tony Lindgren, linux-omap, Mike Frysinger,
	uclinux-dist-devel, Linus Walleij

From: Robert Marklund <robert.marklund@stericsson.com>

Add some basic regulator support for the power pins, as needed
by the ST-Ericsson Snowball platform that powers up the SMSC911
chip using an external regulator.

Platforms that use regulators and the smsc911x and have no defined
regulator for the smsc911x and claim complete regulator
constraints with no dummy regulators will need to provide it, for
example using a fixed voltage regulator. It appears that this may
affect (apart from Ux500 Snowball) possibly these archs/machines
that from some grep:s appear to define both CONFIG_SMSC911X and
CONFIG_REGULATOR:

- ARM Freescale mx3 and OMAP 2 plus, Raumfeld machines
- Blackfin
- Super-H

Cc: Paul Mundt <lethal@linux-sh.org>
Cc: linux-sh@vger.kernel.org
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: uclinux-dist-devel@blackfin.uclinux.org
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Robert Marklund <robert.marklund@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v2->v3:
- Use bulk regulators on Mark's request.
- Add Cc-fileds to some possibly affected platforms.
ChangeLog v1->v2:
- Don't check for NULL regulators and error out properly if the
  regulators can't be found. All platforms using the smsc911x
  and the regulator framework simultaneously need to provide some
  kind of regulator for it.
---
 drivers/net/ethernet/smsc/smsc911x.c |  103 ++++++++++++++++++++++++++++++----
 1 files changed, 92 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 8843071..8ad15a6 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -44,6 +44,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/bug.h>
@@ -88,6 +89,8 @@ struct smsc911x_ops {
 				unsigned int *buf, unsigned int wordcount);
 };
 
+#define SMSC911X_NUM_SUPPLIES 2
+
 struct smsc911x_data {
 	void __iomem *ioaddr;
 
@@ -138,6 +141,9 @@ struct smsc911x_data {
 
 	/* register access functions */
 	const struct smsc911x_ops *ops;
+
+	/* regulators */
+	struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES];
 };
 
 /* Easy access to information */
@@ -362,6 +368,60 @@ out:
 	spin_unlock_irqrestore(&pdata->dev_lock, flags);
 }
 
+/*
+ * Enable or disable resources, currently just regulators.
+ */
+static int smsc911x_enable_disable_resources(struct platform_device *pdev,
+					     bool enable)
+{
+	struct net_device *ndev = platform_get_drvdata(pdev);
+	struct smsc911x_data *pdata = netdev_priv(ndev);
+	int ret = 0;
+
+	/* enable/disable regulators */
+	if (enable) {
+		ret = regulator_bulk_enable(ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
+		if (ret)
+			netdev_err(ndev, "failed to enable regulators %d\n",
+					ret);
+	} else
+		ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
+	return ret;
+}
+
+/*
+ * Request or free resources, currently just regulators.
+ *
+ * The SMSC911x has two power pins: vddvario and vdd33a, in designs where
+ * these are not always-on we need to request regulators to be turned on
+ * before we can try to access the device registers.
+ */
+static int smsc911x_request_free_resources(struct platform_device *pdev,
+		bool request)
+{
+	struct net_device *ndev = platform_get_drvdata(pdev);
+	struct smsc911x_data *pdata = netdev_priv(ndev);
+	int ret = 0;
+
+	/* Request regulators */
+	if (request) {
+		pdata->supplies[0].supply = "vdd33a";
+		pdata->supplies[1].supply = "vddvario";
+		ret = regulator_bulk_get(&pdev->dev,
+				ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
+		if (ret)
+			netdev_err(ndev, "couldn't get regulators %d\n",
+					ret);
+	} else
+		regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
+
+	return ret;
+}
+
 /* waits for MAC not busy, with timeout.  Only called by smsc911x_mac_read
  * and smsc911x_mac_write, so assumes mac_lock is held */
 static int smsc911x_mac_complete(struct smsc911x_data *pdata)
@@ -2065,6 +2125,7 @@ static int __devexit smsc911x_drv_remove(struct platform_device *pdev)
 	struct net_device *dev;
 	struct smsc911x_data *pdata;
 	struct resource *res;
+	int retval;
 
 	dev = platform_get_drvdata(pdev);
 	BUG_ON(!dev);
@@ -2092,6 +2153,12 @@ static int __devexit smsc911x_drv_remove(struct platform_device *pdev)
 
 	iounmap(pdata->ioaddr);
 
+	if (smsc911x_enable_disable_resources(pdev, false))
+		pr_warn("Could not disable resource\n");
+
+	retval = smsc911x_request_free_resources(pdev, false);
+	/* ignore not all have regulators */
+
 	free_netdev(dev);
 
 	return 0;
@@ -2218,10 +2285,24 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 	pdata->dev = dev;
 	pdata->msg_enable = ((1 << debug) - 1);
 
+	platform_set_drvdata(pdev, dev);
+
+	retval = smsc911x_request_free_resources(pdev, true);
+	if (retval) {
+		pr_err("Could request regulators needed aborting\n");
+		goto out_return_resources;
+	}
+
+	retval = smsc911x_enable_disable_resources(pdev, true);
+	if (retval) {
+		pr_err("Could enable regulators needed aborting\n");
+		goto out_disable_resources;
+	}
+
 	if (pdata->ioaddr = NULL) {
 		SMSC_WARN(pdata, probe, "Error smsc911x base address invalid");
 		retval = -ENOMEM;
-		goto out_free_netdev_2;
+		goto out_disable_resources;
 	}
 
 	retval = smsc911x_probe_config_dt(&pdata->config, np);
@@ -2233,7 +2314,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 
 	if (retval) {
 		SMSC_WARN(pdata, probe, "Error smsc911x config not found");
-		goto out_unmap_io_3;
+		goto out_disable_resources;
 	}
 
 	/* assume standard, non-shifted, access to HW registers */
@@ -2244,7 +2325,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 
 	retval = smsc911x_init(dev);
 	if (retval < 0)
-		goto out_unmap_io_3;
+		goto out_disable_resources;
 
 	/* configure irq polarity and type before connecting isr */
 	if (pdata->config.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH)
@@ -2264,15 +2345,13 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 	if (retval) {
 		SMSC_WARN(pdata, probe,
 			  "Unable to claim requested irq: %d", dev->irq);
-		goto out_unmap_io_3;
+		goto out_free_irq;
 	}
 
-	platform_set_drvdata(pdev, dev);
-
 	retval = register_netdev(dev);
 	if (retval) {
 		SMSC_WARN(pdata, probe, "Error %i registering device", retval);
-		goto out_unset_drvdata_4;
+		goto out_free_irq;
 	} else {
 		SMSC_TRACE(pdata, probe,
 			   "Network interface: \"%s\"", dev->name);
@@ -2321,12 +2400,14 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 
 out_unregister_netdev_5:
 	unregister_netdev(dev);
-out_unset_drvdata_4:
-	platform_set_drvdata(pdev, NULL);
+out_free_irq:
 	free_irq(dev->irq, dev);
-out_unmap_io_3:
+out_disable_resources:
+	(void)smsc911x_enable_disable_resources(pdev, false);
+out_return_resources:
+	(void)smsc911x_request_free_resources(pdev, false);
+	platform_set_drvdata(pdev, NULL);
 	iounmap(pdata->ioaddr);
-out_free_netdev_2:
 	free_netdev(dev);
 out_release_io_1:
 	release_mem_region(res->start, resource_size(res));
-- 
1.7.3.2


^ permalink raw reply related

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mark Brown @ 2011-10-26  7:33 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao,
	Grant Likely, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <CAJaTeTp2w85UHnmH-PPMZsQGQMNa-93kw-tjmDxA_wjJXkYQcQ@mail.gmail.com>

On Tue, Oct 25, 2011 at 07:44:14PM -0400, Mike Frysinger wrote:

> i don't think this is generally how asm-generic is handled.  instead, how about:
>  - move the duplicate code to asm-generic/gpio.h
>  - have the arches which merely need asm-generic/gpio.h add "generic-y
> += gpio.h" to their include/asm/Kbuild
>  - for arches which need to override these common funcs in some way,
> add #ifdef protection to the asm-generic/gpio.h

> and it seems like with slightly more work, this path allow you to
> merge most of arch/sh/include/asm/gpio.h.  and it has the advantage of
> not needing new Kconfig symbols.

That's really not how gpiolib is currently handled, unfortunately -
trying to transition over to that model in one patch would be way too
much.  

The goal here from that point of view is to make transitioning to
something more sensible easier by getting rid of the boilerplate code,
it makes doing the more invasive changes like you're suggesting much
easier as we're only dealing with the architectures that are actually
doing something.  It also means that we're able to immediately work on
turning on gpiolib on random architectures which is a definite win.

^ permalink raw reply

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mike Frysinger @ 2011-10-25 23:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao,
	Grant Likely, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <1319528012-19006-1-git-send-email-broonie@opensource.wolfsonmicro.com>

On Tue, Oct 25, 2011 at 03:33, Mark Brown wrote:
> Rather than requiring architectures that use gpiolib but don't have any
> need to define anything custom to copy an asm/gpio.h provide a Kconfig
> symbol which architectures must select in order to include gpio.h and
> for other architectures just provide the trivial implementation directly.

i don't think this is generally how asm-generic is handled.  instead, how about:
 - move the duplicate code to asm-generic/gpio.h
 - have the arches which merely need asm-generic/gpio.h add "generic-y
+= gpio.h" to their include/asm/Kbuild
 - for arches which need to override these common funcs in some way,
add #ifdef protection to the asm-generic/gpio.h

and it seems like with slightly more work, this path allow you to
merge most of arch/sh/include/asm/gpio.h.  and it has the advantage of
not needing new Kconfig symbols.

for example, with asm-generic/atomic.h, it does:
#ifndef atomic_sub_return
static inline int atomic_sub_return(int i, atomic_t *v)
{ ... common implementation ... }
#endif

and then any arch that wants to override it does:
#define atomic_sub_return atomic_sub_return
static inline int atomic_sub_return(int i, atomic_t *v) { weirdness }
#include <asm-generic/atomic.h>
-mike

^ permalink raw reply

* [GIT PULL] Power management updates for 3.2
From: Rafael J. Wysocki @ 2011-10-25 13:19 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: LKML, Linux PM list, Linux-sh list, Turquette, Mike,
	Len Brown (Intel)

Hi Linus,

Please pull power management updates for 3.2 (on top of commit
3ee72ca99288f1de95ec9c570e43f531c8799f06) from:

git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git pm-for-linus

with top-most commit 0ab1e79b825a5cd8aeb3b34d89c9a89dea900056
"PM / Clocks: Remove redundant NULL checks before kfree()".

They include:

* Runtime PM tracepoints (replacing not very useful debug printks) and fixes
  from Ming Lei.

* Introduction of devfreq by MyungJoo Ham (special thanks to Mike Turquette
  for reviewing all of the versions of this patchset).

* Introduction of device PM QoS from Jean Pihet.

* Generic PM domains core code refinements and extensions.

* SH7372 power management changes from Magnus Damm.

* Threaded hibernate image saving from Bojan Smojver.

* New entries for the ACPI suspend blacklist.

* Assorted fixes.

Thanks!


 Documentation/ABI/testing/sysfs-class-devfreq  |   52 ++
 Documentation/kernel-parameters.txt            |    7 +
 Documentation/power/00-INDEX                   |    2 +
 Documentation/power/basic-pm-debugging.txt     |   24 +
 Documentation/power/devices.txt                |    8 +-
 Documentation/power/pm_qos_interface.txt       |   92 +++-
 Documentation/power/runtime_pm.txt             |   21 +-
 Documentation/power/suspend-and-cpuhotplug.txt |  275 ++++++++
 Documentation/usb/power-management.txt         |    8 +-
 MAINTAINERS                                    |   12 +-
 arch/arm/mach-msm/clock.c                      |    2 +-
 arch/arm/mach-omap1/pm_bus.c                   |    1 +
 arch/arm/mach-shmobile/board-ap4evb.c          |    6 +
 arch/arm/mach-shmobile/board-mackerel.c        |   11 +-
 arch/arm/mach-shmobile/include/mach/common.h   |    4 +-
 arch/arm/mach-shmobile/include/mach/sh7372.h   |   13 +
 arch/arm/mach-shmobile/intc-sh7372.c           |   52 ++-
 arch/arm/mach-shmobile/pm-sh7372.c             |  342 ++++++++--
 arch/arm/mach-shmobile/pm_runtime.c            |    1 +
 arch/arm/mach-shmobile/setup-sh7372.c          |   25 +
 arch/arm/mach-shmobile/sleep-sh7372.S          |  221 +------
 arch/s390/Kconfig                              |    1 +
 arch/s390/kernel/suspend.c                     |  118 ++++
 arch/s390/kernel/swsusp_asm64.S                |    3 +
 drivers/Kconfig                                |    2 +
 drivers/Makefile                               |    2 +
 drivers/acpi/processor_idle.c                  |    2 +-
 drivers/acpi/sleep.c                           |   24 +
 drivers/base/power/Makefile                    |    4 +-
 drivers/base/power/clock_ops.c                 |  127 ++--
 drivers/base/power/common.c                    |   86 +++
 drivers/base/power/domain.c                    |  352 ++++++-----
 drivers/base/power/main.c                      |   42 +-
 drivers/base/power/opp.c                       |   30 +
 drivers/base/power/power.h                     |   10 +-
 drivers/base/power/qos.c                       |  419 ++++++++++++
 drivers/base/power/runtime.c                   |  127 +++--
 drivers/base/power/wakeup.c                    |    4 +-
 drivers/bluetooth/btusb.c                      |    2 +-
 drivers/cpuidle/cpuidle.c                      |    2 +-
 drivers/cpuidle/governors/ladder.c             |    2 +-
 drivers/cpuidle/governors/menu.c               |    2 +-
 drivers/devfreq/Kconfig                        |   75 +++
 drivers/devfreq/Makefile                       |    5 +
 drivers/devfreq/devfreq.c                      |  601 +++++++++++++++++
 drivers/devfreq/governor.h                     |   24 +
 drivers/devfreq/governor_performance.c         |   29 +
 drivers/devfreq/governor_powersave.c           |   29 +
 drivers/devfreq/governor_simpleondemand.c      |   88 +++
 drivers/devfreq/governor_userspace.c           |  116 ++++
 drivers/hid/hid-picolcd.c                      |    2 +-
 drivers/hid/usbhid/hid-core.c                  |    7 +-
 drivers/media/video/via-camera.c               |    4 +-
 drivers/net/e1000e/netdev.c                    |    2 +-
 drivers/net/usb/usbnet.c                       |    2 +-
 drivers/net/wimax/i2400m/usb.c                 |    4 +-
 drivers/net/wireless/ipw2x00/ipw2100.c         |    4 +-
 drivers/tty/Kconfig                            |    4 +
 drivers/usb/class/cdc-acm.c                    |    2 +-
 drivers/usb/class/cdc-wdm.c                    |    6 +-
 drivers/usb/core/driver.c                      |    9 +-
 drivers/usb/core/hcd.c                         |    9 +-
 drivers/usb/core/hub.c                         |   15 +-
 drivers/usb/serial/sierra.c                    |    2 +-
 drivers/usb/serial/usb_wwan.c                  |    2 +-
 include/linux/devfreq.h                        |  238 +++++++
 include/linux/device.h                         |    5 +
 include/linux/freezer.h                        |    4 +-
 include/linux/netdevice.h                      |    4 +-
 include/linux/opp.h                            |   12 +
 include/linux/pm.h                             |   26 +-
 include/linux/pm_clock.h                       |   71 ++
 include/linux/pm_domain.h                      |   26 +-
 include/linux/pm_qos.h                         |  155 +++++
 include/linux/pm_qos_params.h                  |   38 --
 include/linux/pm_runtime.h                     |   42 --
 include/linux/suspend.h                        |   95 +++-
 include/sound/pcm.h                            |    4 +-
 include/trace/events/rpm.h                     |   99 +++
 kernel/Makefile                                |    2 +-
 kernel/freezer.c                               |    2 +-
 kernel/power/Kconfig                           |    4 +
 kernel/power/Makefile                          |    4 +-
 kernel/power/console.c                         |    4 +-
 kernel/power/hibernate.c                       |   53 ++-
 kernel/power/main.c                            |  102 +++
 kernel/power/power.h                           |    4 +-
 kernel/power/process.c                         |   30 +-
 kernel/{pm_qos_params.c => power/qos.c}        |  273 ++++----
 kernel/power/snapshot.c                        |   18 +
 kernel/power/suspend.c                         |   17 +-
 kernel/power/swap.c                            |  818 ++++++++++++++++++-----
 kernel/trace/Makefile                          |    3 +
 kernel/trace/rpm-traces.c                      |   20 +
 net/mac80211/main.c                            |    2 +-
 net/mac80211/mlme.c                            |    2 +-
 net/mac80211/scan.c                            |    2 +-
 sound/core/pcm_native.c                        |    2 +-
 sound/usb/card.c                               |    2 +-
 99 files changed, 4720 insertions(+), 1044 deletions(-)

---------------

Alan Stern (3):
      PM / Runtime: Add macro to test for runtime PM events
      USB: Add wakeup info to debugging messages
      PM: Update the policy on default wakeup settings

Barry Song (4):
      PM / Hibernate: Fix typo in a kerneldoc comment
      PM / Hibernate: Add resumewait param to support MMC-like devices as resume file
      PM / Hibernate: Add resumedelay kernel param in addition to resumewait
      PM / Hibernate: Do not initialize static and extern variables to 0

Bogdan Radulescu (1):
      PM / ACPI: Blacklist Vaio VGN-FW520F machine known to require acpi_sleep=nonvs

Bojan Smojver (1):
      PM / Hibernate: Improve performance of LZO/plain hibernation, checksum image

Colin Cross (1):
      PM / Runtime: Add might_sleep() to runtime PM functions

Dan Carpenter (1):
      PM / Suspend: Off by one in pm_suspend()

Dave Jones (1):
      ACPI / PM: Add Sony VGN-FW21E to nonvs blacklist.

H Hartley Sweeten (1):
      PM / VT: Cleanup #if defined uglyness and fix compile error

Jean Pihet (8):
      PM QoS: Move and rename the implementation files
      PM QoS: Minor clean-ups
      PM QoS: Code reorganization
      PM QoS: Reorganize data structs
      PM QoS: Generalize and export constraints management code
      PM QoS: Implement per-device PM QoS constraints
      PM QoS: Add global notification mechanism for device constraints
      PM / QoS: Update Documentation for the pm_qos and dev_pm_qos frameworks

Jeff Layton (1):
      PM / Freezer: Make fake_signal_wake_up() wake TASK_KILLABLE tasks too

Jonghwan Choi (1):
      PM / Clocks: Remove redundant NULL checks before kfree()

Magnus Damm (5):
      ARM: mach-shmobile: sh7372 generic suspend/resume support
      ARM: mach-shmobile: sh7372 A3SM support
      ARM: mach-shmobile: sh7372 sleep warning fixes
      ARM: mach-shmobile: sh7372 A3SP support (v4)
      ARM: mach-shmobile: sh7372 A4R support (v4)

Martin Schwidefsky (1):
      PM / Hibernate: Include storage keys in hibernation image on s390

Ming Lei (7):
      PM / Runtime: pm_runtime_idle() can be called in atomic context
      PM / Runtime: Introduce trace points for tracing rpm_* functions
      PM / Runtime: Replace dev_dbg() with trace_rpm_*()
      PM / Tracing: build rpm-traces.c only if CONFIG_PM_RUNTIME is set
      PM / Runtime: Update document about callbacks
      PM / Runtime: Fix kerneldoc comment for rpm_suspend()
      PM / Runtime: Handle .runtime_suspend() failure correctly

MyungJoo Ham (4):
      PM / OPP: Add OPP availability change notifier.
      PM: Introduce devfreq: generic DVFS framework with device-specific OPPs
      PM / devfreq: Add common sysfs interfaces
      PM / devfreq: Add basic governors

Rafael J. Wysocki (20):
      PM / Domains: Implement subdomain counters as atomic fields
      PM / Domains: Do not take parent locks to modify subdomain counters
      PM / Domains: Make pm_genpd_poweron() always survive parent removal
      PM / Domains: Add "wait for parent" status for generic PM domains
      PM / Domains: Allow generic PM domains to have multiple masters
      PM / Domains: Rename GPD_STATE_WAIT_PARENT to GPD_STATE_WAIT_MASTER
      PM / Domains: Rename argument of pm_genpd_add_subdomain()
      ARM / shmobile: Make A3RV be a subdomain of A4LC on SH7372
      PM: Introduce struct pm_subsys_data
      PM: Reference counting of power.subsys_data
      PM / Domains: Use power.sybsys_data to reduce overhead
      PM: Move clock-related definitions and headers to separate file
      PM / Domains: Preliminary support for devices with power.irq_safe set
      PM / Domains: Split device PM domain data into base and need_restore
      PM / Runtime: Don't run callbacks under lock for power.irq_safe set
      PM / QoS: Add function dev_pm_qos_read_value() (v3)
      PM: Fix build issue in main.c for CONFIG_PM_SLEEP unset
      PM / Hibernate: Freeze kernel threads after preallocating memory
      PM / ACPI: Blacklist Sony Vaio known to require acpi_sleep=nonvs
      PM / Sleep: Mark devices involved in wakeup signaling during suspend

ShuoX Liu (1):
      PM / Suspend: Add statistics debugfs file for suspend to RAM

Srivatsa S. Bhat (1):
      PM / Documentation: Update docs about suspend and CPU hotplug

WANG Cong (1):
      MAINTAINERS: Update linux-pm list address


^ permalink raw reply

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mark Brown @ 2011-10-25  8:39 UTC (permalink / raw)
  To: Grant Likely
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Mike Frysinger, Geert Uytterhoeven, Ralf Baechle, Paul Mundt,
	Guan Xuetao, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <20111025083301.GD4605@ponder.secretlab.ca>

On Tue, Oct 25, 2011 at 10:33:01AM +0200, Grant Likely wrote:

> (not that I've actually tested this much yet; it should probably go
> into a separate branch to marinate in linux-next for a bit without
> impacting the other GPIO patches I've got queued.

Yes, it should.  I've test built a few configurations covering both
asm/gpio.h and default implementations and it seems to be doing the
right thing but I might well have missed something.  I'm hoping to also
have a further patch to go on top of this which makes _OPTIONAL_GPOILIB
on by default.

^ permalink raw reply

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Grant Likely @ 2011-10-25  8:33 UTC (permalink / raw)
  To: Mark Brown
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Mike Frysinger, Geert Uytterhoeven, Ralf Baechle, Paul Mundt,
	Guan Xuetao, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <1319528012-19006-1-git-send-email-broonie@opensource.wolfsonmicro.com>

On Tue, Oct 25, 2011 at 09:33:32AM +0200, Mark Brown wrote:
> Rather than requiring architectures that use gpiolib but don't have any
> need to define anything custom to copy an asm/gpio.h provide a Kconfig
> symbol which architectures must select in order to include gpio.h and
> for other architectures just provide the trivial implementation directly.
> 
> This makes it much easier to do gpiolib updates and is also a step towards
> making gpiolib APIs available on every architecture.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

(not that I've actually tested this much yet; it should probably go
into a separate branch to marinate in linux-next for a bit without
impacting the other GPIO patches I've got queued.

g.

> ---
>  arch/alpha/include/asm/gpio.h      |   55 ------------------------------
>  arch/arm/Kconfig                   |    1 +
>  arch/avr32/Kconfig                 |    1 +
>  arch/blackfin/Kconfig              |    1 +
>  arch/ia64/include/asm/gpio.h       |   55 ------------------------------
>  arch/m68k/Kconfig.cpu              |    1 +
>  arch/microblaze/include/asm/gpio.h |   53 -----------------------------
>  arch/mips/Kconfig                  |    1 +
>  arch/openrisc/include/asm/gpio.h   |   65 ------------------------------------
>  arch/powerpc/include/asm/gpio.h    |   53 -----------------------------
>  arch/sh/Kconfig                    |    1 +
>  arch/sparc/include/asm/gpio.h      |   36 --------------------
>  arch/unicore32/Kconfig             |    1 +
>  arch/x86/include/asm/gpio.h        |   53 -----------------------------
>  arch/xtensa/include/asm/gpio.h     |   56 -------------------------------
>  drivers/gpio/Kconfig               |    8 ++++
>  include/linux/gpio.h               |   34 +++++++++++++++++++
>  17 files changed, 49 insertions(+), 426 deletions(-)
>  delete mode 100644 arch/alpha/include/asm/gpio.h
>  delete mode 100644 arch/ia64/include/asm/gpio.h
>  delete mode 100644 arch/microblaze/include/asm/gpio.h
>  delete mode 100644 arch/openrisc/include/asm/gpio.h
>  delete mode 100644 arch/powerpc/include/asm/gpio.h
>  delete mode 100644 arch/sparc/include/asm/gpio.h
>  delete mode 100644 arch/x86/include/asm/gpio.h
>  delete mode 100644 arch/xtensa/include/asm/gpio.h
> 
> diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h
> deleted file mode 100644
> index 7dc6a63..0000000
> --- a/arch/alpha/include/asm/gpio.h
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -/*
> - * Generic GPIO API implementation for Alpha.
> - *
> - * A stright copy of that for PowerPC which was:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_ALPHA_GPIO_H
> -#define _ASM_ALPHA_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_ALPHA_GPIO_H */
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 7e8ffe7..5e0446c 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1,6 +1,7 @@
>  config ARM
>  	bool
>  	default y
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select HAVE_AOUT
>  	select HAVE_DMA_API_DEBUG
>  	select HAVE_IDE if PCI || ISA || PCMCIA
> diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
> index 197e96f..b2e3e58 100644
> --- a/arch/avr32/Kconfig
> +++ b/arch/avr32/Kconfig
> @@ -10,6 +10,7 @@ config AVR32
>  	select GENERIC_IRQ_PROBE
>  	select HARDIRQS_SW_RESEND
>  	select GENERIC_IRQ_SHOW
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_HAVE_NMI_SAFE_CMPXCHG
>  	help
>  	  AVR32 is a high-performance 32-bit RISC microprocessor core,
> diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
> index c747629..2c13eef 100644
> --- a/arch/blackfin/Kconfig
> +++ b/arch/blackfin/Kconfig
> @@ -31,6 +31,7 @@ config BLACKFIN
>  	select HAVE_KERNEL_LZO if RAMKERNEL
>  	select HAVE_OPROFILE
>  	select HAVE_PERF_EVENTS
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	select HAVE_GENERIC_HARDIRQS
>  	select GENERIC_ATOMIC64
> diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h
> deleted file mode 100644
> index 590a20d..0000000
> --- a/arch/ia64/include/asm/gpio.h
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -/*
> - * Generic GPIO API implementation for IA-64.
> - *
> - * A stright copy of that for PowerPC which was:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_IA64_GPIO_H
> -#define _ASM_IA64_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_IA64_GPIO_H */
> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> index e632b2d..d4a818b 100644
> --- a/arch/m68k/Kconfig.cpu
> +++ b/arch/m68k/Kconfig.cpu
> @@ -21,6 +21,7 @@ config MCPU32
>  config COLDFIRE
>  	bool
>  	select GENERIC_GPIO
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_REQUIRE_GPIOLIB
>  	select CPU_HAS_NO_BITFIELDS
>  	help
> diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h
> deleted file mode 100644
> index 2b2c18b..0000000
> --- a/arch/microblaze/include/asm/gpio.h
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/*
> - * Generic GPIO API implementation for PowerPC.
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_MICROBLAZE_GPIO_H
> -#define _ASM_MICROBLAZE_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_MICROBLAZE_GPIO_H */
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 62b9677..567290c 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -8,6 +8,7 @@ config MIPS
>  	select HAVE_PERF_EVENTS
>  	select PERF_USE_VMALLOC
>  	select HAVE_ARCH_KGDB
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select HAVE_FUNCTION_TRACER
>  	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
>  	select HAVE_DYNAMIC_FTRACE
> diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h
> deleted file mode 100644
> index 0b0d174..0000000
> --- a/arch/openrisc/include/asm/gpio.h
> +++ /dev/null
> @@ -1,65 +0,0 @@
> -/*
> - * OpenRISC Linux
> - *
> - * Linux architectural port borrowing liberally from similar works of
> - * others.  All original copyrights apply as per the original source
> - * declaration.
> - *
> - * OpenRISC implementation:
> - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
> - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
> - * et al.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef __ASM_OPENRISC_GPIO_H
> -#define __ASM_OPENRISC_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really
> - * any standardized implementation that makes sense here.  If passing
> - * through gpiolib becomes a bottleneck then it may make sense, on a
> - * case-by-case basis, to implement these inlined/rapid versions.
> - *
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -/*
> - * Not implemented, yet.
> - */
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return -ENOSYS;
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* __ASM_OPENRISC_GPIO_H */
> diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
> deleted file mode 100644
> index 38762ed..0000000
> --- a/arch/powerpc/include/asm/gpio.h
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/*
> - * Generic GPIO API implementation for PowerPC.
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef __ASM_POWERPC_GPIO_H
> -#define __ASM_POWERPC_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* __ASM_POWERPC_GPIO_H */
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index ff9177c..d00e11a 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -11,6 +11,7 @@ config SUPERH
>  	select HAVE_DMA_ATTRS
>  	select HAVE_IRQ_WORK
>  	select HAVE_PERF_EVENTS
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
>  	select PERF_USE_VMALLOC
>  	select HAVE_KERNEL_GZIP
> diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h
> deleted file mode 100644
> index a0e3ac0..0000000
> --- a/arch/sparc/include/asm/gpio.h
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -#ifndef __ASM_SPARC_GPIO_H
> -#define __ASM_SPARC_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return -ENOSYS;
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* __ASM_SPARC_GPIO_H */
> diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
> index e57dcce..7bdc7c6 100644
> --- a/arch/unicore32/Kconfig
> +++ b/arch/unicore32/Kconfig
> @@ -8,6 +8,7 @@ config UNICORE32
>  	select HAVE_KERNEL_BZIP2
>  	select HAVE_KERNEL_LZO
>  	select HAVE_KERNEL_LZMA
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select GENERIC_FIND_FIRST_BIT
>  	select GENERIC_IRQ_PROBE
>  	select GENERIC_IRQ_SHOW
> diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h
> deleted file mode 100644
> index 91d915a..0000000
> --- a/arch/x86/include/asm/gpio.h
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/*
> - * Generic GPIO API implementation for x86.
> - *
> - * Derived from the generic GPIO API for powerpc:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_X86_GPIO_H
> -#define _ASM_X86_GPIO_H
> -
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_X86_GPIO_H */
> diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h
> deleted file mode 100644
> index a8c9fc4..0000000
> --- a/arch/xtensa/include/asm/gpio.h
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -/*
> - * Generic GPIO API implementation for xtensa.
> - *
> - * Stolen from x86, which is derived from the generic GPIO API for powerpc:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_XTENSA_GPIO_H
> -#define _ASM_XTENSA_GPIO_H
> -
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -/*
> - * Not implemented, yet.
> - */
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_XTENSA_GPIO_H */
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index a107d44..ef920a2 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -2,6 +2,14 @@
>  # GPIO infrastructure and drivers
>  #
>  
> +config ARCH_HAVE_CUSTOM_GPIO_H
> +	bool
> +	help
> +	  Selecting this config option from the architecture Kconfig allows
> +	  the architecture to provide a custom asm/gpio.h implementation
> +	  overriding the default implementations.  New uses of this are
> +	  strongly discouraged.
> +
>  config ARCH_WANT_OPTIONAL_GPIOLIB
>  	bool
>  	help
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index 38ac48b..3149f68 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -1,6 +1,8 @@
>  #ifndef __LINUX_GPIO_H
>  #define __LINUX_GPIO_H
>  
> +#include <linux/errno.h>
> +
>  /* see Documentation/gpio.txt */
>  
>  /* make these flag values available regardless of GPIO kconfig options */
> @@ -27,7 +29,39 @@ struct gpio {
>  };
>  
>  #ifdef CONFIG_GENERIC_GPIO
> +
> +#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
>  #include <asm/gpio.h>
> +#else
> +
> +#include <asm-generic/gpio.h>
> +
> +static inline int gpio_get_value(unsigned int gpio)
> +{
> +	return __gpio_get_value(gpio);
> +}
> +
> +static inline void gpio_set_value(unsigned int gpio, int value)
> +{
> +	__gpio_set_value(gpio, value);
> +}
> +
> +static inline int gpio_cansleep(unsigned int gpio)
> +{
> +	return __gpio_cansleep(gpio);
> +}
> +
> +static inline int gpio_to_irq(unsigned int gpio)
> +{
> +	return __gpio_to_irq(gpio);
> +}
> +
> +static inline int irq_to_gpio(unsigned int irq)
> +{
> +	return -EINVAL;
> +}
> +
> +#endif
>  
>  #else
>  
> -- 
> 1.7.6.3
> 

^ permalink raw reply

* [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mark Brown @ 2011-10-25  7:33 UTC (permalink / raw)
  To: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Mike Frysinger, Geert
  Cc: linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k,
	linux-mips, linux-sh, linux-arch, Mark Brown

Rather than requiring architectures that use gpiolib but don't have any
need to define anything custom to copy an asm/gpio.h provide a Kconfig
symbol which architectures must select in order to include gpio.h and
for other architectures just provide the trivial implementation directly.

This makes it much easier to do gpiolib updates and is also a step towards
making gpiolib APIs available on every architecture.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 arch/alpha/include/asm/gpio.h      |   55 ------------------------------
 arch/arm/Kconfig                   |    1 +
 arch/avr32/Kconfig                 |    1 +
 arch/blackfin/Kconfig              |    1 +
 arch/ia64/include/asm/gpio.h       |   55 ------------------------------
 arch/m68k/Kconfig.cpu              |    1 +
 arch/microblaze/include/asm/gpio.h |   53 -----------------------------
 arch/mips/Kconfig                  |    1 +
 arch/openrisc/include/asm/gpio.h   |   65 ------------------------------------
 arch/powerpc/include/asm/gpio.h    |   53 -----------------------------
 arch/sh/Kconfig                    |    1 +
 arch/sparc/include/asm/gpio.h      |   36 --------------------
 arch/unicore32/Kconfig             |    1 +
 arch/x86/include/asm/gpio.h        |   53 -----------------------------
 arch/xtensa/include/asm/gpio.h     |   56 -------------------------------
 drivers/gpio/Kconfig               |    8 ++++
 include/linux/gpio.h               |   34 +++++++++++++++++++
 17 files changed, 49 insertions(+), 426 deletions(-)
 delete mode 100644 arch/alpha/include/asm/gpio.h
 delete mode 100644 arch/ia64/include/asm/gpio.h
 delete mode 100644 arch/microblaze/include/asm/gpio.h
 delete mode 100644 arch/openrisc/include/asm/gpio.h
 delete mode 100644 arch/powerpc/include/asm/gpio.h
 delete mode 100644 arch/sparc/include/asm/gpio.h
 delete mode 100644 arch/x86/include/asm/gpio.h
 delete mode 100644 arch/xtensa/include/asm/gpio.h

diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h
deleted file mode 100644
index 7dc6a63..0000000
--- a/arch/alpha/include/asm/gpio.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Generic GPIO API implementation for Alpha.
- *
- * A stright copy of that for PowerPC which was:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_ALPHA_GPIO_H
-#define _ASM_ALPHA_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_ALPHA_GPIO_H */
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7e8ffe7..5e0446c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1,6 +1,7 @@
 config ARM
 	bool
 	default y
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select HAVE_AOUT
 	select HAVE_DMA_API_DEBUG
 	select HAVE_IDE if PCI || ISA || PCMCIA
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index 197e96f..b2e3e58 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -10,6 +10,7 @@ config AVR32
 	select GENERIC_IRQ_PROBE
 	select HARDIRQS_SW_RESEND
 	select GENERIC_IRQ_SHOW
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	help
 	  AVR32 is a high-performance 32-bit RISC microprocessor core,
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index c747629..2c13eef 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -31,6 +31,7 @@ config BLACKFIN
 	select HAVE_KERNEL_LZO if RAMKERNEL
 	select HAVE_OPROFILE
 	select HAVE_PERF_EVENTS
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select HAVE_GENERIC_HARDIRQS
 	select GENERIC_ATOMIC64
diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h
deleted file mode 100644
index 590a20d..0000000
--- a/arch/ia64/include/asm/gpio.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Generic GPIO API implementation for IA-64.
- *
- * A stright copy of that for PowerPC which was:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_IA64_GPIO_H
-#define _ASM_IA64_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_IA64_GPIO_H */
diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index e632b2d..d4a818b 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -21,6 +21,7 @@ config MCPU32
 config COLDFIRE
 	bool
 	select GENERIC_GPIO
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_REQUIRE_GPIOLIB
 	select CPU_HAS_NO_BITFIELDS
 	help
diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h
deleted file mode 100644
index 2b2c18b..0000000
--- a/arch/microblaze/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for PowerPC.
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_MICROBLAZE_GPIO_H
-#define _ASM_MICROBLAZE_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_MICROBLAZE_GPIO_H */
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 62b9677..567290c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -8,6 +8,7 @@ config MIPS
 	select HAVE_PERF_EVENTS
 	select PERF_USE_VMALLOC
 	select HAVE_ARCH_KGDB
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_DYNAMIC_FTRACE
diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h
deleted file mode 100644
index 0b0d174..0000000
--- a/arch/openrisc/include/asm/gpio.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * OpenRISC Linux
- *
- * Linux architectural port borrowing liberally from similar works of
- * others.  All original copyrights apply as per the original source
- * declaration.
- *
- * OpenRISC implementation:
- * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
- * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
- * et al.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __ASM_OPENRISC_GPIO_H
-#define __ASM_OPENRISC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * OpenRISC (or1k) does not have on-chip GPIO's so there is not really
- * any standardized implementation that makes sense here.  If passing
- * through gpiolib becomes a bottleneck then it may make sense, on a
- * case-by-case basis, to implement these inlined/rapid versions.
- *
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-/*
- * Not implemented, yet.
- */
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return -ENOSYS;
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_OPENRISC_GPIO_H */
diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
deleted file mode 100644
index 38762ed..0000000
--- a/arch/powerpc/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for PowerPC.
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __ASM_POWERPC_GPIO_H
-#define __ASM_POWERPC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_POWERPC_GPIO_H */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index ff9177c..d00e11a 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -11,6 +11,7 @@ config SUPERH
 	select HAVE_DMA_ATTRS
 	select HAVE_IRQ_WORK
 	select HAVE_PERF_EVENTS
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
 	select PERF_USE_VMALLOC
 	select HAVE_KERNEL_GZIP
diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h
deleted file mode 100644
index a0e3ac0..0000000
--- a/arch/sparc/include/asm/gpio.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __ASM_SPARC_GPIO_H
-#define __ASM_SPARC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return -ENOSYS;
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_SPARC_GPIO_H */
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index e57dcce..7bdc7c6 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -8,6 +8,7 @@ config UNICORE32
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_LZO
 	select HAVE_KERNEL_LZMA
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h
deleted file mode 100644
index 91d915a..0000000
--- a/arch/x86/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for x86.
- *
- * Derived from the generic GPIO API for powerpc:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_X86_GPIO_H
-#define _ASM_X86_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_X86_GPIO_H */
diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h
deleted file mode 100644
index a8c9fc4..0000000
--- a/arch/xtensa/include/asm/gpio.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Generic GPIO API implementation for xtensa.
- *
- * Stolen from x86, which is derived from the generic GPIO API for powerpc:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_XTENSA_GPIO_H
-#define _ASM_XTENSA_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-/*
- * Not implemented, yet.
- */
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_XTENSA_GPIO_H */
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index a107d44..ef920a2 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -2,6 +2,14 @@
 # GPIO infrastructure and drivers
 #
 
+config ARCH_HAVE_CUSTOM_GPIO_H
+	bool
+	help
+	  Selecting this config option from the architecture Kconfig allows
+	  the architecture to provide a custom asm/gpio.h implementation
+	  overriding the default implementations.  New uses of this are
+	  strongly discouraged.
+
 config ARCH_WANT_OPTIONAL_GPIOLIB
 	bool
 	help
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 38ac48b..3149f68 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -1,6 +1,8 @@
 #ifndef __LINUX_GPIO_H
 #define __LINUX_GPIO_H
 
+#include <linux/errno.h>
+
 /* see Documentation/gpio.txt */
 
 /* make these flag values available regardless of GPIO kconfig options */
@@ -27,7 +29,39 @@ struct gpio {
 };
 
 #ifdef CONFIG_GENERIC_GPIO
+
+#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
 #include <asm/gpio.h>
+#else
+
+#include <asm-generic/gpio.h>
+
+static inline int gpio_get_value(unsigned int gpio)
+{
+	return __gpio_get_value(gpio);
+}
+
+static inline void gpio_set_value(unsigned int gpio, int value)
+{
+	__gpio_set_value(gpio, value);
+}
+
+static inline int gpio_cansleep(unsigned int gpio)
+{
+	return __gpio_cansleep(gpio);
+}
+
+static inline int gpio_to_irq(unsigned int gpio)
+{
+	return __gpio_to_irq(gpio);
+}
+
+static inline int irq_to_gpio(unsigned int irq)
+{
+	return -EINVAL;
+}
+
+#endif
 
 #else
 
-- 
1.7.6.3


^ permalink raw reply related

* Question about clk->usecount
From: kuninori.morimoto.gx @ 2011-10-25  0:44 UTC (permalink / raw)
  To: linux-sh


Hi SH ML

renesas_usbhs and sh_eth seems break in SH7724 ecovec board
from 794d78fea51504bad3880d14f354a9847f318f25 (drivers: sh: late disabling of clocks V2)
So I debuged it.

when these driver call pm_runtime_get_sync(),
then, arch/sh/kernel/cpu/hwblk.c :: hwblk_enable() are called,
and it enabled MSTP bit.
This is OK.

But clk_late_init() disabled it.

Does hwblk/pm_runtime (?) not care clk->usecount ?

^ permalink raw reply

* [PATCH 16/49] SH: irq: Remove IRQF_DISABLED
From: Yong Zhang @ 2011-10-22  9:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, Paul Mundt, linux-sh
In-Reply-To: <1319277421-9203-1-git-send-email-yong.zhang0@gmail.com>

Since commit [e58aa3d2: genirq: Run irq handlers with interrupts disabled],
We run all interrupt handlers with interrupts disabled
and we even check and yell when an interrupt handler
returns with interrupts enabled (see commit [b738a50a:
genirq: Warn when handler enables interrupts]).

So now this flag is a NOOP and can be removed.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
---
 arch/sh/boards/board-secureedge5410.c |    3 +--
 arch/sh/boards/mach-cayman/irq.c      |    2 --
 arch/sh/boards/mach-hp6xx/hp6xx_apm.c |    2 +-
 arch/sh/drivers/dma/dma-g2.c          |    2 +-
 arch/sh/drivers/dma/dma-pvr2.c        |    1 -
 arch/sh/drivers/dma/dma-sh.c          |    4 ++--
 arch/sh/drivers/dma/dmabrg.c          |    6 +++---
 arch/sh/drivers/pci/pci-sh5.c         |    4 ++--
 arch/sh/drivers/pci/pci-sh7780.c      |    2 +-
 arch/sh/drivers/push-switch.c         |    2 +-
 arch/sh/kernel/cpu/sh4a/smp-shx3.c    |    2 +-
 11 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/arch/sh/boards/board-secureedge5410.c b/arch/sh/boards/board-secureedge5410.c
index f968f17..03820c3 100644
--- a/arch/sh/boards/board-secureedge5410.c
+++ b/arch/sh/boards/board-secureedge5410.c
@@ -41,8 +41,7 @@ static int __init eraseconfig_init(void)
 	printk("SnapGear: EraseConfig init\n");
 
 	/* Setup "EraseConfig" switch on external IRQ 0 */
-	if (request_irq(irq, eraseconfig_interrupt, IRQF_DISABLED,
-				"Erase Config", NULL))
+	if (request_irq(irq, eraseconfig_interrupt, 0, "Erase Config", NULL))
 		printk("SnapGear: failed to register IRQ%d for Reset witch\n",
 				irq);
 	else
diff --git a/arch/sh/boards/mach-cayman/irq.c b/arch/sh/boards/mach-cayman/irq.c
index 311bceb..724e8b7 100644
--- a/arch/sh/boards/mach-cayman/irq.c
+++ b/arch/sh/boards/mach-cayman/irq.c
@@ -46,13 +46,11 @@ static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id)
 static struct irqaction cayman_action_smsc = {
 	.name		= "Cayman SMSC Mux",
 	.handler	= cayman_interrupt_smsc,
-	.flags		= IRQF_DISABLED,
 };
 
 static struct irqaction cayman_action_pci2 = {
 	.name		= "Cayman PCI2 Mux",
 	.handler	= cayman_interrupt_pci2,
-	.flags		= IRQF_DISABLED,
 };
 
 static void enable_cayman_irq(struct irq_data *data)
diff --git a/arch/sh/boards/mach-hp6xx/hp6xx_apm.c b/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
index b49535c..865d8d6 100644
--- a/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
+++ b/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
@@ -86,7 +86,7 @@ static int __init hp6x0_apm_init(void)
 	int ret;
 
 	ret = request_irq(HP680_BTN_IRQ, hp6x0_apm_interrupt,
-			  IRQF_DISABLED, MODNAME, NULL);
+			  0, MODNAME, NULL);
 	if (unlikely(ret < 0)) {
 		printk(KERN_ERR MODNAME ": IRQ %d request failed\n",
 		       HP680_BTN_IRQ);
diff --git a/arch/sh/drivers/dma/dma-g2.c b/arch/sh/drivers/dma/dma-g2.c
index af7bb58..be9ca7c 100644
--- a/arch/sh/drivers/dma/dma-g2.c
+++ b/arch/sh/drivers/dma/dma-g2.c
@@ -170,7 +170,7 @@ static int __init g2_dma_init(void)
 {
 	int ret;
 
-	ret = request_irq(HW_EVENT_G2_DMA, g2_dma_interrupt, IRQF_DISABLED,
+	ret = request_irq(HW_EVENT_G2_DMA, g2_dma_interrupt, 0,
 			  "g2 DMA handler", &g2_dma_info);
 	if (unlikely(ret))
 		return -EINVAL;
diff --git a/arch/sh/drivers/dma/dma-pvr2.c b/arch/sh/drivers/dma/dma-pvr2.c
index 3cee58e..706a343 100644
--- a/arch/sh/drivers/dma/dma-pvr2.c
+++ b/arch/sh/drivers/dma/dma-pvr2.c
@@ -70,7 +70,6 @@ static int pvr2_xfer_dma(struct dma_channel *chan)
 static struct irqaction pvr2_dma_irq = {
 	.name		= "pvr2 DMA handler",
 	.handler	= pvr2_dma_interrupt,
-	.flags		= IRQF_DISABLED,
 };
 
 static struct dma_ops pvr2_dma_ops = {
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 8272087..a60da6d 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -95,7 +95,7 @@ static int sh_dmac_request_dma(struct dma_channel *chan)
 #if defined(CONFIG_SH_DMA_IRQ_MULTI)
 				IRQF_SHARED,
 #else
-				IRQF_DISABLED,
+				0,
 #endif
 				chan->dev_id, chan);
 }
@@ -305,7 +305,7 @@ static int __init sh_dmac_init(void)
 #if defined(CONFIG_SH_DMA_IRQ_MULTI)
 				IRQF_SHARED,
 #else
-				IRQF_DISABLED,
+				0,
 #endif
 				dmae_name[n], (void *)dmae_name[n]);
 		if (unlikely(i < 0)) {
diff --git a/arch/sh/drivers/dma/dmabrg.c b/arch/sh/drivers/dma/dmabrg.c
index 6ab9c4a..3d66a32 100644
--- a/arch/sh/drivers/dma/dmabrg.c
+++ b/arch/sh/drivers/dma/dmabrg.c
@@ -174,17 +174,17 @@ static int __init dmabrg_init(void)
 	or = __raw_readl(DMAOR);
 	__raw_writel(or | DMAOR_BRG | DMAOR_DMEN, DMAOR);
 
-	ret = request_irq(DMABRGI0, dmabrg_irq, IRQF_DISABLED,
+	ret = request_irq(DMABRGI0, dmabrg_irq, 0,
 			"DMABRG USB address error", NULL);
 	if (ret)
 		goto out0;
 
-	ret = request_irq(DMABRGI1, dmabrg_irq, IRQF_DISABLED,
+	ret = request_irq(DMABRGI1, dmabrg_irq, 0,
 			"DMABRG Transfer End", NULL);
 	if (ret)
 		goto out1;
 
-	ret = request_irq(DMABRGI2, dmabrg_irq, IRQF_DISABLED,
+	ret = request_irq(DMABRGI2, dmabrg_irq, 0,
 			"DMABRG Transfer Half", NULL);
 	if (ret = 0)
 		return ret;
diff --git a/arch/sh/drivers/pci/pci-sh5.c b/arch/sh/drivers/pci/pci-sh5.c
index 0bf296c..16c1e72 100644
--- a/arch/sh/drivers/pci/pci-sh5.c
+++ b/arch/sh/drivers/pci/pci-sh5.c
@@ -107,13 +107,13 @@ static int __init sh5pci_init(void)
 	u32 uval;
 
         if (request_irq(IRQ_ERR, pcish5_err_irq,
-                        IRQF_DISABLED, "PCI Error",NULL) < 0) {
+                        0, "PCI Error",NULL) < 0) {
                 printk(KERN_ERR "PCISH5: Cannot hook PCI_PERR interrupt\n");
                 return -EINVAL;
         }
 
         if (request_irq(IRQ_SERR, pcish5_serr_irq,
-                        IRQF_DISABLED, "PCI SERR interrupt", NULL) < 0) {
+                        0, "PCI SERR interrupt", NULL) < 0) {
                 printk(KERN_ERR "PCISH5: Cannot hook PCI_SERR interrupt\n");
                 return -EINVAL;
         }
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index edb7cca..fa7b978 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -172,7 +172,7 @@ static int __init sh7780_pci_setup_irqs(struct pci_channel *hose)
 		     PCI_STATUS_SIG_TARGET_ABORT | \
 		     PCI_STATUS_PARITY, hose->reg_base + PCI_STATUS);
 
-	ret = request_irq(hose->serr_irq, sh7780_pci_serr_irq, IRQF_DISABLED,
+	ret = request_irq(hose->serr_irq, sh7780_pci_serr_irq, 0,
 			  "PCI SERR interrupt", hose);
 	if (unlikely(ret)) {
 		printk(KERN_ERR "PCI: Failed hooking SERR IRQ\n");
diff --git a/arch/sh/drivers/push-switch.c b/arch/sh/drivers/push-switch.c
index afc2455..637b79b 100644
--- a/arch/sh/drivers/push-switch.c
+++ b/arch/sh/drivers/push-switch.c
@@ -63,7 +63,7 @@ static int switch_drv_probe(struct platform_device *pdev)
 	BUG_ON(!psw_info);
 
 	ret = request_irq(irq, psw_info->irq_handler,
-			  IRQF_DISABLED | psw_info->irq_flags,
+			  psw_info->irq_flags,
 			  psw_info->name ? psw_info->name : DRV_NAME, pdev);
 	if (unlikely(ret < 0))
 		goto err;
diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
index de865ca..03f2b55 100644
--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
@@ -79,7 +79,7 @@ static void shx3_prepare_cpus(unsigned int max_cpus)
 
 	for (i = 0; i < SMP_MSG_NR; i++)
 		request_irq(104 + i, ipi_interrupt_handler,
-			    IRQF_DISABLED | IRQF_PERCPU, "IPI", (void *)(long)i);
+			    IRQF_PERCPU, "IPI", (void *)(long)i);
 
 	for (i = 0; i < max_cpus; i++)
 		set_cpu_present(i, true);
-- 
1.7.1


^ permalink raw reply related

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-22  2:20 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021091524.GB30168@mudshark.cambridge.arm.com>

On Fri, Oct 21, 2011 at 10:15:24AM +0100, Will Deacon wrote:
> On Fri, Oct 21, 2011 at 09:59:58AM +0100, Simon Horman wrote:
> > On Fri, Oct 21, 2011 at 09:46:41AM +0100, Will Deacon wrote:
> > > The more difficult case is when you want to offline the secondary CPUs into
> > > a pen and then boot them in the new kernel. I did get some of this working,
> > > but there are outstanding issues with whether the pen should be at a fixed
> > > location or not. If not, then we need a way to tell the new kernel where it
> > > is, which may involve updating the DT blob...
> > 
> > Is the implication that the (working) callback method does not
> > give the second kernel any secondary CPUs?
> 
> What the callback does it up to you. You just need to make sure that you can
> cope with the kernel disappearing later on, so you'll probably need some
> hardware mechanism for offlining a CPU (for example, placing it in SRAM
> or cutting the power).

Thanks, it seems that I now have a bit of work to do implementing
a callback.

^ permalink raw reply

* [RFC][PATCH 2/2] PM / Domains: Add default power off governor function (v2)
From: Rafael J. Wysocki @ 2011-10-21 23:11 UTC (permalink / raw)
  To: Linux PM list; +Cc: LKML, Linux-sh list, Jean Pihet, Magnus Damm
In-Reply-To: <201110220109.52991.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Add a function deciding whether or not a given PM domain should
be powered off on the basis of that domain's devices' PM QoS
constraints.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/domain_governor.c |   96 +++++++++++++++++++++++++++++++++++
 include/linux/pm_domain.h            |    7 ++
 2 files changed, 103 insertions(+)

Index: linux/include/linux/pm_domain.h
=================================--- linux.orig/include/linux/pm_domain.h
+++ linux/include/linux/pm_domain.h
@@ -49,6 +49,10 @@ struct generic_pm_domain {
 	int (*start_device)(struct device *dev);
 	int (*stop_device)(struct device *dev);
 	bool (*active_wakeup)(struct device *dev);
+	ktime_t power_off_latency;
+	ktime_t power_on_latency;
+	s64 break_even_ns;
+	s64 min_delta_ns;
 };
 
 static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
@@ -64,6 +68,9 @@ struct gpd_link {
 };
 
 struct gpd_gov_dev_data {
+	ktime_t start_latency;
+	ktime_t suspend_latency;
+	ktime_t resume_latency;
 	s64 break_even_ns;
 };
 
Index: linux/drivers/base/power/domain_governor.c
=================================--- linux.orig/drivers/base/power/domain_governor.c
+++ linux/drivers/base/power/domain_governor.c
@@ -35,6 +35,102 @@ bool default_stop_ok(struct device *dev)
 	return constraint_ns > gov_data->break_even_ns;
 }
 
+/* This routine must be executed under the PM domain's lock. */
+static bool default_power_down_ok(struct dev_pm_domain *pd)
+{
+	struct generic_pm_domain *genpd = pd_to_genpd(pd);
+	struct gpd_link *link;
+	struct pm_domain_data *pdd;
+	ktime_t off_time, on_time;
+	s64 delta_ns, min_delta_ns;
+
+	on_time = genpd->power_on_latency;
+	/* Check if slave domains can be off for enough time. */
+	delta_ns = ktime_to_ns(ktime_add(genpd->power_off_latency, on_time));
+	min_delta_ns = 0;
+	/* All slave domains have been powered off at this point. */
+	list_for_each_entry(link, &genpd->master_links, master_node) {
+		if (delta_ns > link->slave->min_delta_ns)
+			return false;
+
+		delta_ns = link->slave->min_delta_ns - delta_ns;
+		if (delta_ns < min_delta_ns)
+			min_delta_ns = delta_ns;
+	}
+
+	genpd->min_delta_ns = min_delta_ns;
+
+	/* Compute the total time needed to power off the domain. */
+	off_time = ktime_set(0, 0);
+	/* All devices have been stopped at this point. */
+	list_for_each_entry(pdd, &genpd->dev_list, list_node) {
+		struct gpd_gov_dev_data *gov_data;
+
+		if (!pdd->dev->driver)
+			continue;
+
+		gov_data = to_gpd_data(pdd)->gov_data;
+		if (!gov_data)
+			continue;
+
+		off_time = ktime_add(off_time, gov_data->suspend_latency);
+	}
+	off_time = ktime_add(off_time, genpd->power_off_latency);
+
+	/*
+	 * For each device in the domain compute the difference between the
+	 * QoS value and the total time required to bring the device back
+	 * assuming that the domain will be powered off and compute the minimum
+	 * of those.
+	 */
+	min_delta_ns = 0;
+	on_time = ktime_add(on_time, off_time);
+	list_for_each_entry(pdd, &genpd->dev_list, list_node) {
+		struct gpd_gov_dev_data *gov_data;
+		struct device *dev = pdd->dev;
+		ktime_t dev_up_time;
+		s32 constraint;
+		s64 constraint_ns;
+
+		if (!dev->driver)
+			continue;
+
+		gov_data = to_gpd_data(pdd)->gov_data;
+		if (gov_data) {
+			dev_up_time = ktime_add(on_time,
+						gov_data->resume_latency);
+			dev_up_time = ktime_add(dev_up_time,
+						gov_data->start_latency);
+		} else {
+			dev_up_time = on_time;
+		}
+
+		constraint = dev_pm_qos_read_value(dev);
+		if (constraint < 0)
+			return false;
+		else if (constraint = 0) /* 0 means "don't care" */
+			continue;
+
+		constraint_ns = constraint;
+		constraint_ns *= NSEC_PER_USEC;
+		delta_ns = constraint_ns - ktime_to_ns(dev_up_time);
+		if (min_delta_ns > delta_ns)
+			min_delta_ns = delta_ns;
+	}
+
+	/* Compare the computed delta with the break even value. */
+	if (min_delta_ns < genpd->break_even_ns)
+		return false;
+
+	/* Store the computed value for the masters to use. */
+	if (genpd->min_delta_ns > min_delta_ns)
+		genpd->min_delta_ns = min_delta_ns;
+
+	/* The domain can be powered off. */
+	return true;
+}
+
 struct dev_power_governor simple_qos_governor = {
 	.stop_ok = default_stop_ok,
+	.power_down_ok = default_power_down_ok,
 };


^ permalink raw reply

* [RFC][PATCH 1/2] PM / Domains: Add device stop governor function (v2)
From: Rafael J. Wysocki @ 2011-10-21 23:10 UTC (permalink / raw)
  To: Linux PM list; +Cc: LKML, Linux-sh list, Jean Pihet, Magnus Damm
In-Reply-To: <201110220109.52991.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Add a function deciding whether or not devices should be
stopped in pm_genpd_runtime_suspend() depending on their
PM QoS values.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 arch/arm/mach-shmobile/pm-sh7372.c   |    4 ++-
 drivers/base/power/Makefile          |    2 -
 drivers/base/power/domain.c          |   29 ++++++++++++++++++----
 drivers/base/power/domain_governor.c |   40 +++++++++++++++++++++++++++++++
 include/linux/pm_domain.h            |   45 +++++++++++++++++++++++++++++++----
 5 files changed, 109 insertions(+), 11 deletions(-)

Index: linux/include/linux/pm_domain.h
=================================--- linux.orig/include/linux/pm_domain.h
+++ linux/include/linux/pm_domain.h
@@ -21,6 +21,7 @@ enum gpd_status {
 
 struct dev_power_governor {
 	bool (*power_down_ok)(struct dev_pm_domain *domain);
+	bool (*stop_ok)(struct device *dev);
 };
 
 struct generic_pm_domain {
@@ -62,8 +63,13 @@ struct gpd_link {
 	struct list_head slave_node;
 };
 
+struct gpd_gov_dev_data {
+	s64 break_even_ns;
+};
+
 struct generic_pm_domain_data {
 	struct pm_domain_data base;
+	struct gpd_gov_dev_data *gov_data;
 	bool need_restore;
 };
 
@@ -73,8 +79,19 @@ static inline struct generic_pm_domain_d
 }
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
-extern int pm_genpd_add_device(struct generic_pm_domain *genpd,
-			       struct device *dev);
+extern struct dev_power_governor simple_qos_governor;
+
+extern struct generic_pm_domain *dev_to_genpd(struct device *dev);
+extern int __pm_genpd_add_device(struct generic_pm_domain *genpd,
+				 struct device *dev,
+				 struct gpd_gov_dev_data *gov_data);
+
+static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
+				      struct device *dev)
+{
+	return __pm_genpd_add_device(genpd, dev, NULL);
+}
+
 extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
 				  struct device *dev);
 extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
@@ -83,8 +100,23 @@ extern int pm_genpd_remove_subdomain(str
 				     struct generic_pm_domain *target);
 extern void pm_genpd_init(struct generic_pm_domain *genpd,
 			  struct dev_power_governor *gov, bool is_off);
+
 extern int pm_genpd_poweron(struct generic_pm_domain *genpd);
+
+extern bool default_stop_ok(struct device *dev);
+
 #else
+
+static inline struct generic_pm_domain *dev_to_genpd(struct device *dev)
+{
+	return ERR_PTR(-ENOSYS);
+}
+static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd,
+					struct device *dev,
+					struct gpd_gov_dev_data *gov_data)
+{
+	return -ENOSYS;
+}
 static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
 				      struct device *dev)
 {
@@ -105,12 +137,17 @@ static inline int pm_genpd_remove_subdom
 {
 	return -ENOSYS;
 }
-static inline void pm_genpd_init(struct generic_pm_domain *genpd,
-				 struct dev_power_governor *gov, bool is_off) {}
+static inline void pm_genpd_init(struct generic_pm_domain *genpd, bool is_off)
+{
+}
 static inline int pm_genpd_poweron(struct generic_pm_domain *genpd)
 {
 	return -ENOSYS;
 }
+static inline bool default_stop_ok(struct device *dev)
+{
+	return false;
+}
 #endif
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS_RUNTIME
Index: linux/drivers/base/power/domain.c
=================================--- linux.orig/drivers/base/power/domain.c
+++ linux/drivers/base/power/domain.c
@@ -21,7 +21,7 @@ static DEFINE_MUTEX(gpd_list_lock);
 
 #ifdef CONFIG_PM
 
-static struct generic_pm_domain *dev_to_genpd(struct device *dev)
+struct generic_pm_domain *dev_to_genpd(struct device *dev)
 {
 	if (IS_ERR_OR_NULL(dev->pm_domain))
 		return ERR_PTR(-EINVAL);
@@ -403,6 +403,22 @@ static void genpd_power_off_work_fn(stru
 }
 
 /**
+ * genpd_stop_dev - Stop a given device if that's beneficial.
+ * @genpd: PM domain the device belongs to.
+ * @dev: Device to stop.
+ */
+static int genpd_stop_dev(struct generic_pm_domain *genpd, struct device *dev)
+{
+	bool (*stop_ok)(struct device *dev);
+
+	stop_ok = genpd->gov ? genpd->gov->stop_ok : NULL;
+	if (stop_ok && !stop_ok(dev))
+		return -EBUSY;
+
+	return genpd->stop_device(dev);
+}
+
+/**
  * pm_genpd_runtime_suspend - Suspend a device belonging to I/O PM domain.
  * @dev: Device to suspend.
  *
@@ -423,7 +439,7 @@ static int pm_genpd_runtime_suspend(stru
 	might_sleep_if(!genpd->dev_irq_safe);
 
 	if (genpd->stop_device) {
-		int ret = genpd->stop_device(dev);
+		int ret = genpd_stop_dev(genpd, dev);
 		if (ret)
 			return ret;
 	}
@@ -495,7 +511,7 @@ static int pm_genpd_runtime_resume(struc
 		mutex_lock(&genpd->lock);
 	}
 	finish_wait(&genpd->status_wait_queue, &wait);
-	__pm_genpd_restore_device(dev->power.subsys_data->domain_data, genpd);
+	__pm_genpd_restore_device(dev_to_psd(dev)->domain_data, genpd);
 	genpd->resume_count--;
 	genpd_set_active(genpd);
 	wake_up_all(&genpd->status_wait_queue);
@@ -1076,11 +1092,13 @@ static void pm_genpd_complete(struct dev
 #endif /* CONFIG_PM_SLEEP */
 
 /**
- * pm_genpd_add_device - Add a device to an I/O PM domain.
+ * __pm_genpd_add_device - Add a device to an I/O PM domain.
  * @genpd: PM domain to add the device to.
  * @dev: Device to be added.
+ * @gov_data: Set of PM QoS parameters to attach to the device.
  */
-int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
+int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
+			  struct gpd_gov_dev_data *gov_data)
 {
 	struct generic_pm_domain_data *gpd_data;
 	struct pm_domain_data *pdd;
@@ -1123,6 +1141,7 @@ int pm_genpd_add_device(struct generic_p
 	gpd_data->base.dev = dev;
 	gpd_data->need_restore = false;
 	list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);
+	gpd_data->gov_data = gov_data;
 
  out:
 	genpd_release_lock(genpd);
Index: linux/drivers/base/power/Makefile
=================================--- linux.orig/drivers/base/power/Makefile
+++ linux/drivers/base/power/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_PM_SLEEP)	+= main.o wakeup.
 obj-$(CONFIG_PM_RUNTIME)	+= runtime.o
 obj-$(CONFIG_PM_TRACE_RTC)	+= trace.o
 obj-$(CONFIG_PM_OPP)	+= opp.o
-obj-$(CONFIG_PM_GENERIC_DOMAINS)	+=  domain.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS)	+=  domain.o domain_governor.o
 obj-$(CONFIG_HAVE_CLK)	+= clock_ops.o
 
 ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
Index: linux/drivers/base/power/domain_governor.c
=================================--- /dev/null
+++ linux/drivers/base/power/domain_governor.c
@@ -0,0 +1,40 @@
+/*
+ * drivers/base/power/domain_governor.c - Governors for device PM domains.
+ *
+ * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
+ *
+ * This file is released under the GPLv2.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/pm_domain.h>
+#include <linux/pm_qos.h>
+
+bool default_stop_ok(struct device *dev)
+{
+	struct gpd_gov_dev_data *gov_data;
+	s64 constraint_ns;
+	s32 constraint;
+
+	dev_dbg(dev, "%s()\n", __func__);
+
+	gov_data = to_gpd_data(dev_to_psd(dev)->domain_data)->gov_data;
+	if (!gov_data)
+		return true;
+
+	constraint = dev_pm_qos_read_value(dev);
+	if (constraint < 0)
+		return false;
+	else if (constraint = 0) /* 0 means "don't care" */
+		return true;
+
+	constraint_ns = constraint;
+	constraint_ns *= NSEC_PER_USEC;
+
+	return constraint_ns > gov_data->break_even_ns;
+}
+
+struct dev_power_governor simple_qos_governor = {
+	.stop_ok = default_stop_ok,
+};
Index: linux/arch/arm/mach-shmobile/pm-sh7372.c
=================================--- linux.orig/arch/arm/mach-shmobile/pm-sh7372.c
+++ linux/arch/arm/mach-shmobile/pm-sh7372.c
@@ -161,13 +161,15 @@ static bool sh7372_power_down_forbidden(
 
 struct dev_power_governor sh7372_always_on_gov = {
 	.power_down_ok = sh7372_power_down_forbidden,
+	.stop_ok = default_stop_ok,
 };
 
 void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd)
 {
 	struct generic_pm_domain *genpd = &sh7372_pd->genpd;
+	struct dev_power_governor *gov = sh7372_pd->gov;
 
-	pm_genpd_init(genpd, sh7372_pd->gov, false);
+	pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
 	genpd->stop_device = pm_clk_suspend;
 	genpd->start_device = pm_clk_resume;
 	genpd->dev_irq_safe = true;


^ permalink raw reply

* [RFC][PATCH 0/2] PM: Generic PM domains and device PM QoS (v2)
From: Rafael J. Wysocki @ 2011-10-21 23:09 UTC (permalink / raw)
  To: Linux PM list; +Cc: LKML, Linux-sh list, Jean Pihet, Magnus Damm

Hi,

This patchset is a refresh of patches introducing simple PM QoS governor
functions for PM domains.  The patches still haven't been tested properly,
although they should build.  The purpose of them is mainly to illustrate
how PM QoS may be used with PM domains to control device runtime PM.

Thanks,
Rafael


^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Will Deacon @ 2011-10-21  9:15 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021085958.GC21850@verge.net.au>

On Fri, Oct 21, 2011 at 09:59:58AM +0100, Simon Horman wrote:
> On Fri, Oct 21, 2011 at 09:46:41AM +0100, Will Deacon wrote:
> > The more difficult case is when you want to offline the secondary CPUs into
> > a pen and then boot them in the new kernel. I did get some of this working,
> > but there are outstanding issues with whether the pen should be at a fixed
> > location or not. If not, then we need a way to tell the new kernel where it
> > is, which may involve updating the DT blob...
> 
> Is the implication that the (working) callback method does not
> give the second kernel any secondary CPUs?

What the callback does it up to you. You just need to make sure that you can
cope with the kernel disappearing later on, so you'll probably need some
hardware mechanism for offlining a CPU (for example, placing it in SRAM
or cutting the power).

Will

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-21  8:59 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021084641.GA30168@mudshark.cambridge.arm.com>

On Fri, Oct 21, 2011 at 09:46:41AM +0100, Will Deacon wrote:
> On Fri, Oct 21, 2011 at 09:34:26AM +0100, Simon Horman wrote:
> > I have tested the kexec/mmu-off branch of your tree on the UP board
> > I mentioned above and kexec works :)
> 
> Hurrah! Thanks for giving it a spin.
> 
> > > You mention UP in particular, which I will test.
> > > Do you have any thoughts on SMP?
> 
> Yes. Currently [i.e. on my branch above] you can do SMP kexec using the CPU
> hotplug platform_cpu_kill callback to take down the CPUs in some
> platform-specific manner.

Thanks, I will take a look into it.

> The more difficult case is when you want to offline the secondary CPUs into
> a pen and then boot them in the new kernel. I did get some of this working,
> but there are outstanding issues with whether the pen should be at a fixed
> location or not. If not, then we need a way to tell the new kernel where it
> is, which may involve updating the DT blob...

Is the implication that the (working) callback method does not
give the second kernel any secondary CPUs?

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Will Deacon @ 2011-10-21  8:46 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021083426.GA16088@verge.net.au>

On Fri, Oct 21, 2011 at 09:34:26AM +0100, Simon Horman wrote:
> I have tested the kexec/mmu-off branch of your tree on the UP board
> I mentioned above and kexec works :)

Hurrah! Thanks for giving it a spin.

> > You mention UP in particular, which I will test.
> > Do you have any thoughts on SMP?

Yes. Currently [i.e. on my branch above] you can do SMP kexec using the CPU
hotplug platform_cpu_kill callback to take down the CPUs in some
platform-specific manner.

The more difficult case is when you want to offline the secondary CPUs into
a pen and then boot them in the new kernel. I did get some of this working,
but there are outstanding issues with whether the pen should be at a fixed
location or not. If not, then we need a way to tell the new kernel where it
is, which may involve updating the DT blob...

Will

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-21  8:34 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111020080823.GA2716@verge.net.au>

On Thu, Oct 20, 2011 at 05:08:24PM +0900, Simon Horman wrote:
> On Thu, Oct 20, 2011 at 08:01:06AM +0100, Will Deacon wrote:
> > On Thu, Oct 20, 2011 at 05:24:45AM +0100, Simon Horman wrote:
> > > Hi Will, Hi All,
> > 
> > Hi Simon,
> 
> Hi Will,
> 
> > > it appears that "ARM: proc: add definition of cpu_reset for
> > >  ARMv6 and ARMv7 cores" (f4daf06fc23b99df5ca5b3e892428b91e148cc52),
> > > which was introduced for 3.1-rc1, causes a regression and that
> > > kexec no longer works on ARM. The board that I am testing
> > > on is a Renesas Mackerel which has an SH7372 (ARMv7) processor.
> > 
> > Wow, I'm surprised the old code worked at all on an ARMv7 CPU! It's certainly
> > highly unlikely to work by the letter of the architecture, so I guess the
> > planets aligned in just the right way for your particular implementation.
> > 
> > Please can you try my kexec/mmu-off patches? They should add the bits and
> > pieces you need for kexec to work reliably on a UP system. I plan to finish
> > these off next week in Prague so hopefully they'll hit mainline in the near
> > future.
> > 
> > https://github.com/wdeacon/linux-wd/commits/kexec/mmu-off
> 
> Thanks, I will try your patches and let you know how I go.

I have tested the kexec/mmu-off branch of your tree on the UP board
I mentioned above and kexec works :)

> You mention UP in particular, which I will test.
> Do you have any thoughts on SMP?

^ permalink raw reply

* Re: Ecovec in current sh-latest
From: Kuninori Morimoto @ 2011-10-21  1:57 UTC (permalink / raw)
  To: linux-sh
In-Reply-To: <Pine.LNX.4.64.1109020025350.15166@axis700.grange>


Hi Magnus, Paul

> > > To get ecovec to run with today's sh-latest (pretty much the same with 
> > > Linux' tree) the following patches have to be reverted:
> > > 
> > > commit 794d78fea51504bad3880d14f354a9847f318f25
> > > Author: Magnus Damm <damm@opensource.se>
> > > Date:   Tue Jun 21 07:55:12 2011 +0000
> > > 
> > >     drivers: sh: late disabling of clocks V2
> > > 
> > Do we know which driver that's the problem for the ecovec case?
> 
> I see at least two drivers misbehaving: ethernet is failing to perform 
> dhcp for nfs root-mount, and LCD gets an image at boot and then slowly 
> fade out.

My renesas_usbhs driver breaks too in SH7724 ecovec board.
So I debuged it.

when my driver call pm_runtime_get_sync(),
then, arch/sh/kernel/cpu/hwblk.c :: hwblk_enable() are called,
and it enabled my driver's MSTP bit.

But clk_late_init() disabled it.

Does hwblk/pm_runtime (?) didn't care clk->usecount ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply

* Re: Ecovec in current sh-latest
From: Kuninori Morimoto @ 2011-10-21  1:53 UTC (permalink / raw)
  To: linux-sh
In-Reply-To: <Pine.LNX.4.64.1109020025350.15166@axis700.grange>


Hi Magnus, Paul

> > > To get ecovec to run with today's sh-latest (pretty much the same with 
> > > Linux' tree) the following patches have to be reverted:
> > > 
> > > commit 794d78fea51504bad3880d14f354a9847f318f25
> > > Author: Magnus Damm <damm@opensource.se>
> > > Date:   Tue Jun 21 07:55:12 2011 +0000
> > > 
> > >     drivers: sh: late disabling of clocks V2
> > > 
> > Do we know which driver that's the problem for the ecovec case?
> 
> I see at least two drivers misbehaving: ethernet is failing to perform 
> dhcp for nfs root-mount, and LCD gets an image at boot and then slowly 
> fade out.

My renesas_usbhs driver breaks too in SH7724 ecovec board.
So I debuged it.

when my driver call pm_runtime_get_sync(),
then, arch/sh/kernel/cpu/hwblk.c :: hwblk_enable() are called,
and it enabled my driver's MSTP bit.

But clk_late_init() disabled it.

Does hwblk/pm_runtime (?) didn't care clk->usecount ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-20  8:08 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111020070105.GA28548@mudshark.cambridge.arm.com>

On Thu, Oct 20, 2011 at 08:01:06AM +0100, Will Deacon wrote:
> On Thu, Oct 20, 2011 at 05:24:45AM +0100, Simon Horman wrote:
> > Hi Will, Hi All,
> 
> Hi Simon,

Hi Will,

> > it appears that "ARM: proc: add definition of cpu_reset for
> >  ARMv6 and ARMv7 cores" (f4daf06fc23b99df5ca5b3e892428b91e148cc52),
> > which was introduced for 3.1-rc1, causes a regression and that
> > kexec no longer works on ARM. The board that I am testing
> > on is a Renesas Mackerel which has an SH7372 (ARMv7) processor.
> 
> Wow, I'm surprised the old code worked at all on an ARMv7 CPU! It's certainly
> highly unlikely to work by the letter of the architecture, so I guess the
> planets aligned in just the right way for your particular implementation.
> 
> Please can you try my kexec/mmu-off patches? They should add the bits and
> pieces you need for kexec to work reliably on a UP system. I plan to finish
> these off next week in Prague so hopefully they'll hit mainline in the near
> future.
> 
> https://github.com/wdeacon/linux-wd/commits/kexec/mmu-off

Thanks, I will try your patches and let you know how I go.

You mention UP in particular, which I will test.
Do you have any thoughts on SMP?


^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Will Deacon @ 2011-10-20  7:01 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111020042444.GA20260@verge.net.au>

On Thu, Oct 20, 2011 at 05:24:45AM +0100, Simon Horman wrote:
> Hi Will, Hi All,

Hi Simon,

> it appears that "ARM: proc: add definition of cpu_reset for
>  ARMv6 and ARMv7 cores" (f4daf06fc23b99df5ca5b3e892428b91e148cc52),
> which was introduced for 3.1-rc1, causes a regression and that
> kexec no longer works on ARM. The board that I am testing
> on is a Renesas Mackerel which has an SH7372 (ARMv7) processor.

Wow, I'm surprised the old code worked at all on an ARMv7 CPU! It's certainly
highly unlikely to work by the letter of the architecture, so I guess the
planets aligned in just the right way for your particular implementation.

Please can you try my kexec/mmu-off patches? They should add the bits and
pieces you need for kexec to work reliably on a UP system. I plan to finish
these off next week in Prague so hopefully they'll hit mainline in the near
future.

https://github.com/wdeacon/linux-wd/commits/kexec/mmu-off

Will

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox