2 * ISA Plug & Play support
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <linux/module.h>
21 #include <linux/isapnp.h>
22 #include <linux/proc_fs.h>
23 #include <linux/init.h>
24 #include <asm/uaccess.h>
26 extern struct pnp_protocol isapnp_protocol
;
28 static struct proc_dir_entry
*isapnp_proc_bus_dir
= NULL
;
30 static loff_t
isapnp_proc_bus_lseek(struct file
*file
, loff_t off
, int whence
)
33 struct inode
*inode
= file_inode(file
);
35 mutex_lock(&inode
->i_mutex
);
41 new = file
->f_pos
+ off
;
47 if (new < 0 || new > 256)
51 mutex_unlock(&inode
->i_mutex
);
55 static ssize_t
isapnp_proc_bus_read(struct file
*file
, char __user
* buf
,
56 size_t nbytes
, loff_t
* ppos
)
58 struct pnp_dev
*dev
= PDE_DATA(file_inode(file
));
66 if (pos
+ nbytes
> size
)
70 if (!access_ok(VERIFY_WRITE
, buf
, cnt
))
73 isapnp_cfg_begin(dev
->card
->number
, dev
->number
);
74 for (; pos
< 256 && cnt
> 0; pos
++, buf
++, cnt
--) {
76 val
= isapnp_read_byte(pos
);
85 static const struct file_operations isapnp_proc_bus_file_operations
= {
87 .llseek
= isapnp_proc_bus_lseek
,
88 .read
= isapnp_proc_bus_read
,
91 static int isapnp_proc_attach_device(struct pnp_dev
*dev
)
93 struct pnp_card
*bus
= dev
->card
;
94 struct proc_dir_entry
*de
, *e
;
97 if (!(de
= bus
->procdir
)) {
98 sprintf(name
, "%02x", bus
->number
);
99 de
= bus
->procdir
= proc_mkdir(name
, isapnp_proc_bus_dir
);
103 sprintf(name
, "%02x", dev
->number
);
104 e
= dev
->procent
= proc_create_data(name
, S_IFREG
| S_IRUGO
, de
,
105 &isapnp_proc_bus_file_operations
, dev
);
112 int __init
isapnp_proc_init(void)
116 isapnp_proc_bus_dir
= proc_mkdir("bus/isapnp", NULL
);
117 protocol_for_each_dev(&isapnp_protocol
, dev
) {
118 isapnp_proc_attach_device(dev
);