Commit 352b9266 authored by Sjoerd Simons's avatar Sjoerd Simons Committed by Greg Kroah-Hartman

serial: sh-sci: Move uart_register_driver call to device probe

uart_register_driver call binds the driver to a specific device
node through tty_register_driver call. This should typically
happen during device probe call.

In a multiplatform scenario, it is possible that multiple serial
drivers are part of the kernel. Currently the driver registration fails
if multiple serial drivers with overlapping major/minor numbers are
included.
Signed-off-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bd8766b1
...@@ -2962,6 +2962,7 @@ static inline int sci_probe_earlyprintk(struct platform_device *pdev) ...@@ -2962,6 +2962,7 @@ static inline int sci_probe_earlyprintk(struct platform_device *pdev)
static const char banner[] __initconst = "SuperH (H)SCI(F) driver initialized"; static const char banner[] __initconst = "SuperH (H)SCI(F) driver initialized";
static DEFINE_MUTEX(sci_uart_registration_lock);
static struct uart_driver sci_uart_driver = { static struct uart_driver sci_uart_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.driver_name = "sci", .driver_name = "sci",
...@@ -3090,6 +3091,16 @@ static int sci_probe_single(struct platform_device *dev, ...@@ -3090,6 +3091,16 @@ static int sci_probe_single(struct platform_device *dev,
return -EINVAL; return -EINVAL;
} }
mutex_lock(&sci_uart_registration_lock);
if (!sci_uart_driver.state) {
ret = uart_register_driver(&sci_uart_driver);
if (ret) {
mutex_unlock(&sci_uart_registration_lock);
return ret;
}
}
mutex_unlock(&sci_uart_registration_lock);
ret = sci_init_single(dev, sciport, index, p, false); ret = sci_init_single(dev, sciport, index, p, false);
if (ret) if (ret)
return ret; return ret;
...@@ -3213,24 +3224,17 @@ static struct platform_driver sci_driver = { ...@@ -3213,24 +3224,17 @@ static struct platform_driver sci_driver = {
static int __init sci_init(void) static int __init sci_init(void)
{ {
int ret;
pr_info("%s\n", banner); pr_info("%s\n", banner);
ret = uart_register_driver(&sci_uart_driver); return platform_driver_register(&sci_driver);
if (likely(ret == 0)) {
ret = platform_driver_register(&sci_driver);
if (unlikely(ret))
uart_unregister_driver(&sci_uart_driver);
}
return ret;
} }
static void __exit sci_exit(void) static void __exit sci_exit(void)
{ {
platform_driver_unregister(&sci_driver); platform_driver_unregister(&sci_driver);
uart_unregister_driver(&sci_uart_driver);
if (sci_uart_driver.state)
uart_unregister_driver(&sci_uart_driver);
} }
#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment