mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 20:33:58 -04:00
msm_serial: msm_uart_next_id decrease when probe failed
When the msm_serial driver defer probed, if msm_uart_next_id increased at the beginning of probe, should decreased when probe failed. Change-Id: I8a2594afca17c4ab5fef78da822ffdf39377d0bb Signed-off-by: Yue Liu <quic_yueliu@quicinc.com>
This commit is contained in:
parent
d6a2023cd2
commit
2c57ec46e1
1 changed files with 22 additions and 5 deletions
|
|
@ -1778,14 +1778,17 @@ static int msm_serial_probe(struct platform_device *pdev)
|
|||
struct uart_port *port;
|
||||
const struct of_device_id *id;
|
||||
int irq, line;
|
||||
bool flag = false;
|
||||
|
||||
if (pdev->dev.of_node)
|
||||
line = of_alias_get_id(pdev->dev.of_node, "serial");
|
||||
else
|
||||
line = pdev->id;
|
||||
|
||||
if (line < 0)
|
||||
if (line < 0) {
|
||||
flag = true;
|
||||
line = atomic_inc_return(&msm_uart_next_id) - 1;
|
||||
}
|
||||
|
||||
if (unlikely(line < 0 || line >= UART_NR))
|
||||
return -ENXIO;
|
||||
|
|
@ -1803,26 +1806,40 @@ static int msm_serial_probe(struct platform_device *pdev)
|
|||
msm_port->is_uartdm = 0;
|
||||
|
||||
msm_port->clk = devm_clk_get(&pdev->dev, "core");
|
||||
if (IS_ERR(msm_port->clk))
|
||||
if (IS_ERR(msm_port->clk)) {
|
||||
if (flag)
|
||||
atomic_dec(&msm_uart_next_id);
|
||||
return PTR_ERR(msm_port->clk);
|
||||
}
|
||||
|
||||
if (msm_port->is_uartdm) {
|
||||
msm_port->pclk = devm_clk_get(&pdev->dev, "iface");
|
||||
if (IS_ERR(msm_port->pclk))
|
||||
if (IS_ERR(msm_port->pclk)) {
|
||||
if (flag)
|
||||
atomic_dec(&msm_uart_next_id);
|
||||
return PTR_ERR(msm_port->pclk);
|
||||
}
|
||||
}
|
||||
|
||||
port->uartclk = clk_get_rate(msm_port->clk);
|
||||
dev_info(&pdev->dev, "uartclk = %d\n", port->uartclk);
|
||||
|
||||
resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (unlikely(!resource))
|
||||
if (unlikely(!resource)) {
|
||||
if (flag)
|
||||
atomic_dec(&msm_uart_next_id);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
port->mapbase = resource->start;
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (unlikely(irq < 0))
|
||||
if (unlikely(irq < 0)) {
|
||||
if (flag)
|
||||
atomic_dec(&msm_uart_next_id);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
port->irq = irq;
|
||||
|
||||
platform_set_drvdata(pdev, port);
|
||||
|
|
|
|||
Loading…
Reference in a new issue