diff options
author | Stefani Seibold <stefani@seibold.net> | 2009-12-21 17:37:27 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-22 17:17:56 -0500 |
commit | c1e13f25674ed564948ecb7dfe5f83e578892896 (patch) | |
tree | 24fac07b3e2b66dff01c3127b34077de1de4c101 /drivers | |
parent | 45465487897a1c6d508b14b904dc5777f7ec7e04 (diff) |
kfifo: move out spinlock
Move the pointer to the spinlock out of struct kfifo. Most users in
tree do not actually use a spinlock, so the few exceptions now have to
call kfifo_{get,put}_locked, which takes an extra argument to a
spinlock.
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/nozomi.c | 2 | ||||
-rw-r--r-- | drivers/char/sonypi.c | 21 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_resource.c | 36 | ||||
-rw-r--r-- | drivers/media/video/meye.c | 35 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/main.c | 2 | ||||
-rw-r--r-- | drivers/platform/x86/fujitsu-laptop.c | 18 | ||||
-rw-r--r-- | drivers/platform/x86/sony-laptop.c | 22 | ||||
-rw-r--r-- | drivers/scsi/libiscsi.c | 2 | ||||
-rw-r--r-- | drivers/scsi/libiscsi_tcp.c | 2 | ||||
-rw-r--r-- | drivers/scsi/libsrp.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/fhci.h | 2 | ||||
-rw-r--r-- | drivers/usb/serial/generic.c | 4 | ||||
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 3 |
13 files changed, 87 insertions, 71 deletions
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c index 0f39bec28b45..935b30d80adf 100644 --- a/drivers/char/nozomi.c +++ b/drivers/char/nozomi.c | |||
@@ -686,7 +686,7 @@ static int nozomi_read_config_table(struct nozomi *dc) | |||
686 | 686 | ||
687 | for (i = PORT_MDM; i < MAX_PORT; i++) { | 687 | for (i = PORT_MDM; i < MAX_PORT; i++) { |
688 | kfifo_alloc(&dc->port[i].fifo_ul, | 688 | kfifo_alloc(&dc->port[i].fifo_ul, |
689 | FIFO_BUFFER_SIZE_UL, GFP_ATOMIC, NULL); | 689 | FIFO_BUFFER_SIZE_UL, GFP_ATOMIC); |
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 | } |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 9e6efb1f029f..dbcb3bd192c7 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -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_get_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_put_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_put_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 | ||
@@ -929,7 +932,8 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf, | |||
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_get_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++; |
@@ -1313,8 +1317,7 @@ 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 | error = kfifo_alloc(&sonypi_device.fifo, SONYPI_BUF_SIZE, GFP_KERNEL, | 1320 | error = kfifo_alloc(&sonypi_device.fifo, SONYPI_BUF_SIZE, GFP_KERNEL); |
1317 | &sonypi_device.fifo_lock); | ||
1318 | if (error) { | 1321 | if (error) { |
1319 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); | 1322 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); |
1320 | return error; | 1323 | return error; |
@@ -1394,7 +1397,7 @@ static int __devinit sonypi_probe(struct platform_device *dev) | |||
1394 | 1397 | ||
1395 | spin_lock_init(&sonypi_device.input_fifo_lock); | 1398 | spin_lock_init(&sonypi_device.input_fifo_lock); |
1396 | error = kfifo_alloc(&sonypi_device.input_fifo, SONYPI_BUF_SIZE, | 1399 | error = kfifo_alloc(&sonypi_device.input_fifo, SONYPI_BUF_SIZE, |
1397 | GFP_KERNEL, &sonypi_device.input_fifo_lock); | 1400 | GFP_KERNEL); |
1398 | if (error) { | 1401 | if (error) { |
1399 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); | 1402 | printk(KERN_ERR "sonypi: kfifo_alloc failed\n"); |
1400 | goto err_inpdev_unregister; | 1403 | goto err_inpdev_unregister; |
diff --git a/drivers/infiniband/hw/cxgb3/cxio_resource.c b/drivers/infiniband/hw/cxgb3/cxio_resource.c index 65072bdfc1bf..98f24e6d906e 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_resource.c +++ b/drivers/infiniband/hw/cxgb3/cxio_resource.c | |||
@@ -55,7 +55,7 @@ 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 | if (kfifo_alloc(fifo, nr * sizeof(u32), GFP_KERNEL, fifo_lock)) | 58 | if (kfifo_alloc(fifo, nr * sizeof(u32), GFP_KERNEL)) |
59 | return -ENOMEM; | 59 | return -ENOMEM; |
60 | 60 | ||
61 | for (i = 0; i < skip_low + skip_high; i++) | 61 | for (i = 0; i < skip_low + skip_high; i++) |
@@ -86,7 +86,8 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo, | |||
86 | __kfifo_put(fifo, (unsigned char *) &i, sizeof(u32)); | 86 | __kfifo_put(fifo, (unsigned char *) &i, sizeof(u32)); |
87 | 87 | ||
88 | for (i = 0; i < skip_low + skip_high; i++) | 88 | for (i = 0; i < skip_low + skip_high; i++) |
89 | kfifo_get(fifo, (unsigned char *) &entry, sizeof(u32)); | 89 | kfifo_get_locked(fifo, (unsigned char *) &entry, |
90 | sizeof(u32), fifo_lock); | ||
90 | return 0; | 91 | return 0; |
91 | } | 92 | } |
92 | 93 | ||
@@ -113,8 +114,7 @@ static int cxio_init_qpid_fifo(struct cxio_rdev *rdev_p) | |||
113 | spin_lock_init(&rdev_p->rscp->qpid_fifo_lock); | 114 | spin_lock_init(&rdev_p->rscp->qpid_fifo_lock); |
114 | 115 | ||
115 | if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, T3_MAX_NUM_QP * sizeof(u32), | 116 | if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, T3_MAX_NUM_QP * sizeof(u32), |
116 | GFP_KERNEL, | 117 | GFP_KERNEL)) |
117 | &rdev_p->rscp->qpid_fifo_lock)) | ||
118 | return -ENOMEM; | 118 | return -ENOMEM; |
119 | 119 | ||
120 | for (i = 16; i < T3_MAX_NUM_QP; i++) | 120 | for (i = 16; i < T3_MAX_NUM_QP; i++) |
@@ -177,33 +177,37 @@ tpt_err: | |||
177 | /* | 177 | /* |
178 | * returns 0 if no resource available | 178 | * returns 0 if no resource available |
179 | */ | 179 | */ |
180 | static u32 cxio_hal_get_resource(struct kfifo *fifo) | 180 | static u32 cxio_hal_get_resource(struct kfifo *fifo, spinlock_t * lock) |
181 | { | 181 | { |
182 | u32 entry; | 182 | u32 entry; |
183 | if (kfifo_get(fifo, (unsigned char *) &entry, sizeof(u32))) | 183 | if (kfifo_get_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock)) |
184 | return entry; | 184 | return entry; |
185 | else | 185 | else |
186 | return 0; /* fifo emptry */ | 186 | return 0; /* fifo emptry */ |
187 | } | 187 | } |
188 | 188 | ||
189 | static void cxio_hal_put_resource(struct kfifo *fifo, u32 entry) | 189 | static void cxio_hal_put_resource(struct kfifo *fifo, spinlock_t * lock, |
190 | u32 entry) | ||
190 | { | 191 | { |
191 | BUG_ON(kfifo_put(fifo, (unsigned char *) &entry, sizeof(u32)) == 0); | 192 | BUG_ON( |
193 | kfifo_put_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock) | ||
194 | == 0); | ||
192 | } | 195 | } |
193 | 196 | ||
194 | u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp) | 197 | u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp) |
195 | { | 198 | { |
196 | return cxio_hal_get_resource(&rscp->tpt_fifo); | 199 | return cxio_hal_get_resource(&rscp->tpt_fifo, &rscp->tpt_fifo_lock); |
197 | } | 200 | } |
198 | 201 | ||
199 | void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag) | 202 | void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag) |
200 | { | 203 | { |
201 | cxio_hal_put_resource(&rscp->tpt_fifo, stag); | 204 | cxio_hal_put_resource(&rscp->tpt_fifo, &rscp->tpt_fifo_lock, stag); |
202 | } | 205 | } |
203 | 206 | ||
204 | u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp) | 207 | u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp) |
205 | { | 208 | { |
206 | u32 qpid = cxio_hal_get_resource(&rscp->qpid_fifo); | 209 | u32 qpid = cxio_hal_get_resource(&rscp->qpid_fifo, |
210 | &rscp->qpid_fifo_lock); | ||
207 | PDBG("%s qpid 0x%x\n", __func__, qpid); | 211 | PDBG("%s qpid 0x%x\n", __func__, qpid); |
208 | return qpid; | 212 | return qpid; |
209 | } | 213 | } |
@@ -211,27 +215,27 @@ u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp) | |||
211 | void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid) | 215 | void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid) |
212 | { | 216 | { |
213 | PDBG("%s qpid 0x%x\n", __func__, qpid); | 217 | PDBG("%s qpid 0x%x\n", __func__, qpid); |
214 | cxio_hal_put_resource(&rscp->qpid_fifo, qpid); | 218 | cxio_hal_put_resource(&rscp->qpid_fifo, &rscp->qpid_fifo_lock, qpid); |
215 | } | 219 | } |
216 | 220 | ||
217 | u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp) | 221 | u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp) |
218 | { | 222 | { |
219 | return cxio_hal_get_resource(&rscp->cqid_fifo); | 223 | return cxio_hal_get_resource(&rscp->cqid_fifo, &rscp->cqid_fifo_lock); |
220 | } | 224 | } |
221 | 225 | ||
222 | void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid) | 226 | void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid) |
223 | { | 227 | { |
224 | cxio_hal_put_resource(&rscp->cqid_fifo, cqid); | 228 | cxio_hal_put_resource(&rscp->cqid_fifo, &rscp->cqid_fifo_lock, cqid); |
225 | } | 229 | } |
226 | 230 | ||
227 | u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp) | 231 | u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp) |
228 | { | 232 | { |
229 | return cxio_hal_get_resource(&rscp->pdid_fifo); | 233 | return cxio_hal_get_resource(&rscp->pdid_fifo, &rscp->pdid_fifo_lock); |
230 | } | 234 | } |
231 | 235 | ||
232 | void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid) | 236 | void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid) |
233 | { | 237 | { |
234 | cxio_hal_put_resource(&rscp->pdid_fifo, pdid); | 238 | cxio_hal_put_resource(&rscp->pdid_fifo, &rscp->pdid_fifo_lock, pdid); |
235 | } | 239 | } |
236 | 240 | ||
237 | void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp) | 241 | void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp) |
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index dacbbb839b9e..38bcedfd9fec 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c | |||
@@ -800,8 +800,8 @@ 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_locked(&meye.grabq, (unsigned char *)&reqnr, |
804 | sizeof(int)) != sizeof(int)) { | 804 | sizeof(int), &meye.grabq_lock) != sizeof(int)) { |
805 | mchip_free_frame(); | 805 | mchip_free_frame(); |
806 | return IRQ_HANDLED; | 806 | return IRQ_HANDLED; |
807 | } | 807 | } |
@@ -811,7 +811,8 @@ 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_locked(&meye.doneq, (unsigned char *)&reqnr, |
815 | sizeof(int), &meye.doneq_lock); | ||
815 | wake_up_interruptible(&meye.proc_list); | 816 | wake_up_interruptible(&meye.proc_list); |
816 | } else { | 817 | } else { |
817 | int size; | 818 | int size; |
@@ -820,8 +821,8 @@ again: | |||
820 | mchip_free_frame(); | 821 | mchip_free_frame(); |
821 | goto again; | 822 | goto again; |
822 | } | 823 | } |
823 | if (kfifo_get(&meye.grabq, (unsigned char *)&reqnr, | 824 | if (kfifo_get_locked(&meye.grabq, (unsigned char *)&reqnr, |
824 | sizeof(int)) != sizeof(int)) { | 825 | sizeof(int), &meye.grabq_lock) != sizeof(int)) { |
825 | mchip_free_frame(); | 826 | mchip_free_frame(); |
826 | goto again; | 827 | goto again; |
827 | } | 828 | } |
@@ -831,7 +832,8 @@ again: | |||
831 | meye.grab_buffer[reqnr].state = MEYE_BUF_DONE; | 832 | meye.grab_buffer[reqnr].state = MEYE_BUF_DONE; |
832 | do_gettimeofday(&meye.grab_buffer[reqnr].timestamp); | 833 | do_gettimeofday(&meye.grab_buffer[reqnr].timestamp); |
833 | meye.grab_buffer[reqnr].sequence = sequence++; | 834 | meye.grab_buffer[reqnr].sequence = sequence++; |
834 | kfifo_put(&meye.doneq, (unsigned char *)&reqnr, sizeof(int)); | 835 | kfifo_put_locked(&meye.doneq, (unsigned char *)&reqnr, |
836 | sizeof(int), &meye.doneq_lock); | ||
835 | wake_up_interruptible(&meye.proc_list); | 837 | wake_up_interruptible(&meye.proc_list); |
836 | } | 838 | } |
837 | mchip_free_frame(); | 839 | mchip_free_frame(); |
@@ -933,7 +935,8 @@ static int meyeioc_qbuf_capt(int *nb) | |||
933 | mchip_cont_compression_start(); | 935 | mchip_cont_compression_start(); |
934 | 936 | ||
935 | meye.grab_buffer[*nb].state = MEYE_BUF_USING; | 937 | meye.grab_buffer[*nb].state = MEYE_BUF_USING; |
936 | kfifo_put(&meye.grabq, (unsigned char *)nb, sizeof(int)); | 938 | kfifo_put_locked(&meye.grabq, (unsigned char *)nb, sizeof(int), |
939 | &meye.grabq_lock); | ||
937 | mutex_unlock(&meye.lock); | 940 | mutex_unlock(&meye.lock); |
938 | 941 | ||
939 | return 0; | 942 | return 0; |
@@ -965,7 +968,8 @@ static int meyeioc_sync(struct file *file, void *fh, int *i) | |||
965 | /* fall through */ | 968 | /* fall through */ |
966 | case MEYE_BUF_DONE: | 969 | case MEYE_BUF_DONE: |
967 | meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; | 970 | meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; |
968 | kfifo_get(&meye.doneq, (unsigned char *)&unused, sizeof(int)); | 971 | kfifo_get_locked(&meye.doneq, (unsigned char *)&unused, |
972 | sizeof(int), &meye.doneq_lock); | ||
969 | } | 973 | } |
970 | *i = meye.grab_buffer[*i].size; | 974 | *i = meye.grab_buffer[*i].size; |
971 | mutex_unlock(&meye.lock); | 975 | mutex_unlock(&meye.lock); |
@@ -1452,7 +1456,8 @@ static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | |||
1452 | buf->flags |= V4L2_BUF_FLAG_QUEUED; | 1456 | buf->flags |= V4L2_BUF_FLAG_QUEUED; |
1453 | buf->flags &= ~V4L2_BUF_FLAG_DONE; | 1457 | buf->flags &= ~V4L2_BUF_FLAG_DONE; |
1454 | meye.grab_buffer[buf->index].state = MEYE_BUF_USING; | 1458 | meye.grab_buffer[buf->index].state = MEYE_BUF_USING; |
1455 | kfifo_put(&meye.grabq, (unsigned char *)&buf->index, sizeof(int)); | 1459 | kfifo_put_locked(&meye.grabq, (unsigned char *)&buf->index, |
1460 | sizeof(int), &meye.grabq_lock); | ||
1456 | mutex_unlock(&meye.lock); | 1461 | mutex_unlock(&meye.lock); |
1457 | 1462 | ||
1458 | return 0; | 1463 | return 0; |
@@ -1478,8 +1483,8 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | |||
1478 | return -EINTR; | 1483 | return -EINTR; |
1479 | } | 1484 | } |
1480 | 1485 | ||
1481 | if (!kfifo_get(&meye.doneq, (unsigned char *)&reqnr, | 1486 | if (!kfifo_get_locked(&meye.doneq, (unsigned char *)&reqnr, |
1482 | sizeof(int))) { | 1487 | sizeof(int), &meye.doneq_lock)) { |
1483 | mutex_unlock(&meye.lock); | 1488 | mutex_unlock(&meye.lock); |
1484 | return -EBUSY; | 1489 | return -EBUSY; |
1485 | } | 1490 | } |
@@ -1745,14 +1750,14 @@ static int __devinit meye_probe(struct pci_dev *pcidev, | |||
1745 | } | 1750 | } |
1746 | 1751 | ||
1747 | spin_lock_init(&meye.grabq_lock); | 1752 | spin_lock_init(&meye.grabq_lock); |
1748 | if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL, | 1753 | if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS, |
1749 | &meye.grabq_lock)) { | 1754 | GFP_KERNEL)) { |
1750 | printk(KERN_ERR "meye: fifo allocation failed\n"); | 1755 | printk(KERN_ERR "meye: fifo allocation failed\n"); |
1751 | goto outkfifoalloc1; | 1756 | goto outkfifoalloc1; |
1752 | } | 1757 | } |
1753 | spin_lock_init(&meye.doneq_lock); | 1758 | spin_lock_init(&meye.doneq_lock); |
1754 | if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL, | 1759 | if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS, |
1755 | &meye.doneq_lock)) { | 1760 | GFP_KERNEL)) { |
1756 | printk(KERN_ERR "meye: fifo allocation failed\n"); | 1761 | printk(KERN_ERR "meye: fifo allocation failed\n"); |
1757 | goto outkfifoalloc2; | 1762 | goto outkfifoalloc2; |
1758 | } | 1763 | } |
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index 403909287414..2cc7ecd8d123 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -883,7 +883,7 @@ 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 | ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL, NULL); | 886 | ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL); |
887 | if (ret) { | 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 | goto out; | 889 | goto out; |
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index f999fba0e25e..13dc7bedcfce 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c | |||
@@ -825,7 +825,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) | |||
825 | /* kfifo */ | 825 | /* kfifo */ |
826 | spin_lock_init(&fujitsu_hotkey->fifo_lock); | 826 | spin_lock_init(&fujitsu_hotkey->fifo_lock); |
827 | error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int), | 827 | error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int), |
828 | GFP_KERNEL, &fujitsu_hotkey->fifo_lock); | 828 | GFP_KERNEL); |
829 | if (error) { | 829 | if (error) { |
830 | printk(KERN_ERR "kfifo_alloc failed\n"); | 830 | printk(KERN_ERR "kfifo_alloc failed\n"); |
831 | goto err_stop; | 831 | goto err_stop; |
@@ -1006,9 +1006,10 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) | |||
1006 | vdbg_printk(FUJLAPTOP_DBG_TRACE, | 1006 | vdbg_printk(FUJLAPTOP_DBG_TRACE, |
1007 | "Push keycode into ringbuffer [%d]\n", | 1007 | "Push keycode into ringbuffer [%d]\n", |
1008 | keycode); | 1008 | keycode); |
1009 | status = kfifo_put(&fujitsu_hotkey->fifo, | 1009 | status = kfifo_put_locked(&fujitsu_hotkey->fifo, |
1010 | (unsigned char *)&keycode, | 1010 | (unsigned char *)&keycode, |
1011 | sizeof(keycode)); | 1011 | sizeof(keycode), |
1012 | &fujitsu_hotkey->fifo_lock); | ||
1012 | if (status != sizeof(keycode)) { | 1013 | if (status != sizeof(keycode)) { |
1013 | vdbg_printk(FUJLAPTOP_DBG_WARN, | 1014 | vdbg_printk(FUJLAPTOP_DBG_WARN, |
1014 | "Could not push keycode [0x%x]\n", | 1015 | "Could not push keycode [0x%x]\n", |
@@ -1019,11 +1020,12 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) | |||
1019 | } | 1020 | } |
1020 | } else if (keycode == 0) { | 1021 | } else if (keycode == 0) { |
1021 | while ((status = | 1022 | while ((status = |
1022 | kfifo_get | 1023 | kfifo_get_locked( |
1023 | (&fujitsu_hotkey->fifo, (unsigned char *) | 1024 | &fujitsu_hotkey->fifo, |
1024 | &keycode_r, | 1025 | (unsigned char *) &keycode_r, |
1025 | sizeof | 1026 | sizeof(keycode_r), |
1026 | (keycode_r))) == sizeof(keycode_r)) { | 1027 | &fujitsu_hotkey->fifo_lock)) |
1028 | == sizeof(keycode_r)) { | ||
1027 | input_report_key(input, keycode_r, 0); | 1029 | input_report_key(input, keycode_r, 0); |
1028 | input_sync(input); | 1030 | input_sync(input); |
1029 | vdbg_printk(FUJLAPTOP_DBG_TRACE, | 1031 | vdbg_printk(FUJLAPTOP_DBG_TRACE, |
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 04625a048e74..1538a0a3c0af 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c | |||
@@ -300,8 +300,9 @@ 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_locked(&sony_laptop_input.fifo, (unsigned char *)&kp, |
304 | sizeof(kp)) == sizeof(kp)) { | 304 | sizeof(kp), &sony_laptop_input.fifo_lock) |
305 | == sizeof(kp)) { | ||
305 | msleep(10); | 306 | msleep(10); |
306 | input_report_key(kp.dev, kp.key, 0); | 307 | input_report_key(kp.dev, kp.key, 0); |
307 | input_sync(kp.dev); | 308 | input_sync(kp.dev); |
@@ -362,8 +363,9 @@ static void sony_laptop_report_input_event(u8 event) | |||
362 | /* we emit the scancode so we can always remap the key */ | 363 | /* we emit the scancode so we can always remap the key */ |
363 | input_event(kp.dev, EV_MSC, MSC_SCAN, event); | 364 | input_event(kp.dev, EV_MSC, MSC_SCAN, event); |
364 | input_sync(kp.dev); | 365 | input_sync(kp.dev); |
365 | kfifo_put(&sony_laptop_input.fifo, | 366 | kfifo_put_locked(&sony_laptop_input.fifo, |
366 | (unsigned char *)&kp, sizeof(kp)); | 367 | (unsigned char *)&kp, sizeof(kp), |
368 | &sony_laptop_input.fifo_lock); | ||
367 | 369 | ||
368 | if (!work_pending(&sony_laptop_release_key_work)) | 370 | if (!work_pending(&sony_laptop_release_key_work)) |
369 | queue_work(sony_laptop_input.wq, | 371 | queue_work(sony_laptop_input.wq, |
@@ -386,8 +388,7 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) | |||
386 | /* kfifo */ | 388 | /* kfifo */ |
387 | spin_lock_init(&sony_laptop_input.fifo_lock); | 389 | spin_lock_init(&sony_laptop_input.fifo_lock); |
388 | error = | 390 | error = |
389 | kfifo_alloc(&sony_laptop_input.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL, | 391 | kfifo_alloc(&sony_laptop_input.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL); |
390 | &sony_laptop_input.fifo_lock); | ||
391 | if (error) { | 392 | if (error) { |
392 | printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); | 393 | printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); |
393 | goto err_dec_users; | 394 | goto err_dec_users; |
@@ -2129,7 +2130,8 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf, | |||
2129 | return ret; | 2130 | return ret; |
2130 | 2131 | ||
2131 | while (ret < count && | 2132 | while (ret < count && |
2132 | (kfifo_get(&sonypi_compat.fifo, &c, sizeof(c)) == sizeof(c))) { | 2133 | (kfifo_get_locked(&sonypi_compat.fifo, &c, sizeof(c), |
2134 | &sonypi_compat.fifo_lock) == sizeof(c))) { | ||
2133 | if (put_user(c, buf++)) | 2135 | if (put_user(c, buf++)) |
2134 | return -EFAULT; | 2136 | return -EFAULT; |
2135 | ret++; | 2137 | ret++; |
@@ -2308,7 +2310,8 @@ static struct miscdevice sonypi_misc_device = { | |||
2308 | 2310 | ||
2309 | static void sonypi_compat_report_event(u8 event) | 2311 | static void sonypi_compat_report_event(u8 event) |
2310 | { | 2312 | { |
2311 | kfifo_put(&sonypi_compat.fifo, (unsigned char *)&event, sizeof(event)); | 2313 | kfifo_put_locked(&sonypi_compat.fifo, (unsigned char *)&event, |
2314 | sizeof(event), &sonypi_compat.fifo_lock); | ||
2312 | kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN); | 2315 | kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN); |
2313 | wake_up_interruptible(&sonypi_compat.fifo_proc_list); | 2316 | wake_up_interruptible(&sonypi_compat.fifo_proc_list); |
2314 | } | 2317 | } |
@@ -2319,8 +2322,7 @@ static int sonypi_compat_init(void) | |||
2319 | 2322 | ||
2320 | spin_lock_init(&sonypi_compat.fifo_lock); | 2323 | spin_lock_init(&sonypi_compat.fifo_lock); |
2321 | error = | 2324 | error = |
2322 | kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL, | 2325 | kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL); |
2323 | &sonypi_compat.fifo_lock); | ||
2324 | if (error) { | 2326 | if (error) { |
2325 | printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); | 2327 | printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); |
2326 | return error; | 2328 | return error; |
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index cf0aa7e90be9..1bccbc1e588e 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -2461,7 +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 | kfifo_init(&q->queue, (void*)q->pool, max * sizeof(void*), NULL); | 2464 | kfifo_init(&q->queue, (void*)q->pool, max * sizeof(void*)); |
2465 | 2465 | ||
2466 | for (i = 0; i < max; i++) { | 2466 | for (i = 0; i < max; i++) { |
2467 | q->pool[i] = kzalloc(item_size, GFP_KERNEL); | 2467 | q->pool[i] = kzalloc(item_size, GFP_KERNEL); |
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index a83ee56a185e..41643c860d26 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c | |||
@@ -1128,7 +1128,7 @@ int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session) | |||
1128 | 1128 | ||
1129 | /* R2T xmit queue */ | 1129 | /* R2T xmit queue */ |
1130 | if (kfifo_alloc(&tcp_task->r2tqueue, | 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)) { |
1132 | iscsi_pool_free(&tcp_task->r2tpool); | 1132 | iscsi_pool_free(&tcp_task->r2tpool); |
1133 | goto r2t_alloc_fail; | 1133 | goto r2t_alloc_fail; |
1134 | } | 1134 | } |
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c index b1b5e51ca8e3..db1b41c55fd3 100644 --- a/drivers/scsi/libsrp.c +++ b/drivers/scsi/libsrp.c | |||
@@ -58,8 +58,7 @@ 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 | kfifo_init(&q->queue, (void *) q->pool, max * sizeof(void *), | 61 | kfifo_init(&q->queue, (void *) q->pool, max * sizeof(void *)); |
62 | &q->lock); | ||
63 | 62 | ||
64 | for (i = 0, iue = q->items; i < max; i++) { | 63 | for (i = 0, iue = q->items; i < max; i++) { |
65 | __kfifo_put(&q->queue, (void *) &iue, sizeof(void *)); | 64 | __kfifo_put(&q->queue, (void *) &iue, sizeof(void *)); |
@@ -164,7 +163,8 @@ struct iu_entry *srp_iu_get(struct srp_target *target) | |||
164 | { | 163 | { |
165 | struct iu_entry *iue = NULL; | 164 | struct iu_entry *iue = NULL; |
166 | 165 | ||
167 | kfifo_get(&target->iu_queue.queue, (void *) &iue, sizeof(void *)); | 166 | kfifo_get_locked(&target->iu_queue.queue, (void *) &iue, |
167 | sizeof(void *), &target->iu_queue.lock); | ||
168 | if (!iue) | 168 | if (!iue) |
169 | return iue; | 169 | return iue; |
170 | iue->target = target; | 170 | iue->target = target; |
@@ -176,7 +176,8 @@ EXPORT_SYMBOL_GPL(srp_iu_get); | |||
176 | 176 | ||
177 | void srp_iu_put(struct iu_entry *iue) | 177 | void srp_iu_put(struct iu_entry *iue) |
178 | { | 178 | { |
179 | kfifo_put(&iue->target->iu_queue.queue, (void *) &iue, sizeof(void *)); | 179 | kfifo_put_locked(&iue->target->iu_queue.queue, (void *) &iue, |
180 | sizeof(void *), &iue->target->iu_queue.lock); | ||
180 | } | 181 | } |
181 | EXPORT_SYMBOL_GPL(srp_iu_put); | 182 | EXPORT_SYMBOL_GPL(srp_iu_put); |
182 | 183 | ||
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h index 2277428ef5d3..a76da201183b 100644 --- a/drivers/usb/host/fhci.h +++ b/drivers/usb/host/fhci.h | |||
@@ -495,7 +495,7 @@ static inline struct usb_hcd *fhci_to_hcd(struct fhci_hcd *fhci) | |||
495 | /* fifo of pointers */ | 495 | /* fifo of pointers */ |
496 | static inline int cq_new(struct kfifo *fifo, int size) | 496 | static inline int cq_new(struct kfifo *fifo, int size) |
497 | { | 497 | { |
498 | return kfifo_alloc(fifo, size * sizeof(void *), GFP_KERNEL, NULL); | 498 | return kfifo_alloc(fifo, size * sizeof(void *), GFP_KERNEL); |
499 | } | 499 | } |
500 | 500 | ||
501 | static inline void cq_delete(struct kfifo *kfifo) | 501 | static inline void cq_delete(struct kfifo *kfifo) |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index bbe005cefcfb..61eef18218be 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -285,7 +285,7 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port) | |||
285 | return 0; | 285 | return 0; |
286 | 286 | ||
287 | data = port->write_urb->transfer_buffer; | 287 | data = port->write_urb->transfer_buffer; |
288 | count = kfifo_get(port->write_fifo, data, port->bulk_out_size); | 288 | count = kfifo_get_locked(port->write_fifo, data, port->bulk_out_size, &port->lock); |
289 | usb_serial_debug_data(debug, &port->dev, __func__, count, data); | 289 | usb_serial_debug_data(debug, &port->dev, __func__, count, data); |
290 | 290 | ||
291 | /* set up our urb */ | 291 | /* set up our urb */ |
@@ -345,7 +345,7 @@ int usb_serial_generic_write(struct tty_struct *tty, | |||
345 | return usb_serial_multi_urb_write(tty, port, | 345 | return usb_serial_multi_urb_write(tty, port, |
346 | buf, count); | 346 | buf, count); |
347 | 347 | ||
348 | count = kfifo_put(port->write_fifo, buf, count); | 348 | count = kfifo_put_locked(port->write_fifo, buf, count, &port->lock); |
349 | result = usb_serial_generic_write_start(port); | 349 | result = usb_serial_generic_write_start(port); |
350 | 350 | ||
351 | if (result >= 0) | 351 | if (result >= 0) |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 44b72d47fac2..636a4f23445e 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -939,8 +939,7 @@ 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 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL, | 942 | if (kfifo_alloc(port->write_fifo, PAGE_SIZE, GFP_KERNEL)) |
943 | &port->lock)) | ||
944 | goto probe_error; | 943 | goto probe_error; |
945 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | 944 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); |
946 | port->bulk_out_size = buffer_size; | 945 | port->bulk_out_size = buffer_size; |