#include #include #include #include struct once_work { struct work_struct work; struct static_key *key; }; static void once_deferred(struct work_struct *w) { struct once_work *work; work = container_of(w, struct once_work, work); BUG_ON(!static_key_enabled(work->key)); static_key_slow_dec(work->key); kfree(work); } static void once_disable_jump(struct static_key *key) { struct once_work *w; w = kmalloc(sizeof(*w), GFP_ATOMIC); if (!w) return; INIT_WORK(&w->work, once_deferred); w->key = key; schedule_work(&w->work); } static DEFINE_SPINLOCK(once_lock); bool __do_once_start(bool *done, unsigned long *flags) __acquires(once_lock) { spin_lock_irqsave(&once_lock, *flags); if (*done) { spin_unlock_irqrestore(&once_lock, *flags); /* Keep sparse happy by restoring an even lock count on * this lock. In case we return here, we don't call into * __do_once_done but return early in the DO_ONCE() macro. */ __acquire(once_lock); return false; } return true; } EXPORT_SYMBOL(__do_once_start); void __do_once_done(bool *done, struct static_key *once_key, unsigned long *flags) __releases(once_lock) { *done = true; spin_unlock_irqrestore(&once_lock, *flags); once_disable_jump(once_key); } EXPORT_SYMBOL(__do_once_done); op-back'>packet-loop-back net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeng <fgao@ikuai8.com>2017-01-20 21:40:43 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2017-02-02 14:30:19 +0100
commit10435c1192d06bdb0bac7666452d8219d7e7c477 (patch)
tree93b76419142fe17b1d162d062c663297a3e8a965 /include/dt-bindings/power/tegra186-powergate.h
parent1a28ad74ebd8f9d3c7eae0d781f72a6d30545e17 (diff)
netfilter: nf_tables: Eliminate duplicated code in nf_tables_table_enable()
If something fails in nf_tables_table_enable(), it unregisters the chains. But the rollback code is the same as nf_tables_table_disable() almostly, except there is one counter check. Now create one wrapper function to eliminate the duplicated codes. Signed-off-by: Feng <fgao@ikuai8.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/dt-bindings/power/tegra186-powergate.h')