diff options
Diffstat (limited to 'drivers/tty/serial/samsung.c')
-rw-r--r-- | drivers/tty/serial/samsung.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 02d07bfcfa8a..bdaa06f3ab69 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c | |||
@@ -82,7 +82,7 @@ static inline const char *s3c24xx_serial_portname(struct uart_port *port) | |||
82 | 82 | ||
83 | static int s3c24xx_serial_txempty_nofifo(struct uart_port *port) | 83 | static int s3c24xx_serial_txempty_nofifo(struct uart_port *port) |
84 | { | 84 | { |
85 | return (rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE); | 85 | return rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE; |
86 | } | 86 | } |
87 | 87 | ||
88 | /* | 88 | /* |
@@ -268,7 +268,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id) | |||
268 | dbg("break!\n"); | 268 | dbg("break!\n"); |
269 | port->icount.brk++; | 269 | port->icount.brk++; |
270 | if (uart_handle_break(port)) | 270 | if (uart_handle_break(port)) |
271 | goto ignore_char; | 271 | goto ignore_char; |
272 | } | 272 | } |
273 | 273 | ||
274 | if (uerstat & S3C2410_UERSTAT_FRAME) | 274 | if (uerstat & S3C2410_UERSTAT_FRAME) |
@@ -459,7 +459,7 @@ static int s3c24xx_serial_startup(struct uart_port *port) | |||
459 | s3c24xx_serial_portname(port), ourport); | 459 | s3c24xx_serial_portname(port), ourport); |
460 | 460 | ||
461 | if (ret != 0) { | 461 | if (ret != 0) { |
462 | printk(KERN_ERR "cannot get irq %d\n", ourport->rx_irq); | 462 | dev_err(port->dev, "cannot get irq %d\n", ourport->rx_irq); |
463 | return ret; | 463 | return ret; |
464 | } | 464 | } |
465 | 465 | ||
@@ -473,7 +473,7 @@ static int s3c24xx_serial_startup(struct uart_port *port) | |||
473 | s3c24xx_serial_portname(port), ourport); | 473 | s3c24xx_serial_portname(port), ourport); |
474 | 474 | ||
475 | if (ret) { | 475 | if (ret) { |
476 | printk(KERN_ERR "cannot get irq %d\n", ourport->tx_irq); | 476 | dev_err(port->dev, "cannot get irq %d\n", ourport->tx_irq); |
477 | goto err; | 477 | goto err; |
478 | } | 478 | } |
479 | 479 | ||
@@ -502,7 +502,7 @@ static int s3c64xx_serial_startup(struct uart_port *port) | |||
502 | ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED, | 502 | ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED, |
503 | s3c24xx_serial_portname(port), ourport); | 503 | s3c24xx_serial_portname(port), ourport); |
504 | if (ret) { | 504 | if (ret) { |
505 | printk(KERN_ERR "cannot get irq %d\n", port->irq); | 505 | dev_err(port->dev, "cannot get irq %d\n", port->irq); |
506 | return ret; | 506 | return ret; |
507 | } | 507 | } |
508 | 508 | ||
@@ -529,7 +529,7 @@ static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level, | |||
529 | 529 | ||
530 | switch (level) { | 530 | switch (level) { |
531 | case 3: | 531 | case 3: |
532 | if (!IS_ERR(ourport->baudclk) && ourport->baudclk != NULL) | 532 | if (!IS_ERR(ourport->baudclk)) |
533 | clk_disable(ourport->baudclk); | 533 | clk_disable(ourport->baudclk); |
534 | 534 | ||
535 | clk_disable(ourport->clk); | 535 | clk_disable(ourport->clk); |
@@ -538,12 +538,12 @@ static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level, | |||
538 | case 0: | 538 | case 0: |
539 | clk_enable(ourport->clk); | 539 | clk_enable(ourport->clk); |
540 | 540 | ||
541 | if (!IS_ERR(ourport->baudclk) && ourport->baudclk != NULL) | 541 | if (!IS_ERR(ourport->baudclk)) |
542 | clk_enable(ourport->baudclk); | 542 | clk_enable(ourport->baudclk); |
543 | 543 | ||
544 | break; | 544 | break; |
545 | default: | 545 | default: |
546 | printk(KERN_ERR "s3c24xx_serial: unknown pm %d\n", level); | 546 | dev_err(port->dev, "s3c24xx_serial: unknown pm %d\n", level); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
@@ -604,7 +604,6 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, | |||
604 | char clkname[MAX_CLK_NAME_LENGTH]; | 604 | char clkname[MAX_CLK_NAME_LENGTH]; |
605 | int calc_deviation, deviation = (1 << 30) - 1; | 605 | int calc_deviation, deviation = (1 << 30) - 1; |
606 | 606 | ||
607 | *best_clk = NULL; | ||
608 | clk_sel = (ourport->cfg->clk_sel) ? ourport->cfg->clk_sel : | 607 | clk_sel = (ourport->cfg->clk_sel) ? ourport->cfg->clk_sel : |
609 | ourport->info->def_clk_sel; | 608 | ourport->info->def_clk_sel; |
610 | for (cnt = 0; cnt < info->num_clks; cnt++) { | 609 | for (cnt = 0; cnt < info->num_clks; cnt++) { |
@@ -613,7 +612,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, | |||
613 | 612 | ||
614 | sprintf(clkname, "clk_uart_baud%d", cnt); | 613 | sprintf(clkname, "clk_uart_baud%d", cnt); |
615 | clk = clk_get(ourport->port.dev, clkname); | 614 | clk = clk_get(ourport->port.dev, clkname); |
616 | if (IS_ERR_OR_NULL(clk)) | 615 | if (IS_ERR(clk)) |
617 | continue; | 616 | continue; |
618 | 617 | ||
619 | rate = clk_get_rate(clk); | 618 | rate = clk_get_rate(clk); |
@@ -684,7 +683,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, | |||
684 | { | 683 | { |
685 | struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port); | 684 | struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port); |
686 | struct s3c24xx_uart_port *ourport = to_ourport(port); | 685 | struct s3c24xx_uart_port *ourport = to_ourport(port); |
687 | struct clk *clk = NULL; | 686 | struct clk *clk = ERR_PTR(-EINVAL); |
688 | unsigned long flags; | 687 | unsigned long flags; |
689 | unsigned int baud, quot, clk_sel = 0; | 688 | unsigned int baud, quot, clk_sel = 0; |
690 | unsigned int ulcon; | 689 | unsigned int ulcon; |
@@ -705,7 +704,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, | |||
705 | quot = s3c24xx_serial_getclk(ourport, baud, &clk, &clk_sel); | 704 | quot = s3c24xx_serial_getclk(ourport, baud, &clk, &clk_sel); |
706 | if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) | 705 | if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) |
707 | quot = port->custom_divisor; | 706 | quot = port->custom_divisor; |
708 | if (!clk) | 707 | if (IS_ERR(clk)) |
709 | return; | 708 | return; |
710 | 709 | ||
711 | /* check to see if we need to change clock source */ | 710 | /* check to see if we need to change clock source */ |
@@ -713,9 +712,9 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, | |||
713 | if (ourport->baudclk != clk) { | 712 | if (ourport->baudclk != clk) { |
714 | s3c24xx_serial_setsource(port, clk_sel); | 713 | s3c24xx_serial_setsource(port, clk_sel); |
715 | 714 | ||
716 | if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) { | 715 | if (!IS_ERR(ourport->baudclk)) { |
717 | clk_disable(ourport->baudclk); | 716 | clk_disable(ourport->baudclk); |
718 | ourport->baudclk = NULL; | 717 | ourport->baudclk = ERR_PTR(-EINVAL); |
719 | } | 718 | } |
720 | 719 | ||
721 | clk_enable(clk); | 720 | clk_enable(clk); |
@@ -1036,10 +1035,10 @@ static int s3c24xx_serial_cpufreq_transition(struct notifier_block *nb, | |||
1036 | if (tty == NULL) | 1035 | if (tty == NULL) |
1037 | goto exit; | 1036 | goto exit; |
1038 | 1037 | ||
1039 | termios = tty->termios; | 1038 | termios = &tty->termios; |
1040 | 1039 | ||
1041 | if (termios == NULL) { | 1040 | if (termios == NULL) { |
1042 | printk(KERN_WARNING "%s: no termios?\n", __func__); | 1041 | dev_warn(uport->dev, "%s: no termios?\n", __func__); |
1043 | goto exit; | 1042 | goto exit; |
1044 | } | 1043 | } |
1045 | 1044 | ||
@@ -1114,7 +1113,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, | |||
1114 | 1113 | ||
1115 | res = platform_get_resource(platdev, IORESOURCE_MEM, 0); | 1114 | res = platform_get_resource(platdev, IORESOURCE_MEM, 0); |
1116 | if (res == NULL) { | 1115 | if (res == NULL) { |
1117 | printk(KERN_ERR "failed to find memory resource for uart\n"); | 1116 | dev_err(port->dev, "failed to find memory resource for uart\n"); |
1118 | return -EINVAL; | 1117 | return -EINVAL; |
1119 | } | 1118 | } |
1120 | 1119 | ||
@@ -1130,7 +1129,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, | |||
1130 | ourport->rx_irq = ret; | 1129 | ourport->rx_irq = ret; |
1131 | ourport->tx_irq = ret + 1; | 1130 | ourport->tx_irq = ret + 1; |
1132 | } | 1131 | } |
1133 | 1132 | ||
1134 | ret = platform_get_irq(platdev, 1); | 1133 | ret = platform_get_irq(platdev, 1); |
1135 | if (ret > 0) | 1134 | if (ret > 0) |
1136 | ourport->tx_irq = ret; | 1135 | ourport->tx_irq = ret; |
@@ -1160,7 +1159,11 @@ static ssize_t s3c24xx_serial_show_clksrc(struct device *dev, | |||
1160 | struct uart_port *port = s3c24xx_dev_to_port(dev); | 1159 | struct uart_port *port = s3c24xx_dev_to_port(dev); |
1161 | struct s3c24xx_uart_port *ourport = to_ourport(port); | 1160 | struct s3c24xx_uart_port *ourport = to_ourport(port); |
1162 | 1161 | ||
1163 | return snprintf(buf, PAGE_SIZE, "* %s\n", ourport->baudclk->name); | 1162 | if (IS_ERR(ourport->baudclk)) |
1163 | return -EINVAL; | ||
1164 | |||
1165 | return snprintf(buf, PAGE_SIZE, "* %s\n", | ||
1166 | ourport->baudclk->name ?: "(null)"); | ||
1164 | } | 1167 | } |
1165 | 1168 | ||
1166 | static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL); | 1169 | static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL); |
@@ -1200,6 +1203,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev) | |||
1200 | return -ENODEV; | 1203 | return -ENODEV; |
1201 | } | 1204 | } |
1202 | 1205 | ||
1206 | ourport->baudclk = ERR_PTR(-EINVAL); | ||
1203 | ourport->info = ourport->drv_data->info; | 1207 | ourport->info = ourport->drv_data->info; |
1204 | ourport->cfg = (pdev->dev.platform_data) ? | 1208 | ourport->cfg = (pdev->dev.platform_data) ? |
1205 | (struct s3c2410_uartcfg *)pdev->dev.platform_data : | 1209 | (struct s3c2410_uartcfg *)pdev->dev.platform_data : |
@@ -1387,7 +1391,7 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud, | |||
1387 | sprintf(clk_name, "clk_uart_baud%d", clk_sel); | 1391 | sprintf(clk_name, "clk_uart_baud%d", clk_sel); |
1388 | 1392 | ||
1389 | clk = clk_get(port->dev, clk_name); | 1393 | clk = clk_get(port->dev, clk_name); |
1390 | if (!IS_ERR(clk) && clk != NULL) | 1394 | if (!IS_ERR(clk)) |
1391 | rate = clk_get_rate(clk); | 1395 | rate = clk_get_rate(clk); |
1392 | else | 1396 | else |
1393 | rate = 1; | 1397 | rate = 1; |
@@ -1679,7 +1683,7 @@ static int __init s3c24xx_serial_modinit(void) | |||
1679 | 1683 | ||
1680 | ret = uart_register_driver(&s3c24xx_uart_drv); | 1684 | ret = uart_register_driver(&s3c24xx_uart_drv); |
1681 | if (ret < 0) { | 1685 | if (ret < 0) { |
1682 | printk(KERN_ERR "failed to register UART driver\n"); | 1686 | pr_err("Failed to register Samsung UART driver\n"); |
1683 | return -1; | 1687 | return -1; |
1684 | } | 1688 | } |
1685 | 1689 | ||