mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
kernel.h is being used as a dump for all kinds of stuff for a long time. Here is the attempt to start cleaning it up by splitting out panic and oops helpers. There are several purposes of doing this: - dropping dependency in bug.h - dropping a loop by moving out panic_notifier.h - unload kernel.h from something which has its own domain At the same time convert users tree-wide to use new headers, although for the time being include new header back to kernel.h to avoid twisted indirected includes for existing users. [akpm@linux-foundation.org: thread_info.h needs limits.h] [andriy.shevchenko@linux.intel.com: ia64 fix] Link: https://lkml.kernel.org/r/20210520130557.55277-1-andriy.shevchenko@linux.intel.com Link: https://lkml.kernel.org/r/20210511074137.33666-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Co-developed-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Mike Rapoport <rppt@linux.ibm.com> Acked-by: Corey Minyard <cminyard@mvista.com> Acked-by: Christian Brauner <christian.brauner@ubuntu.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Kees Cook <keescook@chromium.org> Acked-by: Wei Liu <wei.liu@kernel.org> Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Sebastian Reichel <sre@kernel.org> Acked-by: Luis Chamberlain <mcgrof@kernel.org> Acked-by: Stephen Boyd <sboyd@kernel.org> Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Acked-by: Helge Deller <deller@gmx.de> # parisc Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
115 lines
2.3 KiB
C
115 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Pvpanic Device Support
|
|
*
|
|
* Copyright (C) 2013 Fujitsu.
|
|
* Copyright (C) 2018 ZTE.
|
|
* Copyright (C) 2021 Oracle.
|
|
*/
|
|
|
|
#include <linux/io.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kexec.h>
|
|
#include <linux/mod_devicetable.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/panic_notifier.h>
|
|
#include <linux/types.h>
|
|
#include <linux/cdev.h>
|
|
#include <linux/list.h>
|
|
|
|
#include <uapi/misc/pvpanic.h>
|
|
|
|
#include "pvpanic.h"
|
|
|
|
MODULE_AUTHOR("Mihai Carabas <mihai.carabas@oracle.com>");
|
|
MODULE_DESCRIPTION("pvpanic device driver ");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
static struct list_head pvpanic_list;
|
|
static spinlock_t pvpanic_lock;
|
|
|
|
static void
|
|
pvpanic_send_event(unsigned int event)
|
|
{
|
|
struct pvpanic_instance *pi_cur;
|
|
|
|
spin_lock(&pvpanic_lock);
|
|
list_for_each_entry(pi_cur, &pvpanic_list, list) {
|
|
if (event & pi_cur->capability & pi_cur->events)
|
|
iowrite8(event, pi_cur->base);
|
|
}
|
|
spin_unlock(&pvpanic_lock);
|
|
}
|
|
|
|
static int
|
|
pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
|
|
void *unused)
|
|
{
|
|
unsigned int event = PVPANIC_PANICKED;
|
|
|
|
if (kexec_crash_loaded())
|
|
event = PVPANIC_CRASH_LOADED;
|
|
|
|
pvpanic_send_event(event);
|
|
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
static struct notifier_block pvpanic_panic_nb = {
|
|
.notifier_call = pvpanic_panic_notify,
|
|
.priority = 1, /* let this called before broken drm_fb_helper */
|
|
};
|
|
|
|
int pvpanic_probe(struct pvpanic_instance *pi)
|
|
{
|
|
if (!pi || !pi->base)
|
|
return -EINVAL;
|
|
|
|
spin_lock(&pvpanic_lock);
|
|
list_add(&pi->list, &pvpanic_list);
|
|
spin_unlock(&pvpanic_lock);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(pvpanic_probe);
|
|
|
|
void pvpanic_remove(struct pvpanic_instance *pi)
|
|
{
|
|
struct pvpanic_instance *pi_cur, *pi_next;
|
|
|
|
if (!pi)
|
|
return;
|
|
|
|
spin_lock(&pvpanic_lock);
|
|
list_for_each_entry_safe(pi_cur, pi_next, &pvpanic_list, list) {
|
|
if (pi_cur == pi) {
|
|
list_del(&pi_cur->list);
|
|
break;
|
|
}
|
|
}
|
|
spin_unlock(&pvpanic_lock);
|
|
}
|
|
EXPORT_SYMBOL_GPL(pvpanic_remove);
|
|
|
|
static int pvpanic_init(void)
|
|
{
|
|
INIT_LIST_HEAD(&pvpanic_list);
|
|
spin_lock_init(&pvpanic_lock);
|
|
|
|
atomic_notifier_chain_register(&panic_notifier_list,
|
|
&pvpanic_panic_nb);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void pvpanic_exit(void)
|
|
{
|
|
atomic_notifier_chain_unregister(&panic_notifier_list,
|
|
&pvpanic_panic_nb);
|
|
|
|
}
|
|
|
|
module_init(pvpanic_init);
|
|
module_exit(pvpanic_exit);
|