| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/gfp.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/proc_fs.h> | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 12 | #include <linux/seq_file.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/interrupt.h> | 
 | 14 |  | 
| Adrian Bunk | 97a41e2 | 2006-01-08 01:02:17 -0800 | [diff] [blame] | 15 | #include "internals.h" | 
 | 16 |  | 
| Ingo Molnar | 4a733ee | 2006-06-29 02:24:42 -0700 | [diff] [blame] | 17 | static struct proc_dir_entry *root_irq_dir; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 |  | 
 | 19 | #ifdef CONFIG_SMP | 
 | 20 |  | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 21 | static int irq_affinity_proc_show(struct seq_file *m, void *v) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | { | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 23 | 	struct irq_desc *desc = irq_to_desc((long)m->private); | 
| Mike Travis | 7f7ace0 | 2009-01-10 21:58:08 -0800 | [diff] [blame] | 24 | 	const struct cpumask *mask = desc->affinity; | 
| Andi Kleen | 42ee2b7 | 2007-07-21 17:09:54 +0200 | [diff] [blame] | 25 |  | 
 | 26 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 
 | 27 | 	if (desc->status & IRQ_MOVE_PENDING) | 
| Mike Travis | 7f7ace0 | 2009-01-10 21:58:08 -0800 | [diff] [blame] | 28 | 		mask = desc->pending_mask; | 
| Andi Kleen | 42ee2b7 | 2007-07-21 17:09:54 +0200 | [diff] [blame] | 29 | #endif | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 30 | 	seq_cpumask(m, mask); | 
 | 31 | 	seq_putc(m, '\n'); | 
 | 32 | 	return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } | 
 | 34 |  | 
| Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 35 | static int irq_affinity_hint_proc_show(struct seq_file *m, void *v) | 
 | 36 | { | 
 | 37 | 	struct irq_desc *desc = irq_to_desc((long)m->private); | 
 | 38 | 	unsigned long flags; | 
 | 39 | 	cpumask_var_t mask; | 
 | 40 |  | 
| Peter P Waskiewicz Jr | 4308ad8 | 2010-05-05 13:56:42 -0700 | [diff] [blame] | 41 | 	if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) | 
| Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 42 | 		return -ENOMEM; | 
 | 43 |  | 
 | 44 | 	raw_spin_lock_irqsave(&desc->lock, flags); | 
 | 45 | 	if (desc->affinity_hint) | 
 | 46 | 		cpumask_copy(mask, desc->affinity_hint); | 
| Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 47 | 	raw_spin_unlock_irqrestore(&desc->lock, flags); | 
 | 48 |  | 
 | 49 | 	seq_cpumask(m, mask); | 
 | 50 | 	seq_putc(m, '\n'); | 
 | 51 | 	free_cpumask_var(mask); | 
 | 52 |  | 
 | 53 | 	return 0; | 
 | 54 | } | 
 | 55 |  | 
| John Keller | 25d6157 | 2007-05-10 22:42:44 -0700 | [diff] [blame] | 56 | #ifndef is_affinity_mask_valid | 
 | 57 | #define is_affinity_mask_valid(val) 1 | 
 | 58 | #endif | 
 | 59 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | int no_irq_affinity; | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 61 | static ssize_t irq_affinity_proc_write(struct file *file, | 
 | 62 | 		const char __user *buffer, size_t count, loff_t *pos) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 64 | 	unsigned int irq = (int)(long)PDE(file->f_path.dentry->d_inode)->data; | 
| Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 65 | 	cpumask_var_t new_value; | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 66 | 	int err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 |  | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 68 | 	if (!irq_to_desc(irq)->chip->set_affinity || no_irq_affinity || | 
| Thomas Gleixner | 950f442 | 2007-02-16 01:27:24 -0800 | [diff] [blame] | 69 | 	    irq_balancing_disabled(irq)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | 		return -EIO; | 
 | 71 |  | 
| Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 72 | 	if (!alloc_cpumask_var(&new_value, GFP_KERNEL)) | 
 | 73 | 		return -ENOMEM; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 |  | 
| Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 75 | 	err = cpumask_parse_user(buffer, count, new_value); | 
 | 76 | 	if (err) | 
 | 77 | 		goto free_cpumask; | 
 | 78 |  | 
| Ingo Molnar | 6bdf197 | 2009-01-03 12:50:46 +0100 | [diff] [blame] | 79 | 	if (!is_affinity_mask_valid(new_value)) { | 
| Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 80 | 		err = -EINVAL; | 
 | 81 | 		goto free_cpumask; | 
 | 82 | 	} | 
| John Keller | 25d6157 | 2007-05-10 22:42:44 -0700 | [diff] [blame] | 83 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | 	/* | 
 | 85 | 	 * Do not allow disabling IRQs completely - it's a too easy | 
 | 86 | 	 * way to make the system unusable accidentally :-) At least | 
 | 87 | 	 * one online CPU still has to be targeted. | 
 | 88 | 	 */ | 
| Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 89 | 	if (!cpumask_intersects(new_value, cpu_online_mask)) { | 
| Ivan Kokshaysky | eee4526 | 2006-01-06 00:12:21 -0800 | [diff] [blame] | 90 | 		/* Special case for empty set - allow the architecture | 
 | 91 | 		   code to set default SMP affinity. */ | 
| Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 92 | 		err = irq_select_affinity_usr(irq) ? -EINVAL : count; | 
 | 93 | 	} else { | 
 | 94 | 		irq_set_affinity(irq, new_value); | 
 | 95 | 		err = count; | 
 | 96 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 |  | 
| Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 98 | free_cpumask: | 
 | 99 | 	free_cpumask_var(new_value); | 
 | 100 | 	return err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } | 
 | 102 |  | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 103 | static int irq_affinity_proc_open(struct inode *inode, struct file *file) | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 104 | { | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 105 | 	return single_open(file, irq_affinity_proc_show, PDE(inode)->data); | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 106 | } | 
 | 107 |  | 
| Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 108 | static int irq_affinity_hint_proc_open(struct inode *inode, struct file *file) | 
 | 109 | { | 
 | 110 | 	return single_open(file, irq_affinity_hint_proc_show, PDE(inode)->data); | 
 | 111 | } | 
 | 112 |  | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 113 | static const struct file_operations irq_affinity_proc_fops = { | 
 | 114 | 	.open		= irq_affinity_proc_open, | 
 | 115 | 	.read		= seq_read, | 
 | 116 | 	.llseek		= seq_lseek, | 
 | 117 | 	.release	= single_release, | 
 | 118 | 	.write		= irq_affinity_proc_write, | 
 | 119 | }; | 
 | 120 |  | 
| Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 121 | static const struct file_operations irq_affinity_hint_proc_fops = { | 
 | 122 | 	.open		= irq_affinity_hint_proc_open, | 
 | 123 | 	.read		= seq_read, | 
 | 124 | 	.llseek		= seq_lseek, | 
 | 125 | 	.release	= single_release, | 
 | 126 | }; | 
 | 127 |  | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 128 | static int default_affinity_show(struct seq_file *m, void *v) | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 129 | { | 
| Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 130 | 	seq_cpumask(m, irq_default_affinity); | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 131 | 	seq_putc(m, '\n'); | 
 | 132 | 	return 0; | 
 | 133 | } | 
 | 134 |  | 
 | 135 | static ssize_t default_affinity_write(struct file *file, | 
 | 136 | 		const char __user *buffer, size_t count, loff_t *ppos) | 
 | 137 | { | 
| Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 138 | 	cpumask_var_t new_value; | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 139 | 	int err; | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 140 |  | 
| Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 141 | 	if (!alloc_cpumask_var(&new_value, GFP_KERNEL)) | 
 | 142 | 		return -ENOMEM; | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 143 |  | 
| Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 144 | 	err = cpumask_parse_user(buffer, count, new_value); | 
 | 145 | 	if (err) | 
 | 146 | 		goto out; | 
 | 147 |  | 
 | 148 | 	if (!is_affinity_mask_valid(new_value)) { | 
 | 149 | 		err = -EINVAL; | 
 | 150 | 		goto out; | 
 | 151 | 	} | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 152 |  | 
 | 153 | 	/* | 
 | 154 | 	 * Do not allow disabling IRQs completely - it's a too easy | 
 | 155 | 	 * way to make the system unusable accidentally :-) At least | 
 | 156 | 	 * one online CPU still has to be targeted. | 
 | 157 | 	 */ | 
| Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 158 | 	if (!cpumask_intersects(new_value, cpu_online_mask)) { | 
 | 159 | 		err = -EINVAL; | 
 | 160 | 		goto out; | 
 | 161 | 	} | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 162 |  | 
| Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 163 | 	cpumask_copy(irq_default_affinity, new_value); | 
 | 164 | 	err = count; | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 165 |  | 
| Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 166 | out: | 
 | 167 | 	free_cpumask_var(new_value); | 
 | 168 | 	return err; | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 169 | } | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 170 |  | 
 | 171 | static int default_affinity_open(struct inode *inode, struct file *file) | 
 | 172 | { | 
| Thomas Gleixner | 3476994 | 2009-11-20 11:46:21 +0100 | [diff] [blame] | 173 | 	return single_open(file, default_affinity_show, PDE(inode)->data); | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 174 | } | 
 | 175 |  | 
 | 176 | static const struct file_operations default_affinity_proc_fops = { | 
 | 177 | 	.open		= default_affinity_open, | 
 | 178 | 	.read		= seq_read, | 
 | 179 | 	.llseek		= seq_lseek, | 
 | 180 | 	.release	= single_release, | 
 | 181 | 	.write		= default_affinity_write, | 
 | 182 | }; | 
| Dimitri Sivanich | 92d6b71 | 2010-03-11 14:08:56 -0800 | [diff] [blame] | 183 |  | 
 | 184 | static int irq_node_proc_show(struct seq_file *m, void *v) | 
 | 185 | { | 
 | 186 | 	struct irq_desc *desc = irq_to_desc((long) m->private); | 
 | 187 |  | 
 | 188 | 	seq_printf(m, "%d\n", desc->node); | 
 | 189 | 	return 0; | 
 | 190 | } | 
 | 191 |  | 
 | 192 | static int irq_node_proc_open(struct inode *inode, struct file *file) | 
 | 193 | { | 
 | 194 | 	return single_open(file, irq_node_proc_show, PDE(inode)->data); | 
 | 195 | } | 
 | 196 |  | 
 | 197 | static const struct file_operations irq_node_proc_fops = { | 
 | 198 | 	.open		= irq_node_proc_open, | 
 | 199 | 	.read		= seq_read, | 
 | 200 | 	.llseek		= seq_lseek, | 
 | 201 | 	.release	= single_release, | 
 | 202 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | #endif | 
 | 204 |  | 
| Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 205 | static int irq_spurious_proc_show(struct seq_file *m, void *v) | 
| Andi Kleen | 96d97cf | 2008-01-30 13:32:48 +0100 | [diff] [blame] | 206 | { | 
| Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 207 | 	struct irq_desc *desc = irq_to_desc((long) m->private); | 
 | 208 |  | 
 | 209 | 	seq_printf(m, "count %u\n" "unhandled %u\n" "last_unhandled %u ms\n", | 
 | 210 | 		   desc->irq_count, desc->irqs_unhandled, | 
 | 211 | 		   jiffies_to_msecs(desc->last_unhandled)); | 
 | 212 | 	return 0; | 
| Andi Kleen | 96d97cf | 2008-01-30 13:32:48 +0100 | [diff] [blame] | 213 | } | 
 | 214 |  | 
| Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 215 | static int irq_spurious_proc_open(struct inode *inode, struct file *file) | 
 | 216 | { | 
 | 217 | 	return single_open(file, irq_spurious_proc_show, NULL); | 
 | 218 | } | 
 | 219 |  | 
 | 220 | static const struct file_operations irq_spurious_proc_fops = { | 
 | 221 | 	.open		= irq_spurious_proc_open, | 
 | 222 | 	.read		= seq_read, | 
 | 223 | 	.llseek		= seq_lseek, | 
 | 224 | 	.release	= single_release, | 
 | 225 | }; | 
 | 226 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | #define MAX_NAMELEN 128 | 
 | 228 |  | 
 | 229 | static int name_unique(unsigned int irq, struct irqaction *new_action) | 
 | 230 | { | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 231 | 	struct irq_desc *desc = irq_to_desc(irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | 	struct irqaction *action; | 
| Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 233 | 	unsigned long flags; | 
 | 234 | 	int ret = 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 |  | 
| Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 236 | 	raw_spin_lock_irqsave(&desc->lock, flags); | 
| Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 237 | 	for (action = desc->action ; action; action = action->next) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | 		if ((action != new_action) && action->name && | 
| Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 239 | 				!strcmp(new_action->name, action->name)) { | 
 | 240 | 			ret = 0; | 
 | 241 | 			break; | 
 | 242 | 		} | 
 | 243 | 	} | 
| Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 244 | 	raw_spin_unlock_irqrestore(&desc->lock, flags); | 
| Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 245 | 	return ret; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | } | 
 | 247 |  | 
 | 248 | void register_handler_proc(unsigned int irq, struct irqaction *action) | 
 | 249 | { | 
 | 250 | 	char name [MAX_NAMELEN]; | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 251 | 	struct irq_desc *desc = irq_to_desc(irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 |  | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 253 | 	if (!desc->dir || action->dir || !action->name || | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | 					!name_unique(irq, action)) | 
 | 255 | 		return; | 
 | 256 |  | 
 | 257 | 	memset(name, 0, MAX_NAMELEN); | 
 | 258 | 	snprintf(name, MAX_NAMELEN, "%s", action->name); | 
 | 259 |  | 
 | 260 | 	/* create /proc/irq/1234/handler/ */ | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 261 | 	action->dir = proc_mkdir(name, desc->dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | } | 
 | 263 |  | 
 | 264 | #undef MAX_NAMELEN | 
 | 265 |  | 
 | 266 | #define MAX_NAMELEN 10 | 
 | 267 |  | 
| Yinghai Lu | 2c6927a | 2008-08-19 20:50:11 -0700 | [diff] [blame] | 268 | void register_irq_proc(unsigned int irq, struct irq_desc *desc) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | { | 
 | 270 | 	char name [MAX_NAMELEN]; | 
 | 271 |  | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 272 | 	if (!root_irq_dir || (desc->chip == &no_irq_chip) || desc->dir) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | 		return; | 
 | 274 |  | 
 | 275 | 	memset(name, 0, MAX_NAMELEN); | 
 | 276 | 	sprintf(name, "%d", irq); | 
 | 277 |  | 
 | 278 | 	/* create /proc/irq/1234 */ | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 279 | 	desc->dir = proc_mkdir(name, root_irq_dir); | 
| Cyrill Gorcunov | c82a43d | 2009-10-26 23:28:11 +0300 | [diff] [blame] | 280 | 	if (!desc->dir) | 
 | 281 | 		return; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 |  | 
 | 283 | #ifdef CONFIG_SMP | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 284 | 	/* create /proc/irq/<irq>/smp_affinity */ | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 285 | 	proc_create_data("smp_affinity", 0600, desc->dir, | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 286 | 			 &irq_affinity_proc_fops, (void *)(long)irq); | 
| Dimitri Sivanich | 92d6b71 | 2010-03-11 14:08:56 -0800 | [diff] [blame] | 287 |  | 
| Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 288 | 	/* create /proc/irq/<irq>/affinity_hint */ | 
 | 289 | 	proc_create_data("affinity_hint", 0400, desc->dir, | 
 | 290 | 			 &irq_affinity_hint_proc_fops, (void *)(long)irq); | 
 | 291 |  | 
| Dimitri Sivanich | 92d6b71 | 2010-03-11 14:08:56 -0800 | [diff] [blame] | 292 | 	proc_create_data("node", 0444, desc->dir, | 
 | 293 | 			 &irq_node_proc_fops, (void *)(long)irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | #endif | 
| Andi Kleen | 96d97cf | 2008-01-30 13:32:48 +0100 | [diff] [blame] | 295 |  | 
| Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 296 | 	proc_create_data("spurious", 0444, desc->dir, | 
 | 297 | 			 &irq_spurious_proc_fops, (void *)(long)irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } | 
 | 299 |  | 
 | 300 | #undef MAX_NAMELEN | 
 | 301 |  | 
 | 302 | void unregister_handler_proc(unsigned int irq, struct irqaction *action) | 
 | 303 | { | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 304 | 	if (action->dir) { | 
 | 305 | 		struct irq_desc *desc = irq_to_desc(irq); | 
| Thomas Gleixner | d3c6004 | 2008-10-16 09:55:00 +0200 | [diff] [blame] | 306 |  | 
| Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 307 | 		remove_proc_entry(action->dir->name, desc->dir); | 
 | 308 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } | 
 | 310 |  | 
| roel kluin | 3786fc7 | 2008-10-21 19:49:09 -0400 | [diff] [blame] | 311 | static void register_default_affinity_proc(void) | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 312 | { | 
 | 313 | #ifdef CONFIG_SMP | 
| Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 314 | 	proc_create("irq/default_smp_affinity", 0600, NULL, | 
 | 315 | 		    &default_affinity_proc_fops); | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 316 | #endif | 
 | 317 | } | 
 | 318 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | void init_irq_proc(void) | 
 | 320 | { | 
| Yinghai Lu | 2c6927a | 2008-08-19 20:50:11 -0700 | [diff] [blame] | 321 | 	unsigned int irq; | 
 | 322 | 	struct irq_desc *desc; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 |  | 
 | 324 | 	/* create /proc/irq */ | 
 | 325 | 	root_irq_dir = proc_mkdir("irq", NULL); | 
 | 326 | 	if (!root_irq_dir) | 
 | 327 | 		return; | 
 | 328 |  | 
| Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 329 | 	register_default_affinity_proc(); | 
 | 330 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | 	/* | 
 | 332 | 	 * Create entries for all existing IRQs. | 
 | 333 | 	 */ | 
| Yinghai Lu | 0b8f1ef | 2008-12-05 18:58:31 -0800 | [diff] [blame] | 334 | 	for_each_irq_desc(irq, desc) { | 
 | 335 | 		if (!desc) | 
 | 336 | 			continue; | 
 | 337 |  | 
| Yinghai Lu | 2c6927a | 2008-08-19 20:50:11 -0700 | [diff] [blame] | 338 | 		register_irq_proc(irq, desc); | 
| Yinghai Lu | 0b8f1ef | 2008-12-05 18:58:31 -0800 | [diff] [blame] | 339 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | } | 
 | 341 |  |