1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ISA Plug & Play support
4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
7 #include <linux/module.h>
8 #include <linux/isapnp.h>
9 #include <linux/proc_fs.h>
10 #include <linux/init.h>
11 #include <linux/uaccess.h>
13 extern struct pnp_protocol isapnp_protocol;
15 static struct proc_dir_entry *isapnp_proc_bus_dir = NULL;
17 static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
19 return fixed_size_llseek(file, off, whence, 256);
22 static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
23 size_t nbytes, loff_t * ppos)
25 struct pnp_dev *dev = PDE_DATA(file_inode(file));
33 if (pos + nbytes > size)
37 if (!access_ok(buf, cnt))
40 isapnp_cfg_begin(dev->card->number, dev->number);
41 for (; pos < 256 && cnt > 0; pos++, buf++, cnt--) {
43 val = isapnp_read_byte(pos);
52 static const struct file_operations isapnp_proc_bus_file_operations = {
54 .llseek = isapnp_proc_bus_lseek,
55 .read = isapnp_proc_bus_read,
58 static int isapnp_proc_attach_device(struct pnp_dev *dev)
60 struct pnp_card *bus = dev->card;
61 struct proc_dir_entry *de, *e;
64 if (!(de = bus->procdir)) {
65 sprintf(name, "%02x", bus->number);
66 de = bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir);
70 sprintf(name, "%02x", dev->number);
71 e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de,
72 &isapnp_proc_bus_file_operations, dev);
75 proc_set_size(e, 256);
79 int __init isapnp_proc_init(void)
83 isapnp_proc_bus_dir = proc_mkdir("bus/isapnp", NULL);
84 protocol_for_each_dev(&isapnp_protocol, dev) {
85 isapnp_proc_attach_device(dev);