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 #include "internals.h"
15 static struct proc_dir_entry *root_irq_dir, *irq_dir[NR_IRQS];
20 * The /proc/irq/<irq>/smp_affinity values:
22 static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
24 #ifdef CONFIG_GENERIC_PENDING_IRQ
25 void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
27 set_balance_irq_affinity(irq, mask_val);
30 * Save these away for later use. Re-progam when the
31 * interrupt is pending
33 set_pending_irq(irq, mask_val);
36 void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
38 set_balance_irq_affinity(irq, mask_val);
39 irq_affinity[irq] = mask_val;
40 irq_desc[irq].handler->set_affinity(irq, mask_val);
44 static int irq_affinity_read_proc(char *page, char **start, off_t off,
45 int count, int *eof, void *data)
47 int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
51 len += sprintf(page + len, "\n");
56 static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
57 unsigned long count, void *data)
59 unsigned int irq = (int)(long)data, full_count = count, err;
60 cpumask_t new_value, tmp;
62 if (!irq_desc[irq].handler->set_affinity || no_irq_affinity)
65 err = cpumask_parse(buffer, count, new_value);
70 * Do not allow disabling IRQs completely - it's a too easy
71 * way to make the system unusable accidentally :-) At least
72 * one online CPU still has to be targeted.
74 cpus_and(tmp, new_value, cpu_online_map);
76 /* Special case for empty set - allow the architecture
77 code to set default SMP affinity. */
78 return select_smp_affinity(irq) ? -EINVAL : full_count;
80 proc_set_irq_affinity(irq, new_value);
87 #define MAX_NAMELEN 128
89 static int name_unique(unsigned int irq, struct irqaction *new_action)
91 struct irq_desc *desc = irq_desc + irq;
92 struct irqaction *action;
94 for (action = desc->action ; action; action = action->next)
95 if ((action != new_action) && action->name &&
96 !strcmp(new_action->name, action->name))
101 void register_handler_proc(unsigned int irq, struct irqaction *action)
103 char name [MAX_NAMELEN];
105 if (!irq_dir[irq] || action->dir || !action->name ||
106 !name_unique(irq, action))
109 memset(name, 0, MAX_NAMELEN);
110 snprintf(name, MAX_NAMELEN, "%s", action->name);
112 /* create /proc/irq/1234/handler/ */
113 action->dir = proc_mkdir(name, irq_dir[irq]);
118 #define MAX_NAMELEN 10
120 void register_irq_proc(unsigned int irq)
122 char name [MAX_NAMELEN];
125 (irq_desc[irq].handler == &no_irq_type) ||
129 memset(name, 0, MAX_NAMELEN);
130 sprintf(name, "%d", irq);
132 /* create /proc/irq/1234 */
133 irq_dir[irq] = proc_mkdir(name, root_irq_dir);
137 struct proc_dir_entry *entry;
139 /* create /proc/irq/<irq>/smp_affinity */
140 entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
144 entry->data = (void *)(long)irq;
145 entry->read_proc = irq_affinity_read_proc;
146 entry->write_proc = irq_affinity_write_proc;
148 smp_affinity_entry[irq] = entry;
155 void unregister_handler_proc(unsigned int irq, struct irqaction *action)
158 remove_proc_entry(action->dir->name, irq_dir[irq]);
161 void init_irq_proc(void)
165 /* create /proc/irq */
166 root_irq_dir = proc_mkdir("irq", NULL);
171 * Create entries for all existing IRQs.
173 for (i = 0; i < NR_IRQS; i++)
174 register_irq_proc(i);