aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2009-12-21 17:37:26 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-22 17:17:55 -0500
commit45465487897a1c6d508b14b904dc5777f7ec7e04 (patch)
tree935c8dae68dc793ff2f795d57cf027531475cd53
parent2ec91eec47f713e3d158ba5b28a24a85a2cf3650 (diff)
kfifo: move struct kfifo in place
This is a new generic kernel FIFO implementation. The current kernel fifo API is not very widely used, because it has to many constrains. Only 17 files in the current 2.6.31-rc5 used it. FIFO's are like list's a very basic thing and a kfifo API which handles the most use case would save a lot of development time and memory resources. I think this are the reasons why kfifo is not in use: - The API is to simple, important functions are missing - A fifo can be only allocated dynamically - There is a requirement of a spinlock whether you need it or not - There is no support for data records inside a fifo So I decided to extend the kfifo in a more generic way without blowing up the API to much. The new API has the following benefits: - Generic usage: For kernel internal use and/or device driver. - Provide an API for the most use case. - Slim API: The whole API provides 25 functions. - Linux style habit. - DECLARE_KFIFO, DEFINE_KFIFO and INIT_KFIFO Macros - Direct copy_to_user from the fifo and copy_from_user into the fifo. - The kfifo itself is an in place member of the using data structure, this save an indirection access and does not waste the kernel allocator. - Lockless access: if only one reader and one writer is active on the fifo, which is the common use case, no additional locking is necessary. - Remove spinlock - give the user the freedom of choice what kind of locking to use if one is required. - Ability to handle records. Three type of records are supported: - Variable length records between 0-255 bytes, with a record size field of 1 bytes. - Variable length records between 0-65535 bytes, with a record size field of 2 bytes. - Fixed size records, which no record size field. - Preserve memory resource. - Performance! - Easy to use! This patch: Since most users want to have the kfifo as part of another object, reorganize the code to allow including struct kfifo in another data structure. This requires changing the kfifo_alloc and kfifo_init prototypes so that we pass an existing kfifo pointer into them. This patch changes the implementation and all existing users. [akpm@linux-foundation.org: fix warning] Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/nozomi.c21
-rw-r--r--drivers/char/sonypi.c40
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.h9
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_resource.c60
-rw-r--r--drivers/media/video/meye.c48
-rw-r--r--drivers/media/video/meye.h4
-rw-r--r--drivers/net/wireless/libertas/cmd.c4
-rw-r--r--drivers/net/wireless/libertas/dev.h4
-rw-r--r--drivers/net/wireless/libertas/main.c16
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c18
-rw-r--r--drivers/platform/x86/sony-laptop.c46
-rw-r--r--drivers/scsi/libiscsi.c22
-rw-r--r--drivers/scsi/libiscsi_tcp.c29
-rw-r--r--drivers/scsi/libsrp.c13
-rw-r--r--drivers/usb/host/fhci-sched.c10
-rw-r--r--drivers/usb/host/fhci-tds.c35
-rw-r--r--drivers/usb/host/fhci.h10
-rw-r--r--drivers/usb/serial/usb-serial.c5
-rw-r--r--include/linux/kfifo.h11
-rw-r--r--include/scsi/libiscsi.h3
-rw-r--r--include/scsi/libiscsi_tcp.h2
-rw-r--r--include/scsi/libsrp.h2
-rw-r--r--kernel/kfifo.c65
-rw-r--r--net/dccp/probe.c20
24 files changed, 238 insertions, 259 deletions
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index d3400b20444f..0f39bec28b45 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,8 @@ 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 = 688 kfifo_alloc(&dc->port[i].fifo_ul,
689 kfifo_alloc(FIFO_BUFFER_SIZE_UL, GFP_ATOMIC, NULL); 689 FIFO_BUFFER_SIZE_UL, GFP_ATOMIC, NULL);
690 memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl)); 690 memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl));
691 memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul)); 691 memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul));
692 } 692 }
@@ -798,7 +798,7 @@ static int send_data(enum port_type index, struct nozomi *dc)
798 struct tty_struct *tty = tty_port_tty_get(&port->port); 798 struct tty_struct *tty = tty_port_tty_get(&port->port);
799 799
800 /* Get data from tty and place in buf for now */ 800 /* Get data from tty and place in buf for now */
801 size = __kfifo_get(port->fifo_ul, dc->send_buf, 801 size = __kfifo_get(&port->fifo_ul, dc->send_buf,
802 ul_size < SEND_BUF_MAX ? ul_size : SEND_BUF_MAX); 802 ul_size < SEND_BUF_MAX ? ul_size : SEND_BUF_MAX);
803 803
804 if (size == 0) { 804 if (size == 0) {
@@ -988,11 +988,11 @@ static int receive_flow_control(struct nozomi *dc)
988 988
989 } else if (old_ctrl.CTS == 0 && ctrl_dl.CTS == 1) { 989 } else if (old_ctrl.CTS == 0 && ctrl_dl.CTS == 1) {
990 990
991 if (__kfifo_len(dc->port[port].fifo_ul)) { 991 if (__kfifo_len(&dc->port[port].fifo_ul)) {
992 DBG1("Enable interrupt (0x%04X) on port: %d", 992 DBG1("Enable interrupt (0x%04X) on port: %d",
993 enable_ier, port); 993 enable_ier, port);
994 DBG1("Data in buffer [%d], enable transmit! ", 994 DBG1("Data in buffer [%d], enable transmit! ",
995 __kfifo_len(dc->port[port].fifo_ul)); 995 __kfifo_len(&dc->port[port].fifo_ul));
996 enable_transmit_ul(port, dc); 996 enable_transmit_ul(port, dc);
997 } else { 997 } else {
998 DBG1("No data in buffer..."); 998 DBG1("No data in buffer...");
@@ -1536,8 +1536,7 @@ static void __devexit nozomi_card_exit(struct pci_dev *pdev)
1536 free_irq(pdev->irq, dc); 1536 free_irq(pdev->irq, dc);
1537 1537
1538 for (i = 0; i < MAX_PORT; i++) 1538 for (i = 0; i < MAX_PORT; i++)
1539 if (dc->port[i].fifo_ul) 1539 kfifo_free(&dc->port[i].fifo_ul);
1540 kfifo_free(dc->port[i].fifo_ul);
1541 1540
1542 kfree(dc->send_buf); 1541 kfree(dc->send_buf);
1543 1542
@@ -1673,7 +1672,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
1673 goto exit; 1672 goto exit;
1674 } 1673 }
1675 1674
1676 rval = __kfifo_put(port->fifo_ul, (unsigned char *)buffer, count); 1675 rval = __kfifo_put(&port->fifo_ul, (unsigned char *)buffer, count);
1677 1676
1678 /* notify card */ 1677 /* notify card */
1679 if (unlikely(dc == NULL)) { 1678 if (unlikely(dc == NULL)) {
@@ -1721,7 +1720,7 @@ static int ntty_write_room(struct tty_struct *tty)
1721 if (!port->port.count) 1720 if (!port->port.count)
1722 goto exit; 1721 goto exit;
1723 1722
1724 room = port->fifo_ul->size - __kfifo_len(port->fifo_ul); 1723 room = port->fifo_ul.size - __kfifo_len(&port->fifo_ul);
1725 1724
1726exit: 1725exit:
1727 mutex_unlock(&port->tty_sem); 1726 mutex_unlock(&port->tty_sem);
@@ -1878,7 +1877,7 @@ static s32 ntty_chars_in_buffer(struct tty_struct *tty)
1878 goto exit_in_buffer; 1877 goto exit_in_buffer;
1879 } 1878 }
1880 1879
1881 rval = __kfifo_len(port->fifo_ul); 1880 rval = __kfifo_len(&port->fifo_ul);
1882 1881
1883exit_in_buffer: 1882exit_in_buffer:
1884 return rval; 1883 return rval;
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 8c262aaf7c26..9e6efb1f029f 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,7 +777,7 @@ 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_get(&sonypi_device.input_fifo, (unsigned char *)&kp,
781 sizeof(kp)) == sizeof(kp)) { 781 sizeof(kp)) == sizeof(kp)) {
782 msleep(10); 782 msleep(10);
783 input_report_key(kp.dev, kp.key, 0); 783 input_report_key(kp.dev, kp.key, 0);
@@ -827,7 +827,7 @@ static void sonypi_report_input_event(u8 event)
827 if (kp.dev) { 827 if (kp.dev) {
828 input_report_key(kp.dev, kp.key, 1); 828 input_report_key(kp.dev, kp.key, 1);
829 input_sync(kp.dev); 829 input_sync(kp.dev);
830 kfifo_put(sonypi_device.input_fifo, 830 kfifo_put(&sonypi_device.input_fifo,
831 (unsigned char *)&kp, sizeof(kp)); 831 (unsigned char *)&kp, sizeof(kp));
832 schedule_work(&sonypi_device.input_work); 832 schedule_work(&sonypi_device.input_work);
833 } 833 }
@@ -880,7 +880,7 @@ found:
880 acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event); 880 acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event);
881#endif 881#endif
882 882
883 kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event)); 883 kfifo_put(&sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
884 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN); 884 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
885 wake_up_interruptible(&sonypi_device.fifo_proc_list); 885 wake_up_interruptible(&sonypi_device.fifo_proc_list);
886 886
@@ -906,7 +906,7 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
906 mutex_lock(&sonypi_device.lock); 906 mutex_lock(&sonypi_device.lock);
907 /* Flush input queue on first open */ 907 /* Flush input queue on first open */
908 if (!sonypi_device.open_count) 908 if (!sonypi_device.open_count)
909 kfifo_reset(sonypi_device.fifo); 909 kfifo_reset(&sonypi_device.fifo);
910 sonypi_device.open_count++; 910 sonypi_device.open_count++;
911 mutex_unlock(&sonypi_device.lock); 911 mutex_unlock(&sonypi_device.lock);
912 unlock_kernel(); 912 unlock_kernel();
@@ -919,17 +919,17 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
919 ssize_t ret; 919 ssize_t ret;
920 unsigned char c; 920 unsigned char c;
921 921
922 if ((kfifo_len(sonypi_device.fifo) == 0) && 922 if ((kfifo_len(&sonypi_device.fifo) == 0) &&
923 (file->f_flags & O_NONBLOCK)) 923 (file->f_flags & O_NONBLOCK))
924 return -EAGAIN; 924 return -EAGAIN;
925 925
926 ret = wait_event_interruptible(sonypi_device.fifo_proc_list, 926 ret = wait_event_interruptible(sonypi_device.fifo_proc_list,
927 kfifo_len(sonypi_device.fifo) != 0); 927 kfifo_len(&sonypi_device.fifo) != 0);
928 if (ret) 928 if (ret)
929 return ret; 929 return ret;
930 930
931 while (ret < count && 931 while (ret < count &&
932 (kfifo_get(sonypi_device.fifo, &c, sizeof(c)) == sizeof(c))) { 932 (kfifo_get(&sonypi_device.fifo, &c, sizeof(c)) == sizeof(c))) {
933 if (put_user(c, buf++)) 933 if (put_user(c, buf++))
934 return -EFAULT; 934 return -EFAULT;
935 ret++; 935 ret++;
@@ -946,7 +946,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
946static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait) 946static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
947{ 947{
948 poll_wait(file, &sonypi_device.fifo_proc_list, wait); 948 poll_wait(file, &sonypi_device.fifo_proc_list, wait);
949 if (kfifo_len(sonypi_device.fifo)) 949 if (kfifo_len(&sonypi_device.fifo))
950 return POLLIN | POLLRDNORM; 950 return POLLIN | POLLRDNORM;
951 return 0; 951 return 0;
952} 952}
@@ -1313,11 +1313,11 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1313 "http://www.linux.it/~malattia/wiki/index.php/Sony_drivers\n"); 1313 "http://www.linux.it/~malattia/wiki/index.php/Sony_drivers\n");
1314 1314
1315 spin_lock_init(&sonypi_device.fifo_lock); 1315 spin_lock_init(&sonypi_device.fifo_lock);
1316 sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL, 1316 error = kfifo_alloc(&sonypi_device.fifo, SONYPI_BUF_SIZE, GFP_KERNEL,
1317 &sonypi_device.fifo_lock); 1317 &sonypi_device.fifo_lock);
1318 if (IS_ERR(sonypi_device.fifo)) { 1318 if (error) {
1319 printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); 1319 printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
1320 return PTR_ERR(sonypi_device.fifo); 1320 return error;
1321 } 1321 }
1322 1322
1323 init_waitqueue_head(&sonypi_device.fifo_proc_list); 1323 init_waitqueue_head(&sonypi_device.fifo_proc_list);
@@ -1393,12 +1393,10 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1393 } 1393 }
1394 1394
1395 spin_lock_init(&sonypi_device.input_fifo_lock); 1395 spin_lock_init(&sonypi_device.input_fifo_lock);
1396 sonypi_device.input_fifo = 1396 error = kfifo_alloc(&sonypi_device.input_fifo, SONYPI_BUF_SIZE,
1397 kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL, 1397 GFP_KERNEL, &sonypi_device.input_fifo_lock);
1398 &sonypi_device.input_fifo_lock); 1398 if (error) {
1399 if (IS_ERR(sonypi_device.input_fifo)) {
1400 printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); 1399 printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
1401 error = PTR_ERR(sonypi_device.input_fifo);
1402 goto err_inpdev_unregister; 1400 goto err_inpdev_unregister;
1403 } 1401 }
1404 1402
@@ -1423,7 +1421,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1423 pci_disable_device(pcidev); 1421 pci_disable_device(pcidev);
1424 err_put_pcidev: 1422 err_put_pcidev:
1425 pci_dev_put(pcidev); 1423 pci_dev_put(pcidev);
1426 kfifo_free(sonypi_device.fifo); 1424 kfifo_free(&sonypi_device.fifo);
1427 1425
1428 return error; 1426 return error;
1429} 1427}
@@ -1438,7 +1436,7 @@ static int __devexit sonypi_remove(struct platform_device *dev)
1438 if (useinput) { 1436 if (useinput) {
1439 input_unregister_device(sonypi_device.input_key_dev); 1437 input_unregister_device(sonypi_device.input_key_dev);
1440 input_unregister_device(sonypi_device.input_jog_dev); 1438 input_unregister_device(sonypi_device.input_jog_dev);
1441 kfifo_free(sonypi_device.input_fifo); 1439 kfifo_free(&sonypi_device.input_fifo);
1442 } 1440 }
1443 1441
1444 misc_deregister(&sonypi_misc_device); 1442 misc_deregister(&sonypi_misc_device);
@@ -1451,7 +1449,7 @@ static int __devexit sonypi_remove(struct platform_device *dev)
1451 pci_dev_put(sonypi_device.dev); 1449 pci_dev_put(sonypi_device.dev);
1452 } 1450 }
1453 1451
1454 kfifo_free(sonypi_device.fifo); 1452 kfifo_free(&sonypi_device.fifo);
1455 1453
1456 return 0; 1454 return 0;
1457} 1455}
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h
index bfd03bf8be54..f3d440cc68f2 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.h
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h
@@ -34,6 +34,7 @@
34 34
35#include <linux/list.h> 35#include <linux/list.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/kfifo.h>
37 38
38#include "t3_cpl.h" 39#include "t3_cpl.h"
39#include "t3cdev.h" 40#include "t3cdev.h"
@@ -75,13 +76,13 @@ struct cxio_hal_ctrl_qp {
75}; 76};
76 77
77struct cxio_hal_resource { 78struct cxio_hal_resource {
78 struct kfifo *tpt_fifo; 79 struct kfifo tpt_fifo;
79 spinlock_t tpt_fifo_lock; 80 spinlock_t tpt_fifo_lock;
80 struct kfifo *qpid_fifo; 81 struct kfifo qpid_fifo;
81 spinlock_t qpid_fifo_lock; 82 spinlock_t qpid_fifo_lock;
82 struct kfifo *cqid_fifo; 83 struct kfifo cqid_fifo;
83 spinlock_t cqid_fifo_lock; 84 spinlock_t cqid_fifo_lock;
84 struct kfifo *pdid_fifo; 85 struct kfifo pdid_fifo;
85 spinlock_t pdid_fifo_lock; 86 spinlock_t pdid_fifo_lock;
86}; 87};
87 88
diff --git a/drivers/infiniband/hw/cxgb3/cxio_resource.c b/drivers/infiniband/hw/cxgb3/cxio_resource.c
index bd233c087653..65072bdfc1bf 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_resource.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_resource.c
@@ -39,12 +39,12 @@
39#include "cxio_resource.h" 39#include "cxio_resource.h"
40#include "cxio_hal.h" 40#include "cxio_hal.h"
41 41
42static struct kfifo *rhdl_fifo; 42static struct kfifo rhdl_fifo;
43static spinlock_t rhdl_fifo_lock; 43static spinlock_t rhdl_fifo_lock;
44 44
45#define RANDOM_SIZE 16 45#define RANDOM_SIZE 16
46 46
47static int __cxio_init_resource_fifo(struct kfifo **fifo, 47static int __cxio_init_resource_fifo(struct kfifo *fifo,
48 spinlock_t *fifo_lock, 48 spinlock_t *fifo_lock,
49 u32 nr, u32 skip_low, 49 u32 nr, u32 skip_low,
50 u32 skip_high, 50 u32 skip_high,
@@ -55,12 +55,11 @@ static int __cxio_init_resource_fifo(struct kfifo **fifo,
55 u32 rarray[16]; 55 u32 rarray[16];
56 spin_lock_init(fifo_lock); 56 spin_lock_init(fifo_lock);
57 57
58 *fifo = kfifo_alloc(nr * sizeof(u32), GFP_KERNEL, fifo_lock); 58 if (kfifo_alloc(fifo, nr * sizeof(u32), GFP_KERNEL, fifo_lock))
59 if (IS_ERR(*fifo))
60 return -ENOMEM; 59 return -ENOMEM;
61 60
62 for (i = 0; i < skip_low + skip_high; i++) 61 for (i = 0; i < skip_low + skip_high; i++)
63 __kfifo_put(*fifo, (unsigned char *) &entry, sizeof(u32)); 62 __kfifo_put(fifo, (unsigned char *) &entry, sizeof(u32));
64 if (random) { 63 if (random) {
65 j = 0; 64 j = 0;
66 random_bytes = random32(); 65 random_bytes = random32();
@@ -72,33 +71,33 @@ static int __cxio_init_resource_fifo(struct kfifo **fifo,
72 random_bytes = random32(); 71 random_bytes = random32();
73 } 72 }
74 idx = (random_bytes >> (j * 2)) & 0xF; 73 idx = (random_bytes >> (j * 2)) & 0xF;
75 __kfifo_put(*fifo, 74 __kfifo_put(fifo,
76 (unsigned char *) &rarray[idx], 75 (unsigned char *) &rarray[idx],
77 sizeof(u32)); 76 sizeof(u32));
78 rarray[idx] = i; 77 rarray[idx] = i;
79 j++; 78 j++;
80 } 79 }
81 for (i = 0; i < RANDOM_SIZE; i++) 80 for (i = 0; i < RANDOM_SIZE; i++)
82 __kfifo_put(*fifo, 81 __kfifo_put(fifo,
83 (unsigned char *) &rarray[i], 82 (unsigned char *) &rarray[i],
84 sizeof(u32)); 83 sizeof(u32));
85 } else 84 } else
86 for (i = skip_low; i < nr - skip_high; i++) 85 for (i = skip_low; i < nr - skip_high; i++)
87 __kfifo_put(*fifo, (unsigned char *) &i, sizeof(u32)); 86 __kfifo_put(fifo, (unsigned char *) &i, sizeof(u32));
88 87
89 for (i = 0; i < skip_low + skip_high; i++) 88 for (i = 0; i < skip_low + skip_high; i++)
90 kfifo_get(*fifo, (unsigned char *) &entry, sizeof(u32)); 89 kfifo_get(fifo, (unsigned char *) &entry, sizeof(u32));
91 return 0; 90 return 0;
92} 91}
93 92
94static int cxio_init_resource_fifo(struct kfifo **fifo, spinlock_t * fifo_lock, 93static int cxio_init_resource_fifo(struct kfifo *fifo, spinlock_t * fifo_lock,
95 u32 nr, u32 skip_low, u32 skip_high) 94 u32 nr, u32 skip_low, u32 skip_high)
96{ 95{
97 return (__cxio_init_resource_fifo(fifo, fifo_lock, nr, skip_low, 96 return (__cxio_init_resource_fifo(fifo, fifo_lock, nr, skip_low,
98 skip_high, 0)); 97 skip_high, 0));
99} 98}
100 99
101static int cxio_init_resource_fifo_random(struct kfifo **fifo, 100static int cxio_init_resource_fifo_random(struct kfifo *fifo,
102 spinlock_t * fifo_lock, 101 spinlock_t * fifo_lock,
103 u32 nr, u32 skip_low, u32 skip_high) 102 u32 nr, u32 skip_low, u32 skip_high)
104{ 103{
@@ -113,15 +112,14 @@ static int cxio_init_qpid_fifo(struct cxio_rdev *rdev_p)
113 112
114 spin_lock_init(&rdev_p->rscp->qpid_fifo_lock); 113 spin_lock_init(&rdev_p->rscp->qpid_fifo_lock);
115 114
116 rdev_p->rscp->qpid_fifo = kfifo_alloc(T3_MAX_NUM_QP * sizeof(u32), 115 if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, T3_MAX_NUM_QP * sizeof(u32),
117 GFP_KERNEL, 116 GFP_KERNEL,
118 &rdev_p->rscp->qpid_fifo_lock); 117 &rdev_p->rscp->qpid_fifo_lock))
119 if (IS_ERR(rdev_p->rscp->qpid_fifo))
120 return -ENOMEM; 118 return -ENOMEM;
121 119
122 for (i = 16; i < T3_MAX_NUM_QP; i++) 120 for (i = 16; i < T3_MAX_NUM_QP; i++)
123 if (!(i & rdev_p->qpmask)) 121 if (!(i & rdev_p->qpmask))
124 __kfifo_put(rdev_p->rscp->qpid_fifo, 122 __kfifo_put(&rdev_p->rscp->qpid_fifo,
125 (unsigned char *) &i, sizeof(u32)); 123 (unsigned char *) &i, sizeof(u32));
126 return 0; 124 return 0;
127} 125}
@@ -134,7 +132,7 @@ int cxio_hal_init_rhdl_resource(u32 nr_rhdl)
134 132
135void cxio_hal_destroy_rhdl_resource(void) 133void cxio_hal_destroy_rhdl_resource(void)
136{ 134{
137 kfifo_free(rhdl_fifo); 135 kfifo_free(&rhdl_fifo);
138} 136}
139 137
140/* nr_* must be power of 2 */ 138/* nr_* must be power of 2 */
@@ -167,11 +165,11 @@ int cxio_hal_init_resource(struct cxio_rdev *rdev_p,
167 goto pdid_err; 165 goto pdid_err;
168 return 0; 166 return 0;
169pdid_err: 167pdid_err:
170 kfifo_free(rscp->cqid_fifo); 168 kfifo_free(&rscp->cqid_fifo);
171cqid_err: 169cqid_err:
172 kfifo_free(rscp->qpid_fifo); 170 kfifo_free(&rscp->qpid_fifo);
173qpid_err: 171qpid_err:
174 kfifo_free(rscp->tpt_fifo); 172 kfifo_free(&rscp->tpt_fifo);
175tpt_err: 173tpt_err:
176 return -ENOMEM; 174 return -ENOMEM;
177} 175}
@@ -195,17 +193,17 @@ static void cxio_hal_put_resource(struct kfifo *fifo, u32 entry)
195 193
196u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp) 194u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp)
197{ 195{
198 return cxio_hal_get_resource(rscp->tpt_fifo); 196 return cxio_hal_get_resource(&rscp->tpt_fifo);
199} 197}
200 198
201void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag) 199void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag)
202{ 200{
203 cxio_hal_put_resource(rscp->tpt_fifo, stag); 201 cxio_hal_put_resource(&rscp->tpt_fifo, stag);
204} 202}
205 203
206u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp) 204u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp)
207{ 205{
208 u32 qpid = cxio_hal_get_resource(rscp->qpid_fifo); 206 u32 qpid = cxio_hal_get_resource(&rscp->qpid_fifo);
209 PDBG("%s qpid 0x%x\n", __func__, qpid); 207 PDBG("%s qpid 0x%x\n", __func__, qpid);
210 return qpid; 208 return qpid;
211} 209}
@@ -213,35 +211,35 @@ u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp)
213void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid) 211void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid)
214{ 212{
215 PDBG("%s qpid 0x%x\n", __func__, qpid); 213 PDBG("%s qpid 0x%x\n", __func__, qpid);
216 cxio_hal_put_resource(rscp->qpid_fifo, qpid); 214 cxio_hal_put_resource(&rscp->qpid_fifo, qpid);
217} 215}
218 216
219u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp) 217u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp)
220{ 218{
221 return cxio_hal_get_resource(rscp->cqid_fifo); 219 return cxio_hal_get_resource(&rscp->cqid_fifo);
222} 220}
223 221
224void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid) 222void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid)
225{ 223{
226 cxio_hal_put_resource(rscp->cqid_fifo, cqid); 224 cxio_hal_put_resource(&rscp->cqid_fifo, cqid);
227} 225}
228 226
229u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp) 227u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp)
230{ 228{
231 return cxio_hal_get_resource(rscp->pdid_fifo); 229 return cxio_hal_get_resource(&rscp->pdid_fifo);
232} 230}
233 231
234void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid) 232void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid)
235{ 233{
236 cxio_hal_put_resource(rscp->pdid_fifo, pdid); 234 cxio_hal_put_resource(&rscp->pdid_fifo, pdid);
237} 235}
238 236
239void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp) 237void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp)
240{ 238{
241 kfifo_free(rscp->tpt_fifo); 239 kfifo_free(&rscp->tpt_fifo);
242 kfifo_free(rscp->cqid_fifo); 240 kfifo_free(&rscp->cqid_fifo);
243 kfifo_free(rscp->qpid_fifo); 241 kfifo_free(&rscp->qpid_fifo);
244 kfifo_free(rscp->pdid_fifo); 242 kfifo_free(&rscp->pdid_fifo);
245 kfree(rscp); 243 kfree(rscp);
246} 244}
247 245
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 6ffa64cd1c6d..dacbbb839b9e 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -800,7 +800,7 @@ again:
800 return IRQ_HANDLED; 800 return IRQ_HANDLED;
801 801
802 if (meye.mchip_mode == MCHIP_HIC_MODE_CONT_OUT) { 802 if (meye.mchip_mode == MCHIP_HIC_MODE_CONT_OUT) {
803 if (kfifo_get(meye.grabq, (unsigned char *)&reqnr, 803 if (kfifo_get(&meye.grabq, (unsigned char *)&reqnr,
804 sizeof(int)) != sizeof(int)) { 804 sizeof(int)) != sizeof(int)) {
805 mchip_free_frame(); 805 mchip_free_frame();
806 return IRQ_HANDLED; 806 return IRQ_HANDLED;
@@ -811,7 +811,7 @@ again:
811 meye.grab_buffer[reqnr].state = MEYE_BUF_DONE; 811 meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
812 do_gettimeofday(&meye.grab_buffer[reqnr].timestamp); 812 do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
813 meye.grab_buffer[reqnr].sequence = sequence++; 813 meye.grab_buffer[reqnr].sequence = sequence++;
814 kfifo_put(meye.doneq, (unsigned char *)&reqnr, sizeof(int)); 814 kfifo_put(&meye.doneq, (unsigned char *)&reqnr, sizeof(int));
815 wake_up_interruptible(&meye.proc_list); 815 wake_up_interruptible(&meye.proc_list);
816 } else { 816 } else {
817 int size; 817 int size;
@@ -820,7 +820,7 @@ again:
820 mchip_free_frame(); 820 mchip_free_frame();
821 goto again; 821 goto again;
822 } 822 }
823 if (kfifo_get(meye.grabq, (unsigned char *)&reqnr, 823 if (kfifo_get(&meye.grabq, (unsigned char *)&reqnr,
824 sizeof(int)) != sizeof(int)) { 824 sizeof(int)) != sizeof(int)) {
825 mchip_free_frame(); 825 mchip_free_frame();
826 goto again; 826 goto again;
@@ -831,7 +831,7 @@ again:
831 meye.grab_buffer[reqnr].state = MEYE_BUF_DONE; 831 meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
832 do_gettimeofday(&meye.grab_buffer[reqnr].timestamp); 832 do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
833 meye.grab_buffer[reqnr].sequence = sequence++; 833 meye.grab_buffer[reqnr].sequence = sequence++;
834 kfifo_put(meye.doneq, (unsigned char *)&reqnr, sizeof(int)); 834 kfifo_put(&meye.doneq, (unsigned char *)&reqnr, sizeof(int));
835 wake_up_interruptible(&meye.proc_list); 835 wake_up_interruptible(&meye.proc_list);
836 } 836 }
837 mchip_free_frame(); 837 mchip_free_frame();
@@ -859,8 +859,8 @@ static int meye_open(struct file *file)
859 859
860 for (i = 0; i < MEYE_MAX_BUFNBRS; i++) 860 for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
861 meye.grab_buffer[i].state = MEYE_BUF_UNUSED; 861 meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
862 kfifo_reset(meye.grabq); 862 kfifo_reset(&meye.grabq);
863 kfifo_reset(meye.doneq); 863 kfifo_reset(&meye.doneq);
864 return 0; 864 return 0;
865} 865}
866 866
@@ -933,7 +933,7 @@ static int meyeioc_qbuf_capt(int *nb)
933 mchip_cont_compression_start(); 933 mchip_cont_compression_start();
934 934
935 meye.grab_buffer[*nb].state = MEYE_BUF_USING; 935 meye.grab_buffer[*nb].state = MEYE_BUF_USING;
936 kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int)); 936 kfifo_put(&meye.grabq, (unsigned char *)nb, sizeof(int));
937 mutex_unlock(&meye.lock); 937 mutex_unlock(&meye.lock);
938 938
939 return 0; 939 return 0;
@@ -965,7 +965,7 @@ static int meyeioc_sync(struct file *file, void *fh, int *i)
965 /* fall through */ 965 /* fall through */
966 case MEYE_BUF_DONE: 966 case MEYE_BUF_DONE:
967 meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; 967 meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
968 kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); 968 kfifo_get(&meye.doneq, (unsigned char *)&unused, sizeof(int));
969 } 969 }
970 *i = meye.grab_buffer[*i].size; 970 *i = meye.grab_buffer[*i].size;
971 mutex_unlock(&meye.lock); 971 mutex_unlock(&meye.lock);
@@ -1452,7 +1452,7 @@ static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
1452 buf->flags |= V4L2_BUF_FLAG_QUEUED; 1452 buf->flags |= V4L2_BUF_FLAG_QUEUED;
1453 buf->flags &= ~V4L2_BUF_FLAG_DONE; 1453 buf->flags &= ~V4L2_BUF_FLAG_DONE;
1454 meye.grab_buffer[buf->index].state = MEYE_BUF_USING; 1454 meye.grab_buffer[buf->index].state = MEYE_BUF_USING;
1455 kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int)); 1455 kfifo_put(&meye.grabq, (unsigned char *)&buf->index, sizeof(int));
1456 mutex_unlock(&meye.lock); 1456 mutex_unlock(&meye.lock);
1457 1457
1458 return 0; 1458 return 0;
@@ -1467,18 +1467,18 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
1467 1467
1468 mutex_lock(&meye.lock); 1468 mutex_lock(&meye.lock);
1469 1469
1470 if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) { 1470 if (kfifo_len(&meye.doneq) == 0 && file->f_flags & O_NONBLOCK) {
1471 mutex_unlock(&meye.lock); 1471 mutex_unlock(&meye.lock);
1472 return -EAGAIN; 1472 return -EAGAIN;
1473 } 1473 }
1474 1474
1475 if (wait_event_interruptible(meye.proc_list, 1475 if (wait_event_interruptible(meye.proc_list,
1476 kfifo_len(meye.doneq) != 0) < 0) { 1476 kfifo_len(&meye.doneq) != 0) < 0) {
1477 mutex_unlock(&meye.lock); 1477 mutex_unlock(&meye.lock);
1478 return -EINTR; 1478 return -EINTR;
1479 } 1479 }
1480 1480
1481 if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr, 1481 if (!kfifo_get(&meye.doneq, (unsigned char *)&reqnr,
1482 sizeof(int))) { 1482 sizeof(int))) {
1483 mutex_unlock(&meye.lock); 1483 mutex_unlock(&meye.lock);
1484 return -EBUSY; 1484 return -EBUSY;
@@ -1529,8 +1529,8 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
1529{ 1529{
1530 mutex_lock(&meye.lock); 1530 mutex_lock(&meye.lock);
1531 mchip_hic_stop(); 1531 mchip_hic_stop();
1532 kfifo_reset(meye.grabq); 1532 kfifo_reset(&meye.grabq);
1533 kfifo_reset(meye.doneq); 1533 kfifo_reset(&meye.doneq);
1534 1534
1535 for (i = 0; i < MEYE_MAX_BUFNBRS; i++) 1535 for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
1536 meye.grab_buffer[i].state = MEYE_BUF_UNUSED; 1536 meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
@@ -1572,7 +1572,7 @@ static unsigned int meye_poll(struct file *file, poll_table *wait)
1572 1572
1573 mutex_lock(&meye.lock); 1573 mutex_lock(&meye.lock);
1574 poll_wait(file, &meye.proc_list, wait); 1574 poll_wait(file, &meye.proc_list, wait);
1575 if (kfifo_len(meye.doneq)) 1575 if (kfifo_len(&meye.doneq))
1576 res = POLLIN | POLLRDNORM; 1576 res = POLLIN | POLLRDNORM;
1577 mutex_unlock(&meye.lock); 1577 mutex_unlock(&meye.lock);
1578 return res; 1578 return res;
@@ -1745,16 +1745,14 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1745 } 1745 }
1746 1746
1747 spin_lock_init(&meye.grabq_lock); 1747 spin_lock_init(&meye.grabq_lock);
1748 meye.grabq = kfifo_alloc(sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL, 1748 if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL,
1749 &meye.grabq_lock); 1749 &meye.grabq_lock)) {
1750 if (IS_ERR(meye.grabq)) {
1751 printk(KERN_ERR "meye: fifo allocation failed\n"); 1750 printk(KERN_ERR "meye: fifo allocation failed\n");
1752 goto outkfifoalloc1; 1751 goto outkfifoalloc1;
1753 } 1752 }
1754 spin_lock_init(&meye.doneq_lock); 1753 spin_lock_init(&meye.doneq_lock);
1755 meye.doneq = kfifo_alloc(sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL, 1754 if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL,
1756 &meye.doneq_lock); 1755 &meye.doneq_lock)) {
1757 if (IS_ERR(meye.doneq)) {
1758 printk(KERN_ERR "meye: fifo allocation failed\n"); 1756 printk(KERN_ERR "meye: fifo allocation failed\n");
1759 goto outkfifoalloc2; 1757 goto outkfifoalloc2;
1760 } 1758 }
@@ -1868,9 +1866,9 @@ outregions:
1868outenabledev: 1866outenabledev:
1869 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0); 1867 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0);
1870outsonypienable: 1868outsonypienable:
1871 kfifo_free(meye.doneq); 1869 kfifo_free(&meye.doneq);
1872outkfifoalloc2: 1870outkfifoalloc2:
1873 kfifo_free(meye.grabq); 1871 kfifo_free(&meye.grabq);
1874outkfifoalloc1: 1872outkfifoalloc1:
1875 vfree(meye.grab_temp); 1873 vfree(meye.grab_temp);
1876outvmalloc: 1874outvmalloc:
@@ -1901,8 +1899,8 @@ static void __devexit meye_remove(struct pci_dev *pcidev)
1901 1899
1902 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0); 1900 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0);
1903 1901
1904 kfifo_free(meye.doneq); 1902 kfifo_free(&meye.doneq);
1905 kfifo_free(meye.grabq); 1903 kfifo_free(&meye.grabq);
1906 1904
1907 vfree(meye.grab_temp); 1905 vfree(meye.grab_temp);
1908 1906
diff --git a/drivers/media/video/meye.h b/drivers/media/video/meye.h
index 5f70a106ba2b..1321ad5d6597 100644
--- a/drivers/media/video/meye.h
+++ b/drivers/media/video/meye.h
@@ -303,9 +303,9 @@ struct meye {
303 struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS]; 303 struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS];
304 int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */ 304 int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */
305 struct mutex lock; /* mutex for open/mmap... */ 305 struct mutex lock; /* mutex for open/mmap... */
306 struct kfifo *grabq; /* queue for buffers to be grabbed */ 306 struct kfifo grabq; /* queue for buffers to be grabbed */
307 spinlock_t grabq_lock; /* lock protecting the queue */ 307 spinlock_t grabq_lock; /* lock protecting the queue */
308 struct kfifo *doneq; /* queue for grabbed buffers */ 308 struct kfifo doneq; /* queue for grabbed buffers */
309 spinlock_t doneq_lock; /* lock protecting the queue */ 309 spinlock_t doneq_lock; /* lock protecting the queue */
310 wait_queue_head_t proc_list; /* wait queue */ 310 wait_queue_head_t proc_list; /* wait queue */
311 struct video_device *video_dev; /* video device parameters */ 311 struct video_device *video_dev; /* video device parameters */
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index b9b371bfa30f..ffed17f4f506 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1365,7 +1365,7 @@ static void lbs_send_confirmsleep(struct lbs_private *priv)
1365 priv->dnld_sent = DNLD_RES_RECEIVED; 1365 priv->dnld_sent = DNLD_RES_RECEIVED;
1366 1366
1367 /* If nothing to do, go back to sleep (?) */ 1367 /* If nothing to do, go back to sleep (?) */
1368 if (!__kfifo_len(priv->event_fifo) && !priv->resp_len[priv->resp_idx]) 1368 if (!__kfifo_len(&priv->event_fifo) && !priv->resp_len[priv->resp_idx])
1369 priv->psstate = PS_STATE_SLEEP; 1369 priv->psstate = PS_STATE_SLEEP;
1370 1370
1371 spin_unlock_irqrestore(&priv->driver_lock, flags); 1371 spin_unlock_irqrestore(&priv->driver_lock, flags);
@@ -1439,7 +1439,7 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv)
1439 } 1439 }
1440 1440
1441 /* Pending events or command responses? */ 1441 /* Pending events or command responses? */
1442 if (__kfifo_len(priv->event_fifo) || priv->resp_len[priv->resp_idx]) { 1442 if (__kfifo_len(&priv->event_fifo) || priv->resp_len[priv->resp_idx]) {
1443 allowed = 0; 1443 allowed = 0;
1444 lbs_deb_host("pending events or command responses\n"); 1444 lbs_deb_host("pending events or command responses\n");
1445 } 1445 }
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 6a8d2b291d8c..05bb298dfae9 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -10,7 +10,7 @@
10#include "scan.h" 10#include "scan.h"
11#include "assoc.h" 11#include "assoc.h"
12 12
13 13#include <linux/kfifo.h>
14 14
15/** sleep_params */ 15/** sleep_params */
16struct sleep_params { 16struct sleep_params {
@@ -120,7 +120,7 @@ struct lbs_private {
120 u32 resp_len[2]; 120 u32 resp_len[2];
121 121
122 /* Events sent from hardware to driver */ 122 /* Events sent from hardware to driver */
123 struct kfifo *event_fifo; 123 struct kfifo event_fifo;
124 124
125 /** thread to service interrupts */ 125 /** thread to service interrupts */
126 struct task_struct *main_thread; 126 struct task_struct *main_thread;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index db38a5a719fa..403909287414 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -459,7 +459,7 @@ static int lbs_thread(void *data)
459 else if (!list_empty(&priv->cmdpendingq) && 459 else if (!list_empty(&priv->cmdpendingq) &&
460 !(priv->wakeup_dev_required)) 460 !(priv->wakeup_dev_required))
461 shouldsleep = 0; /* We have a command to send */ 461 shouldsleep = 0; /* We have a command to send */
462 else if (__kfifo_len(priv->event_fifo)) 462 else if (__kfifo_len(&priv->event_fifo))
463 shouldsleep = 0; /* We have an event to process */ 463 shouldsleep = 0; /* We have an event to process */
464 else 464 else
465 shouldsleep = 1; /* No command */ 465 shouldsleep = 1; /* No command */
@@ -511,9 +511,9 @@ static int lbs_thread(void *data)
511 511
512 /* Process hardware events, e.g. card removed, link lost */ 512 /* Process hardware events, e.g. card removed, link lost */
513 spin_lock_irq(&priv->driver_lock); 513 spin_lock_irq(&priv->driver_lock);
514 while (__kfifo_len(priv->event_fifo)) { 514 while (__kfifo_len(&priv->event_fifo)) {
515 u32 event; 515 u32 event;
516 __kfifo_get(priv->event_fifo, (unsigned char *) &event, 516 __kfifo_get(&priv->event_fifo, (unsigned char *) &event,
517 sizeof(event)); 517 sizeof(event));
518 spin_unlock_irq(&priv->driver_lock); 518 spin_unlock_irq(&priv->driver_lock);
519 lbs_process_event(priv, event); 519 lbs_process_event(priv, event);
@@ -883,10 +883,9 @@ static int lbs_init_adapter(struct lbs_private *priv)
883 priv->resp_len[0] = priv->resp_len[1] = 0; 883 priv->resp_len[0] = priv->resp_len[1] = 0;
884 884
885 /* Create the event FIFO */ 885 /* Create the event FIFO */
886 priv->event_fifo = kfifo_alloc(sizeof(u32) * 16, GFP_KERNEL, NULL); 886 ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL, NULL);
887 if (IS_ERR(priv->event_fifo)) { 887 if (ret) {
888 lbs_pr_err("Out of memory allocating event FIFO buffer\n"); 888 lbs_pr_err("Out of memory allocating event FIFO buffer\n");
889 ret = -ENOMEM;
890 goto out; 889 goto out;
891 } 890 }
892 891
@@ -901,8 +900,7 @@ static void lbs_free_adapter(struct lbs_private *priv)
901 lbs_deb_enter(LBS_DEB_MAIN); 900 lbs_deb_enter(LBS_DEB_MAIN);
902 901
903 lbs_free_cmd_buffer(priv); 902 lbs_free_cmd_buffer(priv);
904 if (priv->event_fifo) 903 kfifo_free(&priv->event_fifo);
905 kfifo_free(priv->event_fifo);
906 del_timer(&priv->command_timer); 904 del_timer(&priv->command_timer);
907 del_timer(&priv->auto_deepsleep_timer); 905 del_timer(&priv->auto_deepsleep_timer);
908 kfree(priv->networks); 906 kfree(priv->networks);
@@ -1177,7 +1175,7 @@ void lbs_queue_event(struct lbs_private *priv, u32 event)
1177 if (priv->psstate == PS_STATE_SLEEP) 1175 if (priv->psstate == PS_STATE_SLEEP)
1178 priv->psstate = PS_STATE_AWAKE; 1176 priv->psstate = PS_STATE_AWAKE;
1179 1177
1180 __kfifo_put(priv->event_fifo, (unsigned char *) &event, sizeof(u32)); 1178 __kfifo_put(&priv->event_fifo, (unsigned char *) &event, sizeof(u32));
1181 1179
1182 wake_up_interruptible(&priv->waitq); 1180 wake_up_interruptible(&priv->waitq);
1183 1181
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index bcd4ba8be7db..f999fba0e25e 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -164,7 +164,7 @@ struct fujitsu_hotkey_t {
164 struct input_dev *input; 164 struct input_dev *input;
165 char phys[32]; 165 char phys[32];
166 struct platform_device *pf_device; 166 struct platform_device *pf_device;
167 struct kfifo *fifo; 167 struct kfifo fifo;
168 spinlock_t fifo_lock; 168 spinlock_t fifo_lock;
169 int rfkill_supported; 169 int rfkill_supported;
170 int rfkill_state; 170 int rfkill_state;
@@ -824,12 +824,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
824 824
825 /* kfifo */ 825 /* kfifo */
826 spin_lock_init(&fujitsu_hotkey->fifo_lock); 826 spin_lock_init(&fujitsu_hotkey->fifo_lock);
827 fujitsu_hotkey->fifo = 827 error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int),
828 kfifo_alloc(RINGBUFFERSIZE * sizeof(int), GFP_KERNEL, 828 GFP_KERNEL, &fujitsu_hotkey->fifo_lock);
829 &fujitsu_hotkey->fifo_lock); 829 if (error) {
830 if (IS_ERR(fujitsu_hotkey->fifo)) {
831 printk(KERN_ERR "kfifo_alloc failed\n"); 830 printk(KERN_ERR "kfifo_alloc failed\n");
832 error = PTR_ERR(fujitsu_hotkey->fifo);
833 goto err_stop; 831 goto err_stop;
834 } 832 }
835 833
@@ -934,7 +932,7 @@ err_unregister_input_dev:
934err_free_input_dev: 932err_free_input_dev:
935 input_free_device(input); 933 input_free_device(input);
936err_free_fifo: 934err_free_fifo:
937 kfifo_free(fujitsu_hotkey->fifo); 935 kfifo_free(&fujitsu_hotkey->fifo);
938err_stop: 936err_stop:
939 return result; 937 return result;
940} 938}
@@ -956,7 +954,7 @@ static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
956 954
957 input_free_device(input); 955 input_free_device(input);
958 956
959 kfifo_free(fujitsu_hotkey->fifo); 957 kfifo_free(&fujitsu_hotkey->fifo);
960 958
961 fujitsu_hotkey->acpi_handle = NULL; 959 fujitsu_hotkey->acpi_handle = NULL;
962 960
@@ -1008,7 +1006,7 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
1008 vdbg_printk(FUJLAPTOP_DBG_TRACE, 1006 vdbg_printk(FUJLAPTOP_DBG_TRACE,
1009 "Push keycode into ringbuffer [%d]\n", 1007 "Push keycode into ringbuffer [%d]\n",
1010 keycode); 1008 keycode);
1011 status = kfifo_put(fujitsu_hotkey->fifo, 1009 status = kfifo_put(&fujitsu_hotkey->fifo,
1012 (unsigned char *)&keycode, 1010 (unsigned char *)&keycode,
1013 sizeof(keycode)); 1011 sizeof(keycode));
1014 if (status != sizeof(keycode)) { 1012 if (status != sizeof(keycode)) {
@@ -1022,7 +1020,7 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
1022 } else if (keycode == 0) { 1020 } else if (keycode == 0) {
1023 while ((status = 1021 while ((status =
1024 kfifo_get 1022 kfifo_get
1025 (fujitsu_hotkey->fifo, (unsigned char *) 1023 (&fujitsu_hotkey->fifo, (unsigned char *)
1026 &keycode_r, 1024 &keycode_r,
1027 sizeof 1025 sizeof
1028 (keycode_r))) == sizeof(keycode_r)) { 1026 (keycode_r))) == sizeof(keycode_r)) {
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 7a2cc8a5c975..04625a048e74 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -142,7 +142,7 @@ struct sony_laptop_input_s {
142 atomic_t users; 142 atomic_t users;
143 struct input_dev *jog_dev; 143 struct input_dev *jog_dev;
144 struct input_dev *key_dev; 144 struct input_dev *key_dev;
145 struct kfifo *fifo; 145 struct kfifo fifo;
146 spinlock_t fifo_lock; 146 spinlock_t fifo_lock;
147 struct workqueue_struct *wq; 147 struct workqueue_struct *wq;
148}; 148};
@@ -300,7 +300,7 @@ static void do_sony_laptop_release_key(struct work_struct *work)
300{ 300{
301 struct sony_laptop_keypress kp; 301 struct sony_laptop_keypress kp;
302 302
303 while (kfifo_get(sony_laptop_input.fifo, (unsigned char *)&kp, 303 while (kfifo_get(&sony_laptop_input.fifo, (unsigned char *)&kp,
304 sizeof(kp)) == sizeof(kp)) { 304 sizeof(kp)) == sizeof(kp)) {
305 msleep(10); 305 msleep(10);
306 input_report_key(kp.dev, kp.key, 0); 306 input_report_key(kp.dev, kp.key, 0);
@@ -362,7 +362,7 @@ static void sony_laptop_report_input_event(u8 event)
362 /* we emit the scancode so we can always remap the key */ 362 /* we emit the scancode so we can always remap the key */
363 input_event(kp.dev, EV_MSC, MSC_SCAN, event); 363 input_event(kp.dev, EV_MSC, MSC_SCAN, event);
364 input_sync(kp.dev); 364 input_sync(kp.dev);
365 kfifo_put(sony_laptop_input.fifo, 365 kfifo_put(&sony_laptop_input.fifo,
366 (unsigned char *)&kp, sizeof(kp)); 366 (unsigned char *)&kp, sizeof(kp));
367 367
368 if (!work_pending(&sony_laptop_release_key_work)) 368 if (!work_pending(&sony_laptop_release_key_work))
@@ -385,12 +385,11 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device)
385 385
386 /* kfifo */ 386 /* kfifo */
387 spin_lock_init(&sony_laptop_input.fifo_lock); 387 spin_lock_init(&sony_laptop_input.fifo_lock);
388 sony_laptop_input.fifo = 388 error =
389 kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL, 389 kfifo_alloc(&sony_laptop_input.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL,
390 &sony_laptop_input.fifo_lock); 390 &sony_laptop_input.fifo_lock);
391 if (IS_ERR(sony_laptop_input.fifo)) { 391 if (error) {
392 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); 392 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
393 error = PTR_ERR(sony_laptop_input.fifo);
394 goto err_dec_users; 393 goto err_dec_users;
395 } 394 }
396 395
@@ -474,7 +473,7 @@ err_destroy_wq:
474 destroy_workqueue(sony_laptop_input.wq); 473 destroy_workqueue(sony_laptop_input.wq);
475 474
476err_free_kfifo: 475err_free_kfifo:
477 kfifo_free(sony_laptop_input.fifo); 476 kfifo_free(&sony_laptop_input.fifo);
478 477
479err_dec_users: 478err_dec_users:
480 atomic_dec(&sony_laptop_input.users); 479 atomic_dec(&sony_laptop_input.users);
@@ -500,7 +499,7 @@ static void sony_laptop_remove_input(void)
500 } 499 }
501 500
502 destroy_workqueue(sony_laptop_input.wq); 501 destroy_workqueue(sony_laptop_input.wq);
503 kfifo_free(sony_laptop_input.fifo); 502 kfifo_free(&sony_laptop_input.fifo);
504} 503}
505 504
506/*********** Platform Device ***********/ 505/*********** Platform Device ***********/
@@ -2079,7 +2078,7 @@ static struct attribute_group spic_attribute_group = {
2079 2078
2080struct sonypi_compat_s { 2079struct sonypi_compat_s {
2081 struct fasync_struct *fifo_async; 2080 struct fasync_struct *fifo_async;
2082 struct kfifo *fifo; 2081 struct kfifo fifo;
2083 spinlock_t fifo_lock; 2082 spinlock_t fifo_lock;
2084 wait_queue_head_t fifo_proc_list; 2083 wait_queue_head_t fifo_proc_list;
2085 atomic_t open_count; 2084 atomic_t open_count;
@@ -2104,12 +2103,12 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
2104 /* Flush input queue on first open */ 2103 /* Flush input queue on first open */
2105 unsigned long flags; 2104 unsigned long flags;
2106 2105
2107 spin_lock_irqsave(sonypi_compat.fifo->lock, flags); 2106 spin_lock_irqsave(&sonypi_compat.fifo_lock, flags);
2108 2107
2109 if (atomic_inc_return(&sonypi_compat.open_count) == 1) 2108 if (atomic_inc_return(&sonypi_compat.open_count) == 1)
2110 __kfifo_reset(sonypi_compat.fifo); 2109 __kfifo_reset(&sonypi_compat.fifo);
2111 2110
2112 spin_unlock_irqrestore(sonypi_compat.fifo->lock, flags); 2111 spin_unlock_irqrestore(&sonypi_compat.fifo_lock, flags);
2113 2112
2114 return 0; 2113 return 0;
2115} 2114}
@@ -2120,17 +2119,17 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
2120 ssize_t ret; 2119 ssize_t ret;
2121 unsigned char c; 2120 unsigned char c;
2122 2121
2123 if ((kfifo_len(sonypi_compat.fifo) == 0) && 2122 if ((kfifo_len(&sonypi_compat.fifo) == 0) &&
2124 (file->f_flags & O_NONBLOCK)) 2123 (file->f_flags & O_NONBLOCK))
2125 return -EAGAIN; 2124 return -EAGAIN;
2126 2125
2127 ret = wait_event_interruptible(sonypi_compat.fifo_proc_list, 2126 ret = wait_event_interruptible(sonypi_compat.fifo_proc_list,
2128 kfifo_len(sonypi_compat.fifo) != 0); 2127 kfifo_len(&sonypi_compat.fifo) != 0);
2129 if (ret) 2128 if (ret)
2130 return ret; 2129 return ret;
2131 2130
2132 while (ret < count && 2131 while (ret < count &&
2133 (kfifo_get(sonypi_compat.fifo, &c, sizeof(c)) == sizeof(c))) { 2132 (kfifo_get(&sonypi_compat.fifo, &c, sizeof(c)) == sizeof(c))) {
2134 if (put_user(c, buf++)) 2133 if (put_user(c, buf++))
2135 return -EFAULT; 2134 return -EFAULT;
2136 ret++; 2135 ret++;
@@ -2147,7 +2146,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
2147static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait) 2146static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
2148{ 2147{
2149 poll_wait(file, &sonypi_compat.fifo_proc_list, wait); 2148 poll_wait(file, &sonypi_compat.fifo_proc_list, wait);
2150 if (kfifo_len(sonypi_compat.fifo)) 2149 if (kfifo_len(&sonypi_compat.fifo))
2151 return POLLIN | POLLRDNORM; 2150 return POLLIN | POLLRDNORM;
2152 return 0; 2151 return 0;
2153} 2152}
@@ -2309,7 +2308,7 @@ static struct miscdevice sonypi_misc_device = {
2309 2308
2310static void sonypi_compat_report_event(u8 event) 2309static void sonypi_compat_report_event(u8 event)
2311{ 2310{
2312 kfifo_put(sonypi_compat.fifo, (unsigned char *)&event, sizeof(event)); 2311 kfifo_put(&sonypi_compat.fifo, (unsigned char *)&event, sizeof(event));
2313 kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN); 2312 kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN);
2314 wake_up_interruptible(&sonypi_compat.fifo_proc_list); 2313 wake_up_interruptible(&sonypi_compat.fifo_proc_list);
2315} 2314}
@@ -2319,11 +2318,12 @@ static int sonypi_compat_init(void)
2319 int error; 2318 int error;
2320 2319
2321 spin_lock_init(&sonypi_compat.fifo_lock); 2320 spin_lock_init(&sonypi_compat.fifo_lock);
2322 sonypi_compat.fifo = kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL, 2321 error =
2322 kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL,
2323 &sonypi_compat.fifo_lock); 2323 &sonypi_compat.fifo_lock);
2324 if (IS_ERR(sonypi_compat.fifo)) { 2324 if (error) {
2325 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); 2325 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
2326 return PTR_ERR(sonypi_compat.fifo); 2326 return error;
2327 } 2327 }
2328 2328
2329 init_waitqueue_head(&sonypi_compat.fifo_proc_list); 2329 init_waitqueue_head(&sonypi_compat.fifo_proc_list);
@@ -2342,14 +2342,14 @@ static int sonypi_compat_init(void)
2342 return 0; 2342 return 0;
2343 2343
2344err_free_kfifo: 2344err_free_kfifo:
2345 kfifo_free(sonypi_compat.fifo); 2345 kfifo_free(&sonypi_compat.fifo);
2346 return error; 2346 return error;
2347} 2347}
2348 2348
2349static void sonypi_compat_exit(void) 2349static void sonypi_compat_exit(void)
2350{ 2350{
2351 misc_deregister(&sonypi_misc_device); 2351 misc_deregister(&sonypi_misc_device);
2352 kfifo_free(sonypi_compat.fifo); 2352 kfifo_free(&sonypi_compat.fifo);
2353} 2353}
2354#else 2354#else
2355static int sonypi_compat_init(void) { return 0; } 2355static int sonypi_compat_init(void) { return 0; }
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index b7689f3d05f5..cf0aa7e90be9 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -517,7 +517,7 @@ static void iscsi_free_task(struct iscsi_task *task)
517 if (conn->login_task == task) 517 if (conn->login_task == task)
518 return; 518 return;
519 519
520 __kfifo_put(session->cmdpool.queue, (void*)&task, sizeof(void*)); 520 __kfifo_put(&session->cmdpool.queue, (void*)&task, sizeof(void*));
521 521
522 if (sc) { 522 if (sc) {
523 task->sc = NULL; 523 task->sc = NULL;
@@ -737,7 +737,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
737 BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE); 737 BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
738 BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED); 738 BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
739 739
740 if (!__kfifo_get(session->cmdpool.queue, 740 if (!__kfifo_get(&session->cmdpool.queue,
741 (void*)&task, sizeof(void*))) 741 (void*)&task, sizeof(void*)))
742 return NULL; 742 return NULL;
743 } 743 }
@@ -1567,7 +1567,7 @@ static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn,
1567{ 1567{
1568 struct iscsi_task *task; 1568 struct iscsi_task *task;
1569 1569
1570 if (!__kfifo_get(conn->session->cmdpool.queue, 1570 if (!__kfifo_get(&conn->session->cmdpool.queue,
1571 (void *) &task, sizeof(void *))) 1571 (void *) &task, sizeof(void *)))
1572 return NULL; 1572 return NULL;
1573 1573
@@ -2461,12 +2461,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
2461 if (q->pool == NULL) 2461 if (q->pool == NULL)
2462 return -ENOMEM; 2462 return -ENOMEM;
2463 2463
2464 q->queue = kfifo_init((void*)q->pool, max * sizeof(void*), 2464 kfifo_init(&q->queue, (void*)q->pool, max * sizeof(void*), NULL);
2465 GFP_KERNEL, NULL);
2466 if (IS_ERR(q->queue)) {
2467 q->queue = NULL;
2468 goto enomem;
2469 }
2470 2465
2471 for (i = 0; i < max; i++) { 2466 for (i = 0; i < max; i++) {
2472 q->pool[i] = kzalloc(item_size, GFP_KERNEL); 2467 q->pool[i] = kzalloc(item_size, GFP_KERNEL);
@@ -2474,7 +2469,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
2474 q->max = i; 2469 q->max = i;
2475 goto enomem; 2470 goto enomem;
2476 } 2471 }
2477 __kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*)); 2472 __kfifo_put(&q->queue, (void*)&q->pool[i], sizeof(void*));
2478 } 2473 }
2479 2474
2480 if (items) { 2475 if (items) {
@@ -2497,7 +2492,6 @@ void iscsi_pool_free(struct iscsi_pool *q)
2497 for (i = 0; i < q->max; i++) 2492 for (i = 0; i < q->max; i++)
2498 kfree(q->pool[i]); 2493 kfree(q->pool[i]);
2499 kfree(q->pool); 2494 kfree(q->pool);
2500 kfree(q->queue);
2501} 2495}
2502EXPORT_SYMBOL_GPL(iscsi_pool_free); 2496EXPORT_SYMBOL_GPL(iscsi_pool_free);
2503 2497
@@ -2825,7 +2819,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
2825 2819
2826 /* allocate login_task used for the login/text sequences */ 2820 /* allocate login_task used for the login/text sequences */
2827 spin_lock_bh(&session->lock); 2821 spin_lock_bh(&session->lock);
2828 if (!__kfifo_get(session->cmdpool.queue, 2822 if (!__kfifo_get(&session->cmdpool.queue,
2829 (void*)&conn->login_task, 2823 (void*)&conn->login_task,
2830 sizeof(void*))) { 2824 sizeof(void*))) {
2831 spin_unlock_bh(&session->lock); 2825 spin_unlock_bh(&session->lock);
@@ -2845,7 +2839,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
2845 return cls_conn; 2839 return cls_conn;
2846 2840
2847login_task_data_alloc_fail: 2841login_task_data_alloc_fail:
2848 __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task, 2842 __kfifo_put(&session->cmdpool.queue, (void*)&conn->login_task,
2849 sizeof(void*)); 2843 sizeof(void*));
2850login_task_alloc_fail: 2844login_task_alloc_fail:
2851 iscsi_destroy_conn(cls_conn); 2845 iscsi_destroy_conn(cls_conn);
@@ -2908,7 +2902,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2908 free_pages((unsigned long) conn->data, 2902 free_pages((unsigned long) conn->data,
2909 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN)); 2903 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
2910 kfree(conn->persistent_address); 2904 kfree(conn->persistent_address);
2911 __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task, 2905 __kfifo_put(&session->cmdpool.queue, (void*)&conn->login_task,
2912 sizeof(void*)); 2906 sizeof(void*));
2913 if (session->leadconn == conn) 2907 if (session->leadconn == conn)
2914 session->leadconn = NULL; 2908 session->leadconn = NULL;
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index ca25ee5190b0..a83ee56a185e 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -445,15 +445,15 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
445 return; 445 return;
446 446
447 /* flush task's r2t queues */ 447 /* flush task's r2t queues */
448 while (__kfifo_get(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) { 448 while (__kfifo_get(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
449 __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, 449 __kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
450 sizeof(void*)); 450 sizeof(void*));
451 ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n"); 451 ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n");
452 } 452 }
453 453
454 r2t = tcp_task->r2t; 454 r2t = tcp_task->r2t;
455 if (r2t != NULL) { 455 if (r2t != NULL) {
456 __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, 456 __kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
457 sizeof(void*)); 457 sizeof(void*));
458 tcp_task->r2t = NULL; 458 tcp_task->r2t = NULL;
459 } 459 }
@@ -541,7 +541,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
541 return 0; 541 return 0;
542 } 542 }
543 543
544 rc = __kfifo_get(tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*)); 544 rc = __kfifo_get(&tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
545 if (!rc) { 545 if (!rc) {
546 iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. " 546 iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. "
547 "Target has sent more R2Ts than it " 547 "Target has sent more R2Ts than it "
@@ -554,7 +554,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
554 if (r2t->data_length == 0) { 554 if (r2t->data_length == 0) {
555 iscsi_conn_printk(KERN_ERR, conn, 555 iscsi_conn_printk(KERN_ERR, conn,
556 "invalid R2T with zero data len\n"); 556 "invalid R2T with zero data len\n");
557 __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, 557 __kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
558 sizeof(void*)); 558 sizeof(void*));
559 return ISCSI_ERR_DATALEN; 559 return ISCSI_ERR_DATALEN;
560 } 560 }
@@ -570,7 +570,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
570 "invalid R2T with data len %u at offset %u " 570 "invalid R2T with data len %u at offset %u "
571 "and total length %d\n", r2t->data_length, 571 "and total length %d\n", r2t->data_length,
572 r2t->data_offset, scsi_out(task->sc)->length); 572 r2t->data_offset, scsi_out(task->sc)->length);
573 __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, 573 __kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
574 sizeof(void*)); 574 sizeof(void*));
575 return ISCSI_ERR_DATALEN; 575 return ISCSI_ERR_DATALEN;
576 } 576 }
@@ -580,7 +580,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
580 r2t->sent = 0; 580 r2t->sent = 0;
581 581
582 tcp_task->exp_datasn = r2tsn + 1; 582 tcp_task->exp_datasn = r2tsn + 1;
583 __kfifo_put(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*)); 583 __kfifo_put(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
584 conn->r2t_pdus_cnt++; 584 conn->r2t_pdus_cnt++;
585 585
586 iscsi_requeue_task(task); 586 iscsi_requeue_task(task);
@@ -951,7 +951,7 @@ int iscsi_tcp_task_init(struct iscsi_task *task)
951 return conn->session->tt->init_pdu(task, 0, task->data_count); 951 return conn->session->tt->init_pdu(task, 0, task->data_count);
952 } 952 }
953 953
954 BUG_ON(__kfifo_len(tcp_task->r2tqueue)); 954 BUG_ON(__kfifo_len(&tcp_task->r2tqueue));
955 tcp_task->exp_datasn = 0; 955 tcp_task->exp_datasn = 0;
956 956
957 /* Prepare PDU, optionally w/ immediate data */ 957 /* Prepare PDU, optionally w/ immediate data */
@@ -982,7 +982,7 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
982 if (r2t->data_length <= r2t->sent) { 982 if (r2t->data_length <= r2t->sent) {
983 ISCSI_DBG_TCP(task->conn, 983 ISCSI_DBG_TCP(task->conn,
984 " done with r2t %p\n", r2t); 984 " done with r2t %p\n", r2t);
985 __kfifo_put(tcp_task->r2tpool.queue, 985 __kfifo_put(&tcp_task->r2tpool.queue,
986 (void *)&tcp_task->r2t, 986 (void *)&tcp_task->r2t,
987 sizeof(void *)); 987 sizeof(void *));
988 tcp_task->r2t = r2t = NULL; 988 tcp_task->r2t = r2t = NULL;
@@ -990,7 +990,7 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
990 } 990 }
991 991
992 if (r2t == NULL) { 992 if (r2t == NULL) {
993 __kfifo_get(tcp_task->r2tqueue, 993 __kfifo_get(&tcp_task->r2tqueue,
994 (void *)&tcp_task->r2t, sizeof(void *)); 994 (void *)&tcp_task->r2t, sizeof(void *));
995 r2t = tcp_task->r2t; 995 r2t = tcp_task->r2t;
996 } 996 }
@@ -1127,9 +1127,8 @@ int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session)
1127 } 1127 }
1128 1128
1129 /* R2T xmit queue */ 1129 /* R2T xmit queue */
1130 tcp_task->r2tqueue = kfifo_alloc( 1130 if (kfifo_alloc(&tcp_task->r2tqueue,
1131 session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL); 1131 session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL)) {
1132 if (tcp_task->r2tqueue == ERR_PTR(-ENOMEM)) {
1133 iscsi_pool_free(&tcp_task->r2tpool); 1132 iscsi_pool_free(&tcp_task->r2tpool);
1134 goto r2t_alloc_fail; 1133 goto r2t_alloc_fail;
1135 } 1134 }
@@ -1142,7 +1141,7 @@ r2t_alloc_fail:
1142 struct iscsi_task *task = session->cmds[i]; 1141 struct iscsi_task *task = session->cmds[i];
1143 struct iscsi_tcp_task *tcp_task = task->dd_data; 1142 struct iscsi_tcp_task *tcp_task = task->dd_data;
1144 1143
1145 kfifo_free(tcp_task->r2tqueue); 1144 kfifo_free(&tcp_task->r2tqueue);
1146 iscsi_pool_free(&tcp_task->r2tpool); 1145 iscsi_pool_free(&tcp_task->r2tpool);
1147 } 1146 }
1148 return -ENOMEM; 1147 return -ENOMEM;
@@ -1157,7 +1156,7 @@ void iscsi_tcp_r2tpool_free(struct iscsi_session *session)
1157 struct iscsi_task *task = session->cmds[i]; 1156 struct iscsi_task *task = session->cmds[i];
1158 struct iscsi_tcp_task *tcp_task = task->dd_data; 1157 struct iscsi_tcp_task *tcp_task = task->dd_data;
1159 1158
1160 kfifo_free(tcp_task->r2tqueue); 1159 kfifo_free(&tcp_task->r2tqueue);
1161 iscsi_pool_free(&tcp_task->r2tpool); 1160 iscsi_pool_free(&tcp_task->r2tpool);
1162 } 1161 }
1163} 1162}
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 9ad38e81e343..b1b5e51ca8e3 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -58,19 +58,16 @@ static int srp_iu_pool_alloc(struct srp_queue *q, size_t max,
58 goto free_pool; 58 goto free_pool;
59 59
60 spin_lock_init(&q->lock); 60 spin_lock_init(&q->lock);
61 q->queue = kfifo_init((void *) q->pool, max * sizeof(void *), 61 kfifo_init(&q->queue, (void *) q->pool, max * sizeof(void *),
62 GFP_KERNEL, &q->lock); 62 &q->lock);
63 if (IS_ERR(q->queue))
64 goto free_item;
65 63
66 for (i = 0, iue = q->items; i < max; i++) { 64 for (i = 0, iue = q->items; i < max; i++) {
67 __kfifo_put(q->queue, (void *) &iue, sizeof(void *)); 65 __kfifo_put(&q->queue, (void *) &iue, sizeof(void *));
68 iue->sbuf = ring[i]; 66 iue->sbuf = ring[i];
69 iue++; 67 iue++;
70 } 68 }
71 return 0; 69 return 0;
72 70
73free_item:
74 kfree(q->items); 71 kfree(q->items);
75free_pool: 72free_pool:
76 kfree(q->pool); 73 kfree(q->pool);
@@ -167,7 +164,7 @@ struct iu_entry *srp_iu_get(struct srp_target *target)
167{ 164{
168 struct iu_entry *iue = NULL; 165 struct iu_entry *iue = NULL;
169 166
170 kfifo_get(target->iu_queue.queue, (void *) &iue, sizeof(void *)); 167 kfifo_get(&target->iu_queue.queue, (void *) &iue, sizeof(void *));
171 if (!iue) 168 if (!iue)
172 return iue; 169 return iue;
173 iue->target = target; 170 iue->target = target;
@@ -179,7 +176,7 @@ EXPORT_SYMBOL_GPL(srp_iu_get);
179 176
180void srp_iu_put(struct iu_entry *iue) 177void srp_iu_put(struct iu_entry *iue)
181{ 178{
182 kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *)); 179 kfifo_put(&iue->target->iu_queue.queue, (void *) &iue, sizeof(void *));
183} 180}
184EXPORT_SYMBOL_GPL(srp_iu_put); 181EXPORT_SYMBOL_GPL(srp_iu_put);
185 182
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index 00a29855d0c4..ff43747a614f 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -37,7 +37,7 @@ static void recycle_frame(struct fhci_usb *usb, struct packet *pkt)
37 pkt->info = 0; 37 pkt->info = 0;
38 pkt->priv_data = NULL; 38 pkt->priv_data = NULL;
39 39
40 cq_put(usb->ep0->empty_frame_Q, pkt); 40 cq_put(&usb->ep0->empty_frame_Q, pkt);
41} 41}
42 42
43/* confirm submitted packet */ 43/* confirm submitted packet */
@@ -57,7 +57,7 @@ void fhci_transaction_confirm(struct fhci_usb *usb, struct packet *pkt)
57 if ((td->data + td->actual_len) && trans_len) 57 if ((td->data + td->actual_len) && trans_len)
58 memcpy(td->data + td->actual_len, pkt->data, 58 memcpy(td->data + td->actual_len, pkt->data,
59 trans_len); 59 trans_len);
60 cq_put(usb->ep0->dummy_packets_Q, pkt->data); 60 cq_put(&usb->ep0->dummy_packets_Q, pkt->data);
61 } 61 }
62 62
63 recycle_frame(usb, pkt); 63 recycle_frame(usb, pkt);
@@ -213,7 +213,7 @@ static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td)
213 } 213 }
214 214
215 /* update frame object fields before transmitting */ 215 /* update frame object fields before transmitting */
216 pkt = cq_get(usb->ep0->empty_frame_Q); 216 pkt = cq_get(&usb->ep0->empty_frame_Q);
217 if (!pkt) { 217 if (!pkt) {
218 fhci_dbg(usb->fhci, "there is no empty frame\n"); 218 fhci_dbg(usb->fhci, "there is no empty frame\n");
219 return -1; 219 return -1;
@@ -222,7 +222,7 @@ static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td)
222 222
223 pkt->info = 0; 223 pkt->info = 0;
224 if (data == NULL) { 224 if (data == NULL) {
225 data = cq_get(usb->ep0->dummy_packets_Q); 225 data = cq_get(&usb->ep0->dummy_packets_Q);
226 BUG_ON(!data); 226 BUG_ON(!data);
227 pkt->info = PKT_DUMMY_PACKET; 227 pkt->info = PKT_DUMMY_PACKET;
228 } 228 }
@@ -246,7 +246,7 @@ static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td)
246 list_del_init(&td->frame_lh); 246 list_del_init(&td->frame_lh);
247 td->status = USB_TD_OK; 247 td->status = USB_TD_OK;
248 if (pkt->info & PKT_DUMMY_PACKET) 248 if (pkt->info & PKT_DUMMY_PACKET)
249 cq_put(usb->ep0->dummy_packets_Q, pkt->data); 249 cq_put(&usb->ep0->dummy_packets_Q, pkt->data);
250 recycle_frame(usb, pkt); 250 recycle_frame(usb, pkt);
251 usb->actual_frame->total_bytes -= (len + PROTOCOL_OVERHEAD); 251 usb->actual_frame->total_bytes -= (len + PROTOCOL_OVERHEAD);
252 fhci_err(usb->fhci, "host transaction failed\n"); 252 fhci_err(usb->fhci, "host transaction failed\n");
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
index b40332290319..d224ab467a40 100644
--- a/drivers/usb/host/fhci-tds.c
+++ b/drivers/usb/host/fhci-tds.c
@@ -106,33 +106,33 @@ void fhci_ep0_free(struct fhci_usb *usb)
106 cpm_muram_free(cpm_muram_offset(ep->td_base)); 106 cpm_muram_free(cpm_muram_offset(ep->td_base));
107 107
108 if (ep->conf_frame_Q) { 108 if (ep->conf_frame_Q) {
109 size = cq_howmany(ep->conf_frame_Q); 109 size = cq_howmany(&ep->conf_frame_Q);
110 for (; size; size--) { 110 for (; size; size--) {
111 struct packet *pkt = cq_get(ep->conf_frame_Q); 111 struct packet *pkt = cq_get(&ep->conf_frame_Q);
112 112
113 kfree(pkt); 113 kfree(pkt);
114 } 114 }
115 cq_delete(ep->conf_frame_Q); 115 cq_delete(&ep->conf_frame_Q);
116 } 116 }
117 117
118 if (ep->empty_frame_Q) { 118 if (ep->empty_frame_Q) {
119 size = cq_howmany(ep->empty_frame_Q); 119 size = cq_howmany(&ep->empty_frame_Q);
120 for (; size; size--) { 120 for (; size; size--) {
121 struct packet *pkt = cq_get(ep->empty_frame_Q); 121 struct packet *pkt = cq_get(&ep->empty_frame_Q);
122 122
123 kfree(pkt); 123 kfree(pkt);
124 } 124 }
125 cq_delete(ep->empty_frame_Q); 125 cq_delete(&ep->empty_frame_Q);
126 } 126 }
127 127
128 if (ep->dummy_packets_Q) { 128 if (ep->dummy_packets_Q) {
129 size = cq_howmany(ep->dummy_packets_Q); 129 size = cq_howmany(&ep->dummy_packets_Q);
130 for (; size; size--) { 130 for (; size; size--) {
131 u8 *buff = cq_get(ep->dummy_packets_Q); 131 u8 *buff = cq_get(&ep->dummy_packets_Q);
132 132
133 kfree(buff); 133 kfree(buff);
134 } 134 }
135 cq_delete(ep->dummy_packets_Q); 135 cq_delete(&ep->dummy_packets_Q);
136 } 136 }
137 137
138 kfree(ep); 138 kfree(ep);
@@ -175,10 +175,9 @@ u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
175 ep->td_base = cpm_muram_addr(ep_offset); 175 ep->td_base = cpm_muram_addr(ep_offset);
176 176
177 /* zero all queue pointers */ 177 /* zero all queue pointers */
178 ep->conf_frame_Q = cq_new(ring_len + 2); 178 if (cq_new(&ep->conf_frame_Q, ring_len + 2) ||
179 ep->empty_frame_Q = cq_new(ring_len + 2); 179 cq_new(&ep->empty_frame_Q, ring_len + 2) ||
180 ep->dummy_packets_Q = cq_new(ring_len + 2); 180 cq_new(&ep->dummy_packets_Q, ring_len + 2)) {
181 if (!ep->conf_frame_Q || !ep->empty_frame_Q || !ep->dummy_packets_Q) {
182 err_for = "frame_queues"; 181 err_for = "frame_queues";
183 goto err; 182 goto err;
184 } 183 }
@@ -199,8 +198,8 @@ u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
199 err_for = "buffer"; 198 err_for = "buffer";
200 goto err; 199 goto err;
201 } 200 }
202 cq_put(ep->empty_frame_Q, pkt); 201 cq_put(&ep->empty_frame_Q, pkt);
203 cq_put(ep->dummy_packets_Q, buff); 202 cq_put(&ep->dummy_packets_Q, buff);
204 } 203 }
205 204
206 /* we put the endpoint parameter RAM right behind the TD ring */ 205 /* we put the endpoint parameter RAM right behind the TD ring */
@@ -319,7 +318,7 @@ static void fhci_td_transaction_confirm(struct fhci_usb *usb)
319 if ((buf == DUMMY2_BD_BUFFER) && !(td_status & ~TD_W)) 318 if ((buf == DUMMY2_BD_BUFFER) && !(td_status & ~TD_W))
320 continue; 319 continue;
321 320
322 pkt = cq_get(ep->conf_frame_Q); 321 pkt = cq_get(&ep->conf_frame_Q);
323 if (!pkt) 322 if (!pkt)
324 fhci_err(usb->fhci, "no frame to confirm\n"); 323 fhci_err(usb->fhci, "no frame to confirm\n");
325 324
@@ -460,9 +459,9 @@ u32 fhci_host_transaction(struct fhci_usb *usb,
460 out_be16(&td->length, pkt->len); 459 out_be16(&td->length, pkt->len);
461 460
462 /* put the frame to the confirmation queue */ 461 /* put the frame to the confirmation queue */
463 cq_put(ep->conf_frame_Q, pkt); 462 cq_put(&ep->conf_frame_Q, pkt);
464 463
465 if (cq_howmany(ep->conf_frame_Q) == 1) 464 if (cq_howmany(&ep->conf_frame_Q) == 1)
466 out_8(&usb->fhci->regs->usb_comm, USB_CMD_STR_FIFO); 465 out_8(&usb->fhci->regs->usb_comm, USB_CMD_STR_FIFO);
467 466
468 return 0; 467 return 0;
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
index 7116284ed21a..2277428ef5d3 100644
--- a/drivers/usb/host/fhci.h
+++ b/drivers/usb/host/fhci.h
@@ -423,9 +423,9 @@ struct endpoint {
423 struct usb_td __iomem *td_base; /* first TD in the ring */ 423 struct usb_td __iomem *td_base; /* first TD in the ring */
424 struct usb_td __iomem *conf_td; /* next TD for confirm after transac */ 424 struct usb_td __iomem *conf_td; /* next TD for confirm after transac */
425 struct usb_td __iomem *empty_td;/* next TD for new transaction req. */ 425 struct usb_td __iomem *empty_td;/* next TD for new transaction req. */
426 struct kfifo *empty_frame_Q; /* Empty frames list to use */ 426 struct kfifo empty_frame_Q; /* Empty frames list to use */
427 struct kfifo *conf_frame_Q; /* frames passed to TDs,waiting for tx */ 427 struct kfifo conf_frame_Q; /* frames passed to TDs,waiting for tx */
428 struct kfifo *dummy_packets_Q;/* dummy packets for the CRC overun */ 428 struct kfifo dummy_packets_Q;/* dummy packets for the CRC overun */
429 429
430 bool already_pushed_dummy_bd; 430 bool already_pushed_dummy_bd;
431}; 431};
@@ -493,9 +493,9 @@ static inline struct usb_hcd *fhci_to_hcd(struct fhci_hcd *fhci)
493} 493}
494 494
495/* fifo of pointers */ 495/* fifo of pointers */
496static inline struct kfifo *cq_new(int size) 496static inline int cq_new(struct kfifo *fifo, int size)
497{ 497{
498 return kfifo_alloc(size * sizeof(void *), GFP_KERNEL, NULL); 498 return kfifo_alloc(fifo, size * sizeof(void *), GFP_KERNEL, NULL);
499} 499}
500 500
501static inline void cq_delete(struct kfifo *kfifo) 501static inline void cq_delete(struct kfifo *kfifo)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 4543f359be75..44b72d47fac2 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -939,9 +939,8 @@ int usb_serial_probe(struct usb_interface *interface,
939 dev_err(&interface->dev, "No free urbs available\n"); 939 dev_err(&interface->dev, "No free urbs available\n");
940 goto probe_error; 940 goto probe_error;
941 } 941 }
942 port->write_fifo = kfifo_alloc(PAGE_SIZE, GFP_KERNEL, 942 if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL,
943 &port->lock); 943 &port->lock))
944 if (IS_ERR(port->write_fifo))
945 goto probe_error; 944 goto probe_error;
946 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 945 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
947 port->bulk_out_size = buffer_size; 946 port->bulk_out_size = buffer_size;
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index ad6bdf5a5970..c3f8d82efd34 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * A simple kernel FIFO implementation. 2 * A generic kernel FIFO implementation.
3 * 3 *
4 * Copyright (C) 2009 Stefani Seibold <stefani@seibold.net>
4 * Copyright (C) 2004 Stelian Pop <stelian@popies.net> 5 * Copyright (C) 2004 Stelian Pop <stelian@popies.net>
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -32,10 +33,10 @@ struct kfifo {
32 spinlock_t *lock; /* protects concurrent modifications */ 33 spinlock_t *lock; /* protects concurrent modifications */
33}; 34};
34 35
35extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size, 36extern void kfifo_init(struct kfifo *fifo, unsigned char *buffer,
36 gfp_t gfp_mask, spinlock_t *lock); 37 unsigned int size, spinlock_t *lock);
37extern struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, 38extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size,
38 spinlock_t *lock); 39 gfp_t gfp_mask, spinlock_t *lock);
39extern void kfifo_free(struct kfifo *fifo); 40extern void kfifo_free(struct kfifo *fifo);
40extern unsigned int __kfifo_put(struct kfifo *fifo, 41extern unsigned int __kfifo_put(struct kfifo *fifo,
41 const unsigned char *buffer, unsigned int len); 42 const unsigned char *buffer, unsigned int len);
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 7394e3bc8f4b..ff92b46f5153 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -28,6 +28,7 @@
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/workqueue.h> 30#include <linux/workqueue.h>
31#include <linux/kfifo.h>
31#include <scsi/iscsi_proto.h> 32#include <scsi/iscsi_proto.h>
32#include <scsi/iscsi_if.h> 33#include <scsi/iscsi_if.h>
33#include <scsi/scsi_transport_iscsi.h> 34#include <scsi/scsi_transport_iscsi.h>
@@ -231,7 +232,7 @@ struct iscsi_conn {
231}; 232};
232 233
233struct iscsi_pool { 234struct iscsi_pool {
234 struct kfifo *queue; /* FIFO Queue */ 235 struct kfifo queue; /* FIFO Queue */
235 void **pool; /* Pool of elements */ 236 void **pool; /* Pool of elements */
236 int max; /* Max number of elements */ 237 int max; /* Max number of elements */
237}; 238};
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
index 9e3182e659db..741ae7ed4394 100644
--- a/include/scsi/libiscsi_tcp.h
+++ b/include/scsi/libiscsi_tcp.h
@@ -80,7 +80,7 @@ struct iscsi_tcp_task {
80 int data_offset; 80 int data_offset;
81 struct iscsi_r2t_info *r2t; /* in progress solict R2T */ 81 struct iscsi_r2t_info *r2t; /* in progress solict R2T */
82 struct iscsi_pool r2tpool; 82 struct iscsi_pool r2tpool;
83 struct kfifo *r2tqueue; 83 struct kfifo r2tqueue;
84 void *dd_data; 84 void *dd_data;
85}; 85};
86 86
diff --git a/include/scsi/libsrp.h b/include/scsi/libsrp.h
index ba615e4c1d7c..07e3adde21d9 100644
--- a/include/scsi/libsrp.h
+++ b/include/scsi/libsrp.h
@@ -21,7 +21,7 @@ struct srp_buf {
21struct srp_queue { 21struct srp_queue {
22 void *pool; 22 void *pool;
23 void *items; 23 void *items;
24 struct kfifo *queue; 24 struct kfifo queue;
25 spinlock_t lock; 25 spinlock_t lock;
26}; 26};
27 27
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 3765ff3c1bbe..8da6bb9782bb 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * A simple kernel FIFO implementation. 2 * A generic kernel FIFO implementation.
3 * 3 *
4 * Copyright (C) 2009 Stefani Seibold <stefani@seibold.net>
4 * Copyright (C) 2004 Stelian Pop <stelian@popies.net> 5 * Copyright (C) 2004 Stelian Pop <stelian@popies.net>
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -26,49 +27,51 @@
26#include <linux/kfifo.h> 27#include <linux/kfifo.h>
27#include <linux/log2.h> 28#include <linux/log2.h>
28 29
30static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
31 unsigned int size, spinlock_t *lock)
32{
33 fifo->buffer = buffer;
34 fifo->size = size;
35 fifo->lock = lock;
36
37 kfifo_reset(fifo);
38}
39
29/** 40/**
30 * kfifo_init - allocates a new FIFO using a preallocated buffer 41 * kfifo_init - initialize a FIFO using a preallocated buffer
42 * @fifo: the fifo to assign the buffer
31 * @buffer: the preallocated buffer to be used. 43 * @buffer: the preallocated buffer to be used.
32 * @size: the size of the internal buffer, this have to be a power of 2. 44 * @size: the size of the internal buffer, this have to be a power of 2.
33 * @gfp_mask: get_free_pages mask, passed to kmalloc()
34 * @lock: the lock to be used to protect the fifo buffer 45 * @lock: the lock to be used to protect the fifo buffer
35 * 46 *
36 * Do NOT pass the kfifo to kfifo_free() after use! Simply free the
37 * &struct kfifo with kfree().
38 */ 47 */
39struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size, 48void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size,
40 gfp_t gfp_mask, spinlock_t *lock) 49 spinlock_t *lock)
41{ 50{
42 struct kfifo *fifo;
43
44 /* size must be a power of 2 */ 51 /* size must be a power of 2 */
45 BUG_ON(!is_power_of_2(size)); 52 BUG_ON(!is_power_of_2(size));
46 53
47 fifo = kmalloc(sizeof(struct kfifo), gfp_mask); 54 _kfifo_init(fifo, buffer, size, lock);
48 if (!fifo)
49 return ERR_PTR(-ENOMEM);
50
51 fifo->buffer = buffer;
52 fifo->size = size;
53 fifo->in = fifo->out = 0;
54 fifo->lock = lock;
55
56 return fifo;
57} 55}
58EXPORT_SYMBOL(kfifo_init); 56EXPORT_SYMBOL(kfifo_init);
59 57
60/** 58/**
61 * kfifo_alloc - allocates a new FIFO and its internal buffer 59 * kfifo_alloc - allocates a new FIFO internal buffer
62 * @size: the size of the internal buffer to be allocated. 60 * @fifo: the fifo to assign then new buffer
61 * @size: the size of the buffer to be allocated, this have to be a power of 2.
63 * @gfp_mask: get_free_pages mask, passed to kmalloc() 62 * @gfp_mask: get_free_pages mask, passed to kmalloc()
64 * @lock: the lock to be used to protect the fifo buffer 63 * @lock: the lock to be used to protect the fifo buffer
65 * 64 *
65 * This function dynamically allocates a new fifo internal buffer
66 *
66 * The size will be rounded-up to a power of 2. 67 * The size will be rounded-up to a power of 2.
68 * The buffer will be release with kfifo_free().
69 * Return 0 if no error, otherwise the an error code
67 */ 70 */
68struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock) 71int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask,
72 spinlock_t *lock)
69{ 73{
70 unsigned char *buffer; 74 unsigned char *buffer;
71 struct kfifo *ret;
72 75
73 /* 76 /*
74 * round up to the next power of 2, since our 'let the indices 77 * round up to the next power of 2, since our 'let the indices
@@ -80,26 +83,24 @@ struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock)
80 } 83 }
81 84
82 buffer = kmalloc(size, gfp_mask); 85 buffer = kmalloc(size, gfp_mask);
83 if (!buffer) 86 if (!buffer) {
84 return ERR_PTR(-ENOMEM); 87 _kfifo_init(fifo, 0, 0, NULL);
85 88 return -ENOMEM;
86 ret = kfifo_init(buffer, size, gfp_mask, lock); 89 }
87 90
88 if (IS_ERR(ret)) 91 _kfifo_init(fifo, buffer, size, lock);
89 kfree(buffer);
90 92
91 return ret; 93 return 0;
92} 94}
93EXPORT_SYMBOL(kfifo_alloc); 95EXPORT_SYMBOL(kfifo_alloc);
94 96
95/** 97/**
96 * kfifo_free - frees the FIFO 98 * kfifo_free - frees the FIFO internal buffer
97 * @fifo: the fifo to be freed. 99 * @fifo: the fifo to be freed.
98 */ 100 */
99void kfifo_free(struct kfifo *fifo) 101void kfifo_free(struct kfifo *fifo)
100{ 102{
101 kfree(fifo->buffer); 103 kfree(fifo->buffer);
102 kfree(fifo);
103} 104}
104EXPORT_SYMBOL(kfifo_free); 105EXPORT_SYMBOL(kfifo_free);
105 106
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index dc328425fa20..6230ceb0823e 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -43,7 +43,7 @@ static int bufsize = 64 * 1024;
43static const char procname[] = "dccpprobe"; 43static const char procname[] = "dccpprobe";
44 44
45static struct { 45static struct {
46 struct kfifo *fifo; 46 struct kfifo fifo;
47 spinlock_t lock; 47 spinlock_t lock;
48 wait_queue_head_t wait; 48 wait_queue_head_t wait;
49 struct timespec tstart; 49 struct timespec tstart;
@@ -67,7 +67,7 @@ static void printl(const char *fmt, ...)
67 len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args); 67 len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
68 va_end(args); 68 va_end(args);
69 69
70 kfifo_put(dccpw.fifo, tbuf, len); 70 kfifo_put(&dccpw.fifo, tbuf, len);
71 wake_up(&dccpw.wait); 71 wake_up(&dccpw.wait);
72} 72}
73 73
@@ -109,7 +109,7 @@ static struct jprobe dccp_send_probe = {
109 109
110static int dccpprobe_open(struct inode *inode, struct file *file) 110static int dccpprobe_open(struct inode *inode, struct file *file)
111{ 111{
112 kfifo_reset(dccpw.fifo); 112 kfifo_reset(&dccpw.fifo);
113 getnstimeofday(&dccpw.tstart); 113 getnstimeofday(&dccpw.tstart);
114 return 0; 114 return 0;
115} 115}
@@ -131,11 +131,11 @@ static ssize_t dccpprobe_read(struct file *file, char __user *buf,
131 return -ENOMEM; 131 return -ENOMEM;
132 132
133 error = wait_event_interruptible(dccpw.wait, 133 error = wait_event_interruptible(dccpw.wait,
134 __kfifo_len(dccpw.fifo) != 0); 134 __kfifo_len(&dccpw.fifo) != 0);
135 if (error) 135 if (error)
136 goto out_free; 136 goto out_free;
137 137
138 cnt = kfifo_get(dccpw.fifo, tbuf, len); 138 cnt = kfifo_get(&dccpw.fifo, tbuf, len);
139 error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0; 139 error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0;
140 140
141out_free: 141out_free:
@@ -156,10 +156,8 @@ static __init int dccpprobe_init(void)
156 156
157 init_waitqueue_head(&dccpw.wait); 157 init_waitqueue_head(&dccpw.wait);
158 spin_lock_init(&dccpw.lock); 158 spin_lock_init(&dccpw.lock);
159 dccpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &dccpw.lock); 159 if (kfifo_alloc(&dccpw.fifo, bufsize, GFP_KERNEL, &dccpw.lock))
160 if (IS_ERR(dccpw.fifo)) 160 return ret;
161 return PTR_ERR(dccpw.fifo);
162
163 if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops)) 161 if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops))
164 goto err0; 162 goto err0;
165 163
@@ -172,14 +170,14 @@ static __init int dccpprobe_init(void)
172err1: 170err1:
173 proc_net_remove(&init_net, procname); 171 proc_net_remove(&init_net, procname);
174err0: 172err0:
175 kfifo_free(dccpw.fifo); 173 kfifo_free(&dccpw.fifo);
176 return ret; 174 return ret;
177} 175}
178module_init(dccpprobe_init); 176module_init(dccpprobe_init);
179 177
180static __exit void dccpprobe_exit(void) 178static __exit void dccpprobe_exit(void)
181{ 179{
182 kfifo_free(dccpw.fifo); 180 kfifo_free(&dccpw.fifo);
183 proc_net_remove(&init_net, procname); 181 proc_net_remove(&init_net, procname);
184 unregister_jprobe(&dccp_send_probe); 182 unregister_jprobe(&dccp_send_probe);
185 183