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