23 #include <linux/module.h>
24 #include <linux/types.h>
25 #include <linux/errno.h>
29 #include <linux/slab.h>
30 #include <asm/uaccess.h>
34 #define MODULE_VERS "1.0"
35 #define MODULE_NAME "scanlog"
38 #define SCANLOG_COMPLETE 0
39 #define SCANLOG_HWERROR -1
40 #define SCANLOG_CONTINUE 1
43 static unsigned int ibm_scan_log_dump;
47 size_t count, loff_t *ppos)
53 unsigned long len, off;
57 data = (
unsigned int *)dp->
data;
59 if (count > RTAS_DATA_BUF_SIZE)
60 count = RTAS_DATA_BUF_SIZE;
67 printk(
KERN_ERR "scanlog: cannot perform a small read (%ld)\n", count);
76 spin_lock(&rtas_data_buf_lock);
77 memcpy(rtas_data_buf, data, RTAS_DATA_BUF_SIZE);
80 memcpy(data, rtas_data_buf, RTAS_DATA_BUF_SIZE);
81 spin_unlock(&rtas_data_buf_lock);
83 pr_debug(
"scanlog: status=%d, data[0]=%x, data[1]=%x, " \
84 "data[2]=%x\n", status, data[0], data[1], data[2]);
90 pr_debug(
"scanlog: hardware error reading data\n");
108 "from rtas: %d\n", status);
119 size_t count, loff_t *ppos)
124 if (count > 19) count = 19;
131 if (
strncmp(stkbuf,
"reset", 5) == 0) {
132 pr_debug(
"scanlog: reset scanlog\n");
134 pr_debug(
"scanlog: rtas returns %d\n", status);
140 static int scanlog_open(
struct inode *
inode,
struct file * file)
143 unsigned int *
data = (
unsigned int *)dp->
data;
157 static int scanlog_release(
struct inode * inode,
struct file * file)
160 unsigned int *data = (
unsigned int *)dp->
data;
169 .read = scanlog_read,
170 .write = scanlog_write,
171 .open = scanlog_open,
172 .release = scanlog_release,
176 static int __init scanlog_init(
void)
182 ibm_scan_log_dump =
rtas_token(
"ibm,scan-log-dump");
183 if (ibm_scan_log_dump == RTAS_UNKNOWN_SERVICE)
187 data = kzalloc(RTAS_DATA_BUF_SIZE,
GFP_KERNEL);
192 &scanlog_fops, data);
196 proc_ppc64_scan_log_dump = ent;
204 static void __exit scanlog_cleanup(
void)
206 if (proc_ppc64_scan_log_dump) {