aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/nozomi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/nozomi.c')
-rw-r--r--drivers/char/nozomi.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index d3400b20444f..7d73cd430340 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -358,7 +358,7 @@ struct port {
358 u8 update_flow_control; 358 u8 update_flow_control;
359 struct ctrl_ul ctrl_ul; 359 struct ctrl_ul ctrl_ul;
360 struct ctrl_dl ctrl_dl; 360 struct ctrl_dl ctrl_dl;
361 struct kfifo *fifo_ul; 361 struct kfifo fifo_ul;
362 void __iomem *dl_addr[2]; 362 void __iomem *dl_addr[2];
363 u32 dl_size[2]; 363 u32 dl_size[2];
364 u8 toggle_dl; 364 u8 toggle_dl;
@@ -685,8 +685,6 @@ static int nozomi_read_config_table(struct nozomi *dc)
685 dump_table(dc); 685 dump_table(dc);
686 686
687 for (i = PORT_MDM; i < MAX_PORT; i++) { 687 for (i = PORT_MDM; i < MAX_PORT; i++) {
688 dc->port[i].fifo_ul =
689 kfifo_alloc(FIFO_BUFFER_SIZE_UL, GFP_ATOMIC, NULL);
690 memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl)); 688 memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl));
691 memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul)); 689 memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul));
692 } 690 }
@@ -798,7 +796,7 @@ static int send_data(enum port_type index, struct nozomi *dc)
798 struct tty_struct *tty = tty_port_tty_get(&port->port); 796 struct tty_struct *tty = tty_port_tty_get(&port->port);
799 797
800 /* Get data from tty and place in buf for now */ 798 /* Get data from tty and place in buf for now */
801 size = __kfifo_get(port->fifo_ul, dc->send_buf, 799 size = kfifo_out(&port->fifo_ul, dc->send_buf,
802 ul_size < SEND_BUF_MAX ? ul_size : SEND_BUF_MAX); 800 ul_size < SEND_BUF_MAX ? ul_size : SEND_BUF_MAX);
803 801
804 if (size == 0) { 802 if (size == 0) {
@@ -988,11 +986,11 @@ static int receive_flow_control(struct nozomi *dc)
988 986
989 } else if (old_ctrl.CTS == 0 && ctrl_dl.CTS == 1) { 987 } else if (old_ctrl.CTS == 0 && ctrl_dl.CTS == 1) {
990 988
991 if (__kfifo_len(dc->port[port].fifo_ul)) { 989 if (kfifo_len(&dc->port[port].fifo_ul)) {
992 DBG1("Enable interrupt (0x%04X) on port: %d", 990 DBG1("Enable interrupt (0x%04X) on port: %d",
993 enable_ier, port); 991 enable_ier, port);
994 DBG1("Data in buffer [%d], enable transmit! ", 992 DBG1("Data in buffer [%d], enable transmit! ",
995 __kfifo_len(dc->port[port].fifo_ul)); 993 kfifo_len(&dc->port[port].fifo_ul));
996 enable_transmit_ul(port, dc); 994 enable_transmit_ul(port, dc);
997 } else { 995 } else {
998 DBG1("No data in buffer..."); 996 DBG1("No data in buffer...");
@@ -1433,6 +1431,16 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1433 goto err_free_sbuf; 1431 goto err_free_sbuf;
1434 } 1432 }
1435 1433
1434 for (i = PORT_MDM; i < MAX_PORT; i++) {
1435 if (kfifo_alloc(&dc->port[i].fifo_ul,
1436 FIFO_BUFFER_SIZE_UL, GFP_ATOMIC)) {
1437 dev_err(&pdev->dev,
1438 "Could not allocate kfifo buffer\n");
1439 ret = -ENOMEM;
1440 goto err_free_kfifo;
1441 }
1442 }
1443
1436 spin_lock_init(&dc->spin_mutex); 1444 spin_lock_init(&dc->spin_mutex);
1437 1445
1438 nozomi_setup_private_data(dc); 1446 nozomi_setup_private_data(dc);
@@ -1445,7 +1453,7 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1445 NOZOMI_NAME, dc); 1453 NOZOMI_NAME, dc);
1446 if (unlikely(ret)) { 1454 if (unlikely(ret)) {
1447 dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq); 1455 dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq);
1448 goto err_free_sbuf; 1456 goto err_free_kfifo;
1449 } 1457 }
1450 1458
1451 DBG1("base_addr: %p", dc->base_addr); 1459 DBG1("base_addr: %p", dc->base_addr);
@@ -1464,13 +1472,28 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1464 dc->state = NOZOMI_STATE_ENABLED; 1472 dc->state = NOZOMI_STATE_ENABLED;
1465 1473
1466 for (i = 0; i < MAX_PORT; i++) { 1474 for (i = 0; i < MAX_PORT; i++) {
1475 struct device *tty_dev;
1476
1467 mutex_init(&dc->port[i].tty_sem); 1477 mutex_init(&dc->port[i].tty_sem);
1468 tty_port_init(&dc->port[i].port); 1478 tty_port_init(&dc->port[i].port);
1469 tty_register_device(ntty_driver, dc->index_start + i, 1479 tty_dev = tty_register_device(ntty_driver, dc->index_start + i,
1470 &pdev->dev); 1480 &pdev->dev);
1481
1482 if (IS_ERR(tty_dev)) {
1483 ret = PTR_ERR(tty_dev);
1484 dev_err(&pdev->dev, "Could not allocate tty?\n");
1485 goto err_free_tty;
1486 }
1471 } 1487 }
1488
1472 return 0; 1489 return 0;
1473 1490
1491err_free_tty:
1492 for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i)
1493 tty_unregister_device(ntty_driver, i);
1494err_free_kfifo:
1495 for (i = 0; i < MAX_PORT; i++)
1496 kfifo_free(&dc->port[i].fifo_ul);
1474err_free_sbuf: 1497err_free_sbuf:
1475 kfree(dc->send_buf); 1498 kfree(dc->send_buf);
1476 iounmap(dc->base_addr); 1499 iounmap(dc->base_addr);
@@ -1536,8 +1559,7 @@ static void __devexit nozomi_card_exit(struct pci_dev *pdev)
1536 free_irq(pdev->irq, dc); 1559 free_irq(pdev->irq, dc);
1537 1560
1538 for (i = 0; i < MAX_PORT; i++) 1561 for (i = 0; i < MAX_PORT; i++)
1539 if (dc->port[i].fifo_ul) 1562 kfifo_free(&dc->port[i].fifo_ul);
1540 kfifo_free(dc->port[i].fifo_ul);
1541 1563
1542 kfree(dc->send_buf); 1564 kfree(dc->send_buf);
1543 1565
@@ -1673,7 +1695,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
1673 goto exit; 1695 goto exit;
1674 } 1696 }
1675 1697
1676 rval = __kfifo_put(port->fifo_ul, (unsigned char *)buffer, count); 1698 rval = kfifo_in(&port->fifo_ul, (unsigned char *)buffer, count);
1677 1699
1678 /* notify card */ 1700 /* notify card */
1679 if (unlikely(dc == NULL)) { 1701 if (unlikely(dc == NULL)) {
@@ -1721,7 +1743,7 @@ static int ntty_write_room(struct tty_struct *tty)
1721 if (!port->port.count) 1743 if (!port->port.count)
1722 goto exit; 1744 goto exit;
1723 1745
1724 room = port->fifo_ul->size - __kfifo_len(port->fifo_ul); 1746 room = port->fifo_ul.size - kfifo_len(&port->fifo_ul);
1725 1747
1726exit: 1748exit:
1727 mutex_unlock(&port->tty_sem); 1749 mutex_unlock(&port->tty_sem);
@@ -1878,7 +1900,7 @@ static s32 ntty_chars_in_buffer(struct tty_struct *tty)
1878 goto exit_in_buffer; 1900 goto exit_in_buffer;
1879 } 1901 }
1880 1902
1881 rval = __kfifo_len(port->fifo_ul); 1903 rval = kfifo_len(&port->fifo_ul);
1882 1904
1883exit_in_buffer: 1905exit_in_buffer:
1884 return rval; 1906 return rval;