* [PATCH] ARM: pxa: make pwm driver module_platform_driver
@ 2013-08-08 17:00 Mike Dunn
2013-08-08 20:38 ` Robert Jarzmik
2013-08-09 7:22 ` Marek Vasut
0 siblings, 2 replies; 3+ messages in thread
From: Mike Dunn @ 2013-08-08 17:00 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Marek Vasut, linux-pwm, Mike Dunn, Thierry Reding, Haojian Zhuang,
Chao Xie, Eric Miao, H Hartley Sweeten, Robert Jarzmik
Commit 76abbdde2d95a3807d0dc6bf9f84d03d0dbd4f3d
pwm: Add sysfs interface
causes a kernel oops due to a null pointer dereference on pxa platforms. This
happens because the class added by the patch is registered in a subsys_initcall
(initcall4), but the pxa pwm driver is registered in arch_initcall (initcall3).
If the class is not registered before the driver probe function runs, the oops
occurs in device_add() when the uninitialized pointers in struct class are
dereferenced. I don't see a reason that the driver must be an arch_initcall, so
this patch makes it a regular module_platform_driver (initcall6), preventing the
oops.
Signed-off-by: Mike Dunn <mikedunn@newsguy.com>
---
drivers/pwm/pwm-pxa.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index dc97175..a4d2164 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -182,16 +182,6 @@ static struct platform_driver pwm_driver = {
.id_table = pwm_id_table,
};
-static int __init pwm_init(void)
-{
- return platform_driver_register(&pwm_driver);
-}
-arch_initcall(pwm_init);
-
-static void __exit pwm_exit(void)
-{
- platform_driver_unregister(&pwm_driver);
-}
-module_exit(pwm_exit);
+module_platform_driver(pwm_driver);
MODULE_LICENSE("GPL v2");
--
1.8.1.5
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: pxa: make pwm driver module_platform_driver
2013-08-08 17:00 [PATCH] ARM: pxa: make pwm driver module_platform_driver Mike Dunn
@ 2013-08-08 20:38 ` Robert Jarzmik
2013-08-09 7:22 ` Marek Vasut
1 sibling, 0 replies; 3+ messages in thread
From: Robert Jarzmik @ 2013-08-08 20:38 UTC (permalink / raw)
To: Mike Dunn
Cc: linux-arm-kernel, linux-pwm, Thierry Reding, H Hartley Sweeten,
Haojian Zhuang, Chao Xie, Eric Miao, Marek Vasut
Mike Dunn <mikedunn@newsguy.com> writes:
> Commit 76abbdde2d95a3807d0dc6bf9f84d03d0dbd4f3d
>
> pwm: Add sysfs interface
>
> causes a kernel oops due to a null pointer dereference on pxa platforms. This
> happens because the class added by the patch is registered in a subsys_initcall
> (initcall4), but the pxa pwm driver is registered in arch_initcall (initcall3).
> If the class is not registered before the driver probe function runs, the oops
> occurs in device_add() when the uninitialized pointers in struct class are
> dereferenced. I don't see a reason that the driver must be an arch_initcall, so
> this patch makes it a regular module_platform_driver (initcall6), preventing the
> oops.
That makes sense.
The only users I'm aware of for PWM on pxa is backlight, and that can certainly
wait for regular driver initcall level. I'm not aware of any usage in early boot
stages.
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
--
Robert
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: pxa: make pwm driver module_platform_driver
2013-08-08 17:00 [PATCH] ARM: pxa: make pwm driver module_platform_driver Mike Dunn
2013-08-08 20:38 ` Robert Jarzmik
@ 2013-08-09 7:22 ` Marek Vasut
1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2013-08-09 7:22 UTC (permalink / raw)
To: Mike Dunn
Cc: linux-arm-kernel, linux-pwm, Thierry Reding, H Hartley Sweeten,
Haojian Zhuang, Chao Xie, Eric Miao, Robert Jarzmik
Dear Mike Dunn,
> Commit 76abbdde2d95a3807d0dc6bf9f84d03d0dbd4f3d
>
> pwm: Add sysfs interface
>
> causes a kernel oops due to a null pointer dereference on pxa platforms.
> This happens because the class added by the patch is registered in a
> subsys_initcall (initcall4), but the pxa pwm driver is registered in
> arch_initcall (initcall3). If the class is not registered before the
> driver probe function runs, the oops occurs in device_add() when the
> uninitialized pointers in struct class are dereferenced. I don't see a
> reason that the driver must be an arch_initcall, so this patch makes it a
> regular module_platform_driver (initcall6), preventing the oops.
>
> Signed-off-by: Mike Dunn <mikedunn@newsguy.com>
> ---
> drivers/pwm/pwm-pxa.c | 12 +-----------
> 1 file changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
> index dc97175..a4d2164 100644
> --- a/drivers/pwm/pwm-pxa.c
> +++ b/drivers/pwm/pwm-pxa.c
> @@ -182,16 +182,6 @@ static struct platform_driver pwm_driver = {
> .id_table = pwm_id_table,
> };
>
> -static int __init pwm_init(void)
> -{
> - return platform_driver_register(&pwm_driver);
> -}
> -arch_initcall(pwm_init);
> -
> -static void __exit pwm_exit(void)
> -{
> - platform_driver_unregister(&pwm_driver);
> -}
> -module_exit(pwm_exit);
> +module_platform_driver(pwm_driver);
>
> MODULE_LICENSE("GPL v2");
Acked-by: Marek Vasut <marex@denx.de>
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-09 7:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-08 17:00 [PATCH] ARM: pxa: make pwm driver module_platform_driver Mike Dunn
2013-08-08 20:38 ` Robert Jarzmik
2013-08-09 7:22 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).