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