Skip to content

Commit 730e5eb

Browse files
Danilo KrummrichBartosz Golaszewski
authored andcommitted
gpio: omap: do not register driver in probe()
Commit 11a78b7 ("ARM: OMAP: MPUIO wake updates") registers the omap_mpuio_driver from omap_mpuio_init(), which is called from omap_gpio_probe(). However, it neither makes sense to register drivers from probe() callbacks of other drivers, nor does the driver core allow registering drivers with a device lock already being held. The latter was revealed by commit dc23806 ("driver core: enforce device_lock for driver_match_device()") leading to a potential deadlock condition described in [1]. Additionally, the omap_mpuio_driver is never unregistered from the driver core, even if the module is unloaded. Hence, register the omap_mpuio_driver from the module initcall and unregister it in module_exit(). Link: https://lore.kernel.org/lkml/DFU7CEPUSG9A.1KKGVW4HIPMSH@kernel.org/ [1] Fixes: dc23806 ("driver core: enforce device_lock for driver_match_device()") Fixes: 11a78b7 ("ARM: OMAP: MPUIO wake updates") Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Link: https://patch.msgid.link/20260127201725.35883-1-dakr@kernel.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent d02f20a commit 730e5eb

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

drivers/gpio/gpio-omap.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,13 @@ static struct platform_device omap_mpuio_device = {
799799

800800
static inline void omap_mpuio_init(struct gpio_bank *bank)
801801
{
802-
platform_set_drvdata(&omap_mpuio_device, bank);
802+
static bool registered;
803803

804-
if (platform_driver_register(&omap_mpuio_driver) == 0)
805-
(void) platform_device_register(&omap_mpuio_device);
804+
platform_set_drvdata(&omap_mpuio_device, bank);
805+
if (!registered) {
806+
(void)platform_device_register(&omap_mpuio_device);
807+
registered = true;
808+
}
806809
}
807810

808811
/*---------------------------------------------------------------------*/
@@ -1575,13 +1578,24 @@ static struct platform_driver omap_gpio_driver = {
15751578
*/
15761579
static int __init omap_gpio_drv_reg(void)
15771580
{
1578-
return platform_driver_register(&omap_gpio_driver);
1581+
int ret;
1582+
1583+
ret = platform_driver_register(&omap_mpuio_driver);
1584+
if (ret)
1585+
return ret;
1586+
1587+
ret = platform_driver_register(&omap_gpio_driver);
1588+
if (ret)
1589+
platform_driver_unregister(&omap_mpuio_driver);
1590+
1591+
return ret;
15791592
}
15801593
postcore_initcall(omap_gpio_drv_reg);
15811594

15821595
static void __exit omap_gpio_exit(void)
15831596
{
15841597
platform_driver_unregister(&omap_gpio_driver);
1598+
platform_driver_unregister(&omap_mpuio_driver);
15851599
}
15861600
module_exit(omap_gpio_exit);
15871601

0 commit comments

Comments
 (0)