aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/pnpbios/proc.c')
-rw-r--r--drivers/pnp/pnpbios/proc.c107
1 files changed, 56 insertions, 51 deletions
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 8027073f7919..9c8c07701b65 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -18,9 +18,6 @@
18 * The other files are human-readable. 18 * The other files are human-readable.
19 */ 19 */
20 20
21//#include <pcmcia/config.h>
22//#include <pcmcia/k_compat.h>
23
24#include <linux/module.h> 21#include <linux/module.h>
25#include <linux/kernel.h> 22#include <linux/kernel.h>
26#include <linux/slab.h> 23#include <linux/slab.h>
@@ -37,42 +34,37 @@ static struct proc_dir_entry *proc_pnp = NULL;
37static struct proc_dir_entry *proc_pnp_boot = NULL; 34static struct proc_dir_entry *proc_pnp_boot = NULL;
38 35
39static int proc_read_pnpconfig(char *buf, char **start, off_t pos, 36static int proc_read_pnpconfig(char *buf, char **start, off_t pos,
40 int count, int *eof, void *data) 37 int count, int *eof, void *data)
41{ 38{
42 struct pnp_isa_config_struc pnps; 39 struct pnp_isa_config_struc pnps;
43 40
44 if (pnp_bios_isapnp_config(&pnps)) 41 if (pnp_bios_isapnp_config(&pnps))
45 return -EIO; 42 return -EIO;
46 return snprintf(buf, count, 43 return snprintf(buf, count,
47 "structure_revision %d\n" 44 "structure_revision %d\n"
48 "number_of_CSNs %d\n" 45 "number_of_CSNs %d\n"
49 "ISA_read_data_port 0x%x\n", 46 "ISA_read_data_port 0x%x\n",
50 pnps.revision, 47 pnps.revision, pnps.no_csns, pnps.isa_rd_data_port);
51 pnps.no_csns,
52 pnps.isa_rd_data_port
53 );
54} 48}
55 49
56static int proc_read_escdinfo(char *buf, char **start, off_t pos, 50static int proc_read_escdinfo(char *buf, char **start, off_t pos,
57 int count, int *eof, void *data) 51 int count, int *eof, void *data)
58{ 52{
59 struct escd_info_struc escd; 53 struct escd_info_struc escd;
60 54
61 if (pnp_bios_escd_info(&escd)) 55 if (pnp_bios_escd_info(&escd))
62 return -EIO; 56 return -EIO;
63 return snprintf(buf, count, 57 return snprintf(buf, count,
64 "min_ESCD_write_size %d\n" 58 "min_ESCD_write_size %d\n"
65 "ESCD_size %d\n" 59 "ESCD_size %d\n"
66 "NVRAM_base 0x%x\n", 60 "NVRAM_base 0x%x\n",
67 escd.min_escd_write_size, 61 escd.min_escd_write_size,
68 escd.escd_size, 62 escd.escd_size, escd.nv_storage_base);
69 escd.nv_storage_base
70 );
71} 63}
72 64
73#define MAX_SANE_ESCD_SIZE (32*1024) 65#define MAX_SANE_ESCD_SIZE (32*1024)
74static int proc_read_escd(char *buf, char **start, off_t pos, 66static int proc_read_escd(char *buf, char **start, off_t pos,
75 int count, int *eof, void *data) 67 int count, int *eof, void *data)
76{ 68{
77 struct escd_info_struc escd; 69 struct escd_info_struc escd;
78 char *tmpbuf; 70 char *tmpbuf;
@@ -83,30 +75,36 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
83 75
84 /* sanity check */ 76 /* sanity check */
85 if (escd.escd_size > MAX_SANE_ESCD_SIZE) { 77 if (escd.escd_size > MAX_SANE_ESCD_SIZE) {
86 printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n"); 78 printk(KERN_ERR
79 "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n");
87 return -EFBIG; 80 return -EFBIG;
88 } 81 }
89 82
90 tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL); 83 tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL);
91 if (!tmpbuf) return -ENOMEM; 84 if (!tmpbuf)
85 return -ENOMEM;
92 86
93 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { 87 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
94 kfree(tmpbuf); 88 kfree(tmpbuf);
95 return -EIO; 89 return -EIO;
96 } 90 }
97 91
98 escd_size = (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1])*256; 92 escd_size =
93 (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1]) * 256;
99 94
100 /* sanity check */ 95 /* sanity check */
101 if (escd_size > MAX_SANE_ESCD_SIZE) { 96 if (escd_size > MAX_SANE_ESCD_SIZE) {
102 printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n"); 97 printk(KERN_ERR
98 "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n");
103 return -EFBIG; 99 return -EFBIG;
104 } 100 }
105 101
106 escd_left_to_read = escd_size - pos; 102 escd_left_to_read = escd_size - pos;
107 if (escd_left_to_read < 0) escd_left_to_read = 0; 103 if (escd_left_to_read < 0)
108 if (escd_left_to_read == 0) *eof = 1; 104 escd_left_to_read = 0;
109 n = min(count,escd_left_to_read); 105 if (escd_left_to_read == 0)
106 *eof = 1;
107 n = min(count, escd_left_to_read);
110 memcpy(buf, tmpbuf + pos, n); 108 memcpy(buf, tmpbuf + pos, n);
111 kfree(tmpbuf); 109 kfree(tmpbuf);
112 *start = buf; 110 *start = buf;
@@ -114,17 +112,17 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
114} 112}
115 113
116static int proc_read_legacyres(char *buf, char **start, off_t pos, 114static int proc_read_legacyres(char *buf, char **start, off_t pos,
117 int count, int *eof, void *data) 115 int count, int *eof, void *data)
118{ 116{
119 /* Assume that the following won't overflow the buffer */ 117 /* Assume that the following won't overflow the buffer */
120 if (pnp_bios_get_stat_res(buf)) 118 if (pnp_bios_get_stat_res(buf))
121 return -EIO; 119 return -EIO;
122 120
123 return count; // FIXME: Return actual length 121 return count; // FIXME: Return actual length
124} 122}
125 123
126static int proc_read_devices(char *buf, char **start, off_t pos, 124static int proc_read_devices(char *buf, char **start, off_t pos,
127 int count, int *eof, void *data) 125 int count, int *eof, void *data)
128{ 126{
129 struct pnp_bios_node *node; 127 struct pnp_bios_node *node;
130 u8 nodenum; 128 u8 nodenum;
@@ -134,9 +132,10 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
134 return 0; 132 return 0;
135 133
136 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 134 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
137 if (!node) return -ENOMEM; 135 if (!node)
136 return -ENOMEM;
138 137
139 for (nodenum=pos; nodenum<0xff; ) { 138 for (nodenum = pos; nodenum < 0xff;) {
140 u8 thisnodenum = nodenum; 139 u8 thisnodenum = nodenum;
141 /* 26 = the number of characters per line sprintf'ed */ 140 /* 26 = the number of characters per line sprintf'ed */
142 if ((p - buf + 26) > count) 141 if ((p - buf + 26) > count)
@@ -148,7 +147,11 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
148 node->type_code[0], node->type_code[1], 147 node->type_code[0], node->type_code[1],
149 node->type_code[2], node->flags); 148 node->type_code[2], node->flags);
150 if (nodenum <= thisnodenum) { 149 if (nodenum <= thisnodenum) {
151 printk(KERN_ERR "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", "PnPBIOS: proc_read_devices:", (unsigned int)nodenum, (unsigned int)thisnodenum); 150 printk(KERN_ERR
151 "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n",
152 "PnPBIOS: proc_read_devices:",
153 (unsigned int)nodenum,
154 (unsigned int)thisnodenum);
152 *eof = 1; 155 *eof = 1;
153 break; 156 break;
154 } 157 }
@@ -156,12 +159,12 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
156 kfree(node); 159 kfree(node);
157 if (nodenum == 0xff) 160 if (nodenum == 0xff)
158 *eof = 1; 161 *eof = 1;
159 *start = (char *)((off_t)nodenum - pos); 162 *start = (char *)((off_t) nodenum - pos);
160 return p - buf; 163 return p - buf;
161} 164}
162 165
163static int proc_read_node(char *buf, char **start, off_t pos, 166static int proc_read_node(char *buf, char **start, off_t pos,
164 int count, int *eof, void *data) 167 int count, int *eof, void *data)
165{ 168{
166 struct pnp_bios_node *node; 169 struct pnp_bios_node *node;
167 int boot = (long)data >> 8; 170 int boot = (long)data >> 8;
@@ -169,7 +172,8 @@ static int proc_read_node(char *buf, char **start, off_t pos,
169 int len; 172 int len;
170 173
171 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 174 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
172 if (!node) return -ENOMEM; 175 if (!node)
176 return -ENOMEM;
173 if (pnp_bios_get_dev_node(&nodenum, boot, node)) { 177 if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
174 kfree(node); 178 kfree(node);
175 return -EIO; 179 return -EIO;
@@ -180,8 +184,8 @@ static int proc_read_node(char *buf, char **start, off_t pos,
180 return len; 184 return len;
181} 185}
182 186
183static int proc_write_node(struct file *file, const char __user *buf, 187static int proc_write_node(struct file *file, const char __user * buf,
184 unsigned long count, void *data) 188 unsigned long count, void *data)
185{ 189{
186 struct pnp_bios_node *node; 190 struct pnp_bios_node *node;
187 int boot = (long)data >> 8; 191 int boot = (long)data >> 8;
@@ -208,12 +212,12 @@ static int proc_write_node(struct file *file, const char __user *buf,
208 goto out; 212 goto out;
209 } 213 }
210 ret = count; 214 ret = count;
211out: 215 out:
212 kfree(node); 216 kfree(node);
213 return ret; 217 return ret;
214} 218}
215 219
216int pnpbios_interface_attach_device(struct pnp_bios_node * node) 220int pnpbios_interface_attach_device(struct pnp_bios_node *node)
217{ 221{
218 char name[3]; 222 char name[3];
219 struct proc_dir_entry *ent; 223 struct proc_dir_entry *ent;
@@ -222,7 +226,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
222 226
223 if (!proc_pnp) 227 if (!proc_pnp)
224 return -EIO; 228 return -EIO;
225 if ( !pnpbios_dont_use_current_config ) { 229 if (!pnpbios_dont_use_current_config) {
226 ent = create_proc_entry(name, 0, proc_pnp); 230 ent = create_proc_entry(name, 0, proc_pnp);
227 if (ent) { 231 if (ent) {
228 ent->read_proc = proc_read_node; 232 ent->read_proc = proc_read_node;
@@ -237,7 +241,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
237 if (ent) { 241 if (ent) {
238 ent->read_proc = proc_read_node; 242 ent->read_proc = proc_read_node;
239 ent->write_proc = proc_write_node; 243 ent->write_proc = proc_write_node;
240 ent->data = (void *)(long)(node->handle+0x100); 244 ent->data = (void *)(long)(node->handle + 0x100);
241 return 0; 245 return 0;
242 } 246 }
243 247
@@ -249,7 +253,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
249 * work and the pnpbios_dont_use_current_config flag 253 * work and the pnpbios_dont_use_current_config flag
250 * should already have been set to the appropriate value 254 * should already have been set to the appropriate value
251 */ 255 */
252int __init pnpbios_proc_init( void ) 256int __init pnpbios_proc_init(void)
253{ 257{
254 proc_pnp = proc_mkdir("pnp", proc_bus); 258 proc_pnp = proc_mkdir("pnp", proc_bus);
255 if (!proc_pnp) 259 if (!proc_pnp)
@@ -258,10 +262,13 @@ int __init pnpbios_proc_init( void )
258 if (!proc_pnp_boot) 262 if (!proc_pnp_boot)
259 return -EIO; 263 return -EIO;
260 create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL); 264 create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL);
261 create_proc_read_entry("configuration_info", 0, proc_pnp, proc_read_pnpconfig, NULL); 265 create_proc_read_entry("configuration_info", 0, proc_pnp,
262 create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo, NULL); 266 proc_read_pnpconfig, NULL);
267 create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo,
268 NULL);
263 create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL); 269 create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL);
264 create_proc_read_entry("legacy_device_resources", 0, proc_pnp, proc_read_legacyres, NULL); 270 create_proc_read_entry("legacy_device_resources", 0, proc_pnp,
271 proc_read_legacyres, NULL);
265 272
266 return 0; 273 return 0;
267} 274}
@@ -274,9 +281,9 @@ void __exit pnpbios_proc_exit(void)
274 if (!proc_pnp) 281 if (!proc_pnp)
275 return; 282 return;
276 283
277 for (i=0; i<0xff; i++) { 284 for (i = 0; i < 0xff; i++) {
278 sprintf(name, "%02x", i); 285 sprintf(name, "%02x", i);
279 if ( !pnpbios_dont_use_current_config ) 286 if (!pnpbios_dont_use_current_config)
280 remove_proc_entry(name, proc_pnp); 287 remove_proc_entry(name, proc_pnp);
281 remove_proc_entry(name, proc_pnp_boot); 288 remove_proc_entry(name, proc_pnp_boot);
282 } 289 }
@@ -287,6 +294,4 @@ void __exit pnpbios_proc_exit(void)
287 remove_proc_entry("devices", proc_pnp); 294 remove_proc_entry("devices", proc_pnp);
288 remove_proc_entry("boot", proc_pnp); 295 remove_proc_entry("boot", proc_pnp);
289 remove_proc_entry("pnp", proc_bus); 296 remove_proc_entry("pnp", proc_bus);
290
291 return;
292} 297}