2 * linux/kernel/irq/proc.c
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
6 * This file contains the /proc/irq/ handling code.
10 #include <linux/proc_fs.h>
11 #include <linux/interrupt.h>
13 static struct proc_dir_entry *root_irq_dir, *irq_dir[NR_IRQS];
18 * The /proc/irq/<irq>/smp_affinity values:
20 static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
22 static int irq_affinity_read_proc(char *page, char **start, off_t off,
23 int count, int *eof, void *data)
25 int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
29 len += sprintf(page + len, "\n");
34 static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
35 unsigned long count, void *data)
37 unsigned int irq = (int)(long)data, full_count = count, err;
38 cpumask_t new_value, tmp;
40 if (!irq_desc[irq].handler->set_affinity || no_irq_affinity)
43 err = cpumask_parse(buffer, count, new_value);
48 * Do not allow disabling IRQs completely - it's a too easy
49 * way to make the system unusable accidentally :-) At least
50 * one online CPU still has to be targeted.
52 cpus_and(tmp, new_value, cpu_online_map);
56 irq_affinity[irq] = new_value;
57 irq_desc[irq].handler->set_affinity(irq, new_value);
64 #define MAX_NAMELEN 128
66 static int name_unique(unsigned int irq, struct irqaction *new_action)
68 struct irq_desc *desc = irq_desc + irq;
69 struct irqaction *action;
71 for (action = desc->action ; action; action = action->next)
72 if ((action != new_action) && action->name &&
73 !strcmp(new_action->name, action->name))
78 void register_handler_proc(unsigned int irq, struct irqaction *action)
80 char name [MAX_NAMELEN];
82 if (!irq_dir[irq] || action->dir || !action->name ||
83 !name_unique(irq, action))
86 memset(name, 0, MAX_NAMELEN);
87 snprintf(name, MAX_NAMELEN, "%s", action->name);
89 /* create /proc/irq/1234/handler/ */
90 action->dir = proc_mkdir(name, irq_dir[irq]);
95 #define MAX_NAMELEN 10
97 void register_irq_proc(unsigned int irq)
99 char name [MAX_NAMELEN];
102 (irq_desc[irq].handler == &no_irq_type) ||
106 memset(name, 0, MAX_NAMELEN);
107 sprintf(name, "%d", irq);
109 /* create /proc/irq/1234 */
110 irq_dir[irq] = proc_mkdir(name, root_irq_dir);
114 struct proc_dir_entry *entry;
116 /* create /proc/irq/<irq>/smp_affinity */
117 entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
121 entry->data = (void *)(long)irq;
122 entry->read_proc = irq_affinity_read_proc;
123 entry->write_proc = irq_affinity_write_proc;
125 smp_affinity_entry[irq] = entry;
132 void unregister_handler_proc(unsigned int irq, struct irqaction *action)
135 remove_proc_entry(action->dir->name, irq_dir[irq]);
138 void init_irq_proc(void)
142 /* create /proc/irq */
143 root_irq_dir = proc_mkdir("irq", NULL);
148 * Create entries for all existing IRQs.
150 for (i = 0; i < NR_IRQS; i++)
151 register_irq_proc(i);