aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kfifo.h
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2010-10-27 18:34:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 21:03:18 -0400
commit144ecf310eb52d9df607b9b7eeb096743e232a96 (patch)
tree2a444a3f618ec070f33b3024f7728db29f5ab7d4 /include/linux/kfifo.h
parent12aa4c64174cb0d915cd1c7b763847c0ffa8e92c (diff)
kfifo: fix kfifo_alloc() to return a signed int value
Add a new __kfifo_int_must_check_helper() helper function, which is needed for kfifo_alloc() to return the right signed integer value. The origin __kfifo_must_check_helper() helper was renamed into __kfifo_uint_must_check_helper() to show the sign which is expected and returned. (And revert the temporary disabling of __kfifo_must_check_helper()) Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kfifo.h')
-rw-r--r--include/linux/kfifo.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index c238ad2f82ea..10308c6a3d1c 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -171,8 +171,17 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
171 } 171 }
172 172
173 173
174/* __kfifo_must_check_helper() is temporarily disabled because it was faulty */ 174static inline unsigned int __must_check
175#define __kfifo_must_check_helper(x) (x) 175__kfifo_uint_must_check_helper(unsigned int val)
176{
177 return val;
178}
179
180static inline int __must_check
181__kfifo_int_must_check_helper(int val)
182{
183 return val;
184}
176 185
177/** 186/**
178 * kfifo_initialized - Check if the fifo is initialized 187 * kfifo_initialized - Check if the fifo is initialized
@@ -264,7 +273,7 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
264 * @fifo: address of the fifo to be used 273 * @fifo: address of the fifo to be used
265 */ 274 */
266#define kfifo_avail(fifo) \ 275#define kfifo_avail(fifo) \
267__kfifo_must_check_helper( \ 276__kfifo_uint_must_check_helper( \
268({ \ 277({ \
269 typeof((fifo) + 1) __tmpq = (fifo); \ 278 typeof((fifo) + 1) __tmpq = (fifo); \
270 const size_t __recsize = sizeof(*__tmpq->rectype); \ 279 const size_t __recsize = sizeof(*__tmpq->rectype); \
@@ -297,7 +306,7 @@ __kfifo_must_check_helper( \
297 * This function returns the size of the next fifo record in number of bytes. 306 * This function returns the size of the next fifo record in number of bytes.
298 */ 307 */
299#define kfifo_peek_len(fifo) \ 308#define kfifo_peek_len(fifo) \
300__kfifo_must_check_helper( \ 309__kfifo_uint_must_check_helper( \
301({ \ 310({ \
302 typeof((fifo) + 1) __tmp = (fifo); \ 311 typeof((fifo) + 1) __tmp = (fifo); \
303 const size_t __recsize = sizeof(*__tmp->rectype); \ 312 const size_t __recsize = sizeof(*__tmp->rectype); \
@@ -320,7 +329,7 @@ __kfifo_must_check_helper( \
320 * Return 0 if no error, otherwise an error code. 329 * Return 0 if no error, otherwise an error code.
321 */ 330 */
322#define kfifo_alloc(fifo, size, gfp_mask) \ 331#define kfifo_alloc(fifo, size, gfp_mask) \
323__kfifo_must_check_helper( \ 332__kfifo_int_must_check_helper( \
324({ \ 333({ \
325 typeof((fifo) + 1) __tmp = (fifo); \ 334 typeof((fifo) + 1) __tmp = (fifo); \
326 struct __kfifo *__kfifo = &__tmp->kfifo; \ 335 struct __kfifo *__kfifo = &__tmp->kfifo; \
@@ -416,7 +425,7 @@ __kfifo_must_check_helper( \
416 * writer, you don't need extra locking to use these macro. 425 * writer, you don't need extra locking to use these macro.
417 */ 426 */
418#define kfifo_get(fifo, val) \ 427#define kfifo_get(fifo, val) \
419__kfifo_must_check_helper( \ 428__kfifo_uint_must_check_helper( \
420({ \ 429({ \
421 typeof((fifo) + 1) __tmp = (fifo); \ 430 typeof((fifo) + 1) __tmp = (fifo); \
422 typeof((val) + 1) __val = (val); \ 431 typeof((val) + 1) __val = (val); \
@@ -457,7 +466,7 @@ __kfifo_must_check_helper( \
457 * writer, you don't need extra locking to use these macro. 466 * writer, you don't need extra locking to use these macro.
458 */ 467 */
459#define kfifo_peek(fifo, val) \ 468#define kfifo_peek(fifo, val) \
460__kfifo_must_check_helper( \ 469__kfifo_uint_must_check_helper( \
461({ \ 470({ \
462 typeof((fifo) + 1) __tmp = (fifo); \ 471 typeof((fifo) + 1) __tmp = (fifo); \
463 typeof((val) + 1) __val = (val); \ 472 typeof((val) + 1) __val = (val); \
@@ -549,7 +558,7 @@ __kfifo_must_check_helper( \
549 * writer, you don't need extra locking to use these macro. 558 * writer, you don't need extra locking to use these macro.
550 */ 559 */
551#define kfifo_out(fifo, buf, n) \ 560#define kfifo_out(fifo, buf, n) \
552__kfifo_must_check_helper( \ 561__kfifo_uint_must_check_helper( \
553({ \ 562({ \
554 typeof((fifo) + 1) __tmp = (fifo); \ 563 typeof((fifo) + 1) __tmp = (fifo); \
555 typeof((buf) + 1) __buf = (buf); \ 564 typeof((buf) + 1) __buf = (buf); \
@@ -577,7 +586,7 @@ __kfifo_must_check_helper( \
577 * copied. 586 * copied.
578 */ 587 */
579#define kfifo_out_spinlocked(fifo, buf, n, lock) \ 588#define kfifo_out_spinlocked(fifo, buf, n, lock) \
580__kfifo_must_check_helper( \ 589__kfifo_uint_must_check_helper( \
581({ \ 590({ \
582 unsigned long __flags; \ 591 unsigned long __flags; \
583 unsigned int __ret; \ 592 unsigned int __ret; \
@@ -606,7 +615,7 @@ __kfifo_must_check_helper( \
606 * writer, you don't need extra locking to use these macro. 615 * writer, you don't need extra locking to use these macro.
607 */ 616 */
608#define kfifo_from_user(fifo, from, len, copied) \ 617#define kfifo_from_user(fifo, from, len, copied) \
609__kfifo_must_check_helper( \ 618__kfifo_uint_must_check_helper( \
610({ \ 619({ \
611 typeof((fifo) + 1) __tmp = (fifo); \ 620 typeof((fifo) + 1) __tmp = (fifo); \
612 const void __user *__from = (from); \ 621 const void __user *__from = (from); \
@@ -634,7 +643,7 @@ __kfifo_must_check_helper( \
634 * writer, you don't need extra locking to use these macro. 643 * writer, you don't need extra locking to use these macro.
635 */ 644 */
636#define kfifo_to_user(fifo, to, len, copied) \ 645#define kfifo_to_user(fifo, to, len, copied) \
637__kfifo_must_check_helper( \ 646__kfifo_uint_must_check_helper( \
638({ \ 647({ \
639 typeof((fifo) + 1) __tmp = (fifo); \ 648 typeof((fifo) + 1) __tmp = (fifo); \
640 void __user *__to = (to); \ 649 void __user *__to = (to); \
@@ -761,7 +770,7 @@ __kfifo_must_check_helper( \
761 * writer, you don't need extra locking to use these macro. 770 * writer, you don't need extra locking to use these macro.
762 */ 771 */
763#define kfifo_out_peek(fifo, buf, n) \ 772#define kfifo_out_peek(fifo, buf, n) \
764__kfifo_must_check_helper( \ 773__kfifo_uint_must_check_helper( \
765({ \ 774({ \
766 typeof((fifo) + 1) __tmp = (fifo); \ 775 typeof((fifo) + 1) __tmp = (fifo); \
767 typeof((buf) + 1) __buf = (buf); \ 776 typeof((buf) + 1) __buf = (buf); \