Subject: gpio-pxa initcall level change and machine init breakage

From: [email-masked] (Mike Dunn)
Date: Sat, 20 Apr 2013 08:26:16 -0700

Hi,

After a few months of neglect, I rebased my palm treo 680 kernel with the latest
from Linus' official tree, and now all the calls to gpio lib functions
(gpio_request(), etc) made from the init_machine() method in struct machine_desc
fail.  I tracked this back to commit 6c7e660a27da7494c670bfba21cfeba30457656c
dated Jan 23 2013

    gpio: pxa: set initcall level to module init

    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 <[email-masked]>
    Signed-off-by: Linus Walleij <[email-masked]>

At the time, Haojian addressed a question about this patch regarding module
dependencies, advising use of the deferred probe infrastructure.  But unless I'm
mistaken, mine is an initcall level problem, not a dependency issue among driver
probes.  Now that gpio-pxa initialization is at the device level (initcall6),
calls to gpiolib are no longer possible from init_machine(), which remains at
the initcall3 level.

I feel like I must be missing something, because a lot of pxa boards call
gpiolib from init machine(), so my breakage should not be an isolated case.

If I'm not missing anything and the patch is necessary, it looks like one
solution would be to move all the initializations that use gpiolib to the
init_late method in struct machine_desc, which runs as initcall7.

Grateful for any advice!

Thanks,
Mike