diff mbox

[v7,09/15] gpio: pl061: set initcall level to module init

Message ID 1358494279-16503-10-git-send-email-haojian.zhuang@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Haojian Zhuang Jan. 18, 2013, 7:31 a.m. UTC
Replace subsys initcall by module initcall level. Since pinctrl
driver is already launched before gpio driver. It's unnecessary
to set gpio driver in subsys init call level.

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

Comments

Linus Walleij Jan. 21, 2013, 2:41 p.m. UTC | #1
On Fri, Jan 18, 2013 at 8:31 AM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:

> Replace subsys initcall by module initcall level. Since pinctrl
> driver is already launched before gpio driver. It's unnecessary
> to set gpio driver in subsys init call level.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

On you platform maybe it works, but have you made sure that nobody
else will be affected?

SPEAr of course, then these:

arch/arm/mach-realview/core.c:           * GPIO on PL061 is active,
which is the proper
arch/arm/mach-socfpga/Kconfig:  select GPIO_PL061 if GPIOLIB

Pawel, Dinh: are you OK with this change?

Yours,
Linus Walleij
Pawel Moll Jan. 21, 2013, 4:24 p.m. UTC | #2
On Mon, 2013-01-21 at 14:41 +0000, Linus Walleij wrote:
> On Fri, Jan 18, 2013 at 8:31 AM, Haojian Zhuang
> <haojian.zhuang@linaro.org> wrote:
> 
> > Replace subsys initcall by module initcall level. Since pinctrl
> > driver is already launched before gpio driver. It's unnecessary
> > to set gpio driver in subsys init call level.
> >
> > Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> 
> On you platform maybe it works, but have you made sure that nobody
> else will be affected?
> 
> SPEAr of course, then these:
> 
> arch/arm/mach-realview/core.c:           * GPIO on PL061 is active,
> which is the proper
> arch/arm/mach-socfpga/Kconfig:  select GPIO_PL061 if GPIOLIB
> 
> Pawel, Dinh: are you OK with this change?

Hm. Doesn't this make the MMCI probing depending on the module_init
order? As in: wouldn't it make the mmci probe completely fail (not even
defer it) if it was called before the pl061? In that case even your,
Linus, hack with inverting the CD status wouldn't work...

Pawel
Dinh Nguyen Jan. 21, 2013, 8:20 p.m. UTC | #3
Hi Linus,

On Mon, 2013-01-21 at 16:24 +0000, Pawel Moll wrote:
> On Mon, 2013-01-21 at 14:41 +0000, Linus Walleij wrote:
> > On Fri, Jan 18, 2013 at 8:31 AM, Haojian Zhuang
> > <haojian.zhuang@linaro.org> wrote:
> > 
> > > Replace subsys initcall by module initcall level. Since pinctrl
> > > driver is already launched before gpio driver. It's unnecessary
> > > to set gpio driver in subsys init call level.
> > >
> > > Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> > 
> > On you platform maybe it works, but have you made sure that nobody
> > else will be affected?
> > 
> > SPEAr of course, then these:
> > 
> > arch/arm/mach-realview/core.c:           * GPIO on PL061 is active,
> > which is the proper
> > arch/arm/mach-socfpga/Kconfig:  select GPIO_PL061 if GPIOLIB
> > 
> > Pawel, Dinh: are you OK with this change?

Still works ok on mach-socfpga.

Dinh
> 
> Hm. Doesn't this make the MMCI probing depending on the module_init
> order? As in: wouldn't it make the mmci probe completely fail (not even
> defer it) if it was called before the pl061? In that case even your,
> Linus, hack with inverting the CD status wouldn't work...
> 
> Pawel
> 
> 
> 
>
Haojian Zhuang Jan. 21, 2013, 11:33 p.m. UTC | #4
On 22 January 2013 00:24, Pawel Moll <pawel.moll@arm.com> wrote:
> On Mon, 2013-01-21 at 14:41 +0000, Linus Walleij wrote:
>> On Fri, Jan 18, 2013 at 8:31 AM, Haojian Zhuang
>> <haojian.zhuang@linaro.org> wrote:
>>
>> > Replace subsys initcall by module initcall level. Since pinctrl
>> > driver is already launched before gpio driver. It's unnecessary
>> > to set gpio driver in subsys init call level.
>> >
>> > Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
>>
>> On you platform maybe it works, but have you made sure that nobody
>> else will be affected?
>>
>> SPEAr of course, then these:
>>
>> arch/arm/mach-realview/core.c:           * GPIO on PL061 is active,
>> which is the proper
>> arch/arm/mach-socfpga/Kconfig:  select GPIO_PL061 if GPIOLIB
>>
>> Pawel, Dinh: are you OK with this change?
>
> Hm. Doesn't this make the MMCI probing depending on the module_init
> order? As in: wouldn't it make the mmci probe completely fail (not even
> defer it) if it was called before the pl061? In that case even your,
> Linus, hack with inverting the CD status wouldn't work...
>
> Pawel
>
>
>
The sequence of module probe is pinctrl --> gpio --> mmc. So the dependance
of mmc on gpio isn't broken.

Regards
Haojian
Linus Walleij Jan. 22, 2013, 9:42 a.m. UTC | #5
On Mon, Jan 21, 2013 at 5:24 PM, Pawel Moll <pawel.moll@arm.com> wrote:

> Hm. Doesn't this make the MMCI probing depending on the module_init
> order? As in: wouldn't it make the mmci probe completely fail (not even
> defer it) if it was called before the pl061? In that case even your,
> Linus, hack with inverting the CD status wouldn't work...

According to Haojian it works, but for sure the MMCI driver *should*
(on the eternal list of SHOULDDO) bail out and return any
-EPROBE_DEFER up to the AMBA bus core properly so it
will be tried again later if this happens.

AFAICT gpio_request() will return -EPROBE_DEFER if the GPIO
cannot be located.

Yours,
Linus Walleij
Linus Walleij Jan. 22, 2013, 9:44 a.m. UTC | #6
On Mon, Jan 21, 2013 at 9:20 PM, Dinh Nguyen <dinguyen@altera.com> wrote:

>> > Pawel, Dinh: are you OK with this change?
>
> Still works ok on mach-socfpga.

Thanks! Adding your Tested-by tag, OK?

Yours,
Linus Walleij
Linus Walleij Jan. 22, 2013, 9:45 a.m. UTC | #7
On Fri, Jan 18, 2013 at 8:31 AM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:

> Replace subsys initcall by module initcall level. Since pinctrl
> driver is already launched before gpio driver. It's unnecessary
> to set gpio driver in subsys init call level.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

OK some consensus that this works, and moving initcalls to module_init()
should be encouraged, so applied this and thrown at linux-next for
testing. No pain no gain.

Yours,
Linus Walleij
Pawel Moll Jan. 22, 2013, 10:13 a.m. UTC | #8
On Tue, 2013-01-22 at 09:42 +0000, Linus Walleij wrote:
> AFAICT gpio_request() will return -EPROBE_DEFER if the GPIO
> cannot be located.

If it does, I withdraw all my objections.

Cheers!

Pawe?
Pawel Moll Jan. 22, 2013, 10:21 a.m. UTC | #9
On Mon, 2013-01-21 at 23:33 +0000, Haojian Zhuang wrote:
> The sequence of module probe is pinctrl --> gpio --> mmc. So the dependance
> of mmc on gpio isn't broken.

I don't think you can guarantee the "gpio --> mmc" sequence if both
drivers use module_init (the order could be completely random, generally
it depends on what Kbuild is doing), but if gpio_request() behaves as
Linus said, the sequence in the problematic scenario would be "pinctrl
--> mmc --> EPROBE_DEFER --> gpio --> mmc" which is fine (subject to
mmci driver fix, but it's a separate issue).

Pawe?
Russell King - ARM Linux Jan. 22, 2013, 10:41 a.m. UTC | #10
On Tue, Jan 22, 2013 at 10:42:11AM +0100, Linus Walleij wrote:
> On Mon, Jan 21, 2013 at 5:24 PM, Pawel Moll <pawel.moll@arm.com> wrote:
> 
> > Hm. Doesn't this make the MMCI probing depending on the module_init
> > order? As in: wouldn't it make the mmci probe completely fail (not even
> > defer it) if it was called before the pl061? In that case even your,
> > Linus, hack with inverting the CD status wouldn't work...
> 
> According to Haojian it works, but for sure the MMCI driver *should*
> (on the eternal list of SHOULDDO) bail out and return any

Rather than talking about what should and should not, why not look at
the code - it only takes a few moments to check what the behaviour
would be.  And it is correct - errors are correctly propagated out of
the probe function.

That's hardly surprising given who's supposed to be the maintainer of
that driver.
Linus Walleij Jan. 22, 2013, 12:55 p.m. UTC | #11
On Tue, Jan 22, 2013 at 11:41 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Tue, Jan 22, 2013 at 10:42:11AM +0100, Linus Walleij wrote:
>> On Mon, Jan 21, 2013 at 5:24 PM, Pawel Moll <pawel.moll@arm.com> wrote:
>>
>> > Hm. Doesn't this make the MMCI probing depending on the module_init
>> > order? As in: wouldn't it make the mmci probe completely fail (not even
>> > defer it) if it was called before the pl061? In that case even your,
>> > Linus, hack with inverting the CD status wouldn't work...
>>
>> According to Haojian it works, but for sure the MMCI driver *should*
>> (on the eternal list of SHOULDDO) bail out and return any
>
> Rather than talking about what should and should not, why not look at
> the code - it only takes a few moments to check what the behaviour
> would be.  And it is correct - errors are correctly propagated out of
> the probe function.

OK good!

> That's hardly surprising given who's supposed to be the maintainer of
> that driver.

Aouh that hurt! ;-)

Thanks Russell,
Linus Walleij
Dinh Nguyen Jan. 22, 2013, 3:47 p.m. UTC | #12
Hi Linus,

On Tue, 2013-01-22 at 10:44 +0100, Linus Walleij wrote:
> On Mon, Jan 21, 2013 at 9:20 PM, Dinh Nguyen <dinguyen@altera.com> wrote:
> 
> >> > Pawel, Dinh: are you OK with this change?
> >
> > Still works ok on mach-socfpga.
> 
> Thanks! Adding your Tested-by tag, OK?

Yep, thanks.

Dinh
> 
> Yours,
> Linus Walleij
>
diff mbox

Patch

diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 8cfdf60..76adf33 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -393,7 +393,7 @@  static int __init pl061_gpio_init(void)
 {
 	return amba_driver_register(&pl061_gpio_driver);
 }
-subsys_initcall(pl061_gpio_init);
+module_init(pl061_gpio_init);
 
 MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
 MODULE_DESCRIPTION("PL061 GPIO driver");