History

notifier: Add atomic_notifier_call_chain_is_empty()

Add atomic_notifier_call_chain_is_empty() that returns true if given atomic call chain is empty. The first user of this new notifier API function will be the kernel power-off core code that will support power-off call chains. The core code will need to check whether there is a power-off handler registered at all in order to decide whether to halt machine or power it off.

Dmitry Osipenko committed 4 years ago

Commit 13dfd971 parent 42226c92 files · +15 −0Browse files

Unified · Split

2 files
  1. include/linux/notifier.h +2 −0
  2. kernel/notifier.c +13 −0
include/linux/notifier.h+2−0
@@ -173,6 +173,8 @@ extern int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh · 172 unmodified lines
173extern int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,173extern int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
174 unsigned long val_up, unsigned long val_down, void *v);174 unsigned long val_up, unsigned long val_down, void *v);
175 175
176extern bool atomic_notifier_call_chain_is_empty(struct atomic_notifier_head *nh);
177
176#define NOTIFY_DONE 0x0000 /* Don't care */178#define NOTIFY_DONE 0x0000 /* Don't care */
177#define NOTIFY_OK 0x0001 /* Suits me */179#define NOTIFY_OK 0x0001 /* Suits me */
178#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */180#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
kernel/notifier.c+13−0
@@ -204,6 +204,19 @@ int atomic_notifier_call_chain(struct atomic_notifier_head *nh, · 203 unmodified lines
204EXPORT_SYMBOL_GPL(atomic_notifier_call_chain);204EXPORT_SYMBOL_GPL(atomic_notifier_call_chain);
205NOKPROBE_SYMBOL(atomic_notifier_call_chain);205NOKPROBE_SYMBOL(atomic_notifier_call_chain);
206 206
207/**
208 * atomic_notifier_call_chain_is_empty - Check whether notifier chain is empty
209 * @nh: Pointer to head of the atomic notifier chain
210 *
211 * Checks whether notifier chain is empty.
212 *
213 * Returns true is notifier chain is empty, false otherwise.
214 */
215bool atomic_notifier_call_chain_is_empty(struct atomic_notifier_head *nh)
216{
217 return !rcu_access_pointer(nh->head);
218}
219
207/*220/*
208 * Blocking notifier chain routines. All access to the chain is221 * Blocking notifier chain routines. All access to the chain is
209 * synchronized by an rwsem.222 * synchronized by an rwsem.