aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/proc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /kernel/irq/proc.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'kernel/irq/proc.c')
-rw-r--r--kernel/irq/proc.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
new file mode 100644
index 000000000000..85d08daa6600
--- /dev/null
+++ b/kernel/irq/proc.c
@@ -0,0 +1,159 @@
1/*
2 * linux/kernel/irq/proc.c
3 *
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
5 *
6 * This file contains the /proc/irq/ handling code.
7 */
8
9#include <linux/irq.h>
10#include <linux/proc_fs.h>
11#include <linux/interrupt.h>
12
13static struct proc_dir_entry *root_irq_dir, *irq_dir[NR_IRQS];
14
15#ifdef CONFIG_SMP
16
17/*
18 * The /proc/irq/<irq>/smp_affinity values:
19 */
20static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
21
22void __attribute__((weak))
23proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
24{
25 irq_affinity[irq] = mask_val;
26 irq_desc[irq].handler->set_affinity(irq, mask_val);
27}
28
29static int irq_affinity_read_proc(char *page, char **start, off_t off,
30 int count, int *eof, void *data)
31{
32 int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
33
34 if (count - len < 2)
35 return -EINVAL;
36 len += sprintf(page + len, "\n");
37 return len;
38}
39
40int no_irq_affinity;
41static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
42 unsigned long count, void *data)
43{
44 unsigned int irq = (int)(long)data, full_count = count, err;
45 cpumask_t new_value, tmp;
46
47 if (!irq_desc[irq].handler->set_affinity || no_irq_affinity)
48 return -EIO;
49
50 err = cpumask_parse(buffer, count, new_value);
51 if (err)
52 return err;
53
54 /*
55 * Do not allow disabling IRQs completely - it's a too easy
56 * way to make the system unusable accidentally :-) At least
57 * one online CPU still has to be targeted.
58 */
59 cpus_and(tmp, new_value, cpu_online_map);
60 if (cpus_empty(tmp))
61 return -EINVAL;
62
63 proc_set_irq_affinity(irq, new_value);
64
65 return full_count;
66}
67
68#endif
69
70#define MAX_NAMELEN 128
71
72static int name_unique(unsigned int irq, struct irqaction *new_action)
73{
74 struct irq_desc *desc = irq_desc + irq;
75 struct irqaction *action;
76
77 for (action = desc->action ; action; action = action->next)
78 if ((action != new_action) && action->name &&
79 !strcmp(new_action->name, action->name))
80 return 0;
81 return 1;
82}
83
84void register_handler_proc(unsigned int irq, struct irqaction *action)
85{
86 char name [MAX_NAMELEN];
87
88 if (!irq_dir[irq] || action->dir || !action->name ||
89 !name_unique(irq, action))
90 return;
91
92 memset(name, 0, MAX_NAMELEN);
93 snprintf(name, MAX_NAMELEN, "%s", action->name);
94
95 /* create /proc/irq/1234/handler/ */
96 action->dir = proc_mkdir(name, irq_dir[irq]);
97}
98
99#undef MAX_NAMELEN
100
101#define MAX_NAMELEN 10
102
103void register_irq_proc(unsigned int irq)
104{
105 char name [MAX_NAMELEN];
106
107 if (!root_irq_dir ||
108 (irq_desc[irq].handler == &no_irq_type) ||
109 irq_dir[irq])
110 return;
111
112 memset(name, 0, MAX_NAMELEN);
113 sprintf(name, "%d", irq);
114
115 /* create /proc/irq/1234 */
116 irq_dir[irq] = proc_mkdir(name, root_irq_dir);
117
118#ifdef CONFIG_SMP
119 {
120 struct proc_dir_entry *entry;
121
122 /* create /proc/irq/<irq>/smp_affinity */
123 entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
124
125 if (entry) {
126 entry->nlink = 1;
127 entry->data = (void *)(long)irq;
128 entry->read_proc = irq_affinity_read_proc;
129 entry->write_proc = irq_affinity_write_proc;
130 }
131 smp_affinity_entry[irq] = entry;
132 }
133#endif
134}
135
136#undef MAX_NAMELEN
137
138void unregister_handler_proc(unsigned int irq, struct irqaction *action)
139{
140 if (action->dir)
141 remove_proc_entry(action->dir->name, irq_dir[irq]);
142}
143
144void init_irq_proc(void)
145{
146 int i;
147
148 /* create /proc/irq */
149 root_irq_dir = proc_mkdir("irq", NULL);
150 if (!root_irq_dir)
151 return;
152
153 /*
154 * Create entries for all existing IRQs.
155 */
156 for (i = 0; i < NR_IRQS; i++)
157 register_irq_proc(i);
158}
159