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 void __attribute__((weak
))
23 proc_set_irq_affinity(unsigned int irq
, cpumask_t mask_val
)
25 irq_affinity
[irq
] = mask_val
;
26 irq_desc
[irq
].handler
->set_affinity(irq
, mask_val
);
29 static int irq_affinity_read_proc(char *page
, char **start
, off_t off
,
30 int count
, int *eof
, void *data
)
32 int len
= cpumask_scnprintf(page
, count
, irq_affinity
[(long)data
]);
36 len
+= sprintf(page
+ len
, "\n");
41 static int irq_affinity_write_proc(struct file
*file
, const char __user
*buffer
,
42 unsigned long count
, void *data
)
44 unsigned int irq
= (int)(long)data
, full_count
= count
, err
;
45 cpumask_t new_value
, tmp
;
47 if (!irq_desc
[irq
].handler
->set_affinity
|| no_irq_affinity
)
50 err
= cpumask_parse(buffer
, count
, new_value
);
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.
59 cpus_and(tmp
, new_value
, cpu_online_map
);
63 proc_set_irq_affinity(irq
, new_value
);
70 #define MAX_NAMELEN 128
72 static int name_unique(unsigned int irq
, struct irqaction
*new_action
)
74 struct irq_desc
*desc
= irq_desc
+ irq
;
75 struct irqaction
*action
;
77 for (action
= desc
->action
; action
; action
= action
->next
)
78 if ((action
!= new_action
) && action
->name
&&
79 !strcmp(new_action
->name
, action
->name
))
84 void register_handler_proc(unsigned int irq
, struct irqaction
*action
)
86 char name
[MAX_NAMELEN
];
88 if (!irq_dir
[irq
] || action
->dir
|| !action
->name
||
89 !name_unique(irq
, action
))
92 memset(name
, 0, MAX_NAMELEN
);
93 snprintf(name
, MAX_NAMELEN
, "%s", action
->name
);
95 /* create /proc/irq/1234/handler/ */
96 action
->dir
= proc_mkdir(name
, irq_dir
[irq
]);
101 #define MAX_NAMELEN 10
103 void register_irq_proc(unsigned int irq
)
105 char name
[MAX_NAMELEN
];
108 (irq_desc
[irq
].handler
== &no_irq_type
) ||
112 memset(name
, 0, MAX_NAMELEN
);
113 sprintf(name
, "%d", irq
);
115 /* create /proc/irq/1234 */
116 irq_dir
[irq
] = proc_mkdir(name
, root_irq_dir
);
120 struct proc_dir_entry
*entry
;
122 /* create /proc/irq/<irq>/smp_affinity */
123 entry
= create_proc_entry("smp_affinity", 0600, irq_dir
[irq
]);
127 entry
->data
= (void *)(long)irq
;
128 entry
->read_proc
= irq_affinity_read_proc
;
129 entry
->write_proc
= irq_affinity_write_proc
;
131 smp_affinity_entry
[irq
] = entry
;
138 void unregister_handler_proc(unsigned int irq
, struct irqaction
*action
)
141 remove_proc_entry(action
->dir
->name
, irq_dir
[irq
]);
144 void init_irq_proc(void)
148 /* create /proc/irq */
149 root_irq_dir
= proc_mkdir("irq", NULL
);
154 * Create entries for all existing IRQs.
156 for (i
= 0; i
< NR_IRQS
; i
++)
157 register_irq_proc(i
);