Files
laptops-kernel/drivers/edac/edac_module.c
T

168 lines
3.3 KiB
C
Raw Normal View History

/*
* edac_module.c
*
2007-07-19 01:50:30 -07:00
* (C) 2007 www.softwarebitmaker.com
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*
2007-07-19 01:50:30 -07:00
* Author: Doug Thompson <dougthompson@xmission.com>
*
*/
2007-07-19 01:49:46 -07:00
#include <linux/edac.h>
2016-10-29 15:16:34 -02:00
#include "edac_mc.h"
#include "edac_module.h"
2012-05-10 12:43:01 -03:00
#define EDAC_VERSION "Ver: 3.0.0"
#ifdef CONFIG_EDAC_DEBUG
2012-09-10 16:50:54 +02:00
static int edac_set_debug_level(const char *buf,
const struct kernel_param *kp)
2012-09-10 16:50:54 +02:00
{
unsigned long val;
int ret;
ret = kstrtoul(buf, 0, &val);
if (ret)
return ret;
if (val > 4)
2012-09-10 16:50:54 +02:00
return -EINVAL;
return param_set_int(buf, kp);
}
/* Values of 0 to 4 will generate output */
int edac_debug_level = 2;
EXPORT_SYMBOL_GPL(edac_debug_level);
2012-09-10 16:50:54 +02:00
module_param_call(edac_debug_level, edac_set_debug_level, param_get_int,
&edac_debug_level, 0644);
MODULE_PARM_DESC(edac_debug_level, "EDAC debug level: [0-4], default: 2");
#endif
2007-07-19 01:49:52 -07:00
/*
* edac_op_state_to_string()
2007-07-19 01:49:52 -07:00
*/
char *edac_op_state_to_string(int opstate)
2007-07-19 01:49:52 -07:00
{
if (opstate == OP_RUNNING_POLL)
return "POLLED";
else if (opstate == OP_RUNNING_INTERRUPT)
return "INTERRUPT";
else if (opstate == OP_RUNNING_POLL_INTR)
return "POLL-INTR";
else if (opstate == OP_ALLOC)
return "ALLOC";
else if (opstate == OP_OFFLINE)
return "OFFLINE";
return "UNKNOWN";
}
/*
* sysfs object: /sys/devices/system/edac
* need to export to other files
*/
2015-11-30 14:15:31 +01:00
static struct bus_type edac_subsys = {
.name = "edac",
.dev_name = "edac",
};
static int edac_subsys_init(void)
{
int err;
/* create the /sys/devices/system/edac directory */
err = subsys_system_register(&edac_subsys, NULL);
if (err)
printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
return err;
}
static void edac_subsys_exit(void)
{
bus_unregister(&edac_subsys);
}
/* return pointer to the 'edac' node in sysfs */
struct bus_type *edac_get_sysfs_subsys(void)
{
return &edac_subsys;
}
EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys);
/*
* edac_init
* module initialization entry point
*/
static int __init edac_init(void)
{
2007-07-19 01:49:36 -07:00
int err = 0;
2007-07-19 01:50:30 -07:00
edac_printk(KERN_INFO, EDAC_MC, EDAC_VERSION "\n");
err = edac_subsys_init();
if (err)
return err;
/*
* Harvest and clear any boot/initialization PCI parity errors
*
* FIXME: This only clears errors logged by devices present at time of
2007-07-19 01:49:58 -07:00
* module initialization. We should also do an initial clear
* of each newly hotplugged device.
*/
edac_pci_clear_parity_errors();
err = edac_mc_sysfs_init();
if (err)
goto err_sysfs;
2012-06-11 21:32:12 -05:00
edac_debugfs_init();
2007-07-19 01:49:36 -07:00
err = edac_workqueue_setup();
if (err) {
edac_printk(KERN_ERR, EDAC_MC, "Failure initializing workqueue\n");
goto err_wq;
}
return 0;
2007-07-19 01:49:36 -07:00
err_wq:
edac_debugfs_exit();
edac_mc_sysfs_exit();
err_sysfs:
edac_subsys_exit();
2007-07-19 01:49:36 -07:00
return err;
}
/*
* edac_exit()
* module exit/termination function
*/
static void __exit edac_exit(void)
{
2012-04-29 17:08:39 -03:00
edac_dbg(0, "\n");
2007-07-19 01:49:58 -07:00
/* tear down the various subsystems */
2007-07-19 01:49:36 -07:00
edac_workqueue_teardown();
edac_mc_sysfs_exit();
2012-06-11 21:32:12 -05:00
edac_debugfs_exit();
edac_subsys_exit();
}
/*
* Inform the kernel of our entry and exit points
*/
2013-02-15 07:57:50 -03:00
subsys_initcall(edac_init);
module_exit(edac_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Doug Thompson www.softwarebitmaker.com, et al");
MODULE_DESCRIPTION("Core library routines for EDAC reporting");