Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: atmel_serial: prepare clk before calling enable

Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
avoid common clk framework warnings.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Boris BREZILLON and committed by
Greg Kroah-Hartman
91f8c2d8 805bf3da

+31 -10
+31 -10
drivers/tty/serial/atmel_serial.c
··· 1100 1100 * Enable the peripheral clock for this serial port. 1101 1101 * This is called on uart_open() or a resume event. 1102 1102 */ 1103 - clk_enable(atmel_port->clk); 1103 + clk_prepare_enable(atmel_port->clk); 1104 1104 1105 1105 /* re-enable interrupts if we disabled some on suspend */ 1106 1106 UART_PUT_IER(port, atmel_port->backup_imr); ··· 1114 1114 * Disable the peripheral clock for this serial port. 1115 1115 * This is called on uart_close() or a suspend event. 1116 1116 */ 1117 - clk_disable(atmel_port->clk); 1117 + clk_disable_unprepare(atmel_port->clk); 1118 1118 break; 1119 1119 default: 1120 1120 printk(KERN_ERR "atmel_serial: unknown pm %d\n", state); ··· 1458 1458 /* 1459 1459 * Configure the port from the platform device resource info. 1460 1460 */ 1461 - static void atmel_init_port(struct atmel_uart_port *atmel_port, 1461 + static int atmel_init_port(struct atmel_uart_port *atmel_port, 1462 1462 struct platform_device *pdev) 1463 1463 { 1464 + int ret; 1464 1465 struct uart_port *port = &atmel_port->uart; 1465 1466 struct atmel_uart_data *pdata = pdev->dev.platform_data; 1466 1467 ··· 1497 1496 /* for console, the clock could already be configured */ 1498 1497 if (!atmel_port->clk) { 1499 1498 atmel_port->clk = clk_get(&pdev->dev, "usart"); 1500 - clk_enable(atmel_port->clk); 1499 + if (IS_ERR(atmel_port->clk)) { 1500 + ret = PTR_ERR(atmel_port->clk); 1501 + atmel_port->clk = NULL; 1502 + return ret; 1503 + } 1504 + ret = clk_prepare_enable(atmel_port->clk); 1505 + if (ret) { 1506 + clk_put(atmel_port->clk); 1507 + atmel_port->clk = NULL; 1508 + return ret; 1509 + } 1501 1510 port->uartclk = clk_get_rate(atmel_port->clk); 1502 - clk_disable(atmel_port->clk); 1511 + clk_disable_unprepare(atmel_port->clk); 1503 1512 /* only enable clock when USART is in use */ 1504 1513 } 1505 1514 ··· 1522 1511 } else { 1523 1512 atmel_port->tx_done_mask = ATMEL_US_TXRDY; 1524 1513 } 1514 + 1515 + return 0; 1525 1516 } 1526 1517 1527 1518 struct platform_device *atmel_default_console_device; /* the serial console device */ ··· 1614 1601 1615 1602 static int __init atmel_console_setup(struct console *co, char *options) 1616 1603 { 1604 + int ret; 1617 1605 struct uart_port *port = &atmel_ports[co->index].uart; 1618 1606 int baud = 115200; 1619 1607 int bits = 8; ··· 1626 1612 return -ENODEV; 1627 1613 } 1628 1614 1629 - clk_enable(atmel_ports[co->index].clk); 1615 + ret = clk_prepare_enable(atmel_ports[co->index].clk); 1616 + if (ret) 1617 + return ret; 1630 1618 1631 1619 UART_PUT_IDR(port, -1); 1632 1620 UART_PUT_CR(port, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); ··· 1661 1645 */ 1662 1646 static int __init atmel_console_init(void) 1663 1647 { 1648 + int ret; 1664 1649 if (atmel_default_console_device) { 1665 1650 struct atmel_uart_data *pdata = 1666 1651 atmel_default_console_device->dev.platform_data; ··· 1672 1655 port->uart.line = id; 1673 1656 1674 1657 add_preferred_console(ATMEL_DEVICENAME, id, NULL); 1675 - atmel_init_port(port, atmel_default_console_device); 1658 + ret = atmel_init_port(port, atmel_default_console_device); 1659 + if (ret) 1660 + return ret; 1676 1661 register_console(&atmel_console); 1677 1662 } 1678 1663 ··· 1805 1786 port->backup_imr = 0; 1806 1787 port->uart.line = ret; 1807 1788 1808 - atmel_init_port(port, pdev); 1789 + ret = atmel_init_port(port, pdev); 1790 + if (ret) 1791 + goto err; 1809 1792 1810 1793 pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 1811 1794 if (IS_ERR(pinctrl)) { ··· 1833 1812 && ATMEL_CONSOLE_DEVICE->flags & CON_ENABLED) { 1834 1813 /* 1835 1814 * The serial core enabled the clock for us, so undo 1836 - * the clk_enable() in atmel_console_setup() 1815 + * the clk_prepare_enable() in atmel_console_setup() 1837 1816 */ 1838 - clk_disable(port->clk); 1817 + clk_disable_unprepare(port->clk); 1839 1818 } 1840 1819 #endif 1841 1820