diff options
Diffstat (limited to 'drivers/char')
| -rw-r--r-- | drivers/char/nozomi.c | 48 | ||||
| -rw-r--r-- | drivers/char/nwflash.c | 1 | ||||
| -rw-r--r-- | drivers/char/sonypi.c | 49 |
3 files changed, 61 insertions, 37 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 | ||
| 1491 | err_free_tty: | ||
| 1492 | for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) | ||
| 1493 | tty_unregister_device(ntty_driver, i); | ||
| 1494 | err_free_kfifo: | ||
| 1495 | for (i = 0; i < MAX_PORT; i++) | ||
| 1496 | kfifo_free(&dc->port[i].fifo_ul); | ||
| 1474 | err_free_sbuf: | 1497 | err_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 | ||
| 1726 | exit: | 1748 | exit: |
| 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 | ||
| 1883 | exit_in_buffer: | 1905 | exit_in_buffer: |
| 1884 | return rval; | 1906 | return rval; |
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index 8c7df5ba088f..f80810901db6 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
| 28 | #include <linux/smp_lock.h> | 28 | #include <linux/smp_lock.h> |
| 29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
| 30 | #include <linux/jiffies.h> | ||
| 30 | 31 | ||
| 31 | #include <asm/hardware/dec21285.h> | 32 | #include <asm/hardware/dec21285.h> |
| 32 | #include <asm/io.h> | 33 | #include <asm/io.h> |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 8c262aaf7c26..0798754a607c 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
| @@ -487,7 +487,7 @@ static struct sonypi_device { | |||
| 487 | int camera_power; | 487 | int camera_power; |
| 488 | int bluetooth_power; | 488 | int bluetooth_power; |
| 489 | struct mutex lock; | 489 | struct mutex lock; |
| 490 | struct kfifo *fifo; | 490 | struct kfifo fifo; |
| 491 | spinlock_t fifo_lock; | 491 | spinlock_t fifo_lock; |
| 492 | wait_queue_head_t fifo_proc_list; | 492 | wait_queue_head_t fifo_proc_list; |
| 493 | struct fasync_struct *fifo_async; | 493 | struct fasync_struct *fifo_async; |
| @@ -496,7 +496,7 @@ static struct sonypi_device { | |||
| 496 | struct input_dev *input_jog_dev; | 496 | struct input_dev *input_jog_dev; |
| 497 | struct input_dev *input_key_dev; | 497 | struct input_dev *input_key_dev; |
| 498 | struct work_struct input_work; | 498 | struct work_struct input_work; |
| 499 | struct kfifo *input_fifo; | 499 | struct kfifo input_fifo; |
| 500 | spinlock_t input_fifo_lock; | 500 | spinlock_t input_fifo_lock; |
| 501 | } sonypi_device; | 501 | } sonypi_device; |
| 502 | 502 | ||
| @@ -777,8 +777,9 @@ static void input_keyrelease(struct work_struct *work) | |||
| 777 | { | 777 | { |
| 778 | struct sonypi_keypress kp; | 778 | struct sonypi_keypress kp; |
| 779 | 779 | ||
| 780 | while (kfifo_get(sonypi_device.input_fifo, (unsigned char *)&kp, | 780 | while (kfifo_out_locked(&sonypi_device.input_fifo, (unsigned char *)&kp, |
| 781 | sizeof(kp)) == sizeof(kp)) { | 781 | sizeof(kp), &sonypi_device.input_fifo_lock) |
| 782 | == sizeof(kp)) { | ||
| 782 | msleep(10); | 783 | msleep(10); |
| 783 | input_report_key(kp.dev, kp.key, 0); | 784 | input_report_key(kp.dev, kp.key, 0); |
| 784 | input_sync(kp.dev); | 785 | input_sync(kp.dev); |
| @@ -827,8 +828,9 @@ static void sonypi_report_input_event(u8 event) | |||
| 827 | if (kp.dev) { | 828 | if (kp.dev) { |
| 828 | input_report_key(kp.dev, kp.key, 1); | 829 | input_report_key(kp.dev, kp.key, 1); |
| 829 | input_sync(kp.dev); | 830 | input_sync(kp.dev); |
| 830 | kfifo_put(sonypi_device.input_fifo, | 831 | kfifo_in_locked(&sonypi_device.input_fifo, |
| 831 | (unsigned char *)&kp, sizeof(kp)); | 832 | (unsigned char *)&kp, sizeof(kp), |
| 833 | &sonypi_device.input_fifo_lock); | ||
| 832 | schedule_work(&sonypi_device.input_work); | 834 | schedule_work(&sonypi_device.input_work); |
| 833 | } | 835 | } |
| 834 | } | 836 | } |
| @@ -880,7 +882,8 @@ found: | |||
| 880 | acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event); | 882 | acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event); |
| 881 | #endif | 883 | #endif |
| 882 | 884 | ||
| 883 | kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event)); | 885 | kfifo_in_locked(&sonypi_device.fifo, (unsigned char *)&event, |
| 886 | sizeof(event), &sonypi_device.fifo_lock); | ||
| 884 | kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN); | 887 | kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN); |
| 885 | wake_up_interruptible(&sonypi_device.fifo_proc_list); | 888 | wake_up_interruptible(&sonypi_device.fifo_proc_list); |
| 886 | 889 | ||
| @@ -906,7 +909,7 @@ static int sonypi_misc_open(struct inode *inode, struct file *file) | |||
| 906 | mutex_lock(&sonypi_device.lock); | 909 | mutex_lock(&sonypi_device.lock); |
| 907 | /* Flush input queue on first open */ | 910 | /* Flush input queue on first open */ |
| 908 | if (!sonypi_device.open_count) | 911 | if (!sonypi_device.open_count) |
| 909 | kfifo_reset(sonypi_device.fifo); | 912 | kfifo_reset(&sonypi_device.fifo); |
| 910 | sonypi_device.open_count++; | 913 | sonypi_device.open_count++; |
| 911 | mutex_unlock(&sonypi_device.lock); | 914 | mutex_unlock(&sonypi_device.lock); |
| 912 | unlock_kernel(); | 915 | unlock_kernel(); |
| @@ -919,17 +922,18 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf, | |||
| 919 | ssize_t ret; | 922 | ssize_t ret; |
| 920 | unsigned char c; | 923 | unsigned char c; |
| 921 | 924 | ||
| 922 | if ((kfifo_len(sonypi_device.fifo) == 0) && | 925 | if ((kfifo_len(&sonypi_device.fifo) == 0) && |
| 923 | (file->f_flags & O_NONBLOCK)) | 926 | (file->f_flags & O_NONBLOCK)) |
| 924 | return -EAGAIN; | 927 | return -EAGAIN; |
| 925 | 928 | ||
| 926 | ret = wait_event_interruptible(sonypi_device.fifo_proc_list, | 929 | ret = wait_event_interruptible(sonypi_device.fifo_proc_list, |
| 927 | kfifo_len(sonypi_device.fifo) != 0); | 930 | kfifo_len(&sonypi_device.fifo) != 0); |
| 928 | if (ret) | 931 | if (ret) |
| 929 | return ret; | 932 | return ret; |
| 930 | 933 | ||
| 931 | while (ret < count && | 934 | while (ret < count && |
| 932 | (kfifo_get(sonypi_device.fifo, &c, sizeof(c)) == sizeof(c))) { | 935 | (kfifo_out_locked(&sonypi_device.fifo, &c, sizeof(c), |
| 936 | &sonypi_device.fifo_lock) == sizeof(c))) { | ||
| 933 | if (put_user(c, buf++)) | 937 | if (put_user(c, buf++)) |
| 934 | return -EFAULT; | 938 | return -EFAULT; |
| 935 | ret++; | 939 | ret++; |
| @@ -946,7 +950,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf, | |||
| 946 | static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait) | 950 | static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait) |
| 947 | { | 951 | { |
| 948 | poll_wait(file, &sonypi_device.fifo_proc_list, wait); | 952 | poll_wait(file, &sonypi_device.fifo_proc_list, wait); |
| 949 | if (kfifo_len(sonypi_device.fifo)) | 953 | if (kfifo_len(&sonypi_device.fifo)) |
| 950 | return POLLIN | POLLRDNORM; | 954 | return POLLIN | POLLRDNORM; |
| 951 | return 0; | 955 | return 0; |
| 952 | } | 956 | } |
| @@ -1313,11 +1317,10 @@ static int __devinit sonypi_probe(struct platform_device *dev) | |||
| 1313 | "http://www.linux.it/~malattia/wiki/index.php/Sony_drivers\n"); | 1317 | "http://www.linux.it/~malattia/wiki/index.php/Sony_drivers\n"); |
| 1314 | 1318 | ||
| 1315 | spin_lock_init(&sonypi_device.fifo_lock); | 1319 | spin_lock_init(&sonypi_device.fifo_lock); |
| 1316 | sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL, | 1320 | error = kfifo_alloc(&sonypi_device.fifo, SONYPI_BUF_SIZE, GFP_KERNEL); |
| 1317 | &sonypi_device.fifo_lock); | 1321 | if (error) { |
| 1318 | if (IS_ERR(sonypi_device.fifo)) { | ||
| 1319 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); | 1322 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); |
| 1320 | return PTR_ERR(sonypi_device.fifo); | 1323 | return error; |
| 1321 | } | 1324 | } |
| 1322 | 1325 | ||
| 1323 | init_waitqueue_head(&sonypi_device.fifo_proc_list); | 1326 | init_waitqueue_head(&sonypi_device.fifo_proc_list); |
| @@ -1393,12 +1396,10 @@ static int __devinit sonypi_probe(struct platform_device *dev) | |||
| 1393 | } | 1396 | } |
| 1394 | 1397 | ||
| 1395 | spin_lock_init(&sonypi_device.input_fifo_lock); | 1398 | spin_lock_init(&sonypi_device.input_fifo_lock); |
| 1396 | sonypi_device.input_fifo = | 1399 | error = kfifo_alloc(&sonypi_device.input_fifo, SONYPI_BUF_SIZE, |
| 1397 | kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL, | 1400 | GFP_KERNEL); |
| 1398 | &sonypi_device.input_fifo_lock); | 1401 | if (error) { |
| 1399 | if (IS_ERR(sonypi_device.input_fifo)) { | ||
| 1400 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); | 1402 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); |
| 1401 | error = PTR_ERR(sonypi_device.input_fifo); | ||
| 1402 | goto err_inpdev_unregister; | 1403 | goto err_inpdev_unregister; |
| 1403 | } | 1404 | } |
| 1404 | 1405 | ||
| @@ -1423,7 +1424,7 @@ static int __devinit sonypi_probe(struct platform_device *dev) | |||
| 1423 | pci_disable_device(pcidev); | 1424 | pci_disable_device(pcidev); |
| 1424 | err_put_pcidev: | 1425 | err_put_pcidev: |
| 1425 | pci_dev_put(pcidev); | 1426 | pci_dev_put(pcidev); |
| 1426 | kfifo_free(sonypi_device.fifo); | 1427 | kfifo_free(&sonypi_device.fifo); |
| 1427 | 1428 | ||
| 1428 | return error; | 1429 | return error; |
| 1429 | } | 1430 | } |
| @@ -1438,7 +1439,7 @@ static int __devexit sonypi_remove(struct platform_device *dev) | |||
| 1438 | if (useinput) { | 1439 | if (useinput) { |
| 1439 | input_unregister_device(sonypi_device.input_key_dev); | 1440 | input_unregister_device(sonypi_device.input_key_dev); |
| 1440 | input_unregister_device(sonypi_device.input_jog_dev); | 1441 | input_unregister_device(sonypi_device.input_jog_dev); |
| 1441 | kfifo_free(sonypi_device.input_fifo); | 1442 | kfifo_free(&sonypi_device.input_fifo); |
| 1442 | } | 1443 | } |
| 1443 | 1444 | ||
| 1444 | misc_deregister(&sonypi_misc_device); | 1445 | misc_deregister(&sonypi_misc_device); |
| @@ -1451,7 +1452,7 @@ static int __devexit sonypi_remove(struct platform_device *dev) | |||
| 1451 | pci_dev_put(sonypi_device.dev); | 1452 | pci_dev_put(sonypi_device.dev); |
| 1452 | } | 1453 | } |
| 1453 | 1454 | ||
| 1454 | kfifo_free(sonypi_device.fifo); | 1455 | kfifo_free(&sonypi_device.fifo); |
| 1455 | 1456 | ||
| 1456 | return 0; | 1457 | return 0; |
| 1457 | } | 1458 | } |
