@@ -1457,8 +1457,9 @@ static void __devinit atmel_of_init_port(struct atmel_uart_port *atmel_port,
/*
* Configure the port from the platform device resource info.
+ * Returns 0 for success or 1 in case of error.
*/
-static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
+static int __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
struct platform_device *pdev)
{
struct uart_port *port = &atmel_port->uart;
@@ -1496,6 +1497,8 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
/* for console, the clock could already be configured */
if (!atmel_port->clk) {
atmel_port->clk = clk_get(&pdev->dev, "usart");
+ if (IS_ERR(atmel_port->clk))
+ return 1; /* peripheral clock not found */
clk_enable(atmel_port->clk);
port->uartclk = clk_get_rate(atmel_port->clk);
clk_disable(atmel_port->clk);
@@ -1511,6 +1514,7 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
} else {
atmel_port->tx_done_mask = ATMEL_US_TXRDY;
}
+ return 0;
}
/*
@@ -1666,13 +1670,18 @@ static int __init atmel_console_init(void)
struct atmel_uart_data *pdata =
atmel_default_console_device->dev.platform_data;
int id = pdata->num;
+ int ret;
struct atmel_uart_port *port = &atmel_ports[id];
port->backup_imr = 0;
port->uart.line = id;
add_preferred_console(ATMEL_DEVICENAME, id, NULL);
- atmel_init_port(port, atmel_default_console_device);
+ ret = atmel_init_port(port, atmel_default_console_device);
+ if (ret) {
+ pr_err("No peripheral clock for Atmel console ??\n");
+ return -EINVAL;
+ }
register_console(&atmel_console);
}
@@ -1803,7 +1812,12 @@ static int __devinit atmel_serial_probe(struct platform_device *pdev)
port->backup_imr = 0;
port->uart.line = ret;
- atmel_init_port(port, pdev);
+ ret = atmel_init_port(port, pdev);
+ if (ret) {
+ ret = -EINVAL;
+ pr_err("peripheral clock not found for serial port\n");
+ goto err;
+ }
if (!atmel_use_dma_rx(&port->uart)) {
ret = -ENOMEM;