diff mbox

[01/10] gpio: pxa: set initcall level to module init

Message ID 1358929554-32265-2-git-send-email-haojian.zhuang@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Haojian Zhuang Jan. 23, 2013, 8:25 a.m. UTC
gpio & pinctrl driver are used together. The pinctrl driver is already
launched before gpio driver in Makefile. So set gpio driver to module
init level. Otherwise, the sequence will be inverted.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/gpio/gpio-pxa.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Linus Walleij Jan. 25, 2013, 9:51 a.m. UTC | #1
On Wed, Jan 23, 2013 at 9:25 AM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:

> gpio & pinctrl driver are used together. The pinctrl driver is already
> launched before gpio driver in Makefile. So set gpio driver to module
> init level. Otherwise, the sequence will be inverted.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Applied to my devel branch.

Thanks!
Linus Walleij
Robert Jarzmik Jan. 25, 2013, 9:01 p.m. UTC | #2
Haojian Zhuang <haojian.zhuang@linaro.org> writes:

> gpio & pinctrl driver are used together. The pinctrl driver is already
> launched before gpio driver in Makefile. So set gpio driver to module
> init level. Otherwise, the sequence will be inverted.
Hi Haojian,

If you switch gpio to module level, and as some modules use gpios in their init
path, isn't it possible that some modules will fail their init, as GPIO API
won't provide the gpio_*_value() functions ?

Cheers.

--
Robert
Haojian Zhuang Jan. 28, 2013, 4:26 a.m. UTC | #3
On 26 January 2013 05:01, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
> Haojian Zhuang <haojian.zhuang@linaro.org> writes:
>
>> gpio & pinctrl driver are used together. The pinctrl driver is already
>> launched before gpio driver in Makefile. So set gpio driver to module
>> init level. Otherwise, the sequence will be inverted.
> Hi Haojian,
>
> If you switch gpio to module level, and as some modules use gpios in their init
> path, isn't it possible that some modules will fail their init, as GPIO API
> won't provide the gpio_*_value() functions ?
>

gpio_request() should return EPROBE_DEFER, then the driver is using gpio API
fails and it should be retried after a while. At that time, gpio
driver should be launched
properly.

Regards
Haojian
Linus Walleij Jan. 28, 2013, 10:27 a.m. UTC | #4
On Mon, Jan 28, 2013 at 5:26 AM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:
> On 26 January 2013 05:01, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
>> Haojian Zhuang <haojian.zhuang@linaro.org> writes:
>>
>>> gpio & pinctrl driver are used together. The pinctrl driver is already
>>> launched before gpio driver in Makefile. So set gpio driver to module
>>> init level. Otherwise, the sequence will be inverted.
>> Hi Haojian,
>>
>> If you switch gpio to module level, and as some modules use gpios in their init
>> path, isn't it possible that some modules will fail their init, as GPIO API
>> won't provide the gpio_*_value() functions ?
>
> gpio_request() should return EPROBE_DEFER, then the driver is using gpio API
> fails and it should be retried after a while. At that time, gpio
> driver should be launched
> properly.

Correct. However it is not uncommon for modules to have untested
errorpaths, such as:

ret = gpio_request(12);
if (ret)
   return -ENODEV;

So you will not know before you test.

Then it is often common to have memory leaks in the errorpath...

So Tested-by: tags are appreciated.

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 8325f58..9cc108d 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -642,12 +642,7 @@  static struct platform_driver pxa_gpio_driver = {
 		.of_match_table = of_match_ptr(pxa_gpio_dt_ids),
 	},
 };
-
-static int __init pxa_gpio_init(void)
-{
-	return platform_driver_register(&pxa_gpio_driver);
-}
-postcore_initcall(pxa_gpio_init);
+module_platform_driver(pxa_gpio_driver);
 
 #ifdef CONFIG_PM
 static int pxa_gpio_suspend(void)