blob: d9c003d9490b92744773d1fd0e6e924c95e28924 [file] [log] [blame]
Harald Welte9f240b62016-03-18 10:32:56 +01001#pragma once
2
Harald Welte9d90d282018-06-29 22:25:42 +02003#include <osmocom/core/linuxlist.h>
Harald Welte119624f2017-11-04 12:28:30 +01004#include "utils.h"
Harald Welte9f240b62016-03-18 10:32:56 +01005
Harald Welte9ac794c2017-05-07 11:19:45 +02006static inline void llist_add_irqsafe(struct llist_head *_new,
7 struct llist_head *head)
8{
Harald Welte119624f2017-11-04 12:28:30 +01009 unsigned long x;
10
11 local_irq_save(x);
Harald Welte9ac794c2017-05-07 11:19:45 +020012 llist_add(_new, head);
Harald Weltef2315412017-11-28 19:16:10 +010013 local_irq_restore(x);
Harald Welte9ac794c2017-05-07 11:19:45 +020014}
15
Harald Welte9f240b62016-03-18 10:32:56 +010016static inline void llist_add_tail_irqsafe(struct llist_head *_new,
17 struct llist_head *head)
18{
Harald Welte119624f2017-11-04 12:28:30 +010019 unsigned long x;
20
21 local_irq_save(x);
Harald Welte9f240b62016-03-18 10:32:56 +010022 llist_add_tail(_new, head);
23 __enable_irq();
24}
25
26static inline struct llist_head *llist_head_dequeue_irqsafe(struct llist_head *head)
27{
28 struct llist_head *lh;
Harald Welte119624f2017-11-04 12:28:30 +010029 unsigned long x;
Harald Welte9f240b62016-03-18 10:32:56 +010030
Harald Welte119624f2017-11-04 12:28:30 +010031 local_irq_save(x);
Harald Welte9f240b62016-03-18 10:32:56 +010032 if (llist_empty(head)) {
33 lh = NULL;
34 } else {
35 lh = head->next;
36 llist_del(lh);
37 }
Harald Welte119624f2017-11-04 12:28:30 +010038 local_irq_restore(x);
Harald Welte9f240b62016-03-18 10:32:56 +010039
40 return lh;
41}