提交 ef2889f7 编写于 作者: T Tushar Behera 提交者: Greg Kroah-Hartman

serial: pl011: 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 same default major/minor numbers are
included in the kernel.

A typical case is observed with amba-pl011 and samsung-uart drivers.
Signed-off-by: NTushar Behera <tushar.behera@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 6f134c3c
...@@ -2154,9 +2154,19 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -2154,9 +2154,19 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
amba_ports[i] = uap; amba_ports[i] = uap;
amba_set_drvdata(dev, uap); amba_set_drvdata(dev, uap);
if (!amba_reg.state) {
ret = uart_register_driver(&amba_reg);
if (ret < 0) {
pr_err("Failed to register AMBA-PL011 driver\n");
return ret;
}
}
ret = uart_add_one_port(&amba_reg, &uap->port); ret = uart_add_one_port(&amba_reg, &uap->port);
if (ret) { if (ret) {
amba_ports[i] = NULL; amba_ports[i] = NULL;
uart_unregister_driver(&amba_reg);
pl011_dma_remove(uap); pl011_dma_remove(uap);
} }
out: out:
...@@ -2175,6 +2185,7 @@ static int pl011_remove(struct amba_device *dev) ...@@ -2175,6 +2185,7 @@ static int pl011_remove(struct amba_device *dev)
amba_ports[i] = NULL; amba_ports[i] = NULL;
pl011_dma_remove(uap); pl011_dma_remove(uap);
uart_unregister_driver(&amba_reg);
return 0; return 0;
} }
...@@ -2230,22 +2241,14 @@ static struct amba_driver pl011_driver = { ...@@ -2230,22 +2241,14 @@ static struct amba_driver pl011_driver = {
static int __init pl011_init(void) static int __init pl011_init(void)
{ {
int ret;
printk(KERN_INFO "Serial: AMBA PL011 UART driver\n"); printk(KERN_INFO "Serial: AMBA PL011 UART driver\n");
ret = uart_register_driver(&amba_reg); return amba_driver_register(&pl011_driver);
if (ret == 0) {
ret = amba_driver_register(&pl011_driver);
if (ret)
uart_unregister_driver(&amba_reg);
}
return ret;
} }
static void __exit pl011_exit(void) static void __exit pl011_exit(void)
{ {
amba_driver_unregister(&pl011_driver); amba_driver_unregister(&pl011_driver);
uart_unregister_driver(&amba_reg);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册