Harald Welte | 9f240b6 | 2016-03-18 10:32:56 +0100 | [diff] [blame] | 1 | #pragma once |
2 | |||||
Harald Welte | 9d90d28 | 2018-06-29 22:25:42 +0200 | [diff] [blame] | 3 | #include <osmocom/core/linuxlist.h> |
Harald Welte | 119624f | 2017-11-04 12:28:30 +0100 | [diff] [blame] | 4 | #include "utils.h" |
Harald Welte | 9f240b6 | 2016-03-18 10:32:56 +0100 | [diff] [blame] | 5 | |
Harald Welte | 9ac794c | 2017-05-07 11:19:45 +0200 | [diff] [blame] | 6 | static inline void llist_add_irqsafe(struct llist_head *_new, |
7 | struct llist_head *head) | ||||
8 | { | ||||
Harald Welte | 119624f | 2017-11-04 12:28:30 +0100 | [diff] [blame] | 9 | unsigned long x; |
10 | |||||
11 | local_irq_save(x); | ||||
Harald Welte | 9ac794c | 2017-05-07 11:19:45 +0200 | [diff] [blame] | 12 | llist_add(_new, head); |
Harald Welte | f231541 | 2017-11-28 19:16:10 +0100 | [diff] [blame] | 13 | local_irq_restore(x); |
Harald Welte | 9ac794c | 2017-05-07 11:19:45 +0200 | [diff] [blame] | 14 | } |
15 | |||||
Harald Welte | 9f240b6 | 2016-03-18 10:32:56 +0100 | [diff] [blame] | 16 | static inline void llist_add_tail_irqsafe(struct llist_head *_new, |
17 | struct llist_head *head) | ||||
18 | { | ||||
Harald Welte | 119624f | 2017-11-04 12:28:30 +0100 | [diff] [blame] | 19 | unsigned long x; |
20 | |||||
21 | local_irq_save(x); | ||||
Harald Welte | 9f240b6 | 2016-03-18 10:32:56 +0100 | [diff] [blame] | 22 | llist_add_tail(_new, head); |
23 | __enable_irq(); | ||||
24 | } | ||||
25 | |||||
26 | static inline struct llist_head *llist_head_dequeue_irqsafe(struct llist_head *head) | ||||
27 | { | ||||
28 | struct llist_head *lh; | ||||
Harald Welte | 119624f | 2017-11-04 12:28:30 +0100 | [diff] [blame] | 29 | unsigned long x; |
Harald Welte | 9f240b6 | 2016-03-18 10:32:56 +0100 | [diff] [blame] | 30 | |
Harald Welte | 119624f | 2017-11-04 12:28:30 +0100 | [diff] [blame] | 31 | local_irq_save(x); |
Harald Welte | 9f240b6 | 2016-03-18 10:32:56 +0100 | [diff] [blame] | 32 | if (llist_empty(head)) { |
33 | lh = NULL; | ||||
34 | } else { | ||||
35 | lh = head->next; | ||||
36 | llist_del(lh); | ||||
37 | } | ||||
Harald Welte | 119624f | 2017-11-04 12:28:30 +0100 | [diff] [blame] | 38 | local_irq_restore(x); |
Harald Welte | 9f240b6 | 2016-03-18 10:32:56 +0100 | [diff] [blame] | 39 | |
40 | return lh; | ||||
41 | } |