18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  arch/arm/include/asm/thread_notify.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2006 Russell King.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef ASMARM_THREAD_NOTIFY_H
88c2ecf20Sopenharmony_ci#define ASMARM_THREAD_NOTIFY_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifdef __KERNEL__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/notifier.h>
158c2ecf20Sopenharmony_ci#include <asm/thread_info.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic inline int thread_register_notifier(struct notifier_block *n)
188c2ecf20Sopenharmony_ci{
198c2ecf20Sopenharmony_ci	extern struct atomic_notifier_head thread_notify_head;
208c2ecf20Sopenharmony_ci	return atomic_notifier_chain_register(&thread_notify_head, n);
218c2ecf20Sopenharmony_ci}
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic inline void thread_unregister_notifier(struct notifier_block *n)
248c2ecf20Sopenharmony_ci{
258c2ecf20Sopenharmony_ci	extern struct atomic_notifier_head thread_notify_head;
268c2ecf20Sopenharmony_ci	atomic_notifier_chain_unregister(&thread_notify_head, n);
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic inline void thread_notify(unsigned long rc, struct thread_info *thread)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	extern struct atomic_notifier_head thread_notify_head;
328c2ecf20Sopenharmony_ci	atomic_notifier_call_chain(&thread_notify_head, rc, thread);
338c2ecf20Sopenharmony_ci}
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#endif
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/*
388c2ecf20Sopenharmony_ci * These are the reason codes for the thread notifier.
398c2ecf20Sopenharmony_ci */
408c2ecf20Sopenharmony_ci#define THREAD_NOTIFY_FLUSH	0
418c2ecf20Sopenharmony_ci#define THREAD_NOTIFY_EXIT	1
428c2ecf20Sopenharmony_ci#define THREAD_NOTIFY_SWITCH	2
438c2ecf20Sopenharmony_ci#define THREAD_NOTIFY_COPY	3
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#endif
468c2ecf20Sopenharmony_ci#endif
47