irq_work: Cleanup

Get rid of the __call_single_node union and clean up the API a little
to avoid external code relying on the structure layout as much.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
This commit is contained in:
Peter Zijlstra
2020-06-15 11:51:29 +02:00
parent 23e6082a52
commit 7a9f50a058
9 changed files with 41 additions and 37 deletions

View File

@@ -14,28 +14,37 @@
*/
struct irq_work {
union {
struct __call_single_node node;
struct {
struct llist_node llnode;
atomic_t flags;
};
};
struct __call_single_node node;
void (*func)(struct irq_work *);
};
#define __IRQ_WORK_INIT(_func, _flags) (struct irq_work){ \
.node = { .u_flags = (_flags), }, \
.func = (_func), \
}
#define IRQ_WORK_INIT(_func) __IRQ_WORK_INIT(_func, 0)
#define IRQ_WORK_INIT_LAZY(_func) __IRQ_WORK_INIT(_func, IRQ_WORK_LAZY)
#define IRQ_WORK_INIT_HARD(_func) __IRQ_WORK_INIT(_func, IRQ_WORK_HARD_IRQ)
#define DEFINE_IRQ_WORK(name, _f) \
struct irq_work name = IRQ_WORK_INIT(_f)
static inline
void init_irq_work(struct irq_work *work, void (*func)(struct irq_work *))
{
atomic_set(&work->flags, 0);
work->func = func;
*work = IRQ_WORK_INIT(func);
}
#define DEFINE_IRQ_WORK(name, _f) struct irq_work name = { \
.flags = ATOMIC_INIT(0), \
.func = (_f) \
static inline bool irq_work_is_pending(struct irq_work *work)
{
return atomic_read(&work->node.a_flags) & IRQ_WORK_PENDING;
}
static inline bool irq_work_is_busy(struct irq_work *work)
{
return atomic_read(&work->node.a_flags) & IRQ_WORK_BUSY;
}
bool irq_work_queue(struct irq_work *work);
bool irq_work_queue_on(struct irq_work *work, int cpu);