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
;
19 #ifdef CONFIG_GENERIC_PENDING_IRQ
20 void proc_set_irq_affinity(unsigned int irq
, cpumask_t mask_val
)
22 set_balance_irq_affinity(irq
, mask_val
);
25 * Save these away for later use. Re-progam when the
26 * interrupt is pending
28 set_pending_irq(irq
, mask_val
);
31 void proc_set_irq_affinity(unsigned int irq
, cpumask_t mask_val
)
33 set_balance_irq_affinity(irq
, mask_val
);
34 irq_desc
[irq
].affinity
= mask_val
;
35 irq_desc
[irq
].chip
->set_affinity(irq
, mask_val
);
39 static int irq_affinity_read_proc(char *page
, char **start
, off_t off
,
40 int count
, int *eof
, void *data
)
42 int len
= cpumask_scnprintf(page
, count
, irq_desc
[(long)data
].affinity
);
46 len
+= sprintf(page
+ len
, "\n");
51 static int irq_affinity_write_proc(struct file
*file
, const char __user
*buffer
,
52 unsigned long count
, void *data
)
54 unsigned int irq
= (int)(long)data
, full_count
= count
, err
;
55 cpumask_t new_value
, tmp
;
57 if (!irq_desc
[irq
].chip
->set_affinity
|| no_irq_affinity
||
58 CHECK_IRQ_PER_CPU(irq_desc
[irq
].status
))
61 err
= cpumask_parse_user(buffer
, count
, new_value
);
66 * Do not allow disabling IRQs completely - it's a too easy
67 * way to make the system unusable accidentally :-) At least
68 * one online CPU still has to be targeted.
70 cpus_and(tmp
, new_value
, cpu_online_map
);
72 /* Special case for empty set - allow the architecture
73 code to set default SMP affinity. */
74 return select_smp_affinity(irq
) ? -EINVAL
: full_count
;
76 proc_set_irq_affinity(irq
, new_value
);
83 #define MAX_NAMELEN 128
85 static int name_unique(unsigned int irq
, struct irqaction
*new_action
)
87 struct irq_desc
*desc
= irq_desc
+ irq
;
88 struct irqaction
*action
;
90 for (action
= desc
->action
; action
; action
= action
->next
)
91 if ((action
!= new_action
) && action
->name
&&
92 !strcmp(new_action
->name
, action
->name
))
97 void register_handler_proc(unsigned int irq
, struct irqaction
*action
)
99 char name
[MAX_NAMELEN
];
101 if (!irq_desc
[irq
].dir
|| action
->dir
|| !action
->name
||
102 !name_unique(irq
, action
))
105 memset(name
, 0, MAX_NAMELEN
);
106 snprintf(name
, MAX_NAMELEN
, "%s", action
->name
);
108 /* create /proc/irq/1234/handler/ */
109 action
->dir
= proc_mkdir(name
, irq_desc
[irq
].dir
);
114 #define MAX_NAMELEN 10
116 void register_irq_proc(unsigned int irq
)
118 char name
[MAX_NAMELEN
];
121 (irq_desc
[irq
].chip
== &no_irq_chip
) ||
125 memset(name
, 0, MAX_NAMELEN
);
126 sprintf(name
, "%d", irq
);
128 /* create /proc/irq/1234 */
129 irq_desc
[irq
].dir
= proc_mkdir(name
, root_irq_dir
);
133 struct proc_dir_entry
*entry
;
135 /* create /proc/irq/<irq>/smp_affinity */
136 entry
= create_proc_entry("smp_affinity", 0600, irq_desc
[irq
].dir
);
140 entry
->data
= (void *)(long)irq
;
141 entry
->read_proc
= irq_affinity_read_proc
;
142 entry
->write_proc
= irq_affinity_write_proc
;
150 void unregister_handler_proc(unsigned int irq
, struct irqaction
*action
)
153 remove_proc_entry(action
->dir
->name
, irq_desc
[irq
].dir
);
156 void init_irq_proc(void)
160 /* create /proc/irq */
161 root_irq_dir
= proc_mkdir("irq", NULL
);
166 * Create entries for all existing IRQs.
168 for (i
= 0; i
< NR_IRQS
; i
++)
169 register_irq_proc(i
);