39 #include <linux/capability.h>
41 #include <linux/types.h>
43 #include <linux/module.h>
50 #include <asm/uaccess.h>
75 #define NR_SALINFO_ENTRIES ARRAY_SIZE(salinfo_entries)
77 static char *salinfo_log_name[] = {
200 salinfo_platform_oemdata_cpu(
void *
context)
231 unsigned long flags = 0;
240 for (i = 0, data_saved = data->
data_saved; i < saved_size; ++i, ++data_saved) {
244 if (i == saved_size) {
246 shift1_data_saved(data, 0);
247 data_saved = data->
data_saved + saved_size - 1;
260 salinfo_work_to_do(data);
261 spin_unlock_irqrestore(&data_saved_lock, flags);
266 #define SALINFO_TIMER_DELAY (60*HZ)
278 salinfo_work_to_do(data);
279 spin_unlock_irqrestore(&data_saved_lock, flags);
284 salinfo_timeout (
unsigned long arg)
302 salinfo_event_read(
struct file *file,
char __user *
buffer,
size_t count, loff_t *ppos)
304 struct inode *inode = file->
f_path.dentry->d_inode;
329 if (++n == nr_cpu_ids)
343 snprintf(cmd,
sizeof(cmd),
"read %d\n", cpu);
355 .open = salinfo_event_open,
356 .read = salinfo_event_read,
361 salinfo_log_open(
struct inode *inode,
struct file *file)
369 spin_lock(&data_lock);
371 spin_unlock(&data_lock);
375 spin_unlock(&data_lock);
387 salinfo_log_release(
struct inode *inode,
struct file *file)
398 spin_lock(&data_lock);
400 spin_unlock(&data_lock);
405 call_on_cpu(
int cpu,
void (*
fn)(
void *),
void *
arg)
410 set_cpus_allowed_ptr(
current, &save_cpus_allowed);
414 salinfo_log_read_cpu(
void *
context)
422 ia64_sal_clear_state_info(data->
type);
426 salinfo_log_new_read(
int cpu,
struct salinfo_data *data)
436 for (i = 0, data_saved = data->
data_saved; i < saved_size; ++i, ++data_saved) {
437 if (data_saved->
buffer && data_saved->
cpu == cpu) {
442 if (rh->
id == data_saved->
id) {
447 shift1_data_saved(data, i);
451 spin_unlock_irqrestore(&data_saved_lock, flags);
454 call_on_cpu(cpu, salinfo_log_read_cpu, data);
464 salinfo_log_read(
struct file *file,
char __user *buffer,
size_t count, loff_t *ppos)
466 struct inode *inode = file->
f_path.dentry->d_inode;
486 salinfo_log_clear_cpu(
void *context)
489 ia64_sal_clear_state_info(data->
type);
500 spin_unlock_irqrestore(&data_saved_lock, flags);
505 shift1_data_saved(data, data->
saved_num - 1);
508 spin_unlock_irqrestore(&data_saved_lock, flags);
512 call_on_cpu(cpu, salinfo_log_clear_cpu, data);
514 salinfo_log_new_read(cpu, data);
518 salinfo_work_to_do(data);
519 spin_unlock_irqrestore(&data_saved_lock, flags);
525 salinfo_log_write(
struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
527 struct inode *inode = file->
f_path.dentry->d_inode;
541 if (
sscanf(cmd,
"read %d", &cpu) == 1) {
542 salinfo_log_new_read(cpu, data);
543 }
else if (
sscanf(cmd,
"clear %d", &cpu) == 1) {
545 if ((ret = salinfo_log_clear(data, cpu)))
547 }
else if (
sscanf(cmd,
"oemdata %d %d", &cpu, &offset) == 2) {
559 call_on_cpu(cpu, salinfo_platform_oemdata_cpu, &parms);
571 .open = salinfo_log_open,
572 .release = salinfo_log_release,
573 .read = salinfo_log_read,
574 .write = salinfo_log_write,
581 unsigned int i, cpu = (
unsigned long)hcpu;
592 salinfo_work_to_do(data);
594 spin_unlock_irqrestore(&data_saved_lock, flags);
607 if (data_saved->
buffer && data_saved->
cpu == cpu) {
608 shift1_data_saved(data, j);
613 spin_unlock_irqrestore(&data_saved_lock, flags);
621 .notifier_call = salinfo_cpu_callback,
640 *sdir++ = create_proc_read_entry (salinfo_entries[i].
name, 0, salinfo_dir,
641 salinfo_read, (
void *)salinfo_entries[i].
feature);
644 for (i = 0; i <
ARRAY_SIZE(salinfo_log_name); i++) {
647 sema_init(&data->
mutex, 1);
648 dir =
proc_mkdir(salinfo_log_name[i], salinfo_dir);
653 &salinfo_event_fops, data);
659 &salinfo_data_fops, data);
671 *sdir++ = salinfo_dir;
675 salinfo_timer.
function = &salinfo_timeout;
688 salinfo_read(
char *
page,
char **
start,
off_t off,
int count,
int *eof,
void *data)
694 if (len <= off+count) *eof = 1;
699 if (len>count) len =
count;