History

kfifo: provide noirqsave variants of spinlocked in and out helpers

Provide variants of spinlocked kfifo_in() and kfifo_out() routines which don't disable interrupts.

Bartosz Golaszewski committed 6 years ago

Commit 3f2e4c11 parent 47203191 file · +42 −0Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/kfifo.h+42−0
@@ -517,6 +517,26 @@ __kfifo_uint_must_check_helper( \ · 516 unmodified lines
517517 __ret; \
518518 })
519519
520+/**
521+ * kfifo_in_spinlocked_noirqsave - put data into fifo using a spinlock for
522+ * locking, don't disable interrupts
523+ * @fifo: address of the fifo to be used
524+ * @buf: the data to be added
525+ * @n: number of elements to be added
526+ * @lock: pointer to the spinlock to use for locking
527+ *
528+ * This is a variant of kfifo_in_spinlocked() but uses spin_lock/unlock()
529+ * for locking and doesn't disable interrupts.
530+ */
531+#define kfifo_in_spinlocked_noirqsave(fifo, buf, n, lock) \
532+({ \
533+ unsigned int __ret; \
534+ spin_lock(lock); \
535+ __ret = kfifo_in(fifo, buf, n); \
536+ spin_unlock(lock); \
537+ __ret; \
538+})
539+
520540 /* alias for kfifo_in_spinlocked, will be removed in a future release */
521541 #define kfifo_in_locked(fifo, buf, n, lock) \
522542 kfifo_in_spinlocked(fifo, buf, n, lock)
@@ -569,6 +589,28 @@ __kfifo_uint_must_check_helper( \ · 46 unmodified lines
569589 }) \
570590 )
571591
592+/**
593+ * kfifo_out_spinlocked_noirqsave - get data from the fifo using a spinlock
594+ * for locking, don't disable interrupts
595+ * @fifo: address of the fifo to be used
596+ * @buf: pointer to the storage buffer
597+ * @n: max. number of elements to get
598+ * @lock: pointer to the spinlock to use for locking
599+ *
600+ * This is a variant of kfifo_out_spinlocked() which uses spin_lock/unlock()
601+ * for locking and doesn't disable interrupts.
602+ */
603+#define kfifo_out_spinlocked_noirqsave(fifo, buf, n, lock) \
604+__kfifo_uint_must_check_helper( \
605+({ \
606+ unsigned int __ret; \
607+ spin_lock(lock); \
608+ __ret = kfifo_out(fifo, buf, n); \
609+ spin_unlock(lock); \
610+ __ret; \
611+}) \
612+)
613+
572614 /* alias for kfifo_out_spinlocked, will be removed in a future release */
573615 #define kfifo_out_locked(fifo, buf, n, lock) \
574616 kfifo_out_spinlocked(fifo, buf, n, lock)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t