| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * /proc/bus/pnp interface for Plug and Play devices | 
|  | 3 | * | 
|  | 4 | * Written by David Hinds, dahinds@users.sourceforge.net | 
|  | 5 | * Modified by Thomas Hood | 
|  | 6 | * | 
|  | 7 | * The .../devices and .../<node> and .../boot/<node> files are | 
|  | 8 | * utilized by the lspnp and setpnp utilities, supplied with the | 
|  | 9 | * pcmcia-cs package. | 
|  | 10 | *     http://pcmcia-cs.sourceforge.net | 
|  | 11 | * | 
|  | 12 | * The .../escd file is utilized by the lsescd utility written by | 
|  | 13 | * Gunther Mayer. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * | 
|  | 15 | * The .../legacy_device_resources file is not used yet. | 
|  | 16 | * | 
|  | 17 | * The other files are human-readable. | 
|  | 18 | */ | 
|  | 19 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/module.h> | 
|  | 21 | #include <linux/kernel.h> | 
|  | 22 | #include <linux/slab.h> | 
|  | 23 | #include <linux/types.h> | 
|  | 24 | #include <linux/proc_fs.h> | 
| Bjorn Helgaas | dfd2e1b | 2008-04-28 16:34:42 -0600 | [diff] [blame] | 25 | #include <linux/pnp.h> | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 26 | #include <linux/seq_file.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/init.h> | 
|  | 28 |  | 
|  | 29 | #include <asm/uaccess.h> | 
|  | 30 |  | 
|  | 31 | #include "pnpbios.h" | 
|  | 32 |  | 
|  | 33 | static struct proc_dir_entry *proc_pnp = NULL; | 
|  | 34 | static struct proc_dir_entry *proc_pnp_boot = NULL; | 
|  | 35 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 36 | static int pnpconfig_proc_show(struct seq_file *m, void *v) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | { | 
|  | 38 | struct pnp_isa_config_struc pnps; | 
|  | 39 |  | 
|  | 40 | if (pnp_bios_isapnp_config(&pnps)) | 
|  | 41 | return -EIO; | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 42 | seq_printf(m, "structure_revision %d\n" | 
|  | 43 | "number_of_CSNs %d\n" | 
|  | 44 | "ISA_read_data_port 0x%x\n", | 
|  | 45 | pnps.revision, pnps.no_csns, pnps.isa_rd_data_port); | 
|  | 46 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } | 
|  | 48 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 49 | static int pnpconfig_proc_open(struct inode *inode, struct file *file) | 
|  | 50 | { | 
|  | 51 | return single_open(file, pnpconfig_proc_show, NULL); | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | static const struct file_operations pnpconfig_proc_fops = { | 
|  | 55 | .owner		= THIS_MODULE, | 
|  | 56 | .open		= pnpconfig_proc_open, | 
|  | 57 | .read		= seq_read, | 
|  | 58 | .llseek		= seq_lseek, | 
|  | 59 | .release	= single_release, | 
|  | 60 | }; | 
|  | 61 |  | 
|  | 62 | static int escd_info_proc_show(struct seq_file *m, void *v) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { | 
|  | 64 | struct escd_info_struc escd; | 
|  | 65 |  | 
|  | 66 | if (pnp_bios_escd_info(&escd)) | 
|  | 67 | return -EIO; | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 68 | seq_printf(m, "min_ESCD_write_size %d\n" | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 69 | "ESCD_size %d\n" | 
|  | 70 | "NVRAM_base 0x%x\n", | 
|  | 71 | escd.min_escd_write_size, | 
|  | 72 | escd.escd_size, escd.nv_storage_base); | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 73 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } | 
|  | 75 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 76 | static int escd_info_proc_open(struct inode *inode, struct file *file) | 
|  | 77 | { | 
|  | 78 | return single_open(file, escd_info_proc_show, NULL); | 
|  | 79 | } | 
|  | 80 |  | 
|  | 81 | static const struct file_operations escd_info_proc_fops = { | 
|  | 82 | .owner		= THIS_MODULE, | 
|  | 83 | .open		= escd_info_proc_open, | 
|  | 84 | .read		= seq_read, | 
|  | 85 | .llseek		= seq_lseek, | 
|  | 86 | .release	= single_release, | 
|  | 87 | }; | 
|  | 88 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | #define MAX_SANE_ESCD_SIZE (32*1024) | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 90 | static int escd_proc_show(struct seq_file *m, void *v) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | { | 
|  | 92 | struct escd_info_struc escd; | 
|  | 93 | char *tmpbuf; | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 94 | int escd_size; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 |  | 
|  | 96 | if (pnp_bios_escd_info(&escd)) | 
|  | 97 | return -EIO; | 
|  | 98 |  | 
|  | 99 | /* sanity check */ | 
|  | 100 | if (escd.escd_size > MAX_SANE_ESCD_SIZE) { | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 101 | printk(KERN_ERR | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 102 | "PnPBIOS: %s: ESCD size reported by BIOS escd_info call is too great\n", __func__); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | return -EFBIG; | 
|  | 104 | } | 
|  | 105 |  | 
| Robert P. J. Day | cd86128 | 2006-12-13 00:34:52 -0800 | [diff] [blame] | 106 | tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL); | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 107 | if (!tmpbuf) | 
|  | 108 | return -ENOMEM; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 |  | 
|  | 110 | if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { | 
|  | 111 | kfree(tmpbuf); | 
|  | 112 | return -EIO; | 
|  | 113 | } | 
|  | 114 |  | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 115 | escd_size = | 
|  | 116 | (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1]) * 256; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 |  | 
|  | 118 | /* sanity check */ | 
|  | 119 | if (escd_size > MAX_SANE_ESCD_SIZE) { | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 120 | printk(KERN_ERR "PnPBIOS: %s: ESCD size reported by" | 
|  | 121 | " BIOS read_escd call is too great\n", __func__); | 
| Jesper Juhl | a8b0ac0 | 2007-10-16 23:26:56 -0700 | [diff] [blame] | 122 | kfree(tmpbuf); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | return -EFBIG; | 
|  | 124 | } | 
|  | 125 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 126 | seq_write(m, tmpbuf, escd_size); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | kfree(tmpbuf); | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 128 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } | 
|  | 130 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 131 | static int escd_proc_open(struct inode *inode, struct file *file) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | { | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 133 | return single_open(file, escd_proc_show, NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | } | 
|  | 135 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 136 | static const struct file_operations escd_proc_fops = { | 
|  | 137 | .owner		= THIS_MODULE, | 
|  | 138 | .open		= escd_proc_open, | 
|  | 139 | .read		= seq_read, | 
|  | 140 | .llseek		= seq_lseek, | 
|  | 141 | .release	= single_release, | 
|  | 142 | }; | 
|  | 143 |  | 
|  | 144 | static int pnp_legacyres_proc_show(struct seq_file *m, void *v) | 
|  | 145 | { | 
|  | 146 | void *buf; | 
|  | 147 |  | 
|  | 148 | buf = kmalloc(65536, GFP_KERNEL); | 
|  | 149 | if (!buf) | 
|  | 150 | return -ENOMEM; | 
|  | 151 | if (pnp_bios_get_stat_res(buf)) { | 
|  | 152 | kfree(buf); | 
|  | 153 | return -EIO; | 
|  | 154 | } | 
|  | 155 |  | 
|  | 156 | seq_write(m, buf, 65536); | 
|  | 157 | kfree(buf); | 
|  | 158 | return 0; | 
|  | 159 | } | 
|  | 160 |  | 
|  | 161 | static int pnp_legacyres_proc_open(struct inode *inode, struct file *file) | 
|  | 162 | { | 
|  | 163 | return single_open(file, pnp_legacyres_proc_show, NULL); | 
|  | 164 | } | 
|  | 165 |  | 
|  | 166 | static const struct file_operations pnp_legacyres_proc_fops = { | 
|  | 167 | .owner		= THIS_MODULE, | 
|  | 168 | .open		= pnp_legacyres_proc_open, | 
|  | 169 | .read		= seq_read, | 
|  | 170 | .llseek		= seq_lseek, | 
|  | 171 | .release	= single_release, | 
|  | 172 | }; | 
|  | 173 |  | 
|  | 174 | static int pnp_devices_proc_show(struct seq_file *m, void *v) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | { | 
|  | 176 | struct pnp_bios_node *node; | 
|  | 177 | u8 nodenum; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 |  | 
| Robert P. J. Day | cd86128 | 2006-12-13 00:34:52 -0800 | [diff] [blame] | 179 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 180 | if (!node) | 
|  | 181 | return -ENOMEM; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 183 | for (nodenum = 0; nodenum < 0xff;) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | u8 thisnodenum = nodenum; | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 185 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node)) | 
|  | 187 | break; | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 188 | seq_printf(m, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n", | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | node->handle, node->eisa_id, | 
|  | 190 | node->type_code[0], node->type_code[1], | 
|  | 191 | node->type_code[2], node->flags); | 
|  | 192 | if (nodenum <= thisnodenum) { | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 193 | printk(KERN_ERR | 
|  | 194 | "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", | 
|  | 195 | "PnPBIOS: proc_read_devices:", | 
|  | 196 | (unsigned int)nodenum, | 
|  | 197 | (unsigned int)thisnodenum); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | break; | 
|  | 199 | } | 
|  | 200 | } | 
|  | 201 | kfree(node); | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 202 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | } | 
|  | 204 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 205 | static int pnp_devices_proc_open(struct inode *inode, struct file *file) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | { | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 207 | return single_open(file, pnp_devices_proc_show, NULL); | 
|  | 208 | } | 
|  | 209 |  | 
|  | 210 | static const struct file_operations pnp_devices_proc_fops = { | 
|  | 211 | .owner		= THIS_MODULE, | 
|  | 212 | .open		= pnp_devices_proc_open, | 
|  | 213 | .read		= seq_read, | 
|  | 214 | .llseek		= seq_lseek, | 
|  | 215 | .release	= single_release, | 
|  | 216 | }; | 
|  | 217 |  | 
|  | 218 | static int pnpbios_proc_show(struct seq_file *m, void *v) | 
|  | 219 | { | 
|  | 220 | void *data = m->private; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | struct pnp_bios_node *node; | 
|  | 222 | int boot = (long)data >> 8; | 
|  | 223 | u8 nodenum = (long)data; | 
|  | 224 | int len; | 
|  | 225 |  | 
| Robert P. J. Day | cd86128 | 2006-12-13 00:34:52 -0800 | [diff] [blame] | 226 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 227 | if (!node) | 
|  | 228 | return -ENOMEM; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 
|  | 230 | kfree(node); | 
|  | 231 | return -EIO; | 
|  | 232 | } | 
|  | 233 | len = node->size - sizeof(struct pnp_bios_node); | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 234 | seq_write(m, node->data, len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | kfree(node); | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 236 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | } | 
|  | 238 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 239 | static int pnpbios_proc_open(struct inode *inode, struct file *file) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | { | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 241 | return single_open(file, pnpbios_proc_show, PDE(inode)->data); | 
|  | 242 | } | 
|  | 243 |  | 
|  | 244 | static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf, | 
|  | 245 | size_t count, loff_t *pos) | 
|  | 246 | { | 
|  | 247 | void *data = PDE(file->f_path.dentry->d_inode)->data; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | struct pnp_bios_node *node; | 
|  | 249 | int boot = (long)data >> 8; | 
|  | 250 | u8 nodenum = (long)data; | 
|  | 251 | int ret = count; | 
|  | 252 |  | 
| Robert P. J. Day | cd86128 | 2006-12-13 00:34:52 -0800 | [diff] [blame] | 253 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | if (!node) | 
|  | 255 | return -ENOMEM; | 
|  | 256 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 
|  | 257 | ret = -EIO; | 
|  | 258 | goto out; | 
|  | 259 | } | 
|  | 260 | if (count != node->size - sizeof(struct pnp_bios_node)) { | 
|  | 261 | ret = -EINVAL; | 
|  | 262 | goto out; | 
|  | 263 | } | 
|  | 264 | if (copy_from_user(node->data, buf, count)) { | 
|  | 265 | ret = -EFAULT; | 
|  | 266 | goto out; | 
|  | 267 | } | 
|  | 268 | if (pnp_bios_set_dev_node(node->handle, boot, node) != 0) { | 
|  | 269 | ret = -EINVAL; | 
|  | 270 | goto out; | 
|  | 271 | } | 
|  | 272 | ret = count; | 
| Bjorn Helgaas | 1e0aa9a | 2007-08-15 10:32:08 -0600 | [diff] [blame] | 273 | out: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | kfree(node); | 
|  | 275 | return ret; | 
|  | 276 | } | 
|  | 277 |  | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 278 | static const struct file_operations pnpbios_proc_fops = { | 
|  | 279 | .owner		= THIS_MODULE, | 
|  | 280 | .open		= pnpbios_proc_open, | 
|  | 281 | .read		= seq_read, | 
|  | 282 | .llseek		= seq_lseek, | 
|  | 283 | .release	= single_release, | 
|  | 284 | .write		= pnpbios_proc_write, | 
|  | 285 | }; | 
|  | 286 |  | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 287 | int pnpbios_interface_attach_device(struct pnp_bios_node *node) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { | 
|  | 289 | char name[3]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 |  | 
|  | 291 | sprintf(name, "%02x", node->handle); | 
|  | 292 |  | 
|  | 293 | if (!proc_pnp) | 
|  | 294 | return -EIO; | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 295 | if (!pnpbios_dont_use_current_config) { | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 296 | proc_create_data(name, 0644, proc_pnp, &pnpbios_proc_fops, | 
|  | 297 | (void *)(long)(node->handle)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } | 
|  | 299 |  | 
|  | 300 | if (!proc_pnp_boot) | 
|  | 301 | return -EIO; | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 302 | if (proc_create_data(name, 0644, proc_pnp_boot, &pnpbios_proc_fops, | 
|  | 303 | (void *)(long)(node->handle + 0x100))) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | return -EIO; | 
|  | 306 | } | 
|  | 307 |  | 
|  | 308 | /* | 
|  | 309 | * When this is called, pnpbios functions are assumed to | 
|  | 310 | * work and the pnpbios_dont_use_current_config flag | 
|  | 311 | * should already have been set to the appropriate value | 
|  | 312 | */ | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 313 | int __init pnpbios_proc_init(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | { | 
| Alexey Dobriyan | 9c37066 | 2008-04-29 01:01:41 -0700 | [diff] [blame] | 315 | proc_pnp = proc_mkdir("bus/pnp", NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | if (!proc_pnp) | 
|  | 317 | return -EIO; | 
|  | 318 | proc_pnp_boot = proc_mkdir("boot", proc_pnp); | 
|  | 319 | if (!proc_pnp_boot) | 
|  | 320 | return -EIO; | 
| Alexey Dobriyan | 5116fa2 | 2009-12-15 16:46:47 -0800 | [diff] [blame] | 321 | proc_create("devices", 0, proc_pnp, &pnp_devices_proc_fops); | 
|  | 322 | proc_create("configuration_info", 0, proc_pnp, &pnpconfig_proc_fops); | 
|  | 323 | proc_create("escd_info", 0, proc_pnp, &escd_info_proc_fops); | 
|  | 324 | proc_create("escd", S_IRUSR, proc_pnp, &escd_proc_fops); | 
|  | 325 | proc_create("legacy_device_resources", 0, proc_pnp, &pnp_legacyres_proc_fops); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 |  | 
|  | 327 | return 0; | 
|  | 328 | } | 
|  | 329 |  | 
|  | 330 | void __exit pnpbios_proc_exit(void) | 
|  | 331 | { | 
|  | 332 | int i; | 
|  | 333 | char name[3]; | 
|  | 334 |  | 
|  | 335 | if (!proc_pnp) | 
|  | 336 | return; | 
|  | 337 |  | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 338 | for (i = 0; i < 0xff; i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | sprintf(name, "%02x", i); | 
| Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 340 | if (!pnpbios_dont_use_current_config) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | remove_proc_entry(name, proc_pnp); | 
|  | 342 | remove_proc_entry(name, proc_pnp_boot); | 
|  | 343 | } | 
|  | 344 | remove_proc_entry("legacy_device_resources", proc_pnp); | 
|  | 345 | remove_proc_entry("escd", proc_pnp); | 
|  | 346 | remove_proc_entry("escd_info", proc_pnp); | 
|  | 347 | remove_proc_entry("configuration_info", proc_pnp); | 
|  | 348 | remove_proc_entry("devices", proc_pnp); | 
|  | 349 | remove_proc_entry("boot", proc_pnp); | 
| Alexey Dobriyan | 9c37066 | 2008-04-29 01:01:41 -0700 | [diff] [blame] | 350 | remove_proc_entry("bus/pnp", NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |