if (tty->flip.count >= TTY_FLIPBUF_SIZE)
drop = 1;
if (ZS_IS_ASLEEP(uap))
- return 0;
+ return NULL;
if (!ZS_IS_OPEN(uap))
goto retry;
}
if (r3 & CHBEXT)
pmz_status_handle(uap_b, regs);
if (r3 & CHBRxIP)
- pmz_receive_chars(uap_b, regs);
+ tty = pmz_receive_chars(uap_b, regs);
if (r3 & CHBTxIP)
pmz_transmit_chars(uap_b);
rc = IRQ_HANDLED;
ioremap(np->addrs[np->n_addrs - 1].address, 0x1000);
if (uap->rx_dma_regs == NULL) {
iounmap((void *)uap->tx_dma_regs);
+ uap->tx_dma_regs = NULL;
uap->flags &= ~PMACZILOG_FLAG_HAS_DMA;
goto no_dma;
}
{
struct device_node *np;
- iounmap((void *)uap->control_reg);
np = uap->node;
+ iounmap((void *)uap->rx_dma_regs);
+ iounmap((void *)uap->tx_dma_regs);
+ iounmap((void *)uap->control_reg);
uap->node = NULL;
of_node_put(np);
+ memset(uap, 0, sizeof(struct uart_pmac_port));
}
/*
* Register this driver with the serial core
*/
rc = uart_register_driver(&pmz_uart_reg);
- if (rc != 0)
+ if (rc)
return rc;
/*
struct uart_pmac_port *uport = &pmz_ports[i];
/* NULL node may happen on wallstreet */
if (uport->node != NULL)
- uart_add_one_port(&pmz_uart_reg, &uport->port);
+ rc = uart_add_one_port(&pmz_uart_reg, &uport->port);
+ if (rc)
+ goto err_out;
}
return 0;
+err_out:
+ while (i-- > 0) {
+ struct uart_pmac_port *uport = &pmz_ports[i];
+ uart_remove_one_port(&pmz_uart_reg, &uport->port);
+ }
+ uart_unregister_driver(&pmz_uart_reg);
+ return rc;
}
static struct of_match pmz_match[] =
static int __init init_pmz(void)
{
+ int rc, i;
printk(KERN_INFO "%s\n", version);
/*
/*
* Now we register with the serial layer
*/
- pmz_register();
+ rc = pmz_register();
+ if (rc) {
+ printk(KERN_ERR
+ "pmac_zilog: Error registering serial device, disabling pmac_zilog.\n"
+ "pmac_zilog: Did another serial driver already claim the minors?\n");
+ /* effectively "pmz_unprobe()" */
+ for (i=0; i < pmz_ports_count; i++)
+ pmz_dispose_port(&pmz_ports[i]);
+ return rc;
+ }
/*
* Then we register the macio driver itself
/* Probe ports */
pmz_probe();
-#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
-#endif
/* TODO: Autoprobe console based on OF */
/* pmz_console.index = i; */
register_console(&pmz_console);