diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2007-07-26 13:41:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-26 14:35:20 -0400 |
commit | 9dd78466c956ac4b4f38e12032dc4249ccf57ad1 (patch) | |
tree | 57ee3822b79049d38c1df952fe77e72a97c718f3 /drivers | |
parent | 8ec3cf7d29aef773eee5bc6cd9b0fa4d3fb42480 (diff) |
PNP: Lindent all source files
Run Lindent on all PNP source files.
Produced by:
$ quilt new pnp-lindent
$ find drivers/pnp -name \*.[ch] | xargs quilt add
$ quilt add include/linux/{pnp.h,pnpbios.h}
$ scripts/Lindent drivers/pnp/*.c drivers/pnp/*/*.c include/linux/pnp*.h
$ quilt refresh --sort
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Adam Belay <ambx1@neo.rr.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnp/card.c | 135 | ||||
-rw-r--r-- | drivers/pnp/core.c | 25 | ||||
-rw-r--r-- | drivers/pnp/driver.c | 58 | ||||
-rw-r--r-- | drivers/pnp/interface.c | 215 | ||||
-rw-r--r-- | drivers/pnp/isapnp/compat.c | 30 | ||||
-rw-r--r-- | drivers/pnp/isapnp/core.c | 302 | ||||
-rw-r--r-- | drivers/pnp/isapnp/proc.c | 14 | ||||
-rw-r--r-- | drivers/pnp/manager.c | 120 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 87 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/rsparser.c | 435 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/bioscalls.c | 282 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/core.c | 241 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/proc.c | 102 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/rsparser.c | 278 | ||||
-rw-r--r-- | drivers/pnp/quirks.c | 79 | ||||
-rw-r--r-- | drivers/pnp/resource.c | 79 | ||||
-rw-r--r-- | drivers/pnp/support.c | 9 | ||||
-rw-r--r-- | drivers/pnp/system.c | 38 |
18 files changed, 1384 insertions, 1145 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index dd6384b1efce..a379a38c196c 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c | |||
@@ -13,26 +13,28 @@ | |||
13 | LIST_HEAD(pnp_cards); | 13 | LIST_HEAD(pnp_cards); |
14 | static LIST_HEAD(pnp_card_drivers); | 14 | static LIST_HEAD(pnp_card_drivers); |
15 | 15 | ||
16 | 16 | static const struct pnp_card_device_id *match_card(struct pnp_card_driver *drv, | |
17 | static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card) | 17 | struct pnp_card *card) |
18 | { | 18 | { |
19 | const struct pnp_card_device_id * drv_id = drv->id_table; | 19 | const struct pnp_card_device_id *drv_id = drv->id_table; |
20 | while (*drv_id->id){ | 20 | while (*drv_id->id) { |
21 | if (compare_pnp_id(card->id,drv_id->id)) { | 21 | if (compare_pnp_id(card->id, drv_id->id)) { |
22 | int i = 0; | 22 | int i = 0; |
23 | for (;;) { | 23 | for (;;) { |
24 | int found; | 24 | int found; |
25 | struct pnp_dev *dev; | 25 | struct pnp_dev *dev; |
26 | if (i == PNP_MAX_DEVICES || ! *drv_id->devs[i].id) | 26 | if (i == PNP_MAX_DEVICES |
27 | || !*drv_id->devs[i].id) | ||
27 | return drv_id; | 28 | return drv_id; |
28 | found = 0; | 29 | found = 0; |
29 | card_for_each_dev(card, dev) { | 30 | card_for_each_dev(card, dev) { |
30 | if (compare_pnp_id(dev->id, drv_id->devs[i].id)) { | 31 | if (compare_pnp_id |
32 | (dev->id, drv_id->devs[i].id)) { | ||
31 | found = 1; | 33 | found = 1; |
32 | break; | 34 | break; |
33 | } | 35 | } |
34 | } | 36 | } |
35 | if (! found) | 37 | if (!found) |
36 | break; | 38 | break; |
37 | i++; | 39 | i++; |
38 | } | 40 | } |
@@ -42,14 +44,14 @@ static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv | |||
42 | return NULL; | 44 | return NULL; |
43 | } | 45 | } |
44 | 46 | ||
45 | static void card_remove(struct pnp_dev * dev) | 47 | static void card_remove(struct pnp_dev *dev) |
46 | { | 48 | { |
47 | dev->card_link = NULL; | 49 | dev->card_link = NULL; |
48 | } | 50 | } |
49 | 51 | ||
50 | static void card_remove_first(struct pnp_dev * dev) | 52 | static void card_remove_first(struct pnp_dev *dev) |
51 | { | 53 | { |
52 | struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver); | 54 | struct pnp_card_driver *drv = to_pnp_card_driver(dev->driver); |
53 | if (!dev->card || !drv) | 55 | if (!dev->card || !drv) |
54 | return; | 56 | return; |
55 | if (drv->remove) | 57 | if (drv->remove) |
@@ -67,7 +69,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv) | |||
67 | 69 | ||
68 | if (!drv->probe) | 70 | if (!drv->probe) |
69 | return 0; | 71 | return 0; |
70 | id = match_card(drv,card); | 72 | id = match_card(drv, card); |
71 | if (!id) | 73 | if (!id) |
72 | return 0; | 74 | return 0; |
73 | 75 | ||
@@ -97,9 +99,9 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv) | |||
97 | * | 99 | * |
98 | */ | 100 | */ |
99 | 101 | ||
100 | int pnp_add_card_id(struct pnp_id *id, struct pnp_card * card) | 102 | int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) |
101 | { | 103 | { |
102 | struct pnp_id * ptr; | 104 | struct pnp_id *ptr; |
103 | if (!id) | 105 | if (!id) |
104 | return -EINVAL; | 106 | return -EINVAL; |
105 | if (!card) | 107 | if (!card) |
@@ -115,9 +117,9 @@ int pnp_add_card_id(struct pnp_id *id, struct pnp_card * card) | |||
115 | return 0; | 117 | return 0; |
116 | } | 118 | } |
117 | 119 | ||
118 | static void pnp_free_card_ids(struct pnp_card * card) | 120 | static void pnp_free_card_ids(struct pnp_card *card) |
119 | { | 121 | { |
120 | struct pnp_id * id; | 122 | struct pnp_id *id; |
121 | struct pnp_id *next; | 123 | struct pnp_id *next; |
122 | if (!card) | 124 | if (!card) |
123 | return; | 125 | return; |
@@ -131,49 +133,52 @@ static void pnp_free_card_ids(struct pnp_card * card) | |||
131 | 133 | ||
132 | static void pnp_release_card(struct device *dmdev) | 134 | static void pnp_release_card(struct device *dmdev) |
133 | { | 135 | { |
134 | struct pnp_card * card = to_pnp_card(dmdev); | 136 | struct pnp_card *card = to_pnp_card(dmdev); |
135 | pnp_free_card_ids(card); | 137 | pnp_free_card_ids(card); |
136 | kfree(card); | 138 | kfree(card); |
137 | } | 139 | } |
138 | 140 | ||
139 | 141 | static ssize_t pnp_show_card_name(struct device *dmdev, | |
140 | static ssize_t pnp_show_card_name(struct device *dmdev, struct device_attribute *attr, char *buf) | 142 | struct device_attribute *attr, char *buf) |
141 | { | 143 | { |
142 | char *str = buf; | 144 | char *str = buf; |
143 | struct pnp_card *card = to_pnp_card(dmdev); | 145 | struct pnp_card *card = to_pnp_card(dmdev); |
144 | str += sprintf(str,"%s\n", card->name); | 146 | str += sprintf(str, "%s\n", card->name); |
145 | return (str - buf); | 147 | return (str - buf); |
146 | } | 148 | } |
147 | 149 | ||
148 | static DEVICE_ATTR(name,S_IRUGO,pnp_show_card_name,NULL); | 150 | static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL); |
149 | 151 | ||
150 | static ssize_t pnp_show_card_ids(struct device *dmdev, struct device_attribute *attr, char *buf) | 152 | static ssize_t pnp_show_card_ids(struct device *dmdev, |
153 | struct device_attribute *attr, char *buf) | ||
151 | { | 154 | { |
152 | char *str = buf; | 155 | char *str = buf; |
153 | struct pnp_card *card = to_pnp_card(dmdev); | 156 | struct pnp_card *card = to_pnp_card(dmdev); |
154 | struct pnp_id * pos = card->id; | 157 | struct pnp_id *pos = card->id; |
155 | 158 | ||
156 | while (pos) { | 159 | while (pos) { |
157 | str += sprintf(str,"%s\n", pos->id); | 160 | str += sprintf(str, "%s\n", pos->id); |
158 | pos = pos->next; | 161 | pos = pos->next; |
159 | } | 162 | } |
160 | return (str - buf); | 163 | return (str - buf); |
161 | } | 164 | } |
162 | 165 | ||
163 | static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL); | 166 | static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL); |
164 | 167 | ||
165 | static int pnp_interface_attach_card(struct pnp_card *card) | 168 | static int pnp_interface_attach_card(struct pnp_card *card) |
166 | { | 169 | { |
167 | int rc = device_create_file(&card->dev,&dev_attr_name); | 170 | int rc = device_create_file(&card->dev, &dev_attr_name); |
168 | if (rc) return rc; | 171 | if (rc) |
172 | return rc; | ||
169 | 173 | ||
170 | rc = device_create_file(&card->dev,&dev_attr_card_id); | 174 | rc = device_create_file(&card->dev, &dev_attr_card_id); |
171 | if (rc) goto err_name; | 175 | if (rc) |
176 | goto err_name; | ||
172 | 177 | ||
173 | return 0; | 178 | return 0; |
174 | 179 | ||
175 | err_name: | 180 | err_name: |
176 | device_remove_file(&card->dev,&dev_attr_name); | 181 | device_remove_file(&card->dev, &dev_attr_name); |
177 | return rc; | 182 | return rc; |
178 | } | 183 | } |
179 | 184 | ||
@@ -182,14 +187,15 @@ err_name: | |||
182 | * @card: pointer to the card to add | 187 | * @card: pointer to the card to add |
183 | */ | 188 | */ |
184 | 189 | ||
185 | int pnp_add_card(struct pnp_card * card) | 190 | int pnp_add_card(struct pnp_card *card) |
186 | { | 191 | { |
187 | int error; | 192 | int error; |
188 | struct list_head * pos, * temp; | 193 | struct list_head *pos, *temp; |
189 | if (!card || !card->protocol) | 194 | if (!card || !card->protocol) |
190 | return -EINVAL; | 195 | return -EINVAL; |
191 | 196 | ||
192 | sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number, card->number); | 197 | sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number, |
198 | card->number); | ||
193 | card->dev.parent = &card->protocol->dev; | 199 | card->dev.parent = &card->protocol->dev; |
194 | card->dev.bus = NULL; | 200 | card->dev.bus = NULL; |
195 | card->dev.release = &pnp_release_card; | 201 | card->dev.release = &pnp_release_card; |
@@ -205,18 +211,21 @@ int pnp_add_card(struct pnp_card * card) | |||
205 | /* we wait until now to add devices in order to ensure the drivers | 211 | /* we wait until now to add devices in order to ensure the drivers |
206 | * will be able to use all of the related devices on the card | 212 | * will be able to use all of the related devices on the card |
207 | * without waiting any unresonable length of time */ | 213 | * without waiting any unresonable length of time */ |
208 | list_for_each(pos,&card->devices){ | 214 | list_for_each(pos, &card->devices) { |
209 | struct pnp_dev *dev = card_to_pnp_dev(pos); | 215 | struct pnp_dev *dev = card_to_pnp_dev(pos); |
210 | __pnp_add_device(dev); | 216 | __pnp_add_device(dev); |
211 | } | 217 | } |
212 | 218 | ||
213 | /* match with card drivers */ | 219 | /* match with card drivers */ |
214 | list_for_each_safe(pos,temp,&pnp_card_drivers){ | 220 | list_for_each_safe(pos, temp, &pnp_card_drivers) { |
215 | struct pnp_card_driver * drv = list_entry(pos, struct pnp_card_driver, global_list); | 221 | struct pnp_card_driver *drv = |
216 | card_probe(card,drv); | 222 | list_entry(pos, struct pnp_card_driver, |
223 | global_list); | ||
224 | card_probe(card, drv); | ||
217 | } | 225 | } |
218 | } else | 226 | } else |
219 | pnp_err("sysfs failure, card '%s' will be unavailable", card->dev.bus_id); | 227 | pnp_err("sysfs failure, card '%s' will be unavailable", |
228 | card->dev.bus_id); | ||
220 | return error; | 229 | return error; |
221 | } | 230 | } |
222 | 231 | ||
@@ -225,7 +234,7 @@ int pnp_add_card(struct pnp_card * card) | |||
225 | * @card: pointer to the card to remove | 234 | * @card: pointer to the card to remove |
226 | */ | 235 | */ |
227 | 236 | ||
228 | void pnp_remove_card(struct pnp_card * card) | 237 | void pnp_remove_card(struct pnp_card *card) |
229 | { | 238 | { |
230 | struct list_head *pos, *temp; | 239 | struct list_head *pos, *temp; |
231 | if (!card) | 240 | if (!card) |
@@ -235,7 +244,7 @@ void pnp_remove_card(struct pnp_card * card) | |||
235 | list_del(&card->global_list); | 244 | list_del(&card->global_list); |
236 | list_del(&card->protocol_list); | 245 | list_del(&card->protocol_list); |
237 | spin_unlock(&pnp_lock); | 246 | spin_unlock(&pnp_lock); |
238 | list_for_each_safe(pos,temp,&card->devices){ | 247 | list_for_each_safe(pos, temp, &card->devices) { |
239 | struct pnp_dev *dev = card_to_pnp_dev(pos); | 248 | struct pnp_dev *dev = card_to_pnp_dev(pos); |
240 | pnp_remove_card_device(dev); | 249 | pnp_remove_card_device(dev); |
241 | } | 250 | } |
@@ -247,14 +256,14 @@ void pnp_remove_card(struct pnp_card * card) | |||
247 | * @dev: pointer to the device to add | 256 | * @dev: pointer to the device to add |
248 | */ | 257 | */ |
249 | 258 | ||
250 | int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev) | 259 | int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) |
251 | { | 260 | { |
252 | if (!card || !dev || !dev->protocol) | 261 | if (!card || !dev || !dev->protocol) |
253 | return -EINVAL; | 262 | return -EINVAL; |
254 | dev->dev.parent = &card->dev; | 263 | dev->dev.parent = &card->dev; |
255 | dev->card_link = NULL; | 264 | dev->card_link = NULL; |
256 | snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x", dev->protocol->number, | 265 | snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x", |
257 | card->number,dev->number); | 266 | dev->protocol->number, card->number, dev->number); |
258 | spin_lock(&pnp_lock); | 267 | spin_lock(&pnp_lock); |
259 | dev->card = card; | 268 | dev->card = card; |
260 | list_add_tail(&dev->card_list, &card->devices); | 269 | list_add_tail(&dev->card_list, &card->devices); |
@@ -267,7 +276,7 @@ int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev) | |||
267 | * @dev: pointer to the device to remove | 276 | * @dev: pointer to the device to remove |
268 | */ | 277 | */ |
269 | 278 | ||
270 | void pnp_remove_card_device(struct pnp_dev * dev) | 279 | void pnp_remove_card_device(struct pnp_dev *dev) |
271 | { | 280 | { |
272 | spin_lock(&pnp_lock); | 281 | spin_lock(&pnp_lock); |
273 | dev->card = NULL; | 282 | dev->card = NULL; |
@@ -283,12 +292,13 @@ void pnp_remove_card_device(struct pnp_dev * dev) | |||
283 | * @from: Starting place to search from. If NULL it will start from the begining. | 292 | * @from: Starting place to search from. If NULL it will start from the begining. |
284 | */ | 293 | */ |
285 | 294 | ||
286 | struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from) | 295 | struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, |
296 | const char *id, struct pnp_dev *from) | ||
287 | { | 297 | { |
288 | struct list_head * pos; | 298 | struct list_head *pos; |
289 | struct pnp_dev * dev; | 299 | struct pnp_dev *dev; |
290 | struct pnp_card_driver * drv; | 300 | struct pnp_card_driver *drv; |
291 | struct pnp_card * card; | 301 | struct pnp_card *card; |
292 | if (!clink || !id) | 302 | if (!clink || !id) |
293 | goto done; | 303 | goto done; |
294 | card = clink->card; | 304 | card = clink->card; |
@@ -302,15 +312,15 @@ struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char | |||
302 | } | 312 | } |
303 | while (pos != &card->devices) { | 313 | while (pos != &card->devices) { |
304 | dev = card_to_pnp_dev(pos); | 314 | dev = card_to_pnp_dev(pos); |
305 | if ((!dev->card_link) && compare_pnp_id(dev->id,id)) | 315 | if ((!dev->card_link) && compare_pnp_id(dev->id, id)) |
306 | goto found; | 316 | goto found; |
307 | pos = pos->next; | 317 | pos = pos->next; |
308 | } | 318 | } |
309 | 319 | ||
310 | done: | 320 | done: |
311 | return NULL; | 321 | return NULL; |
312 | 322 | ||
313 | found: | 323 | found: |
314 | dev->card_link = clink; | 324 | dev->card_link = clink; |
315 | dev->dev.driver = &drv->link.driver; | 325 | dev->dev.driver = &drv->link.driver; |
316 | if (pnp_bus_type.probe(&dev->dev)) | 326 | if (pnp_bus_type.probe(&dev->dev)) |
@@ -320,7 +330,7 @@ found: | |||
320 | 330 | ||
321 | return dev; | 331 | return dev; |
322 | 332 | ||
323 | err_out: | 333 | err_out: |
324 | dev->dev.driver = NULL; | 334 | dev->dev.driver = NULL; |
325 | dev->card_link = NULL; | 335 | dev->card_link = NULL; |
326 | return NULL; | 336 | return NULL; |
@@ -331,9 +341,9 @@ err_out: | |||
331 | * @dev: pointer to the PnP device stucture | 341 | * @dev: pointer to the PnP device stucture |
332 | */ | 342 | */ |
333 | 343 | ||
334 | void pnp_release_card_device(struct pnp_dev * dev) | 344 | void pnp_release_card_device(struct pnp_dev *dev) |
335 | { | 345 | { |
336 | struct pnp_card_driver * drv = dev->card_link->driver; | 346 | struct pnp_card_driver *drv = dev->card_link->driver; |
337 | if (!drv) | 347 | if (!drv) |
338 | return; | 348 | return; |
339 | drv->link.remove = &card_remove; | 349 | drv->link.remove = &card_remove; |
@@ -368,7 +378,7 @@ static int card_resume(struct pnp_dev *dev) | |||
368 | * @drv: pointer to the driver to register | 378 | * @drv: pointer to the driver to register |
369 | */ | 379 | */ |
370 | 380 | ||
371 | int pnp_register_card_driver(struct pnp_card_driver * drv) | 381 | int pnp_register_card_driver(struct pnp_card_driver *drv) |
372 | { | 382 | { |
373 | int error; | 383 | int error; |
374 | struct list_head *pos, *temp; | 384 | struct list_head *pos, *temp; |
@@ -389,9 +399,10 @@ int pnp_register_card_driver(struct pnp_card_driver * drv) | |||
389 | list_add_tail(&drv->global_list, &pnp_card_drivers); | 399 | list_add_tail(&drv->global_list, &pnp_card_drivers); |
390 | spin_unlock(&pnp_lock); | 400 | spin_unlock(&pnp_lock); |
391 | 401 | ||
392 | list_for_each_safe(pos,temp,&pnp_cards){ | 402 | list_for_each_safe(pos, temp, &pnp_cards) { |
393 | struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); | 403 | struct pnp_card *card = |
394 | card_probe(card,drv); | 404 | list_entry(pos, struct pnp_card, global_list); |
405 | card_probe(card, drv); | ||
395 | } | 406 | } |
396 | return 0; | 407 | return 0; |
397 | } | 408 | } |
@@ -401,7 +412,7 @@ int pnp_register_card_driver(struct pnp_card_driver * drv) | |||
401 | * @drv: pointer to the driver to unregister | 412 | * @drv: pointer to the driver to unregister |
402 | */ | 413 | */ |
403 | 414 | ||
404 | void pnp_unregister_card_driver(struct pnp_card_driver * drv) | 415 | void pnp_unregister_card_driver(struct pnp_card_driver *drv) |
405 | { | 416 | { |
406 | spin_lock(&pnp_lock); | 417 | spin_lock(&pnp_lock); |
407 | list_del(&drv->global_list); | 418 | list_del(&drv->global_list); |
@@ -415,7 +426,7 @@ EXPORT_SYMBOL(pnp_remove_card); | |||
415 | EXPORT_SYMBOL(pnp_add_card_device); | 426 | EXPORT_SYMBOL(pnp_add_card_device); |
416 | EXPORT_SYMBOL(pnp_remove_card_device); | 427 | EXPORT_SYMBOL(pnp_remove_card_device); |
417 | EXPORT_SYMBOL(pnp_add_card_id); | 428 | EXPORT_SYMBOL(pnp_add_card_id); |
418 | #endif /* 0 */ | 429 | #endif /* 0 */ |
419 | EXPORT_SYMBOL(pnp_request_card_device); | 430 | EXPORT_SYMBOL(pnp_request_card_device); |
420 | EXPORT_SYMBOL(pnp_release_card_device); | 431 | EXPORT_SYMBOL(pnp_release_card_device); |
421 | EXPORT_SYMBOL(pnp_register_card_driver); | 432 | EXPORT_SYMBOL(pnp_register_card_driver); |
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 8e7b2dd38810..1dfdc325211d 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c | |||
@@ -18,7 +18,6 @@ | |||
18 | 18 | ||
19 | #include "base.h" | 19 | #include "base.h" |
20 | 20 | ||
21 | |||
22 | static LIST_HEAD(pnp_protocols); | 21 | static LIST_HEAD(pnp_protocols); |
23 | LIST_HEAD(pnp_global); | 22 | LIST_HEAD(pnp_global); |
24 | DEFINE_SPINLOCK(pnp_lock); | 23 | DEFINE_SPINLOCK(pnp_lock); |
@@ -36,7 +35,7 @@ void *pnp_alloc(long size) | |||
36 | void *result; | 35 | void *result; |
37 | 36 | ||
38 | result = kzalloc(size, GFP_KERNEL); | 37 | result = kzalloc(size, GFP_KERNEL); |
39 | if (!result){ | 38 | if (!result) { |
40 | printk(KERN_ERR "pnp: Out of Memory\n"); | 39 | printk(KERN_ERR "pnp: Out of Memory\n"); |
41 | return NULL; | 40 | return NULL; |
42 | } | 41 | } |
@@ -53,7 +52,7 @@ void *pnp_alloc(long size) | |||
53 | int pnp_register_protocol(struct pnp_protocol *protocol) | 52 | int pnp_register_protocol(struct pnp_protocol *protocol) |
54 | { | 53 | { |
55 | int nodenum; | 54 | int nodenum; |
56 | struct list_head * pos; | 55 | struct list_head *pos; |
57 | 56 | ||
58 | if (!protocol) | 57 | if (!protocol) |
59 | return -EINVAL; | 58 | return -EINVAL; |
@@ -64,9 +63,9 @@ int pnp_register_protocol(struct pnp_protocol *protocol) | |||
64 | spin_lock(&pnp_lock); | 63 | spin_lock(&pnp_lock); |
65 | 64 | ||
66 | /* assign the lowest unused number */ | 65 | /* assign the lowest unused number */ |
67 | list_for_each(pos,&pnp_protocols) { | 66 | list_for_each(pos, &pnp_protocols) { |
68 | struct pnp_protocol * cur = to_pnp_protocol(pos); | 67 | struct pnp_protocol *cur = to_pnp_protocol(pos); |
69 | if (cur->number == nodenum){ | 68 | if (cur->number == nodenum) { |
70 | pos = &pnp_protocols; | 69 | pos = &pnp_protocols; |
71 | nodenum++; | 70 | nodenum++; |
72 | } | 71 | } |
@@ -93,11 +92,10 @@ void pnp_unregister_protocol(struct pnp_protocol *protocol) | |||
93 | device_unregister(&protocol->dev); | 92 | device_unregister(&protocol->dev); |
94 | } | 93 | } |
95 | 94 | ||
96 | |||
97 | static void pnp_free_ids(struct pnp_dev *dev) | 95 | static void pnp_free_ids(struct pnp_dev *dev) |
98 | { | 96 | { |
99 | struct pnp_id * id; | 97 | struct pnp_id *id; |
100 | struct pnp_id * next; | 98 | struct pnp_id *next; |
101 | if (!dev) | 99 | if (!dev) |
102 | return; | 100 | return; |
103 | id = dev->id; | 101 | id = dev->id; |
@@ -110,7 +108,7 @@ static void pnp_free_ids(struct pnp_dev *dev) | |||
110 | 108 | ||
111 | static void pnp_release_device(struct device *dmdev) | 109 | static void pnp_release_device(struct device *dmdev) |
112 | { | 110 | { |
113 | struct pnp_dev * dev = to_pnp_dev(dmdev); | 111 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
114 | pnp_free_option(dev->independent); | 112 | pnp_free_option(dev->independent); |
115 | pnp_free_option(dev->dependent); | 113 | pnp_free_option(dev->dependent); |
116 | pnp_free_ids(dev); | 114 | pnp_free_ids(dev); |
@@ -149,7 +147,8 @@ int pnp_add_device(struct pnp_dev *dev) | |||
149 | if (!dev || !dev->protocol || dev->card) | 147 | if (!dev || !dev->protocol || dev->card) |
150 | return -EINVAL; | 148 | return -EINVAL; |
151 | dev->dev.parent = &dev->protocol->dev; | 149 | dev->dev.parent = &dev->protocol->dev; |
152 | sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, dev->number); | 150 | sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, |
151 | dev->number); | ||
153 | return __pnp_add_device(dev); | 152 | return __pnp_add_device(dev); |
154 | } | 153 | } |
155 | 154 | ||
@@ -175,7 +174,7 @@ void pnp_remove_device(struct pnp_dev *dev) | |||
175 | return; | 174 | return; |
176 | __pnp_remove_device(dev); | 175 | __pnp_remove_device(dev); |
177 | } | 176 | } |
178 | #endif /* 0 */ | 177 | #endif /* 0 */ |
179 | 178 | ||
180 | static int __init pnp_init(void) | 179 | static int __init pnp_init(void) |
181 | { | 180 | { |
@@ -190,4 +189,4 @@ EXPORT_SYMBOL(pnp_register_protocol); | |||
190 | EXPORT_SYMBOL(pnp_unregister_protocol); | 189 | EXPORT_SYMBOL(pnp_unregister_protocol); |
191 | EXPORT_SYMBOL(pnp_add_device); | 190 | EXPORT_SYMBOL(pnp_add_device); |
192 | EXPORT_SYMBOL(pnp_remove_device); | 191 | EXPORT_SYMBOL(pnp_remove_device); |
193 | #endif /* 0 */ | 192 | #endif /* 0 */ |
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 1432806451cd..913d926f8baf 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c | |||
@@ -17,11 +17,9 @@ static int compare_func(const char *ida, const char *idb) | |||
17 | { | 17 | { |
18 | int i; | 18 | int i; |
19 | /* we only need to compare the last 4 chars */ | 19 | /* we only need to compare the last 4 chars */ |
20 | for (i=3; i<7; i++) | 20 | for (i = 3; i < 7; i++) { |
21 | { | ||
22 | if (ida[i] != 'X' && | 21 | if (ida[i] != 'X' && |
23 | idb[i] != 'X' && | 22 | idb[i] != 'X' && toupper(ida[i]) != toupper(idb[i])) |
24 | toupper(ida[i]) != toupper(idb[i])) | ||
25 | return 0; | 23 | return 0; |
26 | } | 24 | } |
27 | return 1; | 25 | return 1; |
@@ -31,18 +29,19 @@ int compare_pnp_id(struct pnp_id *pos, const char *id) | |||
31 | { | 29 | { |
32 | if (!pos || !id || (strlen(id) != 7)) | 30 | if (!pos || !id || (strlen(id) != 7)) |
33 | return 0; | 31 | return 0; |
34 | if (memcmp(id,"ANYDEVS",7)==0) | 32 | if (memcmp(id, "ANYDEVS", 7) == 0) |
35 | return 1; | 33 | return 1; |
36 | while (pos){ | 34 | while (pos) { |
37 | if (memcmp(pos->id,id,3)==0) | 35 | if (memcmp(pos->id, id, 3) == 0) |
38 | if (compare_func(pos->id,id)==1) | 36 | if (compare_func(pos->id, id) == 1) |
39 | return 1; | 37 | return 1; |
40 | pos = pos->next; | 38 | pos = pos->next; |
41 | } | 39 | } |
42 | return 0; | 40 | return 0; |
43 | } | 41 | } |
44 | 42 | ||
45 | static const struct pnp_device_id * match_device(struct pnp_driver *drv, struct pnp_dev *dev) | 43 | static const struct pnp_device_id *match_device(struct pnp_driver *drv, |
44 | struct pnp_dev *dev) | ||
46 | { | 45 | { |
47 | const struct pnp_device_id *drv_id = drv->id_table; | 46 | const struct pnp_device_id *drv_id = drv->id_table; |
48 | if (!drv_id) | 47 | if (!drv_id) |
@@ -59,7 +58,7 @@ static const struct pnp_device_id * match_device(struct pnp_driver *drv, struct | |||
59 | int pnp_device_attach(struct pnp_dev *pnp_dev) | 58 | int pnp_device_attach(struct pnp_dev *pnp_dev) |
60 | { | 59 | { |
61 | spin_lock(&pnp_lock); | 60 | spin_lock(&pnp_lock); |
62 | if(pnp_dev->status != PNP_READY){ | 61 | if (pnp_dev->status != PNP_READY) { |
63 | spin_unlock(&pnp_lock); | 62 | spin_unlock(&pnp_lock); |
64 | return -EBUSY; | 63 | return -EBUSY; |
65 | } | 64 | } |
@@ -86,7 +85,8 @@ static int pnp_device_probe(struct device *dev) | |||
86 | pnp_dev = to_pnp_dev(dev); | 85 | pnp_dev = to_pnp_dev(dev); |
87 | pnp_drv = to_pnp_driver(dev->driver); | 86 | pnp_drv = to_pnp_driver(dev->driver); |
88 | 87 | ||
89 | pnp_dbg("match found with the PnP device '%s' and the driver '%s'", dev->bus_id,pnp_drv->name); | 88 | pnp_dbg("match found with the PnP device '%s' and the driver '%s'", |
89 | dev->bus_id, pnp_drv->name); | ||
90 | 90 | ||
91 | error = pnp_device_attach(pnp_dev); | 91 | error = pnp_device_attach(pnp_dev); |
92 | if (error < 0) | 92 | if (error < 0) |
@@ -99,7 +99,7 @@ static int pnp_device_probe(struct device *dev) | |||
99 | return error; | 99 | return error; |
100 | } | 100 | } |
101 | } else if ((pnp_drv->flags & PNP_DRIVER_RES_DISABLE) | 101 | } else if ((pnp_drv->flags & PNP_DRIVER_RES_DISABLE) |
102 | == PNP_DRIVER_RES_DISABLE) { | 102 | == PNP_DRIVER_RES_DISABLE) { |
103 | error = pnp_disable_dev(pnp_dev); | 103 | error = pnp_disable_dev(pnp_dev); |
104 | if (error < 0) | 104 | if (error < 0) |
105 | return error; | 105 | return error; |
@@ -110,22 +110,22 @@ static int pnp_device_probe(struct device *dev) | |||
110 | if (dev_id != NULL) | 110 | if (dev_id != NULL) |
111 | error = pnp_drv->probe(pnp_dev, dev_id); | 111 | error = pnp_drv->probe(pnp_dev, dev_id); |
112 | } | 112 | } |
113 | if (error >= 0){ | 113 | if (error >= 0) { |
114 | pnp_dev->driver = pnp_drv; | 114 | pnp_dev->driver = pnp_drv; |
115 | error = 0; | 115 | error = 0; |
116 | } else | 116 | } else |
117 | goto fail; | 117 | goto fail; |
118 | return error; | 118 | return error; |
119 | 119 | ||
120 | fail: | 120 | fail: |
121 | pnp_device_detach(pnp_dev); | 121 | pnp_device_detach(pnp_dev); |
122 | return error; | 122 | return error; |
123 | } | 123 | } |
124 | 124 | ||
125 | static int pnp_device_remove(struct device *dev) | 125 | static int pnp_device_remove(struct device *dev) |
126 | { | 126 | { |
127 | struct pnp_dev * pnp_dev = to_pnp_dev(dev); | 127 | struct pnp_dev *pnp_dev = to_pnp_dev(dev); |
128 | struct pnp_driver * drv = pnp_dev->driver; | 128 | struct pnp_driver *drv = pnp_dev->driver; |
129 | 129 | ||
130 | if (drv) { | 130 | if (drv) { |
131 | if (drv->remove) | 131 | if (drv->remove) |
@@ -138,8 +138,8 @@ static int pnp_device_remove(struct device *dev) | |||
138 | 138 | ||
139 | static int pnp_bus_match(struct device *dev, struct device_driver *drv) | 139 | static int pnp_bus_match(struct device *dev, struct device_driver *drv) |
140 | { | 140 | { |
141 | struct pnp_dev * pnp_dev = to_pnp_dev(dev); | 141 | struct pnp_dev *pnp_dev = to_pnp_dev(dev); |
142 | struct pnp_driver * pnp_drv = to_pnp_driver(drv); | 142 | struct pnp_driver *pnp_drv = to_pnp_driver(drv); |
143 | if (match_device(pnp_drv, pnp_dev) == NULL) | 143 | if (match_device(pnp_drv, pnp_dev) == NULL) |
144 | return 0; | 144 | return 0; |
145 | return 1; | 145 | return 1; |
@@ -147,8 +147,8 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv) | |||
147 | 147 | ||
148 | static int pnp_bus_suspend(struct device *dev, pm_message_t state) | 148 | static int pnp_bus_suspend(struct device *dev, pm_message_t state) |
149 | { | 149 | { |
150 | struct pnp_dev * pnp_dev = to_pnp_dev(dev); | 150 | struct pnp_dev *pnp_dev = to_pnp_dev(dev); |
151 | struct pnp_driver * pnp_drv = pnp_dev->driver; | 151 | struct pnp_driver *pnp_drv = pnp_dev->driver; |
152 | int error; | 152 | int error; |
153 | 153 | ||
154 | if (!pnp_drv) | 154 | if (!pnp_drv) |
@@ -162,9 +162,9 @@ static int pnp_bus_suspend(struct device *dev, pm_message_t state) | |||
162 | 162 | ||
163 | if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) && | 163 | if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) && |
164 | pnp_can_disable(pnp_dev)) { | 164 | pnp_can_disable(pnp_dev)) { |
165 | error = pnp_stop_dev(pnp_dev); | 165 | error = pnp_stop_dev(pnp_dev); |
166 | if (error) | 166 | if (error) |
167 | return error; | 167 | return error; |
168 | } | 168 | } |
169 | 169 | ||
170 | if (pnp_dev->protocol && pnp_dev->protocol->suspend) | 170 | if (pnp_dev->protocol && pnp_dev->protocol->suspend) |
@@ -174,8 +174,8 @@ static int pnp_bus_suspend(struct device *dev, pm_message_t state) | |||
174 | 174 | ||
175 | static int pnp_bus_resume(struct device *dev) | 175 | static int pnp_bus_resume(struct device *dev) |
176 | { | 176 | { |
177 | struct pnp_dev * pnp_dev = to_pnp_dev(dev); | 177 | struct pnp_dev *pnp_dev = to_pnp_dev(dev); |
178 | struct pnp_driver * pnp_drv = pnp_dev->driver; | 178 | struct pnp_driver *pnp_drv = pnp_dev->driver; |
179 | int error; | 179 | int error; |
180 | 180 | ||
181 | if (!pnp_drv) | 181 | if (!pnp_drv) |
@@ -197,10 +197,10 @@ static int pnp_bus_resume(struct device *dev) | |||
197 | } | 197 | } |
198 | 198 | ||
199 | struct bus_type pnp_bus_type = { | 199 | struct bus_type pnp_bus_type = { |
200 | .name = "pnp", | 200 | .name = "pnp", |
201 | .match = pnp_bus_match, | 201 | .match = pnp_bus_match, |
202 | .probe = pnp_device_probe, | 202 | .probe = pnp_device_probe, |
203 | .remove = pnp_device_remove, | 203 | .remove = pnp_device_remove, |
204 | .suspend = pnp_bus_suspend, | 204 | .suspend = pnp_bus_suspend, |
205 | .resume = pnp_bus_resume, | 205 | .resume = pnp_bus_resume, |
206 | }; | 206 | }; |
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index ac9fcd499f3f..b6beb8a36da7 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -29,7 +29,7 @@ struct pnp_info_buffer { | |||
29 | 29 | ||
30 | typedef struct pnp_info_buffer pnp_info_buffer_t; | 30 | typedef struct pnp_info_buffer pnp_info_buffer_t; |
31 | 31 | ||
32 | static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...) | 32 | static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt, ...) |
33 | { | 33 | { |
34 | va_list args; | 34 | va_list args; |
35 | int res; | 35 | int res; |
@@ -48,14 +48,18 @@ static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...) | |||
48 | return res; | 48 | return res; |
49 | } | 49 | } |
50 | 50 | ||
51 | static void pnp_print_port(pnp_info_buffer_t *buffer, char *space, struct pnp_port *port) | 51 | static void pnp_print_port(pnp_info_buffer_t * buffer, char *space, |
52 | struct pnp_port *port) | ||
52 | { | 53 | { |
53 | pnp_printf(buffer, "%sport 0x%x-0x%x, align 0x%x, size 0x%x, %i-bit address decoding\n", | 54 | pnp_printf(buffer, |
54 | space, port->min, port->max, port->align ? (port->align-1) : 0, port->size, | 55 | "%sport 0x%x-0x%x, align 0x%x, size 0x%x, %i-bit address decoding\n", |
55 | port->flags & PNP_PORT_FLAG_16BITADDR ? 16 : 10); | 56 | space, port->min, port->max, |
57 | port->align ? (port->align - 1) : 0, port->size, | ||
58 | port->flags & PNP_PORT_FLAG_16BITADDR ? 16 : 10); | ||
56 | } | 59 | } |
57 | 60 | ||
58 | static void pnp_print_irq(pnp_info_buffer_t *buffer, char *space, struct pnp_irq *irq) | 61 | static void pnp_print_irq(pnp_info_buffer_t * buffer, char *space, |
62 | struct pnp_irq *irq) | ||
59 | { | 63 | { |
60 | int first = 1, i; | 64 | int first = 1, i; |
61 | 65 | ||
@@ -85,14 +89,15 @@ static void pnp_print_irq(pnp_info_buffer_t *buffer, char *space, struct pnp_irq | |||
85 | pnp_printf(buffer, "\n"); | 89 | pnp_printf(buffer, "\n"); |
86 | } | 90 | } |
87 | 91 | ||
88 | static void pnp_print_dma(pnp_info_buffer_t *buffer, char *space, struct pnp_dma *dma) | 92 | static void pnp_print_dma(pnp_info_buffer_t * buffer, char *space, |
93 | struct pnp_dma *dma) | ||
89 | { | 94 | { |
90 | int first = 1, i; | 95 | int first = 1, i; |
91 | char *s; | 96 | char *s; |
92 | 97 | ||
93 | pnp_printf(buffer, "%sdma ", space); | 98 | pnp_printf(buffer, "%sdma ", space); |
94 | for (i = 0; i < 8; i++) | 99 | for (i = 0; i < 8; i++) |
95 | if (dma->map & (1<<i)) { | 100 | if (dma->map & (1 << i)) { |
96 | if (!first) { | 101 | if (!first) { |
97 | pnp_printf(buffer, ","); | 102 | pnp_printf(buffer, ","); |
98 | } else { | 103 | } else { |
@@ -136,12 +141,13 @@ static void pnp_print_dma(pnp_info_buffer_t *buffer, char *space, struct pnp_dma | |||
136 | pnp_printf(buffer, " %s\n", s); | 141 | pnp_printf(buffer, " %s\n", s); |
137 | } | 142 | } |
138 | 143 | ||
139 | static void pnp_print_mem(pnp_info_buffer_t *buffer, char *space, struct pnp_mem *mem) | 144 | static void pnp_print_mem(pnp_info_buffer_t * buffer, char *space, |
145 | struct pnp_mem *mem) | ||
140 | { | 146 | { |
141 | char *s; | 147 | char *s; |
142 | 148 | ||
143 | pnp_printf(buffer, "%sMemory 0x%x-0x%x, align 0x%x, size 0x%x", | 149 | pnp_printf(buffer, "%sMemory 0x%x-0x%x, align 0x%x, size 0x%x", |
144 | space, mem->min, mem->max, mem->align, mem->size); | 150 | space, mem->min, mem->max, mem->align, mem->size); |
145 | if (mem->flags & IORESOURCE_MEM_WRITEABLE) | 151 | if (mem->flags & IORESOURCE_MEM_WRITEABLE) |
146 | pnp_printf(buffer, ", writeable"); | 152 | pnp_printf(buffer, ", writeable"); |
147 | if (mem->flags & IORESOURCE_MEM_CACHEABLE) | 153 | if (mem->flags & IORESOURCE_MEM_CACHEABLE) |
@@ -168,7 +174,7 @@ static void pnp_print_mem(pnp_info_buffer_t *buffer, char *space, struct pnp_mem | |||
168 | pnp_printf(buffer, ", %s\n", s); | 174 | pnp_printf(buffer, ", %s\n", s); |
169 | } | 175 | } |
170 | 176 | ||
171 | static void pnp_print_option(pnp_info_buffer_t *buffer, char *space, | 177 | static void pnp_print_option(pnp_info_buffer_t * buffer, char *space, |
172 | struct pnp_option *option, int dep) | 178 | struct pnp_option *option, int dep) |
173 | { | 179 | { |
174 | char *s; | 180 | char *s; |
@@ -179,19 +185,19 @@ static void pnp_print_option(pnp_info_buffer_t *buffer, char *space, | |||
179 | 185 | ||
180 | if (dep) { | 186 | if (dep) { |
181 | switch (option->priority) { | 187 | switch (option->priority) { |
182 | case PNP_RES_PRIORITY_PREFERRED: | 188 | case PNP_RES_PRIORITY_PREFERRED: |
183 | s = "preferred"; | 189 | s = "preferred"; |
184 | break; | 190 | break; |
185 | case PNP_RES_PRIORITY_ACCEPTABLE: | 191 | case PNP_RES_PRIORITY_ACCEPTABLE: |
186 | s = "acceptable"; | 192 | s = "acceptable"; |
187 | break; | 193 | break; |
188 | case PNP_RES_PRIORITY_FUNCTIONAL: | 194 | case PNP_RES_PRIORITY_FUNCTIONAL: |
189 | s = "functional"; | 195 | s = "functional"; |
190 | break; | 196 | break; |
191 | default: | 197 | default: |
192 | s = "invalid"; | 198 | s = "invalid"; |
193 | } | 199 | } |
194 | pnp_printf(buffer, "Dependent: %02i - Priority %s\n",dep, s); | 200 | pnp_printf(buffer, "Dependent: %02i - Priority %s\n", dep, s); |
195 | } | 201 | } |
196 | 202 | ||
197 | for (port = option->port; port; port = port->next) | 203 | for (port = option->port; port; port = port->next) |
@@ -204,16 +210,16 @@ static void pnp_print_option(pnp_info_buffer_t *buffer, char *space, | |||
204 | pnp_print_mem(buffer, space, mem); | 210 | pnp_print_mem(buffer, space, mem); |
205 | } | 211 | } |
206 | 212 | ||
207 | 213 | static ssize_t pnp_show_options(struct device *dmdev, | |
208 | static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *attr, char *buf) | 214 | struct device_attribute *attr, char *buf) |
209 | { | 215 | { |
210 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 216 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
211 | struct pnp_option * independent = dev->independent; | 217 | struct pnp_option *independent = dev->independent; |
212 | struct pnp_option * dependent = dev->dependent; | 218 | struct pnp_option *dependent = dev->dependent; |
213 | int ret, dep = 1; | 219 | int ret, dep = 1; |
214 | 220 | ||
215 | pnp_info_buffer_t *buffer = (pnp_info_buffer_t *) | 221 | pnp_info_buffer_t *buffer = (pnp_info_buffer_t *) |
216 | pnp_alloc(sizeof(pnp_info_buffer_t)); | 222 | pnp_alloc(sizeof(pnp_info_buffer_t)); |
217 | if (!buffer) | 223 | if (!buffer) |
218 | return -ENOMEM; | 224 | return -ENOMEM; |
219 | 225 | ||
@@ -223,7 +229,7 @@ static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *a | |||
223 | if (independent) | 229 | if (independent) |
224 | pnp_print_option(buffer, "", independent, 0); | 230 | pnp_print_option(buffer, "", independent, 0); |
225 | 231 | ||
226 | while (dependent){ | 232 | while (dependent) { |
227 | pnp_print_option(buffer, " ", dependent, dep); | 233 | pnp_print_option(buffer, " ", dependent, dep); |
228 | dependent = dependent->next; | 234 | dependent = dependent->next; |
229 | dep++; | 235 | dep++; |
@@ -233,10 +239,11 @@ static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *a | |||
233 | return ret; | 239 | return ret; |
234 | } | 240 | } |
235 | 241 | ||
236 | static DEVICE_ATTR(options,S_IRUGO,pnp_show_options,NULL); | 242 | static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL); |
237 | |||
238 | 243 | ||
239 | static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_attribute *attr, char *buf) | 244 | static ssize_t pnp_show_current_resources(struct device *dmdev, |
245 | struct device_attribute *attr, | ||
246 | char *buf) | ||
240 | { | 247 | { |
241 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 248 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
242 | int i, ret; | 249 | int i, ret; |
@@ -252,52 +259,56 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at | |||
252 | buffer->buffer = buf; | 259 | buffer->buffer = buf; |
253 | buffer->curr = buffer->buffer; | 260 | buffer->curr = buffer->buffer; |
254 | 261 | ||
255 | pnp_printf(buffer,"state = "); | 262 | pnp_printf(buffer, "state = "); |
256 | if (dev->active) | 263 | if (dev->active) |
257 | pnp_printf(buffer,"active\n"); | 264 | pnp_printf(buffer, "active\n"); |
258 | else | 265 | else |
259 | pnp_printf(buffer,"disabled\n"); | 266 | pnp_printf(buffer, "disabled\n"); |
260 | 267 | ||
261 | for (i = 0; i < PNP_MAX_PORT; i++) { | 268 | for (i = 0; i < PNP_MAX_PORT; i++) { |
262 | if (pnp_port_valid(dev, i)) { | 269 | if (pnp_port_valid(dev, i)) { |
263 | pnp_printf(buffer,"io"); | 270 | pnp_printf(buffer, "io"); |
264 | if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) | 271 | if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) |
265 | pnp_printf(buffer," disabled\n"); | 272 | pnp_printf(buffer, " disabled\n"); |
266 | else | 273 | else |
267 | pnp_printf(buffer," 0x%llx-0x%llx\n", | 274 | pnp_printf(buffer, " 0x%llx-0x%llx\n", |
268 | (unsigned long long)pnp_port_start(dev, i), | 275 | (unsigned long long) |
269 | (unsigned long long)pnp_port_end(dev, i)); | 276 | pnp_port_start(dev, i), |
277 | (unsigned long long)pnp_port_end(dev, | ||
278 | i)); | ||
270 | } | 279 | } |
271 | } | 280 | } |
272 | for (i = 0; i < PNP_MAX_MEM; i++) { | 281 | for (i = 0; i < PNP_MAX_MEM; i++) { |
273 | if (pnp_mem_valid(dev, i)) { | 282 | if (pnp_mem_valid(dev, i)) { |
274 | pnp_printf(buffer,"mem"); | 283 | pnp_printf(buffer, "mem"); |
275 | if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) | 284 | if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) |
276 | pnp_printf(buffer," disabled\n"); | 285 | pnp_printf(buffer, " disabled\n"); |
277 | else | 286 | else |
278 | pnp_printf(buffer," 0x%llx-0x%llx\n", | 287 | pnp_printf(buffer, " 0x%llx-0x%llx\n", |
279 | (unsigned long long)pnp_mem_start(dev, i), | 288 | (unsigned long long) |
280 | (unsigned long long)pnp_mem_end(dev, i)); | 289 | pnp_mem_start(dev, i), |
290 | (unsigned long long)pnp_mem_end(dev, | ||
291 | i)); | ||
281 | } | 292 | } |
282 | } | 293 | } |
283 | for (i = 0; i < PNP_MAX_IRQ; i++) { | 294 | for (i = 0; i < PNP_MAX_IRQ; i++) { |
284 | if (pnp_irq_valid(dev, i)) { | 295 | if (pnp_irq_valid(dev, i)) { |
285 | pnp_printf(buffer,"irq"); | 296 | pnp_printf(buffer, "irq"); |
286 | if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) | 297 | if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) |
287 | pnp_printf(buffer," disabled\n"); | 298 | pnp_printf(buffer, " disabled\n"); |
288 | else | 299 | else |
289 | pnp_printf(buffer," %lld\n", | 300 | pnp_printf(buffer, " %lld\n", |
290 | (unsigned long long)pnp_irq(dev, i)); | 301 | (unsigned long long)pnp_irq(dev, i)); |
291 | } | 302 | } |
292 | } | 303 | } |
293 | for (i = 0; i < PNP_MAX_DMA; i++) { | 304 | for (i = 0; i < PNP_MAX_DMA; i++) { |
294 | if (pnp_dma_valid(dev, i)) { | 305 | if (pnp_dma_valid(dev, i)) { |
295 | pnp_printf(buffer,"dma"); | 306 | pnp_printf(buffer, "dma"); |
296 | if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) | 307 | if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) |
297 | pnp_printf(buffer," disabled\n"); | 308 | pnp_printf(buffer, " disabled\n"); |
298 | else | 309 | else |
299 | pnp_printf(buffer," %lld\n", | 310 | pnp_printf(buffer, " %lld\n", |
300 | (unsigned long long)pnp_dma(dev, i)); | 311 | (unsigned long long)pnp_dma(dev, i)); |
301 | } | 312 | } |
302 | } | 313 | } |
303 | ret = (buffer->curr - buf); | 314 | ret = (buffer->curr - buf); |
@@ -308,55 +319,57 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at | |||
308 | extern struct semaphore pnp_res_mutex; | 319 | extern struct semaphore pnp_res_mutex; |
309 | 320 | ||
310 | static ssize_t | 321 | static ssize_t |
311 | pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, const char * ubuf, size_t count) | 322 | pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, |
323 | const char *ubuf, size_t count) | ||
312 | { | 324 | { |
313 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 325 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
314 | char *buf = (void *)ubuf; | 326 | char *buf = (void *)ubuf; |
315 | int retval = 0; | 327 | int retval = 0; |
316 | 328 | ||
317 | if (dev->status & PNP_ATTACHED) { | 329 | if (dev->status & PNP_ATTACHED) { |
318 | retval = -EBUSY; | 330 | retval = -EBUSY; |
319 | pnp_info("Device %s cannot be configured because it is in use.", dev->dev.bus_id); | 331 | pnp_info("Device %s cannot be configured because it is in use.", |
332 | dev->dev.bus_id); | ||
320 | goto done; | 333 | goto done; |
321 | } | 334 | } |
322 | 335 | ||
323 | while (isspace(*buf)) | 336 | while (isspace(*buf)) |
324 | ++buf; | 337 | ++buf; |
325 | if (!strnicmp(buf,"disable",7)) { | 338 | if (!strnicmp(buf, "disable", 7)) { |
326 | retval = pnp_disable_dev(dev); | 339 | retval = pnp_disable_dev(dev); |
327 | goto done; | 340 | goto done; |
328 | } | 341 | } |
329 | if (!strnicmp(buf,"activate",8)) { | 342 | if (!strnicmp(buf, "activate", 8)) { |
330 | retval = pnp_activate_dev(dev); | 343 | retval = pnp_activate_dev(dev); |
331 | goto done; | 344 | goto done; |
332 | } | 345 | } |
333 | if (!strnicmp(buf,"fill",4)) { | 346 | if (!strnicmp(buf, "fill", 4)) { |
334 | if (dev->active) | 347 | if (dev->active) |
335 | goto done; | 348 | goto done; |
336 | retval = pnp_auto_config_dev(dev); | 349 | retval = pnp_auto_config_dev(dev); |
337 | goto done; | 350 | goto done; |
338 | } | 351 | } |
339 | if (!strnicmp(buf,"auto",4)) { | 352 | if (!strnicmp(buf, "auto", 4)) { |
340 | if (dev->active) | 353 | if (dev->active) |
341 | goto done; | 354 | goto done; |
342 | pnp_init_resource_table(&dev->res); | 355 | pnp_init_resource_table(&dev->res); |
343 | retval = pnp_auto_config_dev(dev); | 356 | retval = pnp_auto_config_dev(dev); |
344 | goto done; | 357 | goto done; |
345 | } | 358 | } |
346 | if (!strnicmp(buf,"clear",5)) { | 359 | if (!strnicmp(buf, "clear", 5)) { |
347 | if (dev->active) | 360 | if (dev->active) |
348 | goto done; | 361 | goto done; |
349 | pnp_init_resource_table(&dev->res); | 362 | pnp_init_resource_table(&dev->res); |
350 | goto done; | 363 | goto done; |
351 | } | 364 | } |
352 | if (!strnicmp(buf,"get",3)) { | 365 | if (!strnicmp(buf, "get", 3)) { |
353 | down(&pnp_res_mutex); | 366 | down(&pnp_res_mutex); |
354 | if (pnp_can_read(dev)) | 367 | if (pnp_can_read(dev)) |
355 | dev->protocol->get(dev, &dev->res); | 368 | dev->protocol->get(dev, &dev->res); |
356 | up(&pnp_res_mutex); | 369 | up(&pnp_res_mutex); |
357 | goto done; | 370 | goto done; |
358 | } | 371 | } |
359 | if (!strnicmp(buf,"set",3)) { | 372 | if (!strnicmp(buf, "set", 3)) { |
360 | int nport = 0, nmem = 0, nirq = 0, ndma = 0; | 373 | int nport = 0, nmem = 0, nirq = 0, ndma = 0; |
361 | if (dev->active) | 374 | if (dev->active) |
362 | goto done; | 375 | goto done; |
@@ -366,65 +379,77 @@ pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, | |||
366 | while (1) { | 379 | while (1) { |
367 | while (isspace(*buf)) | 380 | while (isspace(*buf)) |
368 | ++buf; | 381 | ++buf; |
369 | if (!strnicmp(buf,"io",2)) { | 382 | if (!strnicmp(buf, "io", 2)) { |
370 | buf += 2; | 383 | buf += 2; |
371 | while (isspace(*buf)) | 384 | while (isspace(*buf)) |
372 | ++buf; | 385 | ++buf; |
373 | dev->res.port_resource[nport].start = simple_strtoul(buf,&buf,0); | 386 | dev->res.port_resource[nport].start = |
387 | simple_strtoul(buf, &buf, 0); | ||
374 | while (isspace(*buf)) | 388 | while (isspace(*buf)) |
375 | ++buf; | 389 | ++buf; |
376 | if(*buf == '-') { | 390 | if (*buf == '-') { |
377 | buf += 1; | 391 | buf += 1; |
378 | while (isspace(*buf)) | 392 | while (isspace(*buf)) |
379 | ++buf; | 393 | ++buf; |
380 | dev->res.port_resource[nport].end = simple_strtoul(buf,&buf,0); | 394 | dev->res.port_resource[nport].end = |
395 | simple_strtoul(buf, &buf, 0); | ||
381 | } else | 396 | } else |
382 | dev->res.port_resource[nport].end = dev->res.port_resource[nport].start; | 397 | dev->res.port_resource[nport].end = |
383 | dev->res.port_resource[nport].flags = IORESOURCE_IO; | 398 | dev->res.port_resource[nport].start; |
399 | dev->res.port_resource[nport].flags = | ||
400 | IORESOURCE_IO; | ||
384 | nport++; | 401 | nport++; |
385 | if (nport >= PNP_MAX_PORT) | 402 | if (nport >= PNP_MAX_PORT) |
386 | break; | 403 | break; |
387 | continue; | 404 | continue; |
388 | } | 405 | } |
389 | if (!strnicmp(buf,"mem",3)) { | 406 | if (!strnicmp(buf, "mem", 3)) { |
390 | buf += 3; | 407 | buf += 3; |
391 | while (isspace(*buf)) | 408 | while (isspace(*buf)) |
392 | ++buf; | 409 | ++buf; |
393 | dev->res.mem_resource[nmem].start = simple_strtoul(buf,&buf,0); | 410 | dev->res.mem_resource[nmem].start = |
411 | simple_strtoul(buf, &buf, 0); | ||
394 | while (isspace(*buf)) | 412 | while (isspace(*buf)) |
395 | ++buf; | 413 | ++buf; |
396 | if(*buf == '-') { | 414 | if (*buf == '-') { |
397 | buf += 1; | 415 | buf += 1; |
398 | while (isspace(*buf)) | 416 | while (isspace(*buf)) |
399 | ++buf; | 417 | ++buf; |
400 | dev->res.mem_resource[nmem].end = simple_strtoul(buf,&buf,0); | 418 | dev->res.mem_resource[nmem].end = |
419 | simple_strtoul(buf, &buf, 0); | ||
401 | } else | 420 | } else |
402 | dev->res.mem_resource[nmem].end = dev->res.mem_resource[nmem].start; | 421 | dev->res.mem_resource[nmem].end = |
403 | dev->res.mem_resource[nmem].flags = IORESOURCE_MEM; | 422 | dev->res.mem_resource[nmem].start; |
423 | dev->res.mem_resource[nmem].flags = | ||
424 | IORESOURCE_MEM; | ||
404 | nmem++; | 425 | nmem++; |
405 | if (nmem >= PNP_MAX_MEM) | 426 | if (nmem >= PNP_MAX_MEM) |
406 | break; | 427 | break; |
407 | continue; | 428 | continue; |
408 | } | 429 | } |
409 | if (!strnicmp(buf,"irq",3)) { | 430 | if (!strnicmp(buf, "irq", 3)) { |
410 | buf += 3; | 431 | buf += 3; |
411 | while (isspace(*buf)) | 432 | while (isspace(*buf)) |
412 | ++buf; | 433 | ++buf; |
413 | dev->res.irq_resource[nirq].start = | 434 | dev->res.irq_resource[nirq].start = |
414 | dev->res.irq_resource[nirq].end = simple_strtoul(buf,&buf,0); | 435 | dev->res.irq_resource[nirq].end = |
415 | dev->res.irq_resource[nirq].flags = IORESOURCE_IRQ; | 436 | simple_strtoul(buf, &buf, 0); |
437 | dev->res.irq_resource[nirq].flags = | ||
438 | IORESOURCE_IRQ; | ||
416 | nirq++; | 439 | nirq++; |
417 | if (nirq >= PNP_MAX_IRQ) | 440 | if (nirq >= PNP_MAX_IRQ) |
418 | break; | 441 | break; |
419 | continue; | 442 | continue; |
420 | } | 443 | } |
421 | if (!strnicmp(buf,"dma",3)) { | 444 | if (!strnicmp(buf, "dma", 3)) { |
422 | buf += 3; | 445 | buf += 3; |
423 | while (isspace(*buf)) | 446 | while (isspace(*buf)) |
424 | ++buf; | 447 | ++buf; |
425 | dev->res.dma_resource[ndma].start = | 448 | dev->res.dma_resource[ndma].start = |
426 | dev->res.dma_resource[ndma].end = simple_strtoul(buf,&buf,0); | 449 | dev->res.dma_resource[ndma].end = |
427 | dev->res.dma_resource[ndma].flags = IORESOURCE_DMA; | 450 | simple_strtoul(buf, &buf, 0); |
451 | dev->res.dma_resource[ndma].flags = | ||
452 | IORESOURCE_DMA; | ||
428 | ndma++; | 453 | ndma++; |
429 | if (ndma >= PNP_MAX_DMA) | 454 | if (ndma >= PNP_MAX_DMA) |
430 | break; | 455 | break; |
@@ -435,45 +460,49 @@ pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, | |||
435 | up(&pnp_res_mutex); | 460 | up(&pnp_res_mutex); |
436 | goto done; | 461 | goto done; |
437 | } | 462 | } |
438 | done: | 463 | done: |
439 | if (retval < 0) | 464 | if (retval < 0) |
440 | return retval; | 465 | return retval; |
441 | return count; | 466 | return count; |
442 | } | 467 | } |
443 | 468 | ||
444 | static DEVICE_ATTR(resources,S_IRUGO | S_IWUSR, | 469 | static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR, |
445 | pnp_show_current_resources,pnp_set_current_resources); | 470 | pnp_show_current_resources, pnp_set_current_resources); |
446 | 471 | ||
447 | static ssize_t pnp_show_current_ids(struct device *dmdev, struct device_attribute *attr, char *buf) | 472 | static ssize_t pnp_show_current_ids(struct device *dmdev, |
473 | struct device_attribute *attr, char *buf) | ||
448 | { | 474 | { |
449 | char *str = buf; | 475 | char *str = buf; |
450 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 476 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
451 | struct pnp_id * pos = dev->id; | 477 | struct pnp_id *pos = dev->id; |
452 | 478 | ||
453 | while (pos) { | 479 | while (pos) { |
454 | str += sprintf(str,"%s\n", pos->id); | 480 | str += sprintf(str, "%s\n", pos->id); |
455 | pos = pos->next; | 481 | pos = pos->next; |
456 | } | 482 | } |
457 | return (str - buf); | 483 | return (str - buf); |
458 | } | 484 | } |
459 | 485 | ||
460 | static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL); | 486 | static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); |
461 | 487 | ||
462 | int pnp_interface_attach_device(struct pnp_dev *dev) | 488 | int pnp_interface_attach_device(struct pnp_dev *dev) |
463 | { | 489 | { |
464 | int rc = device_create_file(&dev->dev,&dev_attr_options); | 490 | int rc = device_create_file(&dev->dev, &dev_attr_options); |
465 | if (rc) goto err; | 491 | if (rc) |
466 | rc = device_create_file(&dev->dev,&dev_attr_resources); | 492 | goto err; |
467 | if (rc) goto err_opt; | 493 | rc = device_create_file(&dev->dev, &dev_attr_resources); |
468 | rc = device_create_file(&dev->dev,&dev_attr_id); | 494 | if (rc) |
469 | if (rc) goto err_res; | 495 | goto err_opt; |
496 | rc = device_create_file(&dev->dev, &dev_attr_id); | ||
497 | if (rc) | ||
498 | goto err_res; | ||
470 | 499 | ||
471 | return 0; | 500 | return 0; |
472 | 501 | ||
473 | err_res: | 502 | err_res: |
474 | device_remove_file(&dev->dev,&dev_attr_resources); | 503 | device_remove_file(&dev->dev, &dev_attr_resources); |
475 | err_opt: | 504 | err_opt: |
476 | device_remove_file(&dev->dev,&dev_attr_options); | 505 | device_remove_file(&dev->dev, &dev_attr_options); |
477 | err: | 506 | err: |
478 | return rc; | 507 | return rc; |
479 | } | 508 | } |
diff --git a/drivers/pnp/isapnp/compat.c b/drivers/pnp/isapnp/compat.c index 0697ab88a9ac..aaf45e3ebee2 100644 --- a/drivers/pnp/isapnp/compat.c +++ b/drivers/pnp/isapnp/compat.c | |||
@@ -5,28 +5,26 @@ | |||
5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> | 5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* TODO: see if more isapnp functions are needed here */ | 9 | /* TODO: see if more isapnp functions are needed here */ |
10 | 10 | ||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/isapnp.h> | 12 | #include <linux/isapnp.h> |
13 | #include <linux/string.h> | 13 | #include <linux/string.h> |
14 | 14 | ||
15 | static void pnp_convert_id(char *buf, unsigned short vendor, unsigned short device) | 15 | static void pnp_convert_id(char *buf, unsigned short vendor, |
16 | unsigned short device) | ||
16 | { | 17 | { |
17 | sprintf(buf, "%c%c%c%x%x%x%x", | 18 | sprintf(buf, "%c%c%c%x%x%x%x", |
18 | 'A' + ((vendor >> 2) & 0x3f) - 1, | 19 | 'A' + ((vendor >> 2) & 0x3f) - 1, |
19 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, | 20 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, |
20 | 'A' + ((vendor >> 8) & 0x1f) - 1, | 21 | 'A' + ((vendor >> 8) & 0x1f) - 1, |
21 | (device >> 4) & 0x0f, | 22 | (device >> 4) & 0x0f, |
22 | device & 0x0f, | 23 | device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f); |
23 | (device >> 12) & 0x0f, | ||
24 | (device >> 8) & 0x0f); | ||
25 | } | 24 | } |
26 | 25 | ||
27 | struct pnp_card *pnp_find_card(unsigned short vendor, | 26 | struct pnp_card *pnp_find_card(unsigned short vendor, |
28 | unsigned short device, | 27 | unsigned short device, struct pnp_card *from) |
29 | struct pnp_card *from) | ||
30 | { | 28 | { |
31 | char id[8]; | 29 | char id[8]; |
32 | char any[8]; | 30 | char any[8]; |
@@ -38,7 +36,7 @@ struct pnp_card *pnp_find_card(unsigned short vendor, | |||
38 | 36 | ||
39 | while (list != &pnp_cards) { | 37 | while (list != &pnp_cards) { |
40 | struct pnp_card *card = global_to_pnp_card(list); | 38 | struct pnp_card *card = global_to_pnp_card(list); |
41 | if (compare_pnp_id(card->id,id) || (memcmp(id,any,7)==0)) | 39 | if (compare_pnp_id(card->id, id) || (memcmp(id, any, 7) == 0)) |
42 | return card; | 40 | return card; |
43 | list = list->next; | 41 | list = list->next; |
44 | } | 42 | } |
@@ -47,8 +45,7 @@ struct pnp_card *pnp_find_card(unsigned short vendor, | |||
47 | 45 | ||
48 | struct pnp_dev *pnp_find_dev(struct pnp_card *card, | 46 | struct pnp_dev *pnp_find_dev(struct pnp_card *card, |
49 | unsigned short vendor, | 47 | unsigned short vendor, |
50 | unsigned short function, | 48 | unsigned short function, struct pnp_dev *from) |
51 | struct pnp_dev *from) | ||
52 | { | 49 | { |
53 | char id[8]; | 50 | char id[8]; |
54 | char any[8]; | 51 | char any[8]; |
@@ -63,7 +60,8 @@ struct pnp_dev *pnp_find_dev(struct pnp_card *card, | |||
63 | 60 | ||
64 | while (list != &pnp_global) { | 61 | while (list != &pnp_global) { |
65 | struct pnp_dev *dev = global_to_pnp_dev(list); | 62 | struct pnp_dev *dev = global_to_pnp_dev(list); |
66 | if (compare_pnp_id(dev->id,id) || (memcmp(id,any,7)==0)) | 63 | if (compare_pnp_id(dev->id, id) |
64 | || (memcmp(id, any, 7) == 0)) | ||
67 | return dev; | 65 | return dev; |
68 | list = list->next; | 66 | list = list->next; |
69 | } | 67 | } |
@@ -78,7 +76,7 @@ struct pnp_dev *pnp_find_dev(struct pnp_card *card, | |||
78 | } | 76 | } |
79 | while (list != &card->devices) { | 77 | while (list != &card->devices) { |
80 | struct pnp_dev *dev = card_to_pnp_dev(list); | 78 | struct pnp_dev *dev = card_to_pnp_dev(list); |
81 | if (compare_pnp_id(dev->id,id)) | 79 | if (compare_pnp_id(dev->id, id)) |
82 | return dev; | 80 | return dev; |
83 | list = list->next; | 81 | list = list->next; |
84 | } | 82 | } |
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 914d00c423ad..0d690a7c0d24 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c | |||
@@ -51,10 +51,10 @@ | |||
51 | #define ISAPNP_DEBUG | 51 | #define ISAPNP_DEBUG |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | int isapnp_disable; /* Disable ISA PnP */ | 54 | int isapnp_disable; /* Disable ISA PnP */ |
55 | static int isapnp_rdp; /* Read Data Port */ | 55 | static int isapnp_rdp; /* Read Data Port */ |
56 | static int isapnp_reset = 1; /* reset all PnP cards (deactivate) */ | 56 | static int isapnp_reset = 1; /* reset all PnP cards (deactivate) */ |
57 | static int isapnp_verbose = 1; /* verbose mode */ | 57 | static int isapnp_verbose = 1; /* verbose mode */ |
58 | 58 | ||
59 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); | 59 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); |
60 | MODULE_DESCRIPTION("Generic ISA Plug & Play support"); | 60 | MODULE_DESCRIPTION("Generic ISA Plug & Play support"); |
@@ -126,7 +126,7 @@ static unsigned short isapnp_read_word(unsigned char idx) | |||
126 | unsigned short val; | 126 | unsigned short val; |
127 | 127 | ||
128 | val = isapnp_read_byte(idx); | 128 | val = isapnp_read_byte(idx); |
129 | val = (val << 8) + isapnp_read_byte(idx+1); | 129 | val = (val << 8) + isapnp_read_byte(idx + 1); |
130 | return val; | 130 | return val; |
131 | } | 131 | } |
132 | 132 | ||
@@ -139,7 +139,7 @@ void isapnp_write_byte(unsigned char idx, unsigned char val) | |||
139 | static void isapnp_write_word(unsigned char idx, unsigned short val) | 139 | static void isapnp_write_word(unsigned char idx, unsigned short val) |
140 | { | 140 | { |
141 | isapnp_write_byte(idx, val >> 8); | 141 | isapnp_write_byte(idx, val >> 8); |
142 | isapnp_write_byte(idx+1, val); | 142 | isapnp_write_byte(idx + 1, val); |
143 | } | 143 | } |
144 | 144 | ||
145 | static void isapnp_key(void) | 145 | static void isapnp_key(void) |
@@ -193,7 +193,7 @@ static void isapnp_deactivate(unsigned char logdev) | |||
193 | static void __init isapnp_peek(unsigned char *data, int bytes) | 193 | static void __init isapnp_peek(unsigned char *data, int bytes) |
194 | { | 194 | { |
195 | int i, j; | 195 | int i, j; |
196 | unsigned char d=0; | 196 | unsigned char d = 0; |
197 | 197 | ||
198 | for (i = 1; i <= bytes; i++) { | 198 | for (i = 1; i <= bytes; i++) { |
199 | for (j = 0; j < 20; j++) { | 199 | for (j = 0; j < 20; j++) { |
@@ -220,19 +220,18 @@ static int isapnp_next_rdp(void) | |||
220 | { | 220 | { |
221 | int rdp = isapnp_rdp; | 221 | int rdp = isapnp_rdp; |
222 | static int old_rdp = 0; | 222 | static int old_rdp = 0; |
223 | 223 | ||
224 | if(old_rdp) | 224 | if (old_rdp) { |
225 | { | ||
226 | release_region(old_rdp, 1); | 225 | release_region(old_rdp, 1); |
227 | old_rdp = 0; | 226 | old_rdp = 0; |
228 | } | 227 | } |
229 | while (rdp <= 0x3ff) { | 228 | while (rdp <= 0x3ff) { |
230 | /* | 229 | /* |
231 | * We cannot use NE2000 probe spaces for ISAPnP or we | 230 | * We cannot use NE2000 probe spaces for ISAPnP or we |
232 | * will lock up machines. | 231 | * will lock up machines. |
233 | */ | 232 | */ |
234 | if ((rdp < 0x280 || rdp > 0x380) && request_region(rdp, 1, "ISAPnP")) | 233 | if ((rdp < 0x280 || rdp > 0x380) |
235 | { | 234 | && request_region(rdp, 1, "ISAPnP")) { |
236 | isapnp_rdp = rdp; | 235 | isapnp_rdp = rdp; |
237 | old_rdp = rdp; | 236 | old_rdp = rdp; |
238 | return 0; | 237 | return 0; |
@@ -305,7 +304,9 @@ static int __init isapnp_isolate(void) | |||
305 | udelay(250); | 304 | udelay(250); |
306 | if (data == 0x55aa) | 305 | if (data == 0x55aa) |
307 | bit = 0x01; | 306 | bit = 0x01; |
308 | checksum = ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7) | (checksum >> 1); | 307 | checksum = |
308 | ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7) | ||
309 | | (checksum >> 1); | ||
309 | bit = 0x00; | 310 | bit = 0x00; |
310 | } | 311 | } |
311 | for (i = 65; i <= 72; i++) { | 312 | for (i = 65; i <= 72; i++) { |
@@ -357,7 +358,7 @@ static int __init isapnp_read_tag(unsigned char *type, unsigned short *size) | |||
357 | unsigned char tag, tmp[2]; | 358 | unsigned char tag, tmp[2]; |
358 | 359 | ||
359 | isapnp_peek(&tag, 1); | 360 | isapnp_peek(&tag, 1); |
360 | if (tag == 0) /* invalid tag */ | 361 | if (tag == 0) /* invalid tag */ |
361 | return -1; | 362 | return -1; |
362 | if (tag & 0x80) { /* large item */ | 363 | if (tag & 0x80) { /* large item */ |
363 | *type = tag; | 364 | *type = tag; |
@@ -368,7 +369,8 @@ static int __init isapnp_read_tag(unsigned char *type, unsigned short *size) | |||
368 | *size = tag & 0x07; | 369 | *size = tag & 0x07; |
369 | } | 370 | } |
370 | #if 0 | 371 | #if 0 |
371 | printk(KERN_DEBUG "tag = 0x%x, type = 0x%x, size = %i\n", tag, *type, *size); | 372 | printk(KERN_DEBUG "tag = 0x%x, type = 0x%x, size = %i\n", tag, *type, |
373 | *size); | ||
372 | #endif | 374 | #endif |
373 | if (*type == 0xff && *size == 0xffff) /* probably invalid data */ | 375 | if (*type == 0xff && *size == 0xffff) /* probably invalid data */ |
374 | return -1; | 376 | return -1; |
@@ -388,22 +390,21 @@ static void __init isapnp_skip_bytes(int count) | |||
388 | * Parse EISA id. | 390 | * Parse EISA id. |
389 | */ | 391 | */ |
390 | 392 | ||
391 | static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigned short device) | 393 | static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor, |
394 | unsigned short device) | ||
392 | { | 395 | { |
393 | struct pnp_id * id; | 396 | struct pnp_id *id; |
394 | if (!dev) | 397 | if (!dev) |
395 | return; | 398 | return; |
396 | id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); | 399 | id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
397 | if (!id) | 400 | if (!id) |
398 | return; | 401 | return; |
399 | sprintf(id->id, "%c%c%c%x%x%x%x", | 402 | sprintf(id->id, "%c%c%c%x%x%x%x", |
400 | 'A' + ((vendor >> 2) & 0x3f) - 1, | 403 | 'A' + ((vendor >> 2) & 0x3f) - 1, |
401 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, | 404 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, |
402 | 'A' + ((vendor >> 8) & 0x1f) - 1, | 405 | 'A' + ((vendor >> 8) & 0x1f) - 1, |
403 | (device >> 4) & 0x0f, | 406 | (device >> 4) & 0x0f, |
404 | device & 0x0f, | 407 | device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f); |
405 | (device >> 12) & 0x0f, | ||
406 | (device >> 8) & 0x0f); | ||
407 | pnp_add_id(id, dev); | 408 | pnp_add_id(id, dev); |
408 | } | 409 | } |
409 | 410 | ||
@@ -411,7 +412,8 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne | |||
411 | * Parse logical device tag. | 412 | * Parse logical device tag. |
412 | */ | 413 | */ |
413 | 414 | ||
414 | static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int size, int number) | 415 | static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, |
416 | int size, int number) | ||
415 | { | 417 | { |
416 | unsigned char tmp[6]; | 418 | unsigned char tmp[6]; |
417 | struct pnp_dev *dev; | 419 | struct pnp_dev *dev; |
@@ -435,13 +437,12 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si | |||
435 | return dev; | 437 | return dev; |
436 | } | 438 | } |
437 | 439 | ||
438 | |||
439 | /* | 440 | /* |
440 | * Add IRQ resource to resources list. | 441 | * Add IRQ resource to resources list. |
441 | */ | 442 | */ |
442 | 443 | ||
443 | static void __init isapnp_parse_irq_resource(struct pnp_option *option, | 444 | static void __init isapnp_parse_irq_resource(struct pnp_option *option, |
444 | int size) | 445 | int size) |
445 | { | 446 | { |
446 | unsigned char tmp[3]; | 447 | unsigned char tmp[3]; |
447 | struct pnp_irq *irq; | 448 | struct pnp_irq *irq; |
@@ -466,7 +467,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option, | |||
466 | */ | 467 | */ |
467 | 468 | ||
468 | static void __init isapnp_parse_dma_resource(struct pnp_option *option, | 469 | static void __init isapnp_parse_dma_resource(struct pnp_option *option, |
469 | int size) | 470 | int size) |
470 | { | 471 | { |
471 | unsigned char tmp[2]; | 472 | unsigned char tmp[2]; |
472 | struct pnp_dma *dma; | 473 | struct pnp_dma *dma; |
@@ -486,7 +487,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option, | |||
486 | */ | 487 | */ |
487 | 488 | ||
488 | static void __init isapnp_parse_port_resource(struct pnp_option *option, | 489 | static void __init isapnp_parse_port_resource(struct pnp_option *option, |
489 | int size) | 490 | int size) |
490 | { | 491 | { |
491 | unsigned char tmp[7]; | 492 | unsigned char tmp[7]; |
492 | struct pnp_port *port; | 493 | struct pnp_port *port; |
@@ -500,7 +501,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option, | |||
500 | port->align = tmp[5]; | 501 | port->align = tmp[5]; |
501 | port->size = tmp[6]; | 502 | port->size = tmp[6]; |
502 | port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0; | 503 | port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0; |
503 | pnp_register_port_resource(option,port); | 504 | pnp_register_port_resource(option, port); |
504 | return; | 505 | return; |
505 | } | 506 | } |
506 | 507 | ||
@@ -509,7 +510,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option, | |||
509 | */ | 510 | */ |
510 | 511 | ||
511 | static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, | 512 | static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, |
512 | int size) | 513 | int size) |
513 | { | 514 | { |
514 | unsigned char tmp[3]; | 515 | unsigned char tmp[3]; |
515 | struct pnp_port *port; | 516 | struct pnp_port *port; |
@@ -522,7 +523,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, | |||
522 | port->size = tmp[2]; | 523 | port->size = tmp[2]; |
523 | port->align = 0; | 524 | port->align = 0; |
524 | port->flags = PNP_PORT_FLAG_FIXED; | 525 | port->flags = PNP_PORT_FLAG_FIXED; |
525 | pnp_register_port_resource(option,port); | 526 | pnp_register_port_resource(option, port); |
526 | return; | 527 | return; |
527 | } | 528 | } |
528 | 529 | ||
@@ -531,7 +532,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, | |||
531 | */ | 532 | */ |
532 | 533 | ||
533 | static void __init isapnp_parse_mem_resource(struct pnp_option *option, | 534 | static void __init isapnp_parse_mem_resource(struct pnp_option *option, |
534 | int size) | 535 | int size) |
535 | { | 536 | { |
536 | unsigned char tmp[9]; | 537 | unsigned char tmp[9]; |
537 | struct pnp_mem *mem; | 538 | struct pnp_mem *mem; |
@@ -545,7 +546,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option, | |||
545 | mem->align = (tmp[6] << 8) | tmp[5]; | 546 | mem->align = (tmp[6] << 8) | tmp[5]; |
546 | mem->size = ((tmp[8] << 8) | tmp[7]) << 8; | 547 | mem->size = ((tmp[8] << 8) | tmp[7]) << 8; |
547 | mem->flags = tmp[0]; | 548 | mem->flags = tmp[0]; |
548 | pnp_register_mem_resource(option,mem); | 549 | pnp_register_mem_resource(option, mem); |
549 | return; | 550 | return; |
550 | } | 551 | } |
551 | 552 | ||
@@ -554,7 +555,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option, | |||
554 | */ | 555 | */ |
555 | 556 | ||
556 | static void __init isapnp_parse_mem32_resource(struct pnp_option *option, | 557 | static void __init isapnp_parse_mem32_resource(struct pnp_option *option, |
557 | int size) | 558 | int size) |
558 | { | 559 | { |
559 | unsigned char tmp[17]; | 560 | unsigned char tmp[17]; |
560 | struct pnp_mem *mem; | 561 | struct pnp_mem *mem; |
@@ -565,10 +566,12 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option, | |||
565 | return; | 566 | return; |
566 | mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; | 567 | mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; |
567 | mem->max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; | 568 | mem->max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; |
568 | mem->align = (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9]; | 569 | mem->align = |
569 | mem->size = (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13]; | 570 | (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9]; |
571 | mem->size = | ||
572 | (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13]; | ||
570 | mem->flags = tmp[0]; | 573 | mem->flags = tmp[0]; |
571 | pnp_register_mem_resource(option,mem); | 574 | pnp_register_mem_resource(option, mem); |
572 | } | 575 | } |
573 | 576 | ||
574 | /* | 577 | /* |
@@ -576,7 +579,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option, | |||
576 | */ | 579 | */ |
577 | 580 | ||
578 | static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, | 581 | static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, |
579 | int size) | 582 | int size) |
580 | { | 583 | { |
581 | unsigned char tmp[9]; | 584 | unsigned char tmp[9]; |
582 | struct pnp_mem *mem; | 585 | struct pnp_mem *mem; |
@@ -585,28 +588,30 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, | |||
585 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 588 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
586 | if (!mem) | 589 | if (!mem) |
587 | return; | 590 | return; |
588 | mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; | 591 | mem->min = mem->max = |
592 | (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; | ||
589 | mem->size = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; | 593 | mem->size = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; |
590 | mem->align = 0; | 594 | mem->align = 0; |
591 | mem->flags = tmp[0]; | 595 | mem->flags = tmp[0]; |
592 | pnp_register_mem_resource(option,mem); | 596 | pnp_register_mem_resource(option, mem); |
593 | } | 597 | } |
594 | 598 | ||
595 | /* | 599 | /* |
596 | * Parse card name for ISA PnP device. | 600 | * Parse card name for ISA PnP device. |
597 | */ | 601 | */ |
598 | 602 | ||
599 | static void __init | 603 | static void __init |
600 | isapnp_parse_name(char *name, unsigned int name_max, unsigned short *size) | 604 | isapnp_parse_name(char *name, unsigned int name_max, unsigned short *size) |
601 | { | 605 | { |
602 | if (name[0] == '\0') { | 606 | if (name[0] == '\0') { |
603 | unsigned short size1 = *size >= name_max ? (name_max - 1) : *size; | 607 | unsigned short size1 = |
608 | *size >= name_max ? (name_max - 1) : *size; | ||
604 | isapnp_peek(name, size1); | 609 | isapnp_peek(name, size1); |
605 | name[size1] = '\0'; | 610 | name[size1] = '\0'; |
606 | *size -= size1; | 611 | *size -= size1; |
607 | 612 | ||
608 | /* clean whitespace from end of string */ | 613 | /* clean whitespace from end of string */ |
609 | while (size1 > 0 && name[--size1] == ' ') | 614 | while (size1 > 0 && name[--size1] == ' ') |
610 | name[size1] = '\0'; | 615 | name[size1] = '\0'; |
611 | } | 616 | } |
612 | } | 617 | } |
@@ -629,17 +634,19 @@ static int __init isapnp_create_device(struct pnp_card *card, | |||
629 | kfree(dev); | 634 | kfree(dev); |
630 | return 1; | 635 | return 1; |
631 | } | 636 | } |
632 | pnp_add_card_device(card,dev); | 637 | pnp_add_card_device(card, dev); |
633 | 638 | ||
634 | while (1) { | 639 | while (1) { |
635 | if (isapnp_read_tag(&type, &size)<0) | 640 | if (isapnp_read_tag(&type, &size) < 0) |
636 | return 1; | 641 | return 1; |
637 | if (skip && type != _STAG_LOGDEVID && type != _STAG_END) | 642 | if (skip && type != _STAG_LOGDEVID && type != _STAG_END) |
638 | goto __skip; | 643 | goto __skip; |
639 | switch (type) { | 644 | switch (type) { |
640 | case _STAG_LOGDEVID: | 645 | case _STAG_LOGDEVID: |
641 | if (size >= 5 && size <= 6) { | 646 | if (size >= 5 && size <= 6) { |
642 | if ((dev = isapnp_parse_device(card, size, number++)) == NULL) | 647 | if ((dev = |
648 | isapnp_parse_device(card, size, | ||
649 | number++)) == NULL) | ||
643 | return 1; | 650 | return 1; |
644 | size = 0; | 651 | size = 0; |
645 | skip = 0; | 652 | skip = 0; |
@@ -648,7 +655,7 @@ static int __init isapnp_create_device(struct pnp_card *card, | |||
648 | kfree(dev); | 655 | kfree(dev); |
649 | return 1; | 656 | return 1; |
650 | } | 657 | } |
651 | pnp_add_card_device(card,dev); | 658 | pnp_add_card_device(card, dev); |
652 | } else { | 659 | } else { |
653 | skip = 1; | 660 | skip = 1; |
654 | } | 661 | } |
@@ -658,7 +665,8 @@ static int __init isapnp_create_device(struct pnp_card *card, | |||
658 | case _STAG_COMPATDEVID: | 665 | case _STAG_COMPATDEVID: |
659 | if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) { | 666 | if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) { |
660 | isapnp_peek(tmp, 4); | 667 | isapnp_peek(tmp, 4); |
661 | isapnp_parse_id(dev,(tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2]); | 668 | isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0], |
669 | (tmp[3] << 8) | tmp[2]); | ||
662 | compat++; | 670 | compat++; |
663 | size = 0; | 671 | size = 0; |
664 | } | 672 | } |
@@ -684,7 +692,7 @@ static int __init isapnp_create_device(struct pnp_card *card, | |||
684 | priority = 0x100 | tmp[0]; | 692 | priority = 0x100 | tmp[0]; |
685 | size = 0; | 693 | size = 0; |
686 | } | 694 | } |
687 | option = pnp_register_dependent_option(dev,priority); | 695 | option = pnp_register_dependent_option(dev, priority); |
688 | if (!option) | 696 | if (!option) |
689 | return 1; | 697 | return 1; |
690 | break; | 698 | break; |
@@ -739,11 +747,13 @@ static int __init isapnp_create_device(struct pnp_card *card, | |||
739 | isapnp_skip_bytes(size); | 747 | isapnp_skip_bytes(size); |
740 | return 1; | 748 | return 1; |
741 | default: | 749 | default: |
742 | printk(KERN_ERR "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n", type, dev->number, card->number); | 750 | printk(KERN_ERR |
751 | "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n", | ||
752 | type, dev->number, card->number); | ||
743 | } | 753 | } |
744 | __skip: | 754 | __skip: |
745 | if (size > 0) | 755 | if (size > 0) |
746 | isapnp_skip_bytes(size); | 756 | isapnp_skip_bytes(size); |
747 | } | 757 | } |
748 | return 0; | 758 | return 0; |
749 | } | 759 | } |
@@ -758,7 +768,7 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card) | |||
758 | unsigned short size; | 768 | unsigned short size; |
759 | 769 | ||
760 | while (1) { | 770 | while (1) { |
761 | if (isapnp_read_tag(&type, &size)<0) | 771 | if (isapnp_read_tag(&type, &size) < 0) |
762 | return; | 772 | return; |
763 | switch (type) { | 773 | switch (type) { |
764 | case _STAG_PNPVERNO: | 774 | case _STAG_PNPVERNO: |
@@ -771,7 +781,7 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card) | |||
771 | break; | 781 | break; |
772 | case _STAG_LOGDEVID: | 782 | case _STAG_LOGDEVID: |
773 | if (size >= 5 && size <= 6) { | 783 | if (size >= 5 && size <= 6) { |
774 | if (isapnp_create_device(card, size)==1) | 784 | if (isapnp_create_device(card, size) == 1) |
775 | return; | 785 | return; |
776 | size = 0; | 786 | size = 0; |
777 | } | 787 | } |
@@ -779,7 +789,8 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card) | |||
779 | case _STAG_VENDOR: | 789 | case _STAG_VENDOR: |
780 | break; | 790 | break; |
781 | case _LTAG_ANSISTR: | 791 | case _LTAG_ANSISTR: |
782 | isapnp_parse_name(card->name, sizeof(card->name), &size); | 792 | isapnp_parse_name(card->name, sizeof(card->name), |
793 | &size); | ||
783 | break; | 794 | break; |
784 | case _LTAG_UNICODESTR: | 795 | case _LTAG_UNICODESTR: |
785 | /* silently ignore */ | 796 | /* silently ignore */ |
@@ -792,11 +803,13 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card) | |||
792 | isapnp_skip_bytes(size); | 803 | isapnp_skip_bytes(size); |
793 | return; | 804 | return; |
794 | default: | 805 | default: |
795 | printk(KERN_ERR "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n", type, card->number); | 806 | printk(KERN_ERR |
807 | "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n", | ||
808 | type, card->number); | ||
796 | } | 809 | } |
797 | __skip: | 810 | __skip: |
798 | if (size > 0) | 811 | if (size > 0) |
799 | isapnp_skip_bytes(size); | 812 | isapnp_skip_bytes(size); |
800 | } | 813 | } |
801 | } | 814 | } |
802 | 815 | ||
@@ -815,7 +828,9 @@ static unsigned char __init isapnp_checksum(unsigned char *data) | |||
815 | bit = 0; | 828 | bit = 0; |
816 | if (b & (1 << j)) | 829 | if (b & (1 << j)) |
817 | bit = 1; | 830 | bit = 1; |
818 | checksum = ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7) | (checksum >> 1); | 831 | checksum = |
832 | ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7) | ||
833 | | (checksum >> 1); | ||
819 | } | 834 | } |
820 | } | 835 | } |
821 | return checksum; | 836 | return checksum; |
@@ -825,20 +840,19 @@ static unsigned char __init isapnp_checksum(unsigned char *data) | |||
825 | * Parse EISA id for ISA PnP card. | 840 | * Parse EISA id for ISA PnP card. |
826 | */ | 841 | */ |
827 | 842 | ||
828 | static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) | 843 | static void isapnp_parse_card_id(struct pnp_card *card, unsigned short vendor, |
844 | unsigned short device) | ||
829 | { | 845 | { |
830 | struct pnp_id * id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); | 846 | struct pnp_id *id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
831 | if (!id) | 847 | if (!id) |
832 | return; | 848 | return; |
833 | sprintf(id->id, "%c%c%c%x%x%x%x", | 849 | sprintf(id->id, "%c%c%c%x%x%x%x", |
834 | 'A' + ((vendor >> 2) & 0x3f) - 1, | 850 | 'A' + ((vendor >> 2) & 0x3f) - 1, |
835 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, | 851 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, |
836 | 'A' + ((vendor >> 8) & 0x1f) - 1, | 852 | 'A' + ((vendor >> 8) & 0x1f) - 1, |
837 | (device >> 4) & 0x0f, | 853 | (device >> 4) & 0x0f, |
838 | device & 0x0f, | 854 | device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f); |
839 | (device >> 12) & 0x0f, | 855 | pnp_add_card_id(id, card); |
840 | (device >> 8) & 0x0f); | ||
841 | pnp_add_card_id(id,card); | ||
842 | } | 856 | } |
843 | 857 | ||
844 | /* | 858 | /* |
@@ -858,22 +872,29 @@ static int __init isapnp_build_device_list(void) | |||
858 | isapnp_peek(header, 9); | 872 | isapnp_peek(header, 9); |
859 | checksum = isapnp_checksum(header); | 873 | checksum = isapnp_checksum(header); |
860 | #if 0 | 874 | #if 0 |
861 | printk(KERN_DEBUG "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", | 875 | printk(KERN_DEBUG |
862 | header[0], header[1], header[2], header[3], | 876 | "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", |
863 | header[4], header[5], header[6], header[7], header[8]); | 877 | header[0], header[1], header[2], header[3], header[4], |
878 | header[5], header[6], header[7], header[8]); | ||
864 | printk(KERN_DEBUG "checksum = 0x%x\n", checksum); | 879 | printk(KERN_DEBUG "checksum = 0x%x\n", checksum); |
865 | #endif | 880 | #endif |
866 | if ((card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL) | 881 | if ((card = |
882 | kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL) | ||
867 | continue; | 883 | continue; |
868 | 884 | ||
869 | card->number = csn; | 885 | card->number = csn; |
870 | INIT_LIST_HEAD(&card->devices); | 886 | INIT_LIST_HEAD(&card->devices); |
871 | isapnp_parse_card_id(card, (header[1] << 8) | header[0], (header[3] << 8) | header[2]); | 887 | isapnp_parse_card_id(card, (header[1] << 8) | header[0], |
872 | card->serial = (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | header[4]; | 888 | (header[3] << 8) | header[2]); |
889 | card->serial = | ||
890 | (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | | ||
891 | header[4]; | ||
873 | isapnp_checksum_value = 0x00; | 892 | isapnp_checksum_value = 0x00; |
874 | isapnp_parse_resource_map(card); | 893 | isapnp_parse_resource_map(card); |
875 | if (isapnp_checksum_value != 0x00) | 894 | if (isapnp_checksum_value != 0x00) |
876 | printk(KERN_ERR "isapnp: checksum for device %i is not valid (0x%x)\n", csn, isapnp_checksum_value); | 895 | printk(KERN_ERR |
896 | "isapnp: checksum for device %i is not valid (0x%x)\n", | ||
897 | csn, isapnp_checksum_value); | ||
877 | card->checksum = isapnp_checksum_value; | 898 | card->checksum = isapnp_checksum_value; |
878 | card->protocol = &isapnp_protocol; | 899 | card->protocol = &isapnp_protocol; |
879 | 900 | ||
@@ -911,13 +932,13 @@ int isapnp_cfg_begin(int csn, int logdev) | |||
911 | /* it is possible to set RDP only in the isolation phase */ | 932 | /* it is possible to set RDP only in the isolation phase */ |
912 | /* Jens Thoms Toerring <Jens.Toerring@physik.fu-berlin.de> */ | 933 | /* Jens Thoms Toerring <Jens.Toerring@physik.fu-berlin.de> */ |
913 | isapnp_write_byte(0x02, 0x04); /* clear CSN of card */ | 934 | isapnp_write_byte(0x02, 0x04); /* clear CSN of card */ |
914 | mdelay(2); /* is this necessary? */ | 935 | mdelay(2); /* is this necessary? */ |
915 | isapnp_wake(csn); /* bring card into sleep state */ | 936 | isapnp_wake(csn); /* bring card into sleep state */ |
916 | isapnp_wake(0); /* bring card into isolation state */ | 937 | isapnp_wake(0); /* bring card into isolation state */ |
917 | isapnp_set_rdp(); /* reset the RDP port */ | 938 | isapnp_set_rdp(); /* reset the RDP port */ |
918 | udelay(1000); /* delay 1000us */ | 939 | udelay(1000); /* delay 1000us */ |
919 | isapnp_write_byte(0x06, csn); /* reset CSN to previous value */ | 940 | isapnp_write_byte(0x06, csn); /* reset CSN to previous value */ |
920 | udelay(250); /* is this necessary? */ | 941 | udelay(250); /* is this necessary? */ |
921 | #endif | 942 | #endif |
922 | if (logdev >= 0) | 943 | if (logdev >= 0) |
923 | isapnp_device(logdev); | 944 | isapnp_device(logdev); |
@@ -931,12 +952,10 @@ int isapnp_cfg_end(void) | |||
931 | return 0; | 952 | return 0; |
932 | } | 953 | } |
933 | 954 | ||
934 | |||
935 | /* | 955 | /* |
936 | * Inititialization. | 956 | * Inititialization. |
937 | */ | 957 | */ |
938 | 958 | ||
939 | |||
940 | EXPORT_SYMBOL(isapnp_protocol); | 959 | EXPORT_SYMBOL(isapnp_protocol); |
941 | EXPORT_SYMBOL(isapnp_present); | 960 | EXPORT_SYMBOL(isapnp_present); |
942 | EXPORT_SYMBOL(isapnp_cfg_begin); | 961 | EXPORT_SYMBOL(isapnp_cfg_begin); |
@@ -946,7 +965,8 @@ EXPORT_SYMBOL(isapnp_read_byte); | |||
946 | #endif | 965 | #endif |
947 | EXPORT_SYMBOL(isapnp_write_byte); | 966 | EXPORT_SYMBOL(isapnp_write_byte); |
948 | 967 | ||
949 | static int isapnp_read_resources(struct pnp_dev *dev, struct pnp_resource_table *res) | 968 | static int isapnp_read_resources(struct pnp_dev *dev, |
969 | struct pnp_resource_table *res) | ||
950 | { | 970 | { |
951 | int tmp, ret; | 971 | int tmp, ret; |
952 | 972 | ||
@@ -960,31 +980,37 @@ static int isapnp_read_resources(struct pnp_dev *dev, struct pnp_resource_table | |||
960 | res->port_resource[tmp].flags = IORESOURCE_IO; | 980 | res->port_resource[tmp].flags = IORESOURCE_IO; |
961 | } | 981 | } |
962 | for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { | 982 | for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { |
963 | ret = isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; | 983 | ret = |
984 | isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; | ||
964 | if (!ret) | 985 | if (!ret) |
965 | continue; | 986 | continue; |
966 | res->mem_resource[tmp].start = ret; | 987 | res->mem_resource[tmp].start = ret; |
967 | res->mem_resource[tmp].flags = IORESOURCE_MEM; | 988 | res->mem_resource[tmp].flags = IORESOURCE_MEM; |
968 | } | 989 | } |
969 | for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { | 990 | for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { |
970 | ret = (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >> 8); | 991 | ret = |
992 | (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >> | ||
993 | 8); | ||
971 | if (!ret) | 994 | if (!ret) |
972 | continue; | 995 | continue; |
973 | res->irq_resource[tmp].start = res->irq_resource[tmp].end = ret; | 996 | res->irq_resource[tmp].start = |
997 | res->irq_resource[tmp].end = ret; | ||
974 | res->irq_resource[tmp].flags = IORESOURCE_IRQ; | 998 | res->irq_resource[tmp].flags = IORESOURCE_IRQ; |
975 | } | 999 | } |
976 | for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { | 1000 | for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { |
977 | ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); | 1001 | ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); |
978 | if (ret == 4) | 1002 | if (ret == 4) |
979 | continue; | 1003 | continue; |
980 | res->dma_resource[tmp].start = res->dma_resource[tmp].end = ret; | 1004 | res->dma_resource[tmp].start = |
1005 | res->dma_resource[tmp].end = ret; | ||
981 | res->dma_resource[tmp].flags = IORESOURCE_DMA; | 1006 | res->dma_resource[tmp].flags = IORESOURCE_DMA; |
982 | } | 1007 | } |
983 | } | 1008 | } |
984 | return 0; | 1009 | return 0; |
985 | } | 1010 | } |
986 | 1011 | ||
987 | static int isapnp_get_resources(struct pnp_dev *dev, struct pnp_resource_table * res) | 1012 | static int isapnp_get_resources(struct pnp_dev *dev, |
1013 | struct pnp_resource_table *res) | ||
988 | { | 1014 | { |
989 | int ret; | 1015 | int ret; |
990 | pnp_init_resource_table(res); | 1016 | pnp_init_resource_table(res); |
@@ -994,24 +1020,44 @@ static int isapnp_get_resources(struct pnp_dev *dev, struct pnp_resource_table * | |||
994 | return ret; | 1020 | return ret; |
995 | } | 1021 | } |
996 | 1022 | ||
997 | static int isapnp_set_resources(struct pnp_dev *dev, struct pnp_resource_table * res) | 1023 | static int isapnp_set_resources(struct pnp_dev *dev, |
1024 | struct pnp_resource_table *res) | ||
998 | { | 1025 | { |
999 | int tmp; | 1026 | int tmp; |
1000 | 1027 | ||
1001 | isapnp_cfg_begin(dev->card->number, dev->number); | 1028 | isapnp_cfg_begin(dev->card->number, dev->number); |
1002 | dev->active = 1; | 1029 | dev->active = 1; |
1003 | for (tmp = 0; tmp < PNP_MAX_PORT && (res->port_resource[tmp].flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO; tmp++) | 1030 | for (tmp = 0; |
1004 | isapnp_write_word(ISAPNP_CFG_PORT+(tmp<<1), res->port_resource[tmp].start); | 1031 | tmp < PNP_MAX_PORT |
1005 | for (tmp = 0; tmp < PNP_MAX_IRQ && (res->irq_resource[tmp].flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ; tmp++) { | 1032 | && (res->port_resource[tmp]. |
1033 | flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO; | ||
1034 | tmp++) | ||
1035 | isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), | ||
1036 | res->port_resource[tmp].start); | ||
1037 | for (tmp = 0; | ||
1038 | tmp < PNP_MAX_IRQ | ||
1039 | && (res->irq_resource[tmp]. | ||
1040 | flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ; | ||
1041 | tmp++) { | ||
1006 | int irq = res->irq_resource[tmp].start; | 1042 | int irq = res->irq_resource[tmp].start; |
1007 | if (irq == 2) | 1043 | if (irq == 2) |
1008 | irq = 9; | 1044 | irq = 9; |
1009 | isapnp_write_byte(ISAPNP_CFG_IRQ+(tmp<<1), irq); | 1045 | isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq); |
1010 | } | 1046 | } |
1011 | for (tmp = 0; tmp < PNP_MAX_DMA && (res->dma_resource[tmp].flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA; tmp++) | 1047 | for (tmp = 0; |
1012 | isapnp_write_byte(ISAPNP_CFG_DMA+tmp, res->dma_resource[tmp].start); | 1048 | tmp < PNP_MAX_DMA |
1013 | for (tmp = 0; tmp < PNP_MAX_MEM && (res->mem_resource[tmp].flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM; tmp++) | 1049 | && (res->dma_resource[tmp]. |
1014 | isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<3), (res->mem_resource[tmp].start >> 8) & 0xffff); | 1050 | flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA; |
1051 | tmp++) | ||
1052 | isapnp_write_byte(ISAPNP_CFG_DMA + tmp, | ||
1053 | res->dma_resource[tmp].start); | ||
1054 | for (tmp = 0; | ||
1055 | tmp < PNP_MAX_MEM | ||
1056 | && (res->mem_resource[tmp]. | ||
1057 | flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM; | ||
1058 | tmp++) | ||
1059 | isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), | ||
1060 | (res->mem_resource[tmp].start >> 8) & 0xffff); | ||
1015 | /* FIXME: We aren't handling 32bit mems properly here */ | 1061 | /* FIXME: We aren't handling 32bit mems properly here */ |
1016 | isapnp_activate(dev->number); | 1062 | isapnp_activate(dev->number); |
1017 | isapnp_cfg_end(); | 1063 | isapnp_cfg_end(); |
@@ -1030,9 +1076,9 @@ static int isapnp_disable_resources(struct pnp_dev *dev) | |||
1030 | } | 1076 | } |
1031 | 1077 | ||
1032 | struct pnp_protocol isapnp_protocol = { | 1078 | struct pnp_protocol isapnp_protocol = { |
1033 | .name = "ISA Plug and Play", | 1079 | .name = "ISA Plug and Play", |
1034 | .get = isapnp_get_resources, | 1080 | .get = isapnp_get_resources, |
1035 | .set = isapnp_set_resources, | 1081 | .set = isapnp_set_resources, |
1036 | .disable = isapnp_disable_resources, | 1082 | .disable = isapnp_disable_resources, |
1037 | }; | 1083 | }; |
1038 | 1084 | ||
@@ -1053,31 +1099,36 @@ static int __init isapnp_init(void) | |||
1053 | #endif | 1099 | #endif |
1054 | #ifdef ISAPNP_REGION_OK | 1100 | #ifdef ISAPNP_REGION_OK |
1055 | if (!request_region(_PIDXR, 1, "isapnp index")) { | 1101 | if (!request_region(_PIDXR, 1, "isapnp index")) { |
1056 | printk(KERN_ERR "isapnp: Index Register 0x%x already used\n", _PIDXR); | 1102 | printk(KERN_ERR "isapnp: Index Register 0x%x already used\n", |
1103 | _PIDXR); | ||
1057 | return -EBUSY; | 1104 | return -EBUSY; |
1058 | } | 1105 | } |
1059 | #endif | 1106 | #endif |
1060 | if (!request_region(_PNPWRP, 1, "isapnp write")) { | 1107 | if (!request_region(_PNPWRP, 1, "isapnp write")) { |
1061 | printk(KERN_ERR "isapnp: Write Data Register 0x%x already used\n", _PNPWRP); | 1108 | printk(KERN_ERR |
1109 | "isapnp: Write Data Register 0x%x already used\n", | ||
1110 | _PNPWRP); | ||
1062 | #ifdef ISAPNP_REGION_OK | 1111 | #ifdef ISAPNP_REGION_OK |
1063 | release_region(_PIDXR, 1); | 1112 | release_region(_PIDXR, 1); |
1064 | #endif | 1113 | #endif |
1065 | return -EBUSY; | 1114 | return -EBUSY; |
1066 | } | 1115 | } |
1067 | 1116 | ||
1068 | if(pnp_register_protocol(&isapnp_protocol)<0) | 1117 | if (pnp_register_protocol(&isapnp_protocol) < 0) |
1069 | return -EBUSY; | 1118 | return -EBUSY; |
1070 | 1119 | ||
1071 | /* | 1120 | /* |
1072 | * Print a message. The existing ISAPnP code is hanging machines | 1121 | * Print a message. The existing ISAPnP code is hanging machines |
1073 | * so let the user know where. | 1122 | * so let the user know where. |
1074 | */ | 1123 | */ |
1075 | 1124 | ||
1076 | printk(KERN_INFO "isapnp: Scanning for PnP cards...\n"); | 1125 | printk(KERN_INFO "isapnp: Scanning for PnP cards...\n"); |
1077 | if (isapnp_rdp >= 0x203 && isapnp_rdp <= 0x3ff) { | 1126 | if (isapnp_rdp >= 0x203 && isapnp_rdp <= 0x3ff) { |
1078 | isapnp_rdp |= 3; | 1127 | isapnp_rdp |= 3; |
1079 | if (!request_region(isapnp_rdp, 1, "isapnp read")) { | 1128 | if (!request_region(isapnp_rdp, 1, "isapnp read")) { |
1080 | printk(KERN_ERR "isapnp: Read Data Register 0x%x already used\n", isapnp_rdp); | 1129 | printk(KERN_ERR |
1130 | "isapnp: Read Data Register 0x%x already used\n", | ||
1131 | isapnp_rdp); | ||
1081 | #ifdef ISAPNP_REGION_OK | 1132 | #ifdef ISAPNP_REGION_OK |
1082 | release_region(_PIDXR, 1); | 1133 | release_region(_PIDXR, 1); |
1083 | #endif | 1134 | #endif |
@@ -1089,14 +1140,14 @@ static int __init isapnp_init(void) | |||
1089 | isapnp_detected = 1; | 1140 | isapnp_detected = 1; |
1090 | if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) { | 1141 | if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) { |
1091 | cards = isapnp_isolate(); | 1142 | cards = isapnp_isolate(); |
1092 | if (cards < 0 || | 1143 | if (cards < 0 || (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) { |
1093 | (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) { | ||
1094 | #ifdef ISAPNP_REGION_OK | 1144 | #ifdef ISAPNP_REGION_OK |
1095 | release_region(_PIDXR, 1); | 1145 | release_region(_PIDXR, 1); |
1096 | #endif | 1146 | #endif |
1097 | release_region(_PNPWRP, 1); | 1147 | release_region(_PNPWRP, 1); |
1098 | isapnp_detected = 0; | 1148 | isapnp_detected = 0; |
1099 | printk(KERN_INFO "isapnp: No Plug & Play device found\n"); | 1149 | printk(KERN_INFO |
1150 | "isapnp: No Plug & Play device found\n"); | ||
1100 | return 0; | 1151 | return 0; |
1101 | } | 1152 | } |
1102 | request_region(isapnp_rdp, 1, "isapnp read"); | 1153 | request_region(isapnp_rdp, 1, "isapnp read"); |
@@ -1104,19 +1155,23 @@ static int __init isapnp_init(void) | |||
1104 | isapnp_build_device_list(); | 1155 | isapnp_build_device_list(); |
1105 | cards = 0; | 1156 | cards = 0; |
1106 | 1157 | ||
1107 | protocol_for_each_card(&isapnp_protocol,card) { | 1158 | protocol_for_each_card(&isapnp_protocol, card) { |
1108 | cards++; | 1159 | cards++; |
1109 | if (isapnp_verbose) { | 1160 | if (isapnp_verbose) { |
1110 | printk(KERN_INFO "isapnp: Card '%s'\n", card->name[0]?card->name:"Unknown"); | 1161 | printk(KERN_INFO "isapnp: Card '%s'\n", |
1162 | card->name[0] ? card->name : "Unknown"); | ||
1111 | if (isapnp_verbose < 2) | 1163 | if (isapnp_verbose < 2) |
1112 | continue; | 1164 | continue; |
1113 | card_for_each_dev(card,dev) { | 1165 | card_for_each_dev(card, dev) { |
1114 | printk(KERN_INFO "isapnp: Device '%s'\n", dev->name[0]?dev->name:"Unknown"); | 1166 | printk(KERN_INFO "isapnp: Device '%s'\n", |
1167 | dev->name[0] ? dev->name : "Unknown"); | ||
1115 | } | 1168 | } |
1116 | } | 1169 | } |
1117 | } | 1170 | } |
1118 | if (cards) { | 1171 | if (cards) { |
1119 | printk(KERN_INFO "isapnp: %i Plug & Play card%s detected total\n", cards, cards>1?"s":""); | 1172 | printk(KERN_INFO |
1173 | "isapnp: %i Plug & Play card%s detected total\n", cards, | ||
1174 | cards > 1 ? "s" : ""); | ||
1120 | } else { | 1175 | } else { |
1121 | printk(KERN_INFO "isapnp: No Plug & Play card found\n"); | 1176 | printk(KERN_INFO "isapnp: No Plug & Play card found\n"); |
1122 | } | 1177 | } |
@@ -1141,11 +1196,10 @@ __setup("noisapnp", isapnp_setup_disable); | |||
1141 | 1196 | ||
1142 | static int __init isapnp_setup_isapnp(char *str) | 1197 | static int __init isapnp_setup_isapnp(char *str) |
1143 | { | 1198 | { |
1144 | (void)((get_option(&str,&isapnp_rdp) == 2) && | 1199 | (void)((get_option(&str, &isapnp_rdp) == 2) && |
1145 | (get_option(&str,&isapnp_reset) == 2) && | 1200 | (get_option(&str, &isapnp_reset) == 2) && |
1146 | (get_option(&str,&isapnp_verbose) == 2)); | 1201 | (get_option(&str, &isapnp_verbose) == 2)); |
1147 | return 1; | 1202 | return 1; |
1148 | } | 1203 | } |
1149 | 1204 | ||
1150 | __setup("isapnp=", isapnp_setup_isapnp); | 1205 | __setup("isapnp=", isapnp_setup_isapnp); |
1151 | |||
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c index 40b724ebe23b..fba4b072e6bd 100644 --- a/drivers/pnp/isapnp/proc.c +++ b/drivers/pnp/isapnp/proc.c | |||
@@ -54,7 +54,8 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence) | |||
54 | return (file->f_pos = new); | 54 | return (file->f_pos = new); |
55 | } | 55 | } |
56 | 56 | ||
57 | static ssize_t isapnp_proc_bus_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | 57 | static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf, |
58 | size_t nbytes, loff_t * ppos) | ||
58 | { | 59 | { |
59 | struct inode *ino = file->f_path.dentry->d_inode; | 60 | struct inode *ino = file->f_path.dentry->d_inode; |
60 | struct proc_dir_entry *dp = PDE(ino); | 61 | struct proc_dir_entry *dp = PDE(ino); |
@@ -74,7 +75,7 @@ static ssize_t isapnp_proc_bus_read(struct file *file, char __user *buf, size_t | |||
74 | return -EINVAL; | 75 | return -EINVAL; |
75 | 76 | ||
76 | isapnp_cfg_begin(dev->card->number, dev->number); | 77 | isapnp_cfg_begin(dev->card->number, dev->number); |
77 | for ( ; pos < 256 && cnt > 0; pos++, buf++, cnt--) { | 78 | for (; pos < 256 && cnt > 0; pos++, buf++, cnt--) { |
78 | unsigned char val; | 79 | unsigned char val; |
79 | val = isapnp_read_byte(pos); | 80 | val = isapnp_read_byte(pos); |
80 | __put_user(val, buf); | 81 | __put_user(val, buf); |
@@ -85,10 +86,9 @@ static ssize_t isapnp_proc_bus_read(struct file *file, char __user *buf, size_t | |||
85 | return nbytes; | 86 | return nbytes; |
86 | } | 87 | } |
87 | 88 | ||
88 | static const struct file_operations isapnp_proc_bus_file_operations = | 89 | static const struct file_operations isapnp_proc_bus_file_operations = { |
89 | { | 90 | .llseek = isapnp_proc_bus_lseek, |
90 | .llseek = isapnp_proc_bus_lseek, | 91 | .read = isapnp_proc_bus_read, |
91 | .read = isapnp_proc_bus_read, | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | static int isapnp_proc_attach_device(struct pnp_dev *dev) | 94 | static int isapnp_proc_attach_device(struct pnp_dev *dev) |
@@ -145,7 +145,7 @@ int __init isapnp_proc_init(void) | |||
145 | { | 145 | { |
146 | struct pnp_dev *dev; | 146 | struct pnp_dev *dev; |
147 | isapnp_proc_bus_dir = proc_mkdir("isapnp", proc_bus); | 147 | isapnp_proc_bus_dir = proc_mkdir("isapnp", proc_bus); |
148 | protocol_for_each_dev(&isapnp_protocol,dev) { | 148 | protocol_for_each_dev(&isapnp_protocol, dev) { |
149 | isapnp_proc_attach_device(dev); | 149 | isapnp_proc_attach_device(dev); |
150 | } | 150 | } |
151 | return 0; | 151 | return 0; |
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 57e6ab1004d0..17c95188bd11 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c | |||
@@ -26,7 +26,8 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) | |||
26 | return -EINVAL; | 26 | return -EINVAL; |
27 | 27 | ||
28 | if (idx >= PNP_MAX_PORT) { | 28 | if (idx >= PNP_MAX_PORT) { |
29 | pnp_err("More than 4 ports is incompatible with pnp specifications."); | 29 | pnp_err |
30 | ("More than 4 ports is incompatible with pnp specifications."); | ||
30 | /* pretend we were successful so at least the manager won't try again */ | 31 | /* pretend we were successful so at least the manager won't try again */ |
31 | return 1; | 32 | return 1; |
32 | } | 33 | } |
@@ -41,11 +42,11 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) | |||
41 | 42 | ||
42 | /* set the initial values */ | 43 | /* set the initial values */ |
43 | *flags |= rule->flags | IORESOURCE_IO; | 44 | *flags |= rule->flags | IORESOURCE_IO; |
44 | *flags &= ~IORESOURCE_UNSET; | 45 | *flags &= ~IORESOURCE_UNSET; |
45 | 46 | ||
46 | if (!rule->size) { | 47 | if (!rule->size) { |
47 | *flags |= IORESOURCE_DISABLED; | 48 | *flags |= IORESOURCE_DISABLED; |
48 | return 1; /* skip disabled resource requests */ | 49 | return 1; /* skip disabled resource requests */ |
49 | } | 50 | } |
50 | 51 | ||
51 | *start = rule->min; | 52 | *start = rule->min; |
@@ -70,7 +71,8 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) | |||
70 | return -EINVAL; | 71 | return -EINVAL; |
71 | 72 | ||
72 | if (idx >= PNP_MAX_MEM) { | 73 | if (idx >= PNP_MAX_MEM) { |
73 | pnp_err("More than 8 mems is incompatible with pnp specifications."); | 74 | pnp_err |
75 | ("More than 8 mems is incompatible with pnp specifications."); | ||
74 | /* pretend we were successful so at least the manager won't try again */ | 76 | /* pretend we were successful so at least the manager won't try again */ |
75 | return 1; | 77 | return 1; |
76 | } | 78 | } |
@@ -85,7 +87,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) | |||
85 | 87 | ||
86 | /* set the initial values */ | 88 | /* set the initial values */ |
87 | *flags |= rule->flags | IORESOURCE_MEM; | 89 | *flags |= rule->flags | IORESOURCE_MEM; |
88 | *flags &= ~IORESOURCE_UNSET; | 90 | *flags &= ~IORESOURCE_UNSET; |
89 | 91 | ||
90 | /* convert pnp flags to standard Linux flags */ | 92 | /* convert pnp flags to standard Linux flags */ |
91 | if (!(rule->flags & IORESOURCE_MEM_WRITEABLE)) | 93 | if (!(rule->flags & IORESOURCE_MEM_WRITEABLE)) |
@@ -99,11 +101,11 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) | |||
99 | 101 | ||
100 | if (!rule->size) { | 102 | if (!rule->size) { |
101 | *flags |= IORESOURCE_DISABLED; | 103 | *flags |= IORESOURCE_DISABLED; |
102 | return 1; /* skip disabled resource requests */ | 104 | return 1; /* skip disabled resource requests */ |
103 | } | 105 | } |
104 | 106 | ||
105 | *start = rule->min; | 107 | *start = rule->min; |
106 | *end = *start + rule->size -1; | 108 | *end = *start + rule->size - 1; |
107 | 109 | ||
108 | /* run through until pnp_check_mem is happy */ | 110 | /* run through until pnp_check_mem is happy */ |
109 | while (!pnp_check_mem(dev, idx)) { | 111 | while (!pnp_check_mem(dev, idx)) { |
@@ -115,7 +117,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) | |||
115 | return 1; | 117 | return 1; |
116 | } | 118 | } |
117 | 119 | ||
118 | static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) | 120 | static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) |
119 | { | 121 | { |
120 | resource_size_t *start, *end; | 122 | resource_size_t *start, *end; |
121 | unsigned long *flags; | 123 | unsigned long *flags; |
@@ -130,7 +132,8 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) | |||
130 | return -EINVAL; | 132 | return -EINVAL; |
131 | 133 | ||
132 | if (idx >= PNP_MAX_IRQ) { | 134 | if (idx >= PNP_MAX_IRQ) { |
133 | pnp_err("More than 2 irqs is incompatible with pnp specifications."); | 135 | pnp_err |
136 | ("More than 2 irqs is incompatible with pnp specifications."); | ||
134 | /* pretend we were successful so at least the manager won't try again */ | 137 | /* pretend we were successful so at least the manager won't try again */ |
135 | return 1; | 138 | return 1; |
136 | } | 139 | } |
@@ -145,11 +148,11 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) | |||
145 | 148 | ||
146 | /* set the initial values */ | 149 | /* set the initial values */ |
147 | *flags |= rule->flags | IORESOURCE_IRQ; | 150 | *flags |= rule->flags | IORESOURCE_IRQ; |
148 | *flags &= ~IORESOURCE_UNSET; | 151 | *flags &= ~IORESOURCE_UNSET; |
149 | 152 | ||
150 | if (bitmap_empty(rule->map, PNP_IRQ_NR)) { | 153 | if (bitmap_empty(rule->map, PNP_IRQ_NR)) { |
151 | *flags |= IORESOURCE_DISABLED; | 154 | *flags |= IORESOURCE_DISABLED; |
152 | return 1; /* skip disabled resource requests */ | 155 | return 1; /* skip disabled resource requests */ |
153 | } | 156 | } |
154 | 157 | ||
155 | /* TBD: need check for >16 IRQ */ | 158 | /* TBD: need check for >16 IRQ */ |
@@ -159,9 +162,9 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) | |||
159 | return 1; | 162 | return 1; |
160 | } | 163 | } |
161 | for (i = 0; i < 16; i++) { | 164 | for (i = 0; i < 16; i++) { |
162 | if(test_bit(xtab[i], rule->map)) { | 165 | if (test_bit(xtab[i], rule->map)) { |
163 | *start = *end = xtab[i]; | 166 | *start = *end = xtab[i]; |
164 | if(pnp_check_irq(dev, idx)) | 167 | if (pnp_check_irq(dev, idx)) |
165 | return 1; | 168 | return 1; |
166 | } | 169 | } |
167 | } | 170 | } |
@@ -183,7 +186,8 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
183 | return -EINVAL; | 186 | return -EINVAL; |
184 | 187 | ||
185 | if (idx >= PNP_MAX_DMA) { | 188 | if (idx >= PNP_MAX_DMA) { |
186 | pnp_err("More than 2 dmas is incompatible with pnp specifications."); | 189 | pnp_err |
190 | ("More than 2 dmas is incompatible with pnp specifications."); | ||
187 | /* pretend we were successful so at least the manager won't try again */ | 191 | /* pretend we were successful so at least the manager won't try again */ |
188 | return 1; | 192 | return 1; |
189 | } | 193 | } |
@@ -198,17 +202,17 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
198 | 202 | ||
199 | /* set the initial values */ | 203 | /* set the initial values */ |
200 | *flags |= rule->flags | IORESOURCE_DMA; | 204 | *flags |= rule->flags | IORESOURCE_DMA; |
201 | *flags &= ~IORESOURCE_UNSET; | 205 | *flags &= ~IORESOURCE_UNSET; |
202 | 206 | ||
203 | if (!rule->map) { | 207 | if (!rule->map) { |
204 | *flags |= IORESOURCE_DISABLED; | 208 | *flags |= IORESOURCE_DISABLED; |
205 | return 1; /* skip disabled resource requests */ | 209 | return 1; /* skip disabled resource requests */ |
206 | } | 210 | } |
207 | 211 | ||
208 | for (i = 0; i < 8; i++) { | 212 | for (i = 0; i < 8; i++) { |
209 | if(rule->map & (1<<xtab[i])) { | 213 | if (rule->map & (1 << xtab[i])) { |
210 | *start = *end = xtab[i]; | 214 | *start = *end = xtab[i]; |
211 | if(pnp_check_dma(dev, idx)) | 215 | if (pnp_check_dma(dev, idx)) |
212 | return 1; | 216 | return 1; |
213 | } | 217 | } |
214 | } | 218 | } |
@@ -227,25 +231,29 @@ void pnp_init_resource_table(struct pnp_resource_table *table) | |||
227 | table->irq_resource[idx].name = NULL; | 231 | table->irq_resource[idx].name = NULL; |
228 | table->irq_resource[idx].start = -1; | 232 | table->irq_resource[idx].start = -1; |
229 | table->irq_resource[idx].end = -1; | 233 | table->irq_resource[idx].end = -1; |
230 | table->irq_resource[idx].flags = IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; | 234 | table->irq_resource[idx].flags = |
235 | IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
231 | } | 236 | } |
232 | for (idx = 0; idx < PNP_MAX_DMA; idx++) { | 237 | for (idx = 0; idx < PNP_MAX_DMA; idx++) { |
233 | table->dma_resource[idx].name = NULL; | 238 | table->dma_resource[idx].name = NULL; |
234 | table->dma_resource[idx].start = -1; | 239 | table->dma_resource[idx].start = -1; |
235 | table->dma_resource[idx].end = -1; | 240 | table->dma_resource[idx].end = -1; |
236 | table->dma_resource[idx].flags = IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; | 241 | table->dma_resource[idx].flags = |
242 | IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
237 | } | 243 | } |
238 | for (idx = 0; idx < PNP_MAX_PORT; idx++) { | 244 | for (idx = 0; idx < PNP_MAX_PORT; idx++) { |
239 | table->port_resource[idx].name = NULL; | 245 | table->port_resource[idx].name = NULL; |
240 | table->port_resource[idx].start = 0; | 246 | table->port_resource[idx].start = 0; |
241 | table->port_resource[idx].end = 0; | 247 | table->port_resource[idx].end = 0; |
242 | table->port_resource[idx].flags = IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; | 248 | table->port_resource[idx].flags = |
249 | IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
243 | } | 250 | } |
244 | for (idx = 0; idx < PNP_MAX_MEM; idx++) { | 251 | for (idx = 0; idx < PNP_MAX_MEM; idx++) { |
245 | table->mem_resource[idx].name = NULL; | 252 | table->mem_resource[idx].name = NULL; |
246 | table->mem_resource[idx].start = 0; | 253 | table->mem_resource[idx].start = 0; |
247 | table->mem_resource[idx].end = 0; | 254 | table->mem_resource[idx].end = 0; |
248 | table->mem_resource[idx].flags = IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; | 255 | table->mem_resource[idx].flags = |
256 | IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
249 | } | 257 | } |
250 | } | 258 | } |
251 | 259 | ||
@@ -254,7 +262,7 @@ void pnp_init_resource_table(struct pnp_resource_table *table) | |||
254 | * @res: the resources to clean | 262 | * @res: the resources to clean |
255 | * | 263 | * |
256 | */ | 264 | */ |
257 | static void pnp_clean_resource_table(struct pnp_resource_table * res) | 265 | static void pnp_clean_resource_table(struct pnp_resource_table *res) |
258 | { | 266 | { |
259 | int idx; | 267 | int idx; |
260 | for (idx = 0; idx < PNP_MAX_IRQ; idx++) { | 268 | for (idx = 0; idx < PNP_MAX_IRQ; idx++) { |
@@ -262,28 +270,32 @@ static void pnp_clean_resource_table(struct pnp_resource_table * res) | |||
262 | continue; | 270 | continue; |
263 | res->irq_resource[idx].start = -1; | 271 | res->irq_resource[idx].start = -1; |
264 | res->irq_resource[idx].end = -1; | 272 | res->irq_resource[idx].end = -1; |
265 | res->irq_resource[idx].flags = IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; | 273 | res->irq_resource[idx].flags = |
274 | IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
266 | } | 275 | } |
267 | for (idx = 0; idx < PNP_MAX_DMA; idx++) { | 276 | for (idx = 0; idx < PNP_MAX_DMA; idx++) { |
268 | if (!(res->dma_resource[idx].flags & IORESOURCE_AUTO)) | 277 | if (!(res->dma_resource[idx].flags & IORESOURCE_AUTO)) |
269 | continue; | 278 | continue; |
270 | res->dma_resource[idx].start = -1; | 279 | res->dma_resource[idx].start = -1; |
271 | res->dma_resource[idx].end = -1; | 280 | res->dma_resource[idx].end = -1; |
272 | res->dma_resource[idx].flags = IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; | 281 | res->dma_resource[idx].flags = |
282 | IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
273 | } | 283 | } |
274 | for (idx = 0; idx < PNP_MAX_PORT; idx++) { | 284 | for (idx = 0; idx < PNP_MAX_PORT; idx++) { |
275 | if (!(res->port_resource[idx].flags & IORESOURCE_AUTO)) | 285 | if (!(res->port_resource[idx].flags & IORESOURCE_AUTO)) |
276 | continue; | 286 | continue; |
277 | res->port_resource[idx].start = 0; | 287 | res->port_resource[idx].start = 0; |
278 | res->port_resource[idx].end = 0; | 288 | res->port_resource[idx].end = 0; |
279 | res->port_resource[idx].flags = IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; | 289 | res->port_resource[idx].flags = |
290 | IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
280 | } | 291 | } |
281 | for (idx = 0; idx < PNP_MAX_MEM; idx++) { | 292 | for (idx = 0; idx < PNP_MAX_MEM; idx++) { |
282 | if (!(res->mem_resource[idx].flags & IORESOURCE_AUTO)) | 293 | if (!(res->mem_resource[idx].flags & IORESOURCE_AUTO)) |
283 | continue; | 294 | continue; |
284 | res->mem_resource[idx].start = 0; | 295 | res->mem_resource[idx].start = 0; |
285 | res->mem_resource[idx].end = 0; | 296 | res->mem_resource[idx].end = 0; |
286 | res->mem_resource[idx].flags = IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; | 297 | res->mem_resource[idx].flags = |
298 | IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; | ||
287 | } | 299 | } |
288 | } | 300 | } |
289 | 301 | ||
@@ -306,7 +318,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum) | |||
306 | return -ENODEV; | 318 | return -ENODEV; |
307 | 319 | ||
308 | down(&pnp_res_mutex); | 320 | down(&pnp_res_mutex); |
309 | pnp_clean_resource_table(&dev->res); /* start with a fresh slate */ | 321 | pnp_clean_resource_table(&dev->res); /* start with a fresh slate */ |
310 | if (dev->independent) { | 322 | if (dev->independent) { |
311 | port = dev->independent->port; | 323 | port = dev->independent->port; |
312 | mem = dev->independent->mem; | 324 | mem = dev->independent->mem; |
@@ -341,10 +353,11 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum) | |||
341 | if (depnum) { | 353 | if (depnum) { |
342 | struct pnp_option *dep; | 354 | struct pnp_option *dep; |
343 | int i; | 355 | int i; |
344 | for (i=1,dep=dev->dependent; i<depnum; i++, dep=dep->next) | 356 | for (i = 1, dep = dev->dependent; i < depnum; |
345 | if(!dep) | 357 | i++, dep = dep->next) |
358 | if (!dep) | ||
346 | goto fail; | 359 | goto fail; |
347 | port =dep->port; | 360 | port = dep->port; |
348 | mem = dep->mem; | 361 | mem = dep->mem; |
349 | irq = dep->irq; | 362 | irq = dep->irq; |
350 | dma = dep->dma; | 363 | dma = dep->dma; |
@@ -378,7 +391,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum) | |||
378 | up(&pnp_res_mutex); | 391 | up(&pnp_res_mutex); |
379 | return 1; | 392 | return 1; |
380 | 393 | ||
381 | fail: | 394 | fail: |
382 | pnp_clean_resource_table(&dev->res); | 395 | pnp_clean_resource_table(&dev->res); |
383 | up(&pnp_res_mutex); | 396 | up(&pnp_res_mutex); |
384 | return 0; | 397 | return 0; |
@@ -392,10 +405,11 @@ fail: | |||
392 | * | 405 | * |
393 | * This function can be used by drivers that want to manually set thier resources. | 406 | * This function can be used by drivers that want to manually set thier resources. |
394 | */ | 407 | */ |
395 | int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res, int mode) | 408 | int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, |
409 | int mode) | ||
396 | { | 410 | { |
397 | int i; | 411 | int i; |
398 | struct pnp_resource_table * bak; | 412 | struct pnp_resource_table *bak; |
399 | if (!dev || !res) | 413 | if (!dev || !res) |
400 | return -EINVAL; | 414 | return -EINVAL; |
401 | if (!pnp_can_configure(dev)) | 415 | if (!pnp_can_configure(dev)) |
@@ -409,19 +423,19 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res, | |||
409 | dev->res = *res; | 423 | dev->res = *res; |
410 | if (!(mode & PNP_CONFIG_FORCE)) { | 424 | if (!(mode & PNP_CONFIG_FORCE)) { |
411 | for (i = 0; i < PNP_MAX_PORT; i++) { | 425 | for (i = 0; i < PNP_MAX_PORT; i++) { |
412 | if(!pnp_check_port(dev,i)) | 426 | if (!pnp_check_port(dev, i)) |
413 | goto fail; | 427 | goto fail; |
414 | } | 428 | } |
415 | for (i = 0; i < PNP_MAX_MEM; i++) { | 429 | for (i = 0; i < PNP_MAX_MEM; i++) { |
416 | if(!pnp_check_mem(dev,i)) | 430 | if (!pnp_check_mem(dev, i)) |
417 | goto fail; | 431 | goto fail; |
418 | } | 432 | } |
419 | for (i = 0; i < PNP_MAX_IRQ; i++) { | 433 | for (i = 0; i < PNP_MAX_IRQ; i++) { |
420 | if(!pnp_check_irq(dev,i)) | 434 | if (!pnp_check_irq(dev, i)) |
421 | goto fail; | 435 | goto fail; |
422 | } | 436 | } |
423 | for (i = 0; i < PNP_MAX_DMA; i++) { | 437 | for (i = 0; i < PNP_MAX_DMA; i++) { |
424 | if(!pnp_check_dma(dev,i)) | 438 | if (!pnp_check_dma(dev, i)) |
425 | goto fail; | 439 | goto fail; |
426 | } | 440 | } |
427 | } | 441 | } |
@@ -430,7 +444,7 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res, | |||
430 | kfree(bak); | 444 | kfree(bak); |
431 | return 0; | 445 | return 0; |
432 | 446 | ||
433 | fail: | 447 | fail: |
434 | dev->res = *bak; | 448 | dev->res = *bak; |
435 | up(&pnp_res_mutex); | 449 | up(&pnp_res_mutex); |
436 | kfree(bak); | 450 | kfree(bak); |
@@ -447,11 +461,12 @@ int pnp_auto_config_dev(struct pnp_dev *dev) | |||
447 | struct pnp_option *dep; | 461 | struct pnp_option *dep; |
448 | int i = 1; | 462 | int i = 1; |
449 | 463 | ||
450 | if(!dev) | 464 | if (!dev) |
451 | return -EINVAL; | 465 | return -EINVAL; |
452 | 466 | ||
453 | if(!pnp_can_configure(dev)) { | 467 | if (!pnp_can_configure(dev)) { |
454 | pnp_dbg("Device %s does not support resource configuration.", dev->dev.bus_id); | 468 | pnp_dbg("Device %s does not support resource configuration.", |
469 | dev->dev.bus_id); | ||
455 | return -ENODEV; | 470 | return -ENODEV; |
456 | } | 471 | } |
457 | 472 | ||
@@ -482,11 +497,12 @@ int pnp_auto_config_dev(struct pnp_dev *dev) | |||
482 | int pnp_start_dev(struct pnp_dev *dev) | 497 | int pnp_start_dev(struct pnp_dev *dev) |
483 | { | 498 | { |
484 | if (!pnp_can_write(dev)) { | 499 | if (!pnp_can_write(dev)) { |
485 | pnp_dbg("Device %s does not support activation.", dev->dev.bus_id); | 500 | pnp_dbg("Device %s does not support activation.", |
501 | dev->dev.bus_id); | ||
486 | return -EINVAL; | 502 | return -EINVAL; |
487 | } | 503 | } |
488 | 504 | ||
489 | if (dev->protocol->set(dev, &dev->res)<0) { | 505 | if (dev->protocol->set(dev, &dev->res) < 0) { |
490 | pnp_err("Failed to activate device %s.", dev->dev.bus_id); | 506 | pnp_err("Failed to activate device %s.", dev->dev.bus_id); |
491 | return -EIO; | 507 | return -EIO; |
492 | } | 508 | } |
@@ -506,10 +522,11 @@ int pnp_start_dev(struct pnp_dev *dev) | |||
506 | int pnp_stop_dev(struct pnp_dev *dev) | 522 | int pnp_stop_dev(struct pnp_dev *dev) |
507 | { | 523 | { |
508 | if (!pnp_can_disable(dev)) { | 524 | if (!pnp_can_disable(dev)) { |
509 | pnp_dbg("Device %s does not support disabling.", dev->dev.bus_id); | 525 | pnp_dbg("Device %s does not support disabling.", |
526 | dev->dev.bus_id); | ||
510 | return -EINVAL; | 527 | return -EINVAL; |
511 | } | 528 | } |
512 | if (dev->protocol->disable(dev)<0) { | 529 | if (dev->protocol->disable(dev) < 0) { |
513 | pnp_err("Failed to disable device %s.", dev->dev.bus_id); | 530 | pnp_err("Failed to disable device %s.", dev->dev.bus_id); |
514 | return -EIO; | 531 | return -EIO; |
515 | } | 532 | } |
@@ -532,7 +549,7 @@ int pnp_activate_dev(struct pnp_dev *dev) | |||
532 | if (!dev) | 549 | if (!dev) |
533 | return -EINVAL; | 550 | return -EINVAL; |
534 | if (dev->active) { | 551 | if (dev->active) { |
535 | return 0; /* the device is already active */ | 552 | return 0; /* the device is already active */ |
536 | } | 553 | } |
537 | 554 | ||
538 | /* ensure resources are allocated */ | 555 | /* ensure resources are allocated */ |
@@ -558,10 +575,10 @@ int pnp_disable_dev(struct pnp_dev *dev) | |||
558 | { | 575 | { |
559 | int error; | 576 | int error; |
560 | 577 | ||
561 | if (!dev) | 578 | if (!dev) |
562 | return -EINVAL; | 579 | return -EINVAL; |
563 | if (!dev->active) { | 580 | if (!dev->active) { |
564 | return 0; /* the device is already disabled */ | 581 | return 0; /* the device is already disabled */ |
565 | } | 582 | } |
566 | 583 | ||
567 | error = pnp_stop_dev(dev); | 584 | error = pnp_stop_dev(dev); |
@@ -586,7 +603,7 @@ int pnp_disable_dev(struct pnp_dev *dev) | |||
586 | * | 603 | * |
587 | */ | 604 | */ |
588 | void pnp_resource_change(struct resource *resource, resource_size_t start, | 605 | void pnp_resource_change(struct resource *resource, resource_size_t start, |
589 | resource_size_t size) | 606 | resource_size_t size) |
590 | { | 607 | { |
591 | if (resource == NULL) | 608 | if (resource == NULL) |
592 | return; | 609 | return; |
@@ -595,7 +612,6 @@ void pnp_resource_change(struct resource *resource, resource_size_t start, | |||
595 | resource->end = start + size - 1; | 612 | resource->end = start + size - 1; |
596 | } | 613 | } |
597 | 614 | ||
598 | |||
599 | EXPORT_SYMBOL(pnp_manual_config_dev); | 615 | EXPORT_SYMBOL(pnp_manual_config_dev); |
600 | #if 0 | 616 | #if 0 |
601 | EXPORT_SYMBOL(pnp_auto_config_dev); | 617 | EXPORT_SYMBOL(pnp_auto_config_dev); |
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index fcd32ac575c3..423c8e7e322d 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -36,11 +36,11 @@ static int num = 0; | |||
36 | * have irqs (PIC, Timer) because we call acpi_register_gsi. | 36 | * have irqs (PIC, Timer) because we call acpi_register_gsi. |
37 | * Finaly only devices that have a CRS method need to be in this list. | 37 | * Finaly only devices that have a CRS method need to be in this list. |
38 | */ | 38 | */ |
39 | static __initdata struct acpi_device_id excluded_id_list[] ={ | 39 | static __initdata struct acpi_device_id excluded_id_list[] = { |
40 | {"PNP0C09", 0}, /* EC */ | 40 | {"PNP0C09", 0}, /* EC */ |
41 | {"PNP0C0F", 0}, /* Link device */ | 41 | {"PNP0C0F", 0}, /* Link device */ |
42 | {"PNP0000", 0}, /* PIC */ | 42 | {"PNP0000", 0}, /* PIC */ |
43 | {"PNP0100", 0}, /* Timer */ | 43 | {"PNP0100", 0}, /* Timer */ |
44 | {"", 0}, | 44 | {"", 0}, |
45 | }; | 45 | }; |
46 | 46 | ||
@@ -84,15 +84,17 @@ static void __init pnpidacpi_to_pnpid(char *id, char *str) | |||
84 | str[7] = '\0'; | 84 | str[7] = '\0'; |
85 | } | 85 | } |
86 | 86 | ||
87 | static int pnpacpi_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res) | 87 | static int pnpacpi_get_resources(struct pnp_dev *dev, |
88 | struct pnp_resource_table *res) | ||
88 | { | 89 | { |
89 | acpi_status status; | 90 | acpi_status status; |
90 | status = pnpacpi_parse_allocated_resource((acpi_handle)dev->data, | 91 | status = pnpacpi_parse_allocated_resource((acpi_handle) dev->data, |
91 | &dev->res); | 92 | &dev->res); |
92 | return ACPI_FAILURE(status) ? -ENODEV : 0; | 93 | return ACPI_FAILURE(status) ? -ENODEV : 0; |
93 | } | 94 | } |
94 | 95 | ||
95 | static int pnpacpi_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res) | 96 | static int pnpacpi_set_resources(struct pnp_dev *dev, |
97 | struct pnp_resource_table *res) | ||
96 | { | 98 | { |
97 | acpi_handle handle = dev->data; | 99 | acpi_handle handle = dev->data; |
98 | struct acpi_buffer buffer; | 100 | struct acpi_buffer buffer; |
@@ -119,27 +121,29 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev) | |||
119 | acpi_status status; | 121 | acpi_status status; |
120 | 122 | ||
121 | /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ | 123 | /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ |
122 | status = acpi_evaluate_object((acpi_handle)dev->data, | 124 | status = acpi_evaluate_object((acpi_handle) dev->data, |
123 | "_DIS", NULL, NULL); | 125 | "_DIS", NULL, NULL); |
124 | return ACPI_FAILURE(status) ? -ENODEV : 0; | 126 | return ACPI_FAILURE(status) ? -ENODEV : 0; |
125 | } | 127 | } |
126 | 128 | ||
127 | static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) | 129 | static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) |
128 | { | 130 | { |
129 | return acpi_bus_set_power((acpi_handle)dev->data, | 131 | return acpi_bus_set_power((acpi_handle) dev->data, |
130 | acpi_pm_device_sleep_state(&dev->dev, | 132 | acpi_pm_device_sleep_state(&dev->dev, |
131 | device_may_wakeup(&dev->dev), NULL)); | 133 | device_may_wakeup |
134 | (&dev->dev), | ||
135 | NULL)); | ||
132 | } | 136 | } |
133 | 137 | ||
134 | static int pnpacpi_resume(struct pnp_dev *dev) | 138 | static int pnpacpi_resume(struct pnp_dev *dev) |
135 | { | 139 | { |
136 | return acpi_bus_set_power((acpi_handle)dev->data, ACPI_STATE_D0); | 140 | return acpi_bus_set_power((acpi_handle) dev->data, ACPI_STATE_D0); |
137 | } | 141 | } |
138 | 142 | ||
139 | static struct pnp_protocol pnpacpi_protocol = { | 143 | static struct pnp_protocol pnpacpi_protocol = { |
140 | .name = "Plug and Play ACPI", | 144 | .name = "Plug and Play ACPI", |
141 | .get = pnpacpi_get_resources, | 145 | .get = pnpacpi_get_resources, |
142 | .set = pnpacpi_set_resources, | 146 | .set = pnpacpi_set_resources, |
143 | .disable = pnpacpi_disable_resources, | 147 | .disable = pnpacpi_disable_resources, |
144 | .suspend = pnpacpi_suspend, | 148 | .suspend = pnpacpi_suspend, |
145 | .resume = pnpacpi_resume, | 149 | .resume = pnpacpi_resume, |
@@ -154,11 +158,11 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
154 | 158 | ||
155 | status = acpi_get_handle(device->handle, "_CRS", &temp); | 159 | status = acpi_get_handle(device->handle, "_CRS", &temp); |
156 | if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) || | 160 | if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) || |
157 | is_exclusive_device(device)) | 161 | is_exclusive_device(device)) |
158 | return 0; | 162 | return 0; |
159 | 163 | ||
160 | pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); | 164 | pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); |
161 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); | 165 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); |
162 | if (!dev) { | 166 | if (!dev) { |
163 | pnp_err("Out of memory"); | 167 | pnp_err("Out of memory"); |
164 | return -ENOMEM; | 168 | return -ENOMEM; |
@@ -194,20 +198,23 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
194 | pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); | 198 | pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); |
195 | pnp_add_id(dev_id, dev); | 199 | pnp_add_id(dev_id, dev); |
196 | 200 | ||
197 | if(dev->active) { | 201 | if (dev->active) { |
198 | /* parse allocated resource */ | 202 | /* parse allocated resource */ |
199 | status = pnpacpi_parse_allocated_resource(device->handle, &dev->res); | 203 | status = |
204 | pnpacpi_parse_allocated_resource(device->handle, &dev->res); | ||
200 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { | 205 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { |
201 | pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", dev_id->id); | 206 | pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", |
207 | dev_id->id); | ||
202 | goto err1; | 208 | goto err1; |
203 | } | 209 | } |
204 | } | 210 | } |
205 | 211 | ||
206 | if(dev->capabilities & PNP_CONFIGURABLE) { | 212 | if (dev->capabilities & PNP_CONFIGURABLE) { |
207 | status = pnpacpi_parse_resource_option_data(device->handle, | 213 | status = pnpacpi_parse_resource_option_data(device->handle, |
208 | dev); | 214 | dev); |
209 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { | 215 | if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { |
210 | pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", dev_id->id); | 216 | pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", |
217 | dev_id->id); | ||
211 | goto err1; | 218 | goto err1; |
212 | } | 219 | } |
213 | } | 220 | } |
@@ -233,18 +240,19 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
233 | if (!dev->active) | 240 | if (!dev->active) |
234 | pnp_init_resource_table(&dev->res); | 241 | pnp_init_resource_table(&dev->res); |
235 | pnp_add_device(dev); | 242 | pnp_add_device(dev); |
236 | num ++; | 243 | num++; |
237 | 244 | ||
238 | return AE_OK; | 245 | return AE_OK; |
239 | err1: | 246 | err1: |
240 | kfree(dev_id); | 247 | kfree(dev_id); |
241 | err: | 248 | err: |
242 | kfree(dev); | 249 | kfree(dev); |
243 | return -EINVAL; | 250 | return -EINVAL; |
244 | } | 251 | } |
245 | 252 | ||
246 | static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, | 253 | static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, |
247 | u32 lvl, void *context, void **rv) | 254 | u32 lvl, void *context, |
255 | void **rv) | ||
248 | { | 256 | { |
249 | struct acpi_device *device; | 257 | struct acpi_device *device; |
250 | 258 | ||
@@ -257,23 +265,22 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, | |||
257 | 265 | ||
258 | static int __init acpi_pnp_match(struct device *dev, void *_pnp) | 266 | static int __init acpi_pnp_match(struct device *dev, void *_pnp) |
259 | { | 267 | { |
260 | struct acpi_device *acpi = to_acpi_device(dev); | 268 | struct acpi_device *acpi = to_acpi_device(dev); |
261 | struct pnp_dev *pnp = _pnp; | 269 | struct pnp_dev *pnp = _pnp; |
262 | 270 | ||
263 | /* true means it matched */ | 271 | /* true means it matched */ |
264 | return acpi->flags.hardware_id | 272 | return acpi->flags.hardware_id |
265 | && !acpi_get_physical_device(acpi->handle) | 273 | && !acpi_get_physical_device(acpi->handle) |
266 | && compare_pnp_id(pnp->id, acpi->pnp.hardware_id); | 274 | && compare_pnp_id(pnp->id, acpi->pnp.hardware_id); |
267 | } | 275 | } |
268 | 276 | ||
269 | static int __init acpi_pnp_find_device(struct device *dev, acpi_handle *handle) | 277 | static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle) |
270 | { | 278 | { |
271 | struct device *adev; | 279 | struct device *adev; |
272 | struct acpi_device *acpi; | 280 | struct acpi_device *acpi; |
273 | 281 | ||
274 | adev = bus_find_device(&acpi_bus_type, NULL, | 282 | adev = bus_find_device(&acpi_bus_type, NULL, |
275 | to_pnp_dev(dev), | 283 | to_pnp_dev(dev), acpi_pnp_match); |
276 | acpi_pnp_match); | ||
277 | if (!adev) | 284 | if (!adev) |
278 | return -ENODEV; | 285 | return -ENODEV; |
279 | 286 | ||
@@ -307,6 +314,7 @@ static int __init pnpacpi_init(void) | |||
307 | pnp_platform_devices = 1; | 314 | pnp_platform_devices = 1; |
308 | return 0; | 315 | return 0; |
309 | } | 316 | } |
317 | |||
310 | subsys_initcall(pnpacpi_init); | 318 | subsys_initcall(pnpacpi_init); |
311 | 319 | ||
312 | static int __init pnpacpi_setup(char *str) | 320 | static int __init pnpacpi_setup(char *str) |
@@ -317,6 +325,7 @@ static int __init pnpacpi_setup(char *str) | |||
317 | pnpacpi_disabled = 1; | 325 | pnpacpi_disabled = 1; |
318 | return 1; | 326 | return 1; |
319 | } | 327 | } |
328 | |||
320 | __setup("pnpacpi=", pnpacpi_setup); | 329 | __setup("pnpacpi=", pnpacpi_setup); |
321 | 330 | ||
322 | #if 0 | 331 | #if 0 |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 118ac9779b3c..2f0d66886404 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -40,8 +40,7 @@ static int irq_flags(int triggering, int polarity) | |||
40 | flag = IORESOURCE_IRQ_LOWLEVEL; | 40 | flag = IORESOURCE_IRQ_LOWLEVEL; |
41 | else | 41 | else |
42 | flag = IORESOURCE_IRQ_HIGHLEVEL; | 42 | flag = IORESOURCE_IRQ_HIGHLEVEL; |
43 | } | 43 | } else { |
44 | else { | ||
45 | if (polarity == ACPI_ACTIVE_LOW) | 44 | if (polarity == ACPI_ACTIVE_LOW) |
46 | flag = IORESOURCE_IRQ_LOWEDGE; | 45 | flag = IORESOURCE_IRQ_LOWEDGE; |
47 | else | 46 | else |
@@ -74,7 +73,7 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity) | |||
74 | 73 | ||
75 | static void | 74 | static void |
76 | pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, | 75 | pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, |
77 | int triggering, int polarity, int shareable) | 76 | int triggering, int polarity, int shareable) |
78 | { | 77 | { |
79 | int i = 0; | 78 | int i = 0; |
80 | int irq; | 79 | int irq; |
@@ -83,12 +82,12 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, | |||
83 | return; | 82 | return; |
84 | 83 | ||
85 | while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && | 84 | while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && |
86 | i < PNP_MAX_IRQ) | 85 | i < PNP_MAX_IRQ) |
87 | i++; | 86 | i++; |
88 | if (i >= PNP_MAX_IRQ) | 87 | if (i >= PNP_MAX_IRQ) |
89 | return; | 88 | return; |
90 | 89 | ||
91 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag | 90 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag |
92 | res->irq_resource[i].flags |= irq_flags(triggering, polarity); | 91 | res->irq_resource[i].flags |= irq_flags(triggering, polarity); |
93 | irq = acpi_register_gsi(gsi, triggering, polarity); | 92 | irq = acpi_register_gsi(gsi, triggering, polarity); |
94 | if (irq < 0) { | 93 | if (irq < 0) { |
@@ -149,15 +148,16 @@ static int dma_flags(int type, int bus_master, int transfer) | |||
149 | 148 | ||
150 | static void | 149 | static void |
151 | pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, | 150 | pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, |
152 | int type, int bus_master, int transfer) | 151 | int type, int bus_master, int transfer) |
153 | { | 152 | { |
154 | int i = 0; | 153 | int i = 0; |
155 | while (i < PNP_MAX_DMA && | 154 | while (i < PNP_MAX_DMA && |
156 | !(res->dma_resource[i].flags & IORESOURCE_UNSET)) | 155 | !(res->dma_resource[i].flags & IORESOURCE_UNSET)) |
157 | i++; | 156 | i++; |
158 | if (i < PNP_MAX_DMA) { | 157 | if (i < PNP_MAX_DMA) { |
159 | res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag | 158 | res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag |
160 | res->dma_resource[i].flags |= dma_flags(type, bus_master, transfer); | 159 | res->dma_resource[i].flags |= |
160 | dma_flags(type, bus_master, transfer); | ||
161 | if (dma == -1) { | 161 | if (dma == -1) { |
162 | res->dma_resource[i].flags |= IORESOURCE_DISABLED; | 162 | res->dma_resource[i].flags |= IORESOURCE_DISABLED; |
163 | return; | 163 | return; |
@@ -169,17 +169,17 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, | |||
169 | 169 | ||
170 | static void | 170 | static void |
171 | pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, | 171 | pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, |
172 | u64 io, u64 len, int io_decode) | 172 | u64 io, u64 len, int io_decode) |
173 | { | 173 | { |
174 | int i = 0; | 174 | int i = 0; |
175 | while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && | 175 | while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && |
176 | i < PNP_MAX_PORT) | 176 | i < PNP_MAX_PORT) |
177 | i++; | 177 | i++; |
178 | if (i < PNP_MAX_PORT) { | 178 | if (i < PNP_MAX_PORT) { |
179 | res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag | 179 | res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag |
180 | if (io_decode == ACPI_DECODE_16) | 180 | if (io_decode == ACPI_DECODE_16) |
181 | res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR; | 181 | res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR; |
182 | if (len <= 0 || (io + len -1) >= 0x10003) { | 182 | if (len <= 0 || (io + len - 1) >= 0x10003) { |
183 | res->port_resource[i].flags |= IORESOURCE_DISABLED; | 183 | res->port_resource[i].flags |= IORESOURCE_DISABLED; |
184 | return; | 184 | return; |
185 | } | 185 | } |
@@ -190,19 +190,19 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, | |||
190 | 190 | ||
191 | static void | 191 | static void |
192 | pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, | 192 | pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, |
193 | u64 mem, u64 len, int write_protect) | 193 | u64 mem, u64 len, int write_protect) |
194 | { | 194 | { |
195 | int i = 0; | 195 | int i = 0; |
196 | while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && | 196 | while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && |
197 | (i < PNP_MAX_MEM)) | 197 | (i < PNP_MAX_MEM)) |
198 | i++; | 198 | i++; |
199 | if (i < PNP_MAX_MEM) { | 199 | if (i < PNP_MAX_MEM) { |
200 | res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag | 200 | res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag |
201 | if (len <= 0) { | 201 | if (len <= 0) { |
202 | res->mem_resource[i].flags |= IORESOURCE_DISABLED; | 202 | res->mem_resource[i].flags |= IORESOURCE_DISABLED; |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | if(write_protect == ACPI_READ_WRITE_MEMORY) | 205 | if (write_protect == ACPI_READ_WRITE_MEMORY) |
206 | res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE; | 206 | res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE; |
207 | 207 | ||
208 | res->mem_resource[i].start = mem; | 208 | res->mem_resource[i].start = mem; |
@@ -212,7 +212,7 @@ pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, | |||
212 | 212 | ||
213 | static void | 213 | static void |
214 | pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, | 214 | pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, |
215 | struct acpi_resource *res) | 215 | struct acpi_resource *res) |
216 | { | 216 | { |
217 | struct acpi_resource_address64 addr, *p = &addr; | 217 | struct acpi_resource_address64 addr, *p = &addr; |
218 | acpi_status status; | 218 | acpi_status status; |
@@ -220,7 +220,7 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, | |||
220 | status = acpi_resource_to_address64(res, p); | 220 | status = acpi_resource_to_address64(res, p); |
221 | if (!ACPI_SUCCESS(status)) { | 221 | if (!ACPI_SUCCESS(status)) { |
222 | pnp_warn("PnPACPI: failed to convert resource type %d", | 222 | pnp_warn("PnPACPI: failed to convert resource type %d", |
223 | res->type); | 223 | res->type); |
224 | return; | 224 | return; |
225 | } | 225 | } |
226 | 226 | ||
@@ -229,17 +229,23 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, | |||
229 | 229 | ||
230 | if (p->resource_type == ACPI_MEMORY_RANGE) | 230 | if (p->resource_type == ACPI_MEMORY_RANGE) |
231 | pnpacpi_parse_allocated_memresource(res_table, | 231 | pnpacpi_parse_allocated_memresource(res_table, |
232 | p->minimum, p->address_length, p->info.mem.write_protect); | 232 | p->minimum, |
233 | p->address_length, | ||
234 | p->info.mem.write_protect); | ||
233 | else if (p->resource_type == ACPI_IO_RANGE) | 235 | else if (p->resource_type == ACPI_IO_RANGE) |
234 | pnpacpi_parse_allocated_ioresource(res_table, | 236 | pnpacpi_parse_allocated_ioresource(res_table, |
235 | p->minimum, p->address_length, | 237 | p->minimum, |
236 | p->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16); | 238 | p->address_length, |
239 | p->granularity == | ||
240 | 0xfff ? ACPI_DECODE_10 : | ||
241 | ACPI_DECODE_16); | ||
237 | } | 242 | } |
238 | 243 | ||
239 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | 244 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, |
240 | void *data) | 245 | void *data) |
241 | { | 246 | { |
242 | struct pnp_resource_table *res_table = (struct pnp_resource_table *)data; | 247 | struct pnp_resource_table *res_table = |
248 | (struct pnp_resource_table *)data; | ||
243 | int i; | 249 | int i; |
244 | 250 | ||
245 | switch (res->type) { | 251 | switch (res->type) { |
@@ -250,27 +256,34 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
250 | */ | 256 | */ |
251 | for (i = 0; i < res->data.irq.interrupt_count; i++) { | 257 | for (i = 0; i < res->data.irq.interrupt_count; i++) { |
252 | pnpacpi_parse_allocated_irqresource(res_table, | 258 | pnpacpi_parse_allocated_irqresource(res_table, |
253 | res->data.irq.interrupts[i], | 259 | res->data.irq. |
254 | res->data.irq.triggering, | 260 | interrupts[i], |
255 | res->data.irq.polarity, | 261 | res->data.irq. |
256 | res->data.irq.sharable); | 262 | triggering, |
263 | res->data.irq. | ||
264 | polarity, | ||
265 | res->data.irq. | ||
266 | sharable); | ||
257 | } | 267 | } |
258 | break; | 268 | break; |
259 | 269 | ||
260 | case ACPI_RESOURCE_TYPE_DMA: | 270 | case ACPI_RESOURCE_TYPE_DMA: |
261 | if (res->data.dma.channel_count > 0) | 271 | if (res->data.dma.channel_count > 0) |
262 | pnpacpi_parse_allocated_dmaresource(res_table, | 272 | pnpacpi_parse_allocated_dmaresource(res_table, |
263 | res->data.dma.channels[0], | 273 | res->data.dma. |
264 | res->data.dma.type, | 274 | channels[0], |
265 | res->data.dma.bus_master, | 275 | res->data.dma.type, |
266 | res->data.dma.transfer); | 276 | res->data.dma. |
277 | bus_master, | ||
278 | res->data.dma. | ||
279 | transfer); | ||
267 | break; | 280 | break; |
268 | 281 | ||
269 | case ACPI_RESOURCE_TYPE_IO: | 282 | case ACPI_RESOURCE_TYPE_IO: |
270 | pnpacpi_parse_allocated_ioresource(res_table, | 283 | pnpacpi_parse_allocated_ioresource(res_table, |
271 | res->data.io.minimum, | 284 | res->data.io.minimum, |
272 | res->data.io.address_length, | 285 | res->data.io.address_length, |
273 | res->data.io.io_decode); | 286 | res->data.io.io_decode); |
274 | break; | 287 | break; |
275 | 288 | ||
276 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 289 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
@@ -279,9 +292,10 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
279 | 292 | ||
280 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 293 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
281 | pnpacpi_parse_allocated_ioresource(res_table, | 294 | pnpacpi_parse_allocated_ioresource(res_table, |
282 | res->data.fixed_io.address, | 295 | res->data.fixed_io.address, |
283 | res->data.fixed_io.address_length, | 296 | res->data.fixed_io. |
284 | ACPI_DECODE_10); | 297 | address_length, |
298 | ACPI_DECODE_10); | ||
285 | break; | 299 | break; |
286 | 300 | ||
287 | case ACPI_RESOURCE_TYPE_VENDOR: | 301 | case ACPI_RESOURCE_TYPE_VENDOR: |
@@ -292,21 +306,28 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
292 | 306 | ||
293 | case ACPI_RESOURCE_TYPE_MEMORY24: | 307 | case ACPI_RESOURCE_TYPE_MEMORY24: |
294 | pnpacpi_parse_allocated_memresource(res_table, | 308 | pnpacpi_parse_allocated_memresource(res_table, |
295 | res->data.memory24.minimum, | 309 | res->data.memory24.minimum, |
296 | res->data.memory24.address_length, | 310 | res->data.memory24. |
297 | res->data.memory24.write_protect); | 311 | address_length, |
312 | res->data.memory24. | ||
313 | write_protect); | ||
298 | break; | 314 | break; |
299 | case ACPI_RESOURCE_TYPE_MEMORY32: | 315 | case ACPI_RESOURCE_TYPE_MEMORY32: |
300 | pnpacpi_parse_allocated_memresource(res_table, | 316 | pnpacpi_parse_allocated_memresource(res_table, |
301 | res->data.memory32.minimum, | 317 | res->data.memory32.minimum, |
302 | res->data.memory32.address_length, | 318 | res->data.memory32. |
303 | res->data.memory32.write_protect); | 319 | address_length, |
320 | res->data.memory32. | ||
321 | write_protect); | ||
304 | break; | 322 | break; |
305 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 323 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
306 | pnpacpi_parse_allocated_memresource(res_table, | 324 | pnpacpi_parse_allocated_memresource(res_table, |
307 | res->data.fixed_memory32.address, | 325 | res->data.fixed_memory32. |
308 | res->data.fixed_memory32.address_length, | 326 | address, |
309 | res->data.fixed_memory32.write_protect); | 327 | res->data.fixed_memory32. |
328 | address_length, | ||
329 | res->data.fixed_memory32. | ||
330 | write_protect); | ||
310 | break; | 331 | break; |
311 | case ACPI_RESOURCE_TYPE_ADDRESS16: | 332 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
312 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 333 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
@@ -325,10 +346,18 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
325 | 346 | ||
326 | for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { | 347 | for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { |
327 | pnpacpi_parse_allocated_irqresource(res_table, | 348 | pnpacpi_parse_allocated_irqresource(res_table, |
328 | res->data.extended_irq.interrupts[i], | 349 | res->data. |
329 | res->data.extended_irq.triggering, | 350 | extended_irq. |
330 | res->data.extended_irq.polarity, | 351 | interrupts[i], |
331 | res->data.extended_irq.sharable); | 352 | res->data. |
353 | extended_irq. | ||
354 | triggering, | ||
355 | res->data. | ||
356 | extended_irq. | ||
357 | polarity, | ||
358 | res->data. | ||
359 | extended_irq. | ||
360 | sharable); | ||
332 | } | 361 | } |
333 | break; | 362 | break; |
334 | 363 | ||
@@ -343,18 +372,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
343 | return AE_OK; | 372 | return AE_OK; |
344 | } | 373 | } |
345 | 374 | ||
346 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table *res) | 375 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, |
376 | struct pnp_resource_table * res) | ||
347 | { | 377 | { |
348 | /* Blank the resource table values */ | 378 | /* Blank the resource table values */ |
349 | pnp_init_resource_table(res); | 379 | pnp_init_resource_table(res); |
350 | 380 | ||
351 | return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res); | 381 | return acpi_walk_resources(handle, METHOD_NAME__CRS, |
382 | pnpacpi_allocated_resource, res); | ||
352 | } | 383 | } |
353 | 384 | ||
354 | static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_resource_dma *p) | 385 | static void pnpacpi_parse_dma_option(struct pnp_option *option, |
386 | struct acpi_resource_dma *p) | ||
355 | { | 387 | { |
356 | int i; | 388 | int i; |
357 | struct pnp_dma * dma; | 389 | struct pnp_dma *dma; |
358 | 390 | ||
359 | if (p->channel_count == 0) | 391 | if (p->channel_count == 0) |
360 | return; | 392 | return; |
@@ -362,7 +394,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso | |||
362 | if (!dma) | 394 | if (!dma) |
363 | return; | 395 | return; |
364 | 396 | ||
365 | for(i = 0; i < p->channel_count; i++) | 397 | for (i = 0; i < p->channel_count; i++) |
366 | dma->map |= 1 << p->channels[i]; | 398 | dma->map |= 1 << p->channels[i]; |
367 | 399 | ||
368 | dma->flags = dma_flags(p->type, p->bus_master, p->transfer); | 400 | dma->flags = dma_flags(p->type, p->bus_master, p->transfer); |
@@ -371,9 +403,8 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso | |||
371 | return; | 403 | return; |
372 | } | 404 | } |
373 | 405 | ||
374 | |||
375 | static void pnpacpi_parse_irq_option(struct pnp_option *option, | 406 | static void pnpacpi_parse_irq_option(struct pnp_option *option, |
376 | struct acpi_resource_irq *p) | 407 | struct acpi_resource_irq *p) |
377 | { | 408 | { |
378 | int i; | 409 | int i; |
379 | struct pnp_irq *irq; | 410 | struct pnp_irq *irq; |
@@ -384,7 +415,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, | |||
384 | if (!irq) | 415 | if (!irq) |
385 | return; | 416 | return; |
386 | 417 | ||
387 | for(i = 0; i < p->interrupt_count; i++) | 418 | for (i = 0; i < p->interrupt_count; i++) |
388 | if (p->interrupts[i]) | 419 | if (p->interrupts[i]) |
389 | __set_bit(p->interrupts[i], irq->map); | 420 | __set_bit(p->interrupts[i], irq->map); |
390 | irq->flags = irq_flags(p->triggering, p->polarity); | 421 | irq->flags = irq_flags(p->triggering, p->polarity); |
@@ -394,7 +425,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, | |||
394 | } | 425 | } |
395 | 426 | ||
396 | static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, | 427 | static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, |
397 | struct acpi_resource_extended_irq *p) | 428 | struct acpi_resource_extended_irq *p) |
398 | { | 429 | { |
399 | int i; | 430 | int i; |
400 | struct pnp_irq *irq; | 431 | struct pnp_irq *irq; |
@@ -405,7 +436,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, | |||
405 | if (!irq) | 436 | if (!irq) |
406 | return; | 437 | return; |
407 | 438 | ||
408 | for(i = 0; i < p->interrupt_count; i++) | 439 | for (i = 0; i < p->interrupt_count; i++) |
409 | if (p->interrupts[i]) | 440 | if (p->interrupts[i]) |
410 | __set_bit(p->interrupts[i], irq->map); | 441 | __set_bit(p->interrupts[i], irq->map); |
411 | irq->flags = irq_flags(p->triggering, p->polarity); | 442 | irq->flags = irq_flags(p->triggering, p->polarity); |
@@ -416,7 +447,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, | |||
416 | 447 | ||
417 | static void | 448 | static void |
418 | pnpacpi_parse_port_option(struct pnp_option *option, | 449 | pnpacpi_parse_port_option(struct pnp_option *option, |
419 | struct acpi_resource_io *io) | 450 | struct acpi_resource_io *io) |
420 | { | 451 | { |
421 | struct pnp_port *port; | 452 | struct pnp_port *port; |
422 | 453 | ||
@@ -430,14 +461,14 @@ pnpacpi_parse_port_option(struct pnp_option *option, | |||
430 | port->align = io->alignment; | 461 | port->align = io->alignment; |
431 | port->size = io->address_length; | 462 | port->size = io->address_length; |
432 | port->flags = ACPI_DECODE_16 == io->io_decode ? | 463 | port->flags = ACPI_DECODE_16 == io->io_decode ? |
433 | PNP_PORT_FLAG_16BITADDR : 0; | 464 | PNP_PORT_FLAG_16BITADDR : 0; |
434 | pnp_register_port_resource(option, port); | 465 | pnp_register_port_resource(option, port); |
435 | return; | 466 | return; |
436 | } | 467 | } |
437 | 468 | ||
438 | static void | 469 | static void |
439 | pnpacpi_parse_fixed_port_option(struct pnp_option *option, | 470 | pnpacpi_parse_fixed_port_option(struct pnp_option *option, |
440 | struct acpi_resource_fixed_io *io) | 471 | struct acpi_resource_fixed_io *io) |
441 | { | 472 | { |
442 | struct pnp_port *port; | 473 | struct pnp_port *port; |
443 | 474 | ||
@@ -456,7 +487,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, | |||
456 | 487 | ||
457 | static void | 488 | static void |
458 | pnpacpi_parse_mem24_option(struct pnp_option *option, | 489 | pnpacpi_parse_mem24_option(struct pnp_option *option, |
459 | struct acpi_resource_memory24 *p) | 490 | struct acpi_resource_memory24 *p) |
460 | { | 491 | { |
461 | struct pnp_mem *mem; | 492 | struct pnp_mem *mem; |
462 | 493 | ||
@@ -471,7 +502,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, | |||
471 | mem->size = p->address_length; | 502 | mem->size = p->address_length; |
472 | 503 | ||
473 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? | 504 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
474 | IORESOURCE_MEM_WRITEABLE : 0; | 505 | IORESOURCE_MEM_WRITEABLE : 0; |
475 | 506 | ||
476 | pnp_register_mem_resource(option, mem); | 507 | pnp_register_mem_resource(option, mem); |
477 | return; | 508 | return; |
@@ -479,7 +510,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, | |||
479 | 510 | ||
480 | static void | 511 | static void |
481 | pnpacpi_parse_mem32_option(struct pnp_option *option, | 512 | pnpacpi_parse_mem32_option(struct pnp_option *option, |
482 | struct acpi_resource_memory32 *p) | 513 | struct acpi_resource_memory32 *p) |
483 | { | 514 | { |
484 | struct pnp_mem *mem; | 515 | struct pnp_mem *mem; |
485 | 516 | ||
@@ -494,7 +525,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, | |||
494 | mem->size = p->address_length; | 525 | mem->size = p->address_length; |
495 | 526 | ||
496 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? | 527 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
497 | IORESOURCE_MEM_WRITEABLE : 0; | 528 | IORESOURCE_MEM_WRITEABLE : 0; |
498 | 529 | ||
499 | pnp_register_mem_resource(option, mem); | 530 | pnp_register_mem_resource(option, mem); |
500 | return; | 531 | return; |
@@ -502,7 +533,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, | |||
502 | 533 | ||
503 | static void | 534 | static void |
504 | pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, | 535 | pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, |
505 | struct acpi_resource_fixed_memory32 *p) | 536 | struct acpi_resource_fixed_memory32 *p) |
506 | { | 537 | { |
507 | struct pnp_mem *mem; | 538 | struct pnp_mem *mem; |
508 | 539 | ||
@@ -516,7 +547,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, | |||
516 | mem->align = 0; | 547 | mem->align = 0; |
517 | 548 | ||
518 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? | 549 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
519 | IORESOURCE_MEM_WRITEABLE : 0; | 550 | IORESOURCE_MEM_WRITEABLE : 0; |
520 | 551 | ||
521 | pnp_register_mem_resource(option, mem); | 552 | pnp_register_mem_resource(option, mem); |
522 | return; | 553 | return; |
@@ -532,7 +563,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) | |||
532 | 563 | ||
533 | status = acpi_resource_to_address64(r, p); | 564 | status = acpi_resource_to_address64(r, p); |
534 | if (!ACPI_SUCCESS(status)) { | 565 | if (!ACPI_SUCCESS(status)) { |
535 | pnp_warn("PnPACPI: failed to convert resource type %d", r->type); | 566 | pnp_warn("PnPACPI: failed to convert resource type %d", |
567 | r->type); | ||
536 | return; | 568 | return; |
537 | } | 569 | } |
538 | 570 | ||
@@ -547,7 +579,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) | |||
547 | mem->size = p->address_length; | 579 | mem->size = p->address_length; |
548 | mem->align = 0; | 580 | mem->align = 0; |
549 | mem->flags = (p->info.mem.write_protect == | 581 | mem->flags = (p->info.mem.write_protect == |
550 | ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; | 582 | ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE |
583 | : 0; | ||
551 | pnp_register_mem_resource(option, mem); | 584 | pnp_register_mem_resource(option, mem); |
552 | } else if (p->resource_type == ACPI_IO_RANGE) { | 585 | } else if (p->resource_type == ACPI_IO_RANGE) { |
553 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); | 586 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
@@ -568,109 +601,108 @@ struct acpipnp_parse_option_s { | |||
568 | }; | 601 | }; |
569 | 602 | ||
570 | static acpi_status pnpacpi_option_resource(struct acpi_resource *res, | 603 | static acpi_status pnpacpi_option_resource(struct acpi_resource *res, |
571 | void *data) | 604 | void *data) |
572 | { | 605 | { |
573 | int priority = 0; | 606 | int priority = 0; |
574 | struct acpipnp_parse_option_s *parse_data = (struct acpipnp_parse_option_s *)data; | 607 | struct acpipnp_parse_option_s *parse_data = |
608 | (struct acpipnp_parse_option_s *)data; | ||
575 | struct pnp_dev *dev = parse_data->dev; | 609 | struct pnp_dev *dev = parse_data->dev; |
576 | struct pnp_option *option = parse_data->option; | 610 | struct pnp_option *option = parse_data->option; |
577 | 611 | ||
578 | switch (res->type) { | 612 | switch (res->type) { |
579 | case ACPI_RESOURCE_TYPE_IRQ: | 613 | case ACPI_RESOURCE_TYPE_IRQ: |
580 | pnpacpi_parse_irq_option(option, &res->data.irq); | 614 | pnpacpi_parse_irq_option(option, &res->data.irq); |
581 | break; | 615 | break; |
582 | 616 | ||
583 | case ACPI_RESOURCE_TYPE_DMA: | 617 | case ACPI_RESOURCE_TYPE_DMA: |
584 | pnpacpi_parse_dma_option(option, &res->data.dma); | 618 | pnpacpi_parse_dma_option(option, &res->data.dma); |
585 | break; | 619 | break; |
586 | 620 | ||
587 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 621 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
588 | switch (res->data.start_dpf.compatibility_priority) { | 622 | switch (res->data.start_dpf.compatibility_priority) { |
589 | case ACPI_GOOD_CONFIGURATION: | 623 | case ACPI_GOOD_CONFIGURATION: |
590 | priority = PNP_RES_PRIORITY_PREFERRED; | 624 | priority = PNP_RES_PRIORITY_PREFERRED; |
591 | break; | ||
592 | |||
593 | case ACPI_ACCEPTABLE_CONFIGURATION: | ||
594 | priority = PNP_RES_PRIORITY_ACCEPTABLE; | ||
595 | break; | ||
596 | |||
597 | case ACPI_SUB_OPTIMAL_CONFIGURATION: | ||
598 | priority = PNP_RES_PRIORITY_FUNCTIONAL; | ||
599 | break; | ||
600 | default: | ||
601 | priority = PNP_RES_PRIORITY_INVALID; | ||
602 | break; | ||
603 | } | ||
604 | /* TBD: Considering performace/robustness bits */ | ||
605 | option = pnp_register_dependent_option(dev, priority); | ||
606 | if (!option) | ||
607 | return AE_ERROR; | ||
608 | parse_data->option = option; | ||
609 | break; | 625 | break; |
610 | 626 | ||
611 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: | 627 | case ACPI_ACCEPTABLE_CONFIGURATION: |
612 | /*only one EndDependentFn is allowed*/ | 628 | priority = PNP_RES_PRIORITY_ACCEPTABLE; |
613 | if (!parse_data->option_independent) { | ||
614 | pnp_warn("PnPACPI: more than one EndDependentFn"); | ||
615 | return AE_ERROR; | ||
616 | } | ||
617 | parse_data->option = parse_data->option_independent; | ||
618 | parse_data->option_independent = NULL; | ||
619 | break; | 629 | break; |
620 | 630 | ||
621 | case ACPI_RESOURCE_TYPE_IO: | 631 | case ACPI_SUB_OPTIMAL_CONFIGURATION: |
622 | pnpacpi_parse_port_option(option, &res->data.io); | 632 | priority = PNP_RES_PRIORITY_FUNCTIONAL; |
623 | break; | 633 | break; |
624 | 634 | default: | |
625 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 635 | priority = PNP_RES_PRIORITY_INVALID; |
626 | pnpacpi_parse_fixed_port_option(option, | ||
627 | &res->data.fixed_io); | ||
628 | break; | 636 | break; |
637 | } | ||
638 | /* TBD: Considering performace/robustness bits */ | ||
639 | option = pnp_register_dependent_option(dev, priority); | ||
640 | if (!option) | ||
641 | return AE_ERROR; | ||
642 | parse_data->option = option; | ||
643 | break; | ||
629 | 644 | ||
630 | case ACPI_RESOURCE_TYPE_VENDOR: | 645 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
631 | case ACPI_RESOURCE_TYPE_END_TAG: | 646 | /*only one EndDependentFn is allowed */ |
632 | break; | 647 | if (!parse_data->option_independent) { |
648 | pnp_warn("PnPACPI: more than one EndDependentFn"); | ||
649 | return AE_ERROR; | ||
650 | } | ||
651 | parse_data->option = parse_data->option_independent; | ||
652 | parse_data->option_independent = NULL; | ||
653 | break; | ||
633 | 654 | ||
634 | case ACPI_RESOURCE_TYPE_MEMORY24: | 655 | case ACPI_RESOURCE_TYPE_IO: |
635 | pnpacpi_parse_mem24_option(option, &res->data.memory24); | 656 | pnpacpi_parse_port_option(option, &res->data.io); |
636 | break; | 657 | break; |
637 | 658 | ||
638 | case ACPI_RESOURCE_TYPE_MEMORY32: | 659 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
639 | pnpacpi_parse_mem32_option(option, &res->data.memory32); | 660 | pnpacpi_parse_fixed_port_option(option, &res->data.fixed_io); |
640 | break; | 661 | break; |
641 | 662 | ||
642 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 663 | case ACPI_RESOURCE_TYPE_VENDOR: |
643 | pnpacpi_parse_fixed_mem32_option(option, | 664 | case ACPI_RESOURCE_TYPE_END_TAG: |
644 | &res->data.fixed_memory32); | 665 | break; |
645 | break; | ||
646 | 666 | ||
647 | case ACPI_RESOURCE_TYPE_ADDRESS16: | 667 | case ACPI_RESOURCE_TYPE_MEMORY24: |
648 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 668 | pnpacpi_parse_mem24_option(option, &res->data.memory24); |
649 | case ACPI_RESOURCE_TYPE_ADDRESS64: | 669 | break; |
650 | pnpacpi_parse_address_option(option, res); | ||
651 | break; | ||
652 | 670 | ||
653 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: | 671 | case ACPI_RESOURCE_TYPE_MEMORY32: |
654 | break; | 672 | pnpacpi_parse_mem32_option(option, &res->data.memory32); |
673 | break; | ||
655 | 674 | ||
656 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | 675 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
657 | pnpacpi_parse_ext_irq_option(option, | 676 | pnpacpi_parse_fixed_mem32_option(option, |
658 | &res->data.extended_irq); | 677 | &res->data.fixed_memory32); |
659 | break; | 678 | break; |
660 | 679 | ||
661 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: | 680 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
662 | break; | 681 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
682 | case ACPI_RESOURCE_TYPE_ADDRESS64: | ||
683 | pnpacpi_parse_address_option(option, res); | ||
684 | break; | ||
663 | 685 | ||
664 | default: | 686 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
665 | pnp_warn("PnPACPI: unknown resource type %d", res->type); | 687 | break; |
666 | return AE_ERROR; | 688 | |
689 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | ||
690 | pnpacpi_parse_ext_irq_option(option, &res->data.extended_irq); | ||
691 | break; | ||
692 | |||
693 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: | ||
694 | break; | ||
695 | |||
696 | default: | ||
697 | pnp_warn("PnPACPI: unknown resource type %d", res->type); | ||
698 | return AE_ERROR; | ||
667 | } | 699 | } |
668 | 700 | ||
669 | return AE_OK; | 701 | return AE_OK; |
670 | } | 702 | } |
671 | 703 | ||
672 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, | 704 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, |
673 | struct pnp_dev *dev) | 705 | struct pnp_dev * dev) |
674 | { | 706 | { |
675 | acpi_status status; | 707 | acpi_status status; |
676 | struct acpipnp_parse_option_s parse_data; | 708 | struct acpipnp_parse_option_s parse_data; |
@@ -681,7 +713,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, | |||
681 | parse_data.option_independent = parse_data.option; | 713 | parse_data.option_independent = parse_data.option; |
682 | parse_data.dev = dev; | 714 | parse_data.dev = dev; |
683 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, | 715 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, |
684 | pnpacpi_option_resource, &parse_data); | 716 | pnpacpi_option_resource, &parse_data); |
685 | 717 | ||
686 | return status; | 718 | return status; |
687 | } | 719 | } |
@@ -709,7 +741,7 @@ static int pnpacpi_supported_resource(struct acpi_resource *res) | |||
709 | * Set resource | 741 | * Set resource |
710 | */ | 742 | */ |
711 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, | 743 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, |
712 | void *data) | 744 | void *data) |
713 | { | 745 | { |
714 | int *res_cnt = (int *)data; | 746 | int *res_cnt = (int *)data; |
715 | 747 | ||
@@ -732,14 +764,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) | |||
732 | } | 764 | } |
733 | 765 | ||
734 | int pnpacpi_build_resource_template(acpi_handle handle, | 766 | int pnpacpi_build_resource_template(acpi_handle handle, |
735 | struct acpi_buffer *buffer) | 767 | struct acpi_buffer *buffer) |
736 | { | 768 | { |
737 | struct acpi_resource *resource; | 769 | struct acpi_resource *resource; |
738 | int res_cnt = 0; | 770 | int res_cnt = 0; |
739 | acpi_status status; | 771 | acpi_status status; |
740 | 772 | ||
741 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 773 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
742 | pnpacpi_count_resources, &res_cnt); | 774 | pnpacpi_count_resources, &res_cnt); |
743 | if (ACPI_FAILURE(status)) { | 775 | if (ACPI_FAILURE(status)) { |
744 | pnp_err("Evaluate _CRS failed"); | 776 | pnp_err("Evaluate _CRS failed"); |
745 | return -EINVAL; | 777 | return -EINVAL; |
@@ -753,7 +785,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, | |||
753 | pnp_dbg("Res cnt %d", res_cnt); | 785 | pnp_dbg("Res cnt %d", res_cnt); |
754 | resource = (struct acpi_resource *)buffer->pointer; | 786 | resource = (struct acpi_resource *)buffer->pointer; |
755 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 787 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
756 | pnpacpi_type_resources, &resource); | 788 | pnpacpi_type_resources, &resource); |
757 | if (ACPI_FAILURE(status)) { | 789 | if (ACPI_FAILURE(status)) { |
758 | kfree(buffer->pointer); | 790 | kfree(buffer->pointer); |
759 | pnp_err("Evaluate _CRS failed"); | 791 | pnp_err("Evaluate _CRS failed"); |
@@ -766,7 +798,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, | |||
766 | } | 798 | } |
767 | 799 | ||
768 | static void pnpacpi_encode_irq(struct acpi_resource *resource, | 800 | static void pnpacpi_encode_irq(struct acpi_resource *resource, |
769 | struct resource *p) | 801 | struct resource *p) |
770 | { | 802 | { |
771 | int triggering, polarity; | 803 | int triggering, polarity; |
772 | 804 | ||
@@ -782,7 +814,7 @@ static void pnpacpi_encode_irq(struct acpi_resource *resource, | |||
782 | } | 814 | } |
783 | 815 | ||
784 | static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, | 816 | static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, |
785 | struct resource *p) | 817 | struct resource *p) |
786 | { | 818 | { |
787 | int triggering, polarity; | 819 | int triggering, polarity; |
788 | 820 | ||
@@ -799,32 +831,32 @@ static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, | |||
799 | } | 831 | } |
800 | 832 | ||
801 | static void pnpacpi_encode_dma(struct acpi_resource *resource, | 833 | static void pnpacpi_encode_dma(struct acpi_resource *resource, |
802 | struct resource *p) | 834 | struct resource *p) |
803 | { | 835 | { |
804 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ | 836 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ |
805 | switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { | 837 | switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { |
806 | case IORESOURCE_DMA_TYPEA: | 838 | case IORESOURCE_DMA_TYPEA: |
807 | resource->data.dma.type = ACPI_TYPE_A; | 839 | resource->data.dma.type = ACPI_TYPE_A; |
808 | break; | 840 | break; |
809 | case IORESOURCE_DMA_TYPEB: | 841 | case IORESOURCE_DMA_TYPEB: |
810 | resource->data.dma.type = ACPI_TYPE_B; | 842 | resource->data.dma.type = ACPI_TYPE_B; |
811 | break; | 843 | break; |
812 | case IORESOURCE_DMA_TYPEF: | 844 | case IORESOURCE_DMA_TYPEF: |
813 | resource->data.dma.type = ACPI_TYPE_F; | 845 | resource->data.dma.type = ACPI_TYPE_F; |
814 | break; | 846 | break; |
815 | default: | 847 | default: |
816 | resource->data.dma.type = ACPI_COMPATIBILITY; | 848 | resource->data.dma.type = ACPI_COMPATIBILITY; |
817 | } | 849 | } |
818 | 850 | ||
819 | switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { | 851 | switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { |
820 | case IORESOURCE_DMA_8BIT: | 852 | case IORESOURCE_DMA_8BIT: |
821 | resource->data.dma.transfer = ACPI_TRANSFER_8; | 853 | resource->data.dma.transfer = ACPI_TRANSFER_8; |
822 | break; | 854 | break; |
823 | case IORESOURCE_DMA_8AND16BIT: | 855 | case IORESOURCE_DMA_8AND16BIT: |
824 | resource->data.dma.transfer = ACPI_TRANSFER_8_16; | 856 | resource->data.dma.transfer = ACPI_TRANSFER_8_16; |
825 | break; | 857 | break; |
826 | default: | 858 | default: |
827 | resource->data.dma.transfer = ACPI_TRANSFER_16; | 859 | resource->data.dma.transfer = ACPI_TRANSFER_16; |
828 | } | 860 | } |
829 | 861 | ||
830 | resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); | 862 | resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); |
@@ -833,31 +865,31 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource, | |||
833 | } | 865 | } |
834 | 866 | ||
835 | static void pnpacpi_encode_io(struct acpi_resource *resource, | 867 | static void pnpacpi_encode_io(struct acpi_resource *resource, |
836 | struct resource *p) | 868 | struct resource *p) |
837 | { | 869 | { |
838 | /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ | 870 | /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ |
839 | resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? | 871 | resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ? |
840 | ACPI_DECODE_16 : ACPI_DECODE_10; | 872 | ACPI_DECODE_16 : ACPI_DECODE_10; |
841 | resource->data.io.minimum = p->start; | 873 | resource->data.io.minimum = p->start; |
842 | resource->data.io.maximum = p->end; | 874 | resource->data.io.maximum = p->end; |
843 | resource->data.io.alignment = 0; /* Correct? */ | 875 | resource->data.io.alignment = 0; /* Correct? */ |
844 | resource->data.io.address_length = p->end - p->start + 1; | 876 | resource->data.io.address_length = p->end - p->start + 1; |
845 | } | 877 | } |
846 | 878 | ||
847 | static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, | 879 | static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, |
848 | struct resource *p) | 880 | struct resource *p) |
849 | { | 881 | { |
850 | resource->data.fixed_io.address = p->start; | 882 | resource->data.fixed_io.address = p->start; |
851 | resource->data.fixed_io.address_length = p->end - p->start + 1; | 883 | resource->data.fixed_io.address_length = p->end - p->start + 1; |
852 | } | 884 | } |
853 | 885 | ||
854 | static void pnpacpi_encode_mem24(struct acpi_resource *resource, | 886 | static void pnpacpi_encode_mem24(struct acpi_resource *resource, |
855 | struct resource *p) | 887 | struct resource *p) |
856 | { | 888 | { |
857 | /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ | 889 | /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ |
858 | resource->data.memory24.write_protect = | 890 | resource->data.memory24.write_protect = |
859 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? | 891 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
860 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; | 892 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
861 | resource->data.memory24.minimum = p->start; | 893 | resource->data.memory24.minimum = p->start; |
862 | resource->data.memory24.maximum = p->end; | 894 | resource->data.memory24.maximum = p->end; |
863 | resource->data.memory24.alignment = 0; | 895 | resource->data.memory24.alignment = 0; |
@@ -865,11 +897,11 @@ static void pnpacpi_encode_mem24(struct acpi_resource *resource, | |||
865 | } | 897 | } |
866 | 898 | ||
867 | static void pnpacpi_encode_mem32(struct acpi_resource *resource, | 899 | static void pnpacpi_encode_mem32(struct acpi_resource *resource, |
868 | struct resource *p) | 900 | struct resource *p) |
869 | { | 901 | { |
870 | resource->data.memory32.write_protect = | 902 | resource->data.memory32.write_protect = |
871 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? | 903 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
872 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; | 904 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
873 | resource->data.memory32.minimum = p->start; | 905 | resource->data.memory32.minimum = p->start; |
874 | resource->data.memory32.maximum = p->end; | 906 | resource->data.memory32.maximum = p->end; |
875 | resource->data.memory32.alignment = 0; | 907 | resource->data.memory32.alignment = 0; |
@@ -877,74 +909,77 @@ static void pnpacpi_encode_mem32(struct acpi_resource *resource, | |||
877 | } | 909 | } |
878 | 910 | ||
879 | static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, | 911 | static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, |
880 | struct resource *p) | 912 | struct resource *p) |
881 | { | 913 | { |
882 | resource->data.fixed_memory32.write_protect = | 914 | resource->data.fixed_memory32.write_protect = |
883 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? | 915 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
884 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; | 916 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
885 | resource->data.fixed_memory32.address = p->start; | 917 | resource->data.fixed_memory32.address = p->start; |
886 | resource->data.fixed_memory32.address_length = p->end - p->start + 1; | 918 | resource->data.fixed_memory32.address_length = p->end - p->start + 1; |
887 | } | 919 | } |
888 | 920 | ||
889 | int pnpacpi_encode_resources(struct pnp_resource_table *res_table, | 921 | int pnpacpi_encode_resources(struct pnp_resource_table *res_table, |
890 | struct acpi_buffer *buffer) | 922 | struct acpi_buffer *buffer) |
891 | { | 923 | { |
892 | int i = 0; | 924 | int i = 0; |
893 | /* pnpacpi_build_resource_template allocates extra mem */ | 925 | /* pnpacpi_build_resource_template allocates extra mem */ |
894 | int res_cnt = (buffer->length - 1)/sizeof(struct acpi_resource) - 1; | 926 | int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; |
895 | struct acpi_resource *resource = (struct acpi_resource*)buffer->pointer; | 927 | struct acpi_resource *resource = |
928 | (struct acpi_resource *)buffer->pointer; | ||
896 | int port = 0, irq = 0, dma = 0, mem = 0; | 929 | int port = 0, irq = 0, dma = 0, mem = 0; |
897 | 930 | ||
898 | pnp_dbg("res cnt %d", res_cnt); | 931 | pnp_dbg("res cnt %d", res_cnt); |
899 | while (i < res_cnt) { | 932 | while (i < res_cnt) { |
900 | switch(resource->type) { | 933 | switch (resource->type) { |
901 | case ACPI_RESOURCE_TYPE_IRQ: | 934 | case ACPI_RESOURCE_TYPE_IRQ: |
902 | pnp_dbg("Encode irq"); | 935 | pnp_dbg("Encode irq"); |
903 | pnpacpi_encode_irq(resource, | 936 | pnpacpi_encode_irq(resource, |
904 | &res_table->irq_resource[irq]); | 937 | &res_table->irq_resource[irq]); |
905 | irq++; | 938 | irq++; |
906 | break; | 939 | break; |
907 | 940 | ||
908 | case ACPI_RESOURCE_TYPE_DMA: | 941 | case ACPI_RESOURCE_TYPE_DMA: |
909 | pnp_dbg("Encode dma"); | 942 | pnp_dbg("Encode dma"); |
910 | pnpacpi_encode_dma(resource, | 943 | pnpacpi_encode_dma(resource, |
911 | &res_table->dma_resource[dma]); | 944 | &res_table->dma_resource[dma]); |
912 | dma++; | 945 | dma++; |
913 | break; | 946 | break; |
914 | case ACPI_RESOURCE_TYPE_IO: | 947 | case ACPI_RESOURCE_TYPE_IO: |
915 | pnp_dbg("Encode io"); | 948 | pnp_dbg("Encode io"); |
916 | pnpacpi_encode_io(resource, | 949 | pnpacpi_encode_io(resource, |
917 | &res_table->port_resource[port]); | 950 | &res_table->port_resource[port]); |
918 | port++; | 951 | port++; |
919 | break; | 952 | break; |
920 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 953 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
921 | pnp_dbg("Encode fixed io"); | 954 | pnp_dbg("Encode fixed io"); |
922 | pnpacpi_encode_fixed_io(resource, | 955 | pnpacpi_encode_fixed_io(resource, |
923 | &res_table->port_resource[port]); | 956 | &res_table-> |
957 | port_resource[port]); | ||
924 | port++; | 958 | port++; |
925 | break; | 959 | break; |
926 | case ACPI_RESOURCE_TYPE_MEMORY24: | 960 | case ACPI_RESOURCE_TYPE_MEMORY24: |
927 | pnp_dbg("Encode mem24"); | 961 | pnp_dbg("Encode mem24"); |
928 | pnpacpi_encode_mem24(resource, | 962 | pnpacpi_encode_mem24(resource, |
929 | &res_table->mem_resource[mem]); | 963 | &res_table->mem_resource[mem]); |
930 | mem++; | 964 | mem++; |
931 | break; | 965 | break; |
932 | case ACPI_RESOURCE_TYPE_MEMORY32: | 966 | case ACPI_RESOURCE_TYPE_MEMORY32: |
933 | pnp_dbg("Encode mem32"); | 967 | pnp_dbg("Encode mem32"); |
934 | pnpacpi_encode_mem32(resource, | 968 | pnpacpi_encode_mem32(resource, |
935 | &res_table->mem_resource[mem]); | 969 | &res_table->mem_resource[mem]); |
936 | mem++; | 970 | mem++; |
937 | break; | 971 | break; |
938 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 972 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
939 | pnp_dbg("Encode fixed mem32"); | 973 | pnp_dbg("Encode fixed mem32"); |
940 | pnpacpi_encode_fixed_mem32(resource, | 974 | pnpacpi_encode_fixed_mem32(resource, |
941 | &res_table->mem_resource[mem]); | 975 | &res_table-> |
976 | mem_resource[mem]); | ||
942 | mem++; | 977 | mem++; |
943 | break; | 978 | break; |
944 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | 979 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
945 | pnp_dbg("Encode ext irq"); | 980 | pnp_dbg("Encode ext irq"); |
946 | pnpacpi_encode_ext_irq(resource, | 981 | pnpacpi_encode_ext_irq(resource, |
947 | &res_table->irq_resource[irq]); | 982 | &res_table->irq_resource[irq]); |
948 | irq++; | 983 | irq++; |
949 | break; | 984 | break; |
950 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 985 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
@@ -956,7 +991,7 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table, | |||
956 | case ACPI_RESOURCE_TYPE_ADDRESS64: | 991 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
957 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: | 992 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
958 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: | 993 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
959 | default: /* other type */ | 994 | default: /* other type */ |
960 | pnp_warn("unknown resource type %d", resource->type); | 995 | pnp_warn("unknown resource type %d", resource->type); |
961 | return -EINVAL; | 996 | return -EINVAL; |
962 | } | 997 | } |
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c index a1f0b0ba2bfe..d546f79d4d3b 100644 --- a/drivers/pnp/pnpbios/bioscalls.c +++ b/drivers/pnp/pnpbios/bioscalls.c | |||
@@ -26,11 +26,10 @@ | |||
26 | #include "pnpbios.h" | 26 | #include "pnpbios.h" |
27 | 27 | ||
28 | static struct { | 28 | static struct { |
29 | u16 offset; | 29 | u16 offset; |
30 | u16 segment; | 30 | u16 segment; |
31 | } pnp_bios_callpoint; | 31 | } pnp_bios_callpoint; |
32 | 32 | ||
33 | |||
34 | /* | 33 | /* |
35 | * These are some opcodes for a "static asmlinkage" | 34 | * These are some opcodes for a "static asmlinkage" |
36 | * As this code is *not* executed inside the linux kernel segment, but in a | 35 | * As this code is *not* executed inside the linux kernel segment, but in a |
@@ -44,8 +43,7 @@ static struct { | |||
44 | 43 | ||
45 | asmlinkage void pnp_bios_callfunc(void); | 44 | asmlinkage void pnp_bios_callfunc(void); |
46 | 45 | ||
47 | __asm__( | 46 | __asm__(".text \n" |
48 | ".text \n" | ||
49 | __ALIGN_STR "\n" | 47 | __ALIGN_STR "\n" |
50 | "pnp_bios_callfunc:\n" | 48 | "pnp_bios_callfunc:\n" |
51 | " pushl %edx \n" | 49 | " pushl %edx \n" |
@@ -54,9 +52,7 @@ __asm__( | |||
54 | " pushl %eax \n" | 52 | " pushl %eax \n" |
55 | " lcallw *pnp_bios_callpoint\n" | 53 | " lcallw *pnp_bios_callpoint\n" |
56 | " addl $16, %esp \n" | 54 | " addl $16, %esp \n" |
57 | " lret \n" | 55 | " lret \n" ".previous \n"); |
58 | ".previous \n" | ||
59 | ); | ||
60 | 56 | ||
61 | #define Q2_SET_SEL(cpu, selname, address, size) \ | 57 | #define Q2_SET_SEL(cpu, selname, address, size) \ |
62 | do { \ | 58 | do { \ |
@@ -78,7 +74,6 @@ u32 pnp_bios_is_utter_crap = 0; | |||
78 | 74 | ||
79 | static spinlock_t pnp_bios_lock; | 75 | static spinlock_t pnp_bios_lock; |
80 | 76 | ||
81 | |||
82 | /* | 77 | /* |
83 | * Support Functions | 78 | * Support Functions |
84 | */ | 79 | */ |
@@ -97,7 +92,7 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3, | |||
97 | * PnP BIOSes are generally not terribly re-entrant. | 92 | * PnP BIOSes are generally not terribly re-entrant. |
98 | * Also, don't rely on them to save everything correctly. | 93 | * Also, don't rely on them to save everything correctly. |
99 | */ | 94 | */ |
100 | if(pnp_bios_is_utter_crap) | 95 | if (pnp_bios_is_utter_crap) |
101 | return PNP_FUNCTION_NOT_SUPPORTED; | 96 | return PNP_FUNCTION_NOT_SUPPORTED; |
102 | 97 | ||
103 | cpu = get_cpu(); | 98 | cpu = get_cpu(); |
@@ -113,112 +108,127 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3, | |||
113 | if (ts2_size) | 108 | if (ts2_size) |
114 | Q2_SET_SEL(smp_processor_id(), PNP_TS2, ts2_base, ts2_size); | 109 | Q2_SET_SEL(smp_processor_id(), PNP_TS2, ts2_base, ts2_size); |
115 | 110 | ||
116 | __asm__ __volatile__( | 111 | __asm__ __volatile__("pushl %%ebp\n\t" |
117 | "pushl %%ebp\n\t" | 112 | "pushl %%edi\n\t" |
118 | "pushl %%edi\n\t" | 113 | "pushl %%esi\n\t" |
119 | "pushl %%esi\n\t" | 114 | "pushl %%ds\n\t" |
120 | "pushl %%ds\n\t" | 115 | "pushl %%es\n\t" |
121 | "pushl %%es\n\t" | 116 | "pushl %%fs\n\t" |
122 | "pushl %%fs\n\t" | 117 | "pushl %%gs\n\t" |
123 | "pushl %%gs\n\t" | 118 | "pushfl\n\t" |
124 | "pushfl\n\t" | 119 | "movl %%esp, pnp_bios_fault_esp\n\t" |
125 | "movl %%esp, pnp_bios_fault_esp\n\t" | 120 | "movl $1f, pnp_bios_fault_eip\n\t" |
126 | "movl $1f, pnp_bios_fault_eip\n\t" | 121 | "lcall %5,%6\n\t" |
127 | "lcall %5,%6\n\t" | 122 | "1:popfl\n\t" |
128 | "1:popfl\n\t" | 123 | "popl %%gs\n\t" |
129 | "popl %%gs\n\t" | 124 | "popl %%fs\n\t" |
130 | "popl %%fs\n\t" | 125 | "popl %%es\n\t" |
131 | "popl %%es\n\t" | 126 | "popl %%ds\n\t" |
132 | "popl %%ds\n\t" | 127 | "popl %%esi\n\t" |
133 | "popl %%esi\n\t" | 128 | "popl %%edi\n\t" "popl %%ebp\n\t":"=a"(status) |
134 | "popl %%edi\n\t" | 129 | :"0"((func) | (((u32) arg1) << 16)), |
135 | "popl %%ebp\n\t" | 130 | "b"((arg2) | (((u32) arg3) << 16)), |
136 | : "=a" (status) | 131 | "c"((arg4) | (((u32) arg5) << 16)), |
137 | : "0" ((func) | (((u32)arg1) << 16)), | 132 | "d"((arg6) | (((u32) arg7) << 16)), |
138 | "b" ((arg2) | (((u32)arg3) << 16)), | 133 | "i"(PNP_CS32), "i"(0) |
139 | "c" ((arg4) | (((u32)arg5) << 16)), | 134 | :"memory"); |
140 | "d" ((arg6) | (((u32)arg7) << 16)), | ||
141 | "i" (PNP_CS32), | ||
142 | "i" (0) | ||
143 | : "memory" | ||
144 | ); | ||
145 | spin_unlock_irqrestore(&pnp_bios_lock, flags); | 135 | spin_unlock_irqrestore(&pnp_bios_lock, flags); |
146 | 136 | ||
147 | get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40; | 137 | get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40; |
148 | put_cpu(); | 138 | put_cpu(); |
149 | 139 | ||
150 | /* If we get here and this is set then the PnP BIOS faulted on us. */ | 140 | /* If we get here and this is set then the PnP BIOS faulted on us. */ |
151 | if(pnp_bios_is_utter_crap) | 141 | if (pnp_bios_is_utter_crap) { |
152 | { | 142 | printk(KERN_ERR |
153 | printk(KERN_ERR "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n"); | 143 | "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n"); |
154 | printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n"); | 144 | printk(KERN_ERR |
155 | printk(KERN_ERR "PnPBIOS: Check with your vendor for an updated BIOS\n"); | 145 | "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n"); |
146 | printk(KERN_ERR | ||
147 | "PnPBIOS: Check with your vendor for an updated BIOS\n"); | ||
156 | } | 148 | } |
157 | 149 | ||
158 | return status; | 150 | return status; |
159 | } | 151 | } |
160 | 152 | ||
161 | void pnpbios_print_status(const char * module, u16 status) | 153 | void pnpbios_print_status(const char *module, u16 status) |
162 | { | 154 | { |
163 | switch(status) { | 155 | switch (status) { |
164 | case PNP_SUCCESS: | 156 | case PNP_SUCCESS: |
165 | printk(KERN_ERR "PnPBIOS: %s: function successful\n", module); | 157 | printk(KERN_ERR "PnPBIOS: %s: function successful\n", module); |
166 | break; | 158 | break; |
167 | case PNP_NOT_SET_STATICALLY: | 159 | case PNP_NOT_SET_STATICALLY: |
168 | printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n", module); | 160 | printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n", |
161 | module); | ||
169 | break; | 162 | break; |
170 | case PNP_UNKNOWN_FUNCTION: | 163 | case PNP_UNKNOWN_FUNCTION: |
171 | printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n", module); | 164 | printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n", |
165 | module); | ||
172 | break; | 166 | break; |
173 | case PNP_FUNCTION_NOT_SUPPORTED: | 167 | case PNP_FUNCTION_NOT_SUPPORTED: |
174 | printk(KERN_ERR "PnPBIOS: %s: function not supported on this system\n", module); | 168 | printk(KERN_ERR |
169 | "PnPBIOS: %s: function not supported on this system\n", | ||
170 | module); | ||
175 | break; | 171 | break; |
176 | case PNP_INVALID_HANDLE: | 172 | case PNP_INVALID_HANDLE: |
177 | printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module); | 173 | printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module); |
178 | break; | 174 | break; |
179 | case PNP_BAD_PARAMETER: | 175 | case PNP_BAD_PARAMETER: |
180 | printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n", module); | 176 | printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n", |
177 | module); | ||
181 | break; | 178 | break; |
182 | case PNP_SET_FAILED: | 179 | case PNP_SET_FAILED: |
183 | printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n", module); | 180 | printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n", |
181 | module); | ||
184 | break; | 182 | break; |
185 | case PNP_EVENTS_NOT_PENDING: | 183 | case PNP_EVENTS_NOT_PENDING: |
186 | printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module); | 184 | printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module); |
187 | break; | 185 | break; |
188 | case PNP_SYSTEM_NOT_DOCKED: | 186 | case PNP_SYSTEM_NOT_DOCKED: |
189 | printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n", module); | 187 | printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n", |
188 | module); | ||
190 | break; | 189 | break; |
191 | case PNP_NO_ISA_PNP_CARDS: | 190 | case PNP_NO_ISA_PNP_CARDS: |
192 | printk(KERN_ERR "PnPBIOS: %s: no isapnp cards are installed on this system\n", module); | 191 | printk(KERN_ERR |
192 | "PnPBIOS: %s: no isapnp cards are installed on this system\n", | ||
193 | module); | ||
193 | break; | 194 | break; |
194 | case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES: | 195 | case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES: |
195 | printk(KERN_ERR "PnPBIOS: %s: cannot determine the capabilities of the docking station\n", module); | 196 | printk(KERN_ERR |
197 | "PnPBIOS: %s: cannot determine the capabilities of the docking station\n", | ||
198 | module); | ||
196 | break; | 199 | break; |
197 | case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY: | 200 | case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY: |
198 | printk(KERN_ERR "PnPBIOS: %s: unable to undock, the system does not have a battery\n", module); | 201 | printk(KERN_ERR |
202 | "PnPBIOS: %s: unable to undock, the system does not have a battery\n", | ||
203 | module); | ||
199 | break; | 204 | break; |
200 | case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT: | 205 | case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT: |
201 | printk(KERN_ERR "PnPBIOS: %s: could not dock due to resource conflicts\n", module); | 206 | printk(KERN_ERR |
207 | "PnPBIOS: %s: could not dock due to resource conflicts\n", | ||
208 | module); | ||
202 | break; | 209 | break; |
203 | case PNP_BUFFER_TOO_SMALL: | 210 | case PNP_BUFFER_TOO_SMALL: |
204 | printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n", module); | 211 | printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n", |
212 | module); | ||
205 | break; | 213 | break; |
206 | case PNP_USE_ESCD_SUPPORT: | 214 | case PNP_USE_ESCD_SUPPORT: |
207 | printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module); | 215 | printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module); |
208 | break; | 216 | break; |
209 | case PNP_MESSAGE_NOT_SUPPORTED: | 217 | case PNP_MESSAGE_NOT_SUPPORTED: |
210 | printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n", module); | 218 | printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n", |
219 | module); | ||
211 | break; | 220 | break; |
212 | case PNP_HARDWARE_ERROR: | 221 | case PNP_HARDWARE_ERROR: |
213 | printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occured\n", module); | 222 | printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occured\n", |
223 | module); | ||
214 | break; | 224 | break; |
215 | default: | 225 | default: |
216 | printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module, status); | 226 | printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module, |
227 | status); | ||
217 | break; | 228 | break; |
218 | } | 229 | } |
219 | } | 230 | } |
220 | 231 | ||
221 | |||
222 | /* | 232 | /* |
223 | * PnP BIOS Low Level Calls | 233 | * PnP BIOS Low Level Calls |
224 | */ | 234 | */ |
@@ -245,17 +255,19 @@ static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data) | |||
245 | u16 status; | 255 | u16 status; |
246 | if (!pnp_bios_present()) | 256 | if (!pnp_bios_present()) |
247 | return PNP_FUNCTION_NOT_SUPPORTED; | 257 | return PNP_FUNCTION_NOT_SUPPORTED; |
248 | status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, PNP_DS, 0, 0, | 258 | status = |
249 | data, sizeof(struct pnp_dev_node_info), NULL, 0); | 259 | call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, |
260 | PNP_DS, 0, 0, data, sizeof(struct pnp_dev_node_info), | ||
261 | NULL, 0); | ||
250 | data->no_nodes &= 0xff; | 262 | data->no_nodes &= 0xff; |
251 | return status; | 263 | return status; |
252 | } | 264 | } |
253 | 265 | ||
254 | int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) | 266 | int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) |
255 | { | 267 | { |
256 | int status = __pnp_bios_dev_node_info( data ); | 268 | int status = __pnp_bios_dev_node_info(data); |
257 | if ( status ) | 269 | if (status) |
258 | pnpbios_print_status( "dev_node_info", status ); | 270 | pnpbios_print_status("dev_node_info", status); |
259 | return status; | 271 | return status; |
260 | } | 272 | } |
261 | 273 | ||
@@ -273,60 +285,64 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) | |||
273 | * or volatile current (0) config | 285 | * or volatile current (0) config |
274 | * Output: *nodenum=next node or 0xff if no more nodes | 286 | * Output: *nodenum=next node or 0xff if no more nodes |
275 | */ | 287 | */ |
276 | static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) | 288 | static int __pnp_bios_get_dev_node(u8 * nodenum, char boot, |
289 | struct pnp_bios_node *data) | ||
277 | { | 290 | { |
278 | u16 status; | 291 | u16 status; |
279 | u16 tmp_nodenum; | 292 | u16 tmp_nodenum; |
280 | if (!pnp_bios_present()) | 293 | if (!pnp_bios_present()) |
281 | return PNP_FUNCTION_NOT_SUPPORTED; | 294 | return PNP_FUNCTION_NOT_SUPPORTED; |
282 | if ( !boot && pnpbios_dont_use_current_config ) | 295 | if (!boot && pnpbios_dont_use_current_config) |
283 | return PNP_FUNCTION_NOT_SUPPORTED; | 296 | return PNP_FUNCTION_NOT_SUPPORTED; |
284 | tmp_nodenum = *nodenum; | 297 | tmp_nodenum = *nodenum; |
285 | status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0, | 298 | status = |
286 | &tmp_nodenum, sizeof(tmp_nodenum), data, 65536); | 299 | call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, |
300 | boot ? 2 : 1, PNP_DS, 0, &tmp_nodenum, | ||
301 | sizeof(tmp_nodenum), data, 65536); | ||
287 | *nodenum = tmp_nodenum; | 302 | *nodenum = tmp_nodenum; |
288 | return status; | 303 | return status; |
289 | } | 304 | } |
290 | 305 | ||
291 | int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) | 306 | int pnp_bios_get_dev_node(u8 * nodenum, char boot, struct pnp_bios_node *data) |
292 | { | 307 | { |
293 | int status; | 308 | int status; |
294 | status = __pnp_bios_get_dev_node( nodenum, boot, data ); | 309 | status = __pnp_bios_get_dev_node(nodenum, boot, data); |
295 | if ( status ) | 310 | if (status) |
296 | pnpbios_print_status( "get_dev_node", status ); | 311 | pnpbios_print_status("get_dev_node", status); |
297 | return status; | 312 | return status; |
298 | } | 313 | } |
299 | 314 | ||
300 | |||
301 | /* | 315 | /* |
302 | * Call PnP BIOS with function 0x02, "set system device node" | 316 | * Call PnP BIOS with function 0x02, "set system device node" |
303 | * Input: *nodenum = desired node, | 317 | * Input: *nodenum = desired node, |
304 | * boot = whether to set nonvolatile boot (!=0) | 318 | * boot = whether to set nonvolatile boot (!=0) |
305 | * or volatile current (0) config | 319 | * or volatile current (0) config |
306 | */ | 320 | */ |
307 | static int __pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) | 321 | static int __pnp_bios_set_dev_node(u8 nodenum, char boot, |
322 | struct pnp_bios_node *data) | ||
308 | { | 323 | { |
309 | u16 status; | 324 | u16 status; |
310 | if (!pnp_bios_present()) | 325 | if (!pnp_bios_present()) |
311 | return PNP_FUNCTION_NOT_SUPPORTED; | 326 | return PNP_FUNCTION_NOT_SUPPORTED; |
312 | if ( !boot && pnpbios_dont_use_current_config ) | 327 | if (!boot && pnpbios_dont_use_current_config) |
313 | return PNP_FUNCTION_NOT_SUPPORTED; | 328 | return PNP_FUNCTION_NOT_SUPPORTED; |
314 | status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0, | 329 | status = |
315 | data, 65536, NULL, 0); | 330 | call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, |
331 | boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, NULL, 0); | ||
316 | return status; | 332 | return status; |
317 | } | 333 | } |
318 | 334 | ||
319 | int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) | 335 | int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) |
320 | { | 336 | { |
321 | int status; | 337 | int status; |
322 | status = __pnp_bios_set_dev_node( nodenum, boot, data ); | 338 | status = __pnp_bios_set_dev_node(nodenum, boot, data); |
323 | if ( status ) { | 339 | if (status) { |
324 | pnpbios_print_status( "set_dev_node", status ); | 340 | pnpbios_print_status("set_dev_node", status); |
325 | return status; | 341 | return status; |
326 | } | 342 | } |
327 | if ( !boot ) { /* Update devlist */ | 343 | if (!boot) { /* Update devlist */ |
328 | status = pnp_bios_get_dev_node( &nodenum, boot, data ); | 344 | status = pnp_bios_get_dev_node(&nodenum, boot, data); |
329 | if ( status ) | 345 | if (status) |
330 | return status; | 346 | return status; |
331 | } | 347 | } |
332 | return status; | 348 | return status; |
@@ -336,12 +352,12 @@ int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) | |||
336 | /* | 352 | /* |
337 | * Call PnP BIOS with function 0x03, "get event" | 353 | * Call PnP BIOS with function 0x03, "get event" |
338 | */ | 354 | */ |
339 | static int pnp_bios_get_event(u16 *event) | 355 | static int pnp_bios_get_event(u16 * event) |
340 | { | 356 | { |
341 | u16 status; | 357 | u16 status; |
342 | if (!pnp_bios_present()) | 358 | if (!pnp_bios_present()) |
343 | return PNP_FUNCTION_NOT_SUPPORTED; | 359 | return PNP_FUNCTION_NOT_SUPPORTED; |
344 | status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0 ,0 ,0, | 360 | status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, |
345 | event, sizeof(u16), NULL, 0); | 361 | event, sizeof(u16), NULL, 0); |
346 | return status; | 362 | return status; |
347 | } | 363 | } |
@@ -356,7 +372,9 @@ static int pnp_bios_send_message(u16 message) | |||
356 | u16 status; | 372 | u16 status; |
357 | if (!pnp_bios_present()) | 373 | if (!pnp_bios_present()) |
358 | return PNP_FUNCTION_NOT_SUPPORTED; | 374 | return PNP_FUNCTION_NOT_SUPPORTED; |
359 | status = call_pnp_bios(PNP_SEND_MESSAGE, message, PNP_DS, 0, 0, 0, 0, 0, 0, 0, 0, 0); | 375 | status = |
376 | call_pnp_bios(PNP_SEND_MESSAGE, message, PNP_DS, 0, 0, 0, 0, 0, 0, | ||
377 | 0, 0, 0); | ||
360 | return status; | 378 | return status; |
361 | } | 379 | } |
362 | #endif | 380 | #endif |
@@ -369,8 +387,10 @@ int pnp_bios_dock_station_info(struct pnp_docking_station_info *data) | |||
369 | u16 status; | 387 | u16 status; |
370 | if (!pnp_bios_present()) | 388 | if (!pnp_bios_present()) |
371 | return PNP_FUNCTION_NOT_SUPPORTED; | 389 | return PNP_FUNCTION_NOT_SUPPORTED; |
372 | status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, | 390 | status = |
373 | data, sizeof(struct pnp_docking_station_info), NULL, 0); | 391 | call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1, |
392 | PNP_DS, 0, 0, 0, 0, data, | ||
393 | sizeof(struct pnp_docking_station_info), NULL, 0); | ||
374 | return status; | 394 | return status; |
375 | } | 395 | } |
376 | 396 | ||
@@ -384,8 +404,9 @@ static int pnp_bios_set_stat_res(char *info) | |||
384 | u16 status; | 404 | u16 status; |
385 | if (!pnp_bios_present()) | 405 | if (!pnp_bios_present()) |
386 | return PNP_FUNCTION_NOT_SUPPORTED; | 406 | return PNP_FUNCTION_NOT_SUPPORTED; |
387 | status = call_pnp_bios(PNP_SET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, | 407 | status = |
388 | info, *((u16 *) info), 0, 0); | 408 | call_pnp_bios(PNP_SET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, |
409 | 0, 0, 0, 0, info, *((u16 *) info), 0, 0); | ||
389 | return status; | 410 | return status; |
390 | } | 411 | } |
391 | #endif | 412 | #endif |
@@ -399,17 +420,18 @@ static int __pnp_bios_get_stat_res(char *info) | |||
399 | u16 status; | 420 | u16 status; |
400 | if (!pnp_bios_present()) | 421 | if (!pnp_bios_present()) |
401 | return PNP_FUNCTION_NOT_SUPPORTED; | 422 | return PNP_FUNCTION_NOT_SUPPORTED; |
402 | status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, | 423 | status = |
403 | info, 65536, NULL, 0); | 424 | call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, |
425 | 0, 0, 0, 0, info, 65536, NULL, 0); | ||
404 | return status; | 426 | return status; |
405 | } | 427 | } |
406 | 428 | ||
407 | int pnp_bios_get_stat_res(char *info) | 429 | int pnp_bios_get_stat_res(char *info) |
408 | { | 430 | { |
409 | int status; | 431 | int status; |
410 | status = __pnp_bios_get_stat_res( info ); | 432 | status = __pnp_bios_get_stat_res(info); |
411 | if ( status ) | 433 | if (status) |
412 | pnpbios_print_status( "get_stat_res", status ); | 434 | pnpbios_print_status("get_stat_res", status); |
413 | return status; | 435 | return status; |
414 | } | 436 | } |
415 | 437 | ||
@@ -417,13 +439,14 @@ int pnp_bios_get_stat_res(char *info) | |||
417 | /* | 439 | /* |
418 | * Call PnP BIOS with function 0x0b, "get APM id table" | 440 | * Call PnP BIOS with function 0x0b, "get APM id table" |
419 | */ | 441 | */ |
420 | static int pnp_bios_apm_id_table(char *table, u16 *size) | 442 | static int pnp_bios_apm_id_table(char *table, u16 * size) |
421 | { | 443 | { |
422 | u16 status; | 444 | u16 status; |
423 | if (!pnp_bios_present()) | 445 | if (!pnp_bios_present()) |
424 | return PNP_FUNCTION_NOT_SUPPORTED; | 446 | return PNP_FUNCTION_NOT_SUPPORTED; |
425 | status = call_pnp_bios(PNP_GET_APM_ID_TABLE, 0, PNP_TS2, 0, PNP_TS1, PNP_DS, 0, 0, | 447 | status = |
426 | table, *size, size, sizeof(u16)); | 448 | call_pnp_bios(PNP_GET_APM_ID_TABLE, 0, PNP_TS2, 0, PNP_TS1, PNP_DS, |
449 | 0, 0, table, *size, size, sizeof(u16)); | ||
427 | return status; | 450 | return status; |
428 | } | 451 | } |
429 | #endif | 452 | #endif |
@@ -436,17 +459,19 @@ static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) | |||
436 | u16 status; | 459 | u16 status; |
437 | if (!pnp_bios_present()) | 460 | if (!pnp_bios_present()) |
438 | return PNP_FUNCTION_NOT_SUPPORTED; | 461 | return PNP_FUNCTION_NOT_SUPPORTED; |
439 | status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, | 462 | status = |
440 | data, sizeof(struct pnp_isa_config_struc), NULL, 0); | 463 | call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, |
464 | 0, 0, 0, data, sizeof(struct pnp_isa_config_struc), | ||
465 | NULL, 0); | ||
441 | return status; | 466 | return status; |
442 | } | 467 | } |
443 | 468 | ||
444 | int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) | 469 | int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) |
445 | { | 470 | { |
446 | int status; | 471 | int status; |
447 | status = __pnp_bios_isapnp_config( data ); | 472 | status = __pnp_bios_isapnp_config(data); |
448 | if ( status ) | 473 | if (status) |
449 | pnpbios_print_status( "isapnp_config", status ); | 474 | pnpbios_print_status("isapnp_config", status); |
450 | return status; | 475 | return status; |
451 | } | 476 | } |
452 | 477 | ||
@@ -458,17 +483,19 @@ static int __pnp_bios_escd_info(struct escd_info_struc *data) | |||
458 | u16 status; | 483 | u16 status; |
459 | if (!pnp_bios_present()) | 484 | if (!pnp_bios_present()) |
460 | return ESCD_FUNCTION_NOT_SUPPORTED; | 485 | return ESCD_FUNCTION_NOT_SUPPORTED; |
461 | status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, PNP_DS, | 486 | status = |
462 | data, sizeof(struct escd_info_struc), NULL, 0); | 487 | call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, |
488 | PNP_DS, data, sizeof(struct escd_info_struc), NULL, | ||
489 | 0); | ||
463 | return status; | 490 | return status; |
464 | } | 491 | } |
465 | 492 | ||
466 | int pnp_bios_escd_info(struct escd_info_struc *data) | 493 | int pnp_bios_escd_info(struct escd_info_struc *data) |
467 | { | 494 | { |
468 | int status; | 495 | int status; |
469 | status = __pnp_bios_escd_info( data ); | 496 | status = __pnp_bios_escd_info(data); |
470 | if ( status ) | 497 | if (status) |
471 | pnpbios_print_status( "escd_info", status ); | 498 | pnpbios_print_status("escd_info", status); |
472 | return status; | 499 | return status; |
473 | } | 500 | } |
474 | 501 | ||
@@ -481,17 +508,18 @@ static int __pnp_bios_read_escd(char *data, u32 nvram_base) | |||
481 | u16 status; | 508 | u16 status; |
482 | if (!pnp_bios_present()) | 509 | if (!pnp_bios_present()) |
483 | return ESCD_FUNCTION_NOT_SUPPORTED; | 510 | return ESCD_FUNCTION_NOT_SUPPORTED; |
484 | status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, | 511 | status = |
485 | data, 65536, __va(nvram_base), 65536); | 512 | call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, |
513 | data, 65536, __va(nvram_base), 65536); | ||
486 | return status; | 514 | return status; |
487 | } | 515 | } |
488 | 516 | ||
489 | int pnp_bios_read_escd(char *data, u32 nvram_base) | 517 | int pnp_bios_read_escd(char *data, u32 nvram_base) |
490 | { | 518 | { |
491 | int status; | 519 | int status; |
492 | status = __pnp_bios_read_escd( data, nvram_base ); | 520 | status = __pnp_bios_read_escd(data, nvram_base); |
493 | if ( status ) | 521 | if (status) |
494 | pnpbios_print_status( "read_escd", status ); | 522 | pnpbios_print_status("read_escd", status); |
495 | return status; | 523 | return status; |
496 | } | 524 | } |
497 | 525 | ||
@@ -504,13 +532,13 @@ static int pnp_bios_write_escd(char *data, u32 nvram_base) | |||
504 | u16 status; | 532 | u16 status; |
505 | if (!pnp_bios_present()) | 533 | if (!pnp_bios_present()) |
506 | return ESCD_FUNCTION_NOT_SUPPORTED; | 534 | return ESCD_FUNCTION_NOT_SUPPORTED; |
507 | status = call_pnp_bios(PNP_WRITE_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, | 535 | status = |
508 | data, 65536, __va(nvram_base), 65536); | 536 | call_pnp_bios(PNP_WRITE_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, |
537 | data, 65536, __va(nvram_base), 65536); | ||
509 | return status; | 538 | return status; |
510 | } | 539 | } |
511 | #endif | 540 | #endif |
512 | 541 | ||
513 | |||
514 | /* | 542 | /* |
515 | * Initialization | 543 | * Initialization |
516 | */ | 544 | */ |
@@ -524,12 +552,14 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header) | |||
524 | 552 | ||
525 | set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); | 553 | set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); |
526 | _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); | 554 | _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); |
527 | for (i = 0; i < NR_CPUS; i++) { | 555 | for (i = 0; i < NR_CPUS; i++) { |
528 | struct desc_struct *gdt = get_cpu_gdt_table(i); | 556 | struct desc_struct *gdt = get_cpu_gdt_table(i); |
529 | if (!gdt) | 557 | if (!gdt) |
530 | continue; | 558 | continue; |
531 | set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc); | 559 | set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc); |
532 | set_base(gdt[GDT_ENTRY_PNPBIOS_CS16], __va(header->fields.pm16cseg)); | 560 | set_base(gdt[GDT_ENTRY_PNPBIOS_CS16], |
533 | set_base(gdt[GDT_ENTRY_PNPBIOS_DS], __va(header->fields.pm16dseg)); | 561 | __va(header->fields.pm16cseg)); |
534 | } | 562 | set_base(gdt[GDT_ENTRY_PNPBIOS_DS], |
563 | __va(header->fields.pm16dseg)); | ||
564 | } | ||
535 | } | 565 | } |
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index ed112ee16012..21289cb13a33 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c | |||
@@ -32,7 +32,7 @@ | |||
32 | * along with this program; if not, write to the Free Software | 32 | * along with this program; if not, write to the Free Software |
33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
34 | */ | 34 | */ |
35 | 35 | ||
36 | /* Change Log | 36 | /* Change Log |
37 | * | 37 | * |
38 | * Adam Belay - <ambx1@neo.rr.com> - March 16, 2003 | 38 | * Adam Belay - <ambx1@neo.rr.com> - March 16, 2003 |
@@ -71,14 +71,13 @@ | |||
71 | 71 | ||
72 | #include "pnpbios.h" | 72 | #include "pnpbios.h" |
73 | 73 | ||
74 | |||
75 | /* | 74 | /* |
76 | * | 75 | * |
77 | * PnP BIOS INTERFACE | 76 | * PnP BIOS INTERFACE |
78 | * | 77 | * |
79 | */ | 78 | */ |
80 | 79 | ||
81 | static union pnp_bios_install_struct * pnp_bios_install = NULL; | 80 | static union pnp_bios_install_struct *pnp_bios_install = NULL; |
82 | 81 | ||
83 | int pnp_bios_present(void) | 82 | int pnp_bios_present(void) |
84 | { | 83 | { |
@@ -101,36 +100,36 @@ static struct completion unload_sem; | |||
101 | /* | 100 | /* |
102 | * (Much of this belongs in a shared routine somewhere) | 101 | * (Much of this belongs in a shared routine somewhere) |
103 | */ | 102 | */ |
104 | 103 | ||
105 | static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) | 104 | static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) |
106 | { | 105 | { |
107 | char *argv [3], **envp, *buf, *scratch; | 106 | char *argv[3], **envp, *buf, *scratch; |
108 | int i = 0, value; | 107 | int i = 0, value; |
109 | 108 | ||
110 | if (!current->fs->root) { | 109 | if (!current->fs->root) { |
111 | return -EAGAIN; | 110 | return -EAGAIN; |
112 | } | 111 | } |
113 | if (!(envp = kcalloc(20, sizeof (char *), GFP_KERNEL))) { | 112 | if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) { |
114 | return -ENOMEM; | 113 | return -ENOMEM; |
115 | } | 114 | } |
116 | if (!(buf = kzalloc(256, GFP_KERNEL))) { | 115 | if (!(buf = kzalloc(256, GFP_KERNEL))) { |
117 | kfree (envp); | 116 | kfree(envp); |
118 | return -ENOMEM; | 117 | return -ENOMEM; |
119 | } | 118 | } |
120 | 119 | ||
121 | /* FIXME: if there are actual users of this, it should be integrated into | 120 | /* FIXME: if there are actual users of this, it should be integrated into |
122 | * the driver core and use the usual infrastructure like sysfs and uevents */ | 121 | * the driver core and use the usual infrastructure like sysfs and uevents */ |
123 | argv [0] = "/sbin/pnpbios"; | 122 | argv[0] = "/sbin/pnpbios"; |
124 | argv [1] = "dock"; | 123 | argv[1] = "dock"; |
125 | argv [2] = NULL; | 124 | argv[2] = NULL; |
126 | 125 | ||
127 | /* minimal command environment */ | 126 | /* minimal command environment */ |
128 | envp [i++] = "HOME=/"; | 127 | envp[i++] = "HOME=/"; |
129 | envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | 128 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; |
130 | 129 | ||
131 | #ifdef DEBUG | 130 | #ifdef DEBUG |
132 | /* hint that policy agent should enter no-stdout debug mode */ | 131 | /* hint that policy agent should enter no-stdout debug mode */ |
133 | envp [i++] = "DEBUG=kernel"; | 132 | envp[i++] = "DEBUG=kernel"; |
134 | #endif | 133 | #endif |
135 | /* extensible set of named bus-specific parameters, | 134 | /* extensible set of named bus-specific parameters, |
136 | * supporting multiple driver selection algorithms. | 135 | * supporting multiple driver selection algorithms. |
@@ -138,33 +137,32 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) | |||
138 | scratch = buf; | 137 | scratch = buf; |
139 | 138 | ||
140 | /* action: add, remove */ | 139 | /* action: add, remove */ |
141 | envp [i++] = scratch; | 140 | envp[i++] = scratch; |
142 | scratch += sprintf (scratch, "ACTION=%s", dock?"add":"remove") + 1; | 141 | scratch += sprintf(scratch, "ACTION=%s", dock ? "add" : "remove") + 1; |
143 | 142 | ||
144 | /* Report the ident for the dock */ | 143 | /* Report the ident for the dock */ |
145 | envp [i++] = scratch; | 144 | envp[i++] = scratch; |
146 | scratch += sprintf (scratch, "DOCK=%x/%x/%x", | 145 | scratch += sprintf(scratch, "DOCK=%x/%x/%x", |
147 | info->location_id, info->serial, info->capabilities); | 146 | info->location_id, info->serial, info->capabilities); |
148 | envp[i] = NULL; | 147 | envp[i] = NULL; |
149 | 148 | ||
150 | value = call_usermodehelper (argv [0], argv, envp, UMH_WAIT_EXEC); | 149 | value = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); |
151 | kfree (buf); | 150 | kfree(buf); |
152 | kfree (envp); | 151 | kfree(envp); |
153 | return 0; | 152 | return 0; |
154 | } | 153 | } |
155 | 154 | ||
156 | /* | 155 | /* |
157 | * Poll the PnP docking at regular intervals | 156 | * Poll the PnP docking at regular intervals |
158 | */ | 157 | */ |
159 | static int pnp_dock_thread(void * unused) | 158 | static int pnp_dock_thread(void *unused) |
160 | { | 159 | { |
161 | static struct pnp_docking_station_info now; | 160 | static struct pnp_docking_station_info now; |
162 | int docked = -1, d = 0; | 161 | int docked = -1, d = 0; |
163 | set_freezable(); | 162 | set_freezable(); |
164 | while (!unloading) | 163 | while (!unloading) { |
165 | { | ||
166 | int status; | 164 | int status; |
167 | 165 | ||
168 | /* | 166 | /* |
169 | * Poll every 2 seconds | 167 | * Poll every 2 seconds |
170 | */ | 168 | */ |
@@ -175,30 +173,29 @@ static int pnp_dock_thread(void * unused) | |||
175 | 173 | ||
176 | status = pnp_bios_dock_station_info(&now); | 174 | status = pnp_bios_dock_station_info(&now); |
177 | 175 | ||
178 | switch(status) | 176 | switch (status) { |
179 | { | ||
180 | /* | 177 | /* |
181 | * No dock to manage | 178 | * No dock to manage |
182 | */ | 179 | */ |
183 | case PNP_FUNCTION_NOT_SUPPORTED: | 180 | case PNP_FUNCTION_NOT_SUPPORTED: |
184 | complete_and_exit(&unload_sem, 0); | 181 | complete_and_exit(&unload_sem, 0); |
185 | case PNP_SYSTEM_NOT_DOCKED: | 182 | case PNP_SYSTEM_NOT_DOCKED: |
186 | d = 0; | 183 | d = 0; |
187 | break; | 184 | break; |
188 | case PNP_SUCCESS: | 185 | case PNP_SUCCESS: |
189 | d = 1; | 186 | d = 1; |
190 | break; | 187 | break; |
191 | default: | 188 | default: |
192 | pnpbios_print_status( "pnp_dock_thread", status ); | 189 | pnpbios_print_status("pnp_dock_thread", status); |
193 | continue; | 190 | continue; |
194 | } | 191 | } |
195 | if(d != docked) | 192 | if (d != docked) { |
196 | { | 193 | if (pnp_dock_event(d, &now) == 0) { |
197 | if(pnp_dock_event(d, &now)==0) | ||
198 | { | ||
199 | docked = d; | 194 | docked = d; |
200 | #if 0 | 195 | #if 0 |
201 | printk(KERN_INFO "PnPBIOS: Docking station %stached\n", docked?"at":"de"); | 196 | printk(KERN_INFO |
197 | "PnPBIOS: Docking station %stached\n", | ||
198 | docked ? "at" : "de"); | ||
202 | #endif | 199 | #endif |
203 | } | 200 | } |
204 | } | 201 | } |
@@ -206,21 +203,22 @@ static int pnp_dock_thread(void * unused) | |||
206 | complete_and_exit(&unload_sem, 0); | 203 | complete_and_exit(&unload_sem, 0); |
207 | } | 204 | } |
208 | 205 | ||
209 | #endif /* CONFIG_HOTPLUG */ | 206 | #endif /* CONFIG_HOTPLUG */ |
210 | 207 | ||
211 | static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res) | 208 | static int pnpbios_get_resources(struct pnp_dev *dev, |
209 | struct pnp_resource_table *res) | ||
212 | { | 210 | { |
213 | u8 nodenum = dev->number; | 211 | u8 nodenum = dev->number; |
214 | struct pnp_bios_node * node; | 212 | struct pnp_bios_node *node; |
215 | 213 | ||
216 | /* just in case */ | 214 | /* just in case */ |
217 | if(!pnpbios_is_dynamic(dev)) | 215 | if (!pnpbios_is_dynamic(dev)) |
218 | return -EPERM; | 216 | return -EPERM; |
219 | 217 | ||
220 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); | 218 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
221 | if (!node) | 219 | if (!node) |
222 | return -1; | 220 | return -1; |
223 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 221 | if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) { |
224 | kfree(node); | 222 | kfree(node); |
225 | return -ENODEV; | 223 | return -ENODEV; |
226 | } | 224 | } |
@@ -230,10 +228,11 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
230 | return 0; | 228 | return 0; |
231 | } | 229 | } |
232 | 230 | ||
233 | static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res) | 231 | static int pnpbios_set_resources(struct pnp_dev *dev, |
232 | struct pnp_resource_table *res) | ||
234 | { | 233 | { |
235 | u8 nodenum = dev->number; | 234 | u8 nodenum = dev->number; |
236 | struct pnp_bios_node * node; | 235 | struct pnp_bios_node *node; |
237 | int ret; | 236 | int ret; |
238 | 237 | ||
239 | /* just in case */ | 238 | /* just in case */ |
@@ -243,11 +242,11 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
243 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); | 242 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
244 | if (!node) | 243 | if (!node) |
245 | return -1; | 244 | return -1; |
246 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 245 | if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) { |
247 | kfree(node); | 246 | kfree(node); |
248 | return -ENODEV; | 247 | return -ENODEV; |
249 | } | 248 | } |
250 | if(pnpbios_write_resources_to_node(res, node)<0) { | 249 | if (pnpbios_write_resources_to_node(res, node) < 0) { |
251 | kfree(node); | 250 | kfree(node); |
252 | return -1; | 251 | return -1; |
253 | } | 252 | } |
@@ -258,18 +257,18 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
258 | return ret; | 257 | return ret; |
259 | } | 258 | } |
260 | 259 | ||
261 | static void pnpbios_zero_data_stream(struct pnp_bios_node * node) | 260 | static void pnpbios_zero_data_stream(struct pnp_bios_node *node) |
262 | { | 261 | { |
263 | unsigned char * p = (char *)node->data; | 262 | unsigned char *p = (char *)node->data; |
264 | unsigned char * end = (char *)(node->data + node->size); | 263 | unsigned char *end = (char *)(node->data + node->size); |
265 | unsigned int len; | 264 | unsigned int len; |
266 | int i; | 265 | int i; |
267 | while ((char *)p < (char *)end) { | 266 | while ((char *)p < (char *)end) { |
268 | if(p[0] & 0x80) { /* large tag */ | 267 | if (p[0] & 0x80) { /* large tag */ |
269 | len = (p[2] << 8) | p[1]; | 268 | len = (p[2] << 8) | p[1]; |
270 | p += 3; | 269 | p += 3; |
271 | } else { | 270 | } else { |
272 | if (((p[0]>>3) & 0x0f) == 0x0f) | 271 | if (((p[0] >> 3) & 0x0f) == 0x0f) |
273 | return; | 272 | return; |
274 | len = p[0] & 0x07; | 273 | len = p[0] & 0x07; |
275 | p += 1; | 274 | p += 1; |
@@ -278,24 +277,25 @@ static void pnpbios_zero_data_stream(struct pnp_bios_node * node) | |||
278 | p[i] = 0; | 277 | p[i] = 0; |
279 | p += len; | 278 | p += len; |
280 | } | 279 | } |
281 | printk(KERN_ERR "PnPBIOS: Resource structure did not contain an end tag.\n"); | 280 | printk(KERN_ERR |
281 | "PnPBIOS: Resource structure did not contain an end tag.\n"); | ||
282 | } | 282 | } |
283 | 283 | ||
284 | static int pnpbios_disable_resources(struct pnp_dev *dev) | 284 | static int pnpbios_disable_resources(struct pnp_dev *dev) |
285 | { | 285 | { |
286 | struct pnp_bios_node * node; | 286 | struct pnp_bios_node *node; |
287 | u8 nodenum = dev->number; | 287 | u8 nodenum = dev->number; |
288 | int ret; | 288 | int ret; |
289 | 289 | ||
290 | /* just in case */ | 290 | /* just in case */ |
291 | if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) | 291 | if (dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) |
292 | return -EPERM; | 292 | return -EPERM; |
293 | 293 | ||
294 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); | 294 | node = kzalloc(node_info.max_node_size, GFP_KERNEL); |
295 | if (!node) | 295 | if (!node) |
296 | return -ENOMEM; | 296 | return -ENOMEM; |
297 | 297 | ||
298 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 298 | if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) { |
299 | kfree(node); | 299 | kfree(node); |
300 | return -ENODEV; | 300 | return -ENODEV; |
301 | } | 301 | } |
@@ -311,22 +311,22 @@ static int pnpbios_disable_resources(struct pnp_dev *dev) | |||
311 | /* PnP Layer support */ | 311 | /* PnP Layer support */ |
312 | 312 | ||
313 | struct pnp_protocol pnpbios_protocol = { | 313 | struct pnp_protocol pnpbios_protocol = { |
314 | .name = "Plug and Play BIOS", | 314 | .name = "Plug and Play BIOS", |
315 | .get = pnpbios_get_resources, | 315 | .get = pnpbios_get_resources, |
316 | .set = pnpbios_set_resources, | 316 | .set = pnpbios_set_resources, |
317 | .disable = pnpbios_disable_resources, | 317 | .disable = pnpbios_disable_resources, |
318 | }; | 318 | }; |
319 | 319 | ||
320 | static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) | 320 | static int insert_device(struct pnp_dev *dev, struct pnp_bios_node *node) |
321 | { | 321 | { |
322 | struct list_head * pos; | 322 | struct list_head *pos; |
323 | struct pnp_dev * pnp_dev; | 323 | struct pnp_dev *pnp_dev; |
324 | struct pnp_id *dev_id; | 324 | struct pnp_id *dev_id; |
325 | char id[8]; | 325 | char id[8]; |
326 | 326 | ||
327 | /* check if the device is already added */ | 327 | /* check if the device is already added */ |
328 | dev->number = node->handle; | 328 | dev->number = node->handle; |
329 | list_for_each (pos, &pnpbios_protocol.devices){ | 329 | list_for_each(pos, &pnpbios_protocol.devices) { |
330 | pnp_dev = list_entry(pos, struct pnp_dev, protocol_list); | 330 | pnp_dev = list_entry(pos, struct pnp_dev, protocol_list); |
331 | if (dev->number == pnp_dev->number) | 331 | if (dev->number == pnp_dev->number) |
332 | return -1; | 332 | return -1; |
@@ -336,8 +336,8 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) | |||
336 | dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); | 336 | dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
337 | if (!dev_id) | 337 | if (!dev_id) |
338 | return -1; | 338 | return -1; |
339 | pnpid32_to_pnpid(node->eisa_id,id); | 339 | pnpid32_to_pnpid(node->eisa_id, id); |
340 | memcpy(dev_id->id,id,7); | 340 | memcpy(dev_id->id, id, 7); |
341 | pnp_add_id(dev_id, dev); | 341 | pnp_add_id(dev_id, dev); |
342 | pnpbios_parse_data_stream(dev, node); | 342 | pnpbios_parse_data_stream(dev, node); |
343 | dev->active = pnp_is_active(dev); | 343 | dev->active = pnp_is_active(dev); |
@@ -375,35 +375,41 @@ static void __init build_devlist(void) | |||
375 | if (!node) | 375 | if (!node) |
376 | return; | 376 | return; |
377 | 377 | ||
378 | for(nodenum=0; nodenum<0xff; ) { | 378 | for (nodenum = 0; nodenum < 0xff;) { |
379 | u8 thisnodenum = nodenum; | 379 | u8 thisnodenum = nodenum; |
380 | /* eventually we will want to use PNPMODE_STATIC here but for now | 380 | /* eventually we will want to use PNPMODE_STATIC here but for now |
381 | * dynamic will help us catch buggy bioses to add to the blacklist. | 381 | * dynamic will help us catch buggy bioses to add to the blacklist. |
382 | */ | 382 | */ |
383 | if (!pnpbios_dont_use_current_config) { | 383 | if (!pnpbios_dont_use_current_config) { |
384 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) | 384 | if (pnp_bios_get_dev_node |
385 | (&nodenum, (char)PNPMODE_DYNAMIC, node)) | ||
385 | break; | 386 | break; |
386 | } else { | 387 | } else { |
387 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node)) | 388 | if (pnp_bios_get_dev_node |
389 | (&nodenum, (char)PNPMODE_STATIC, node)) | ||
388 | break; | 390 | break; |
389 | } | 391 | } |
390 | nodes_got++; | 392 | nodes_got++; |
391 | dev = kzalloc(sizeof (struct pnp_dev), GFP_KERNEL); | 393 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); |
392 | if (!dev) | 394 | if (!dev) |
393 | break; | 395 | break; |
394 | if(insert_device(dev,node)<0) | 396 | if (insert_device(dev, node) < 0) |
395 | kfree(dev); | 397 | kfree(dev); |
396 | else | 398 | else |
397 | devs++; | 399 | devs++; |
398 | if (nodenum <= thisnodenum) { | 400 | if (nodenum <= thisnodenum) { |
399 | printk(KERN_ERR "PnPBIOS: build_devlist: Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", (unsigned int)nodenum, (unsigned int)thisnodenum); | 401 | printk(KERN_ERR |
402 | "PnPBIOS: build_devlist: Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", | ||
403 | (unsigned int)nodenum, | ||
404 | (unsigned int)thisnodenum); | ||
400 | break; | 405 | break; |
401 | } | 406 | } |
402 | } | 407 | } |
403 | kfree(node); | 408 | kfree(node); |
404 | 409 | ||
405 | printk(KERN_INFO "PnPBIOS: %i node%s reported by PnP BIOS; %i recorded by driver\n", | 410 | printk(KERN_INFO |
406 | nodes_got, nodes_got != 1 ? "s" : "", devs); | 411 | "PnPBIOS: %i node%s reported by PnP BIOS; %i recorded by driver\n", |
412 | nodes_got, nodes_got != 1 ? "s" : "", devs); | ||
407 | } | 413 | } |
408 | 414 | ||
409 | /* | 415 | /* |
@@ -412,8 +418,8 @@ static void __init build_devlist(void) | |||
412 | * | 418 | * |
413 | */ | 419 | */ |
414 | 420 | ||
415 | static int pnpbios_disabled; /* = 0 */ | 421 | static int pnpbios_disabled; /* = 0 */ |
416 | int pnpbios_dont_use_current_config; /* = 0 */ | 422 | int pnpbios_dont_use_current_config; /* = 0 */ |
417 | 423 | ||
418 | #ifndef MODULE | 424 | #ifndef MODULE |
419 | static int __init pnpbios_setup(char *str) | 425 | static int __init pnpbios_setup(char *str) |
@@ -422,9 +428,9 @@ static int __init pnpbios_setup(char *str) | |||
422 | 428 | ||
423 | while ((str != NULL) && (*str != '\0')) { | 429 | while ((str != NULL) && (*str != '\0')) { |
424 | if (strncmp(str, "off", 3) == 0) | 430 | if (strncmp(str, "off", 3) == 0) |
425 | pnpbios_disabled=1; | 431 | pnpbios_disabled = 1; |
426 | if (strncmp(str, "on", 2) == 0) | 432 | if (strncmp(str, "on", 2) == 0) |
427 | pnpbios_disabled=0; | 433 | pnpbios_disabled = 0; |
428 | invert = (strncmp(str, "no-", 3) == 0); | 434 | invert = (strncmp(str, "no-", 3) == 0); |
429 | if (invert) | 435 | if (invert) |
430 | str += 3; | 436 | str += 3; |
@@ -453,35 +459,41 @@ static int __init pnpbios_probe_system(void) | |||
453 | printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n"); | 459 | printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n"); |
454 | 460 | ||
455 | /* | 461 | /* |
456 | * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS | 462 | * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS |
457 | * structure and, if one is found, sets up the selectors and | 463 | * structure and, if one is found, sets up the selectors and |
458 | * entry points | 464 | * entry points |
459 | */ | 465 | */ |
460 | for (check = (union pnp_bios_install_struct *) __va(0xf0000); | 466 | for (check = (union pnp_bios_install_struct *)__va(0xf0000); |
461 | check < (union pnp_bios_install_struct *) __va(0xffff0); | 467 | check < (union pnp_bios_install_struct *)__va(0xffff0); |
462 | check = (void *)check + 16) { | 468 | check = (void *)check + 16) { |
463 | if (check->fields.signature != PNP_SIGNATURE) | 469 | if (check->fields.signature != PNP_SIGNATURE) |
464 | continue; | 470 | continue; |
465 | printk(KERN_INFO "PnPBIOS: Found PnP BIOS installation structure at 0x%p\n", check); | 471 | printk(KERN_INFO |
472 | "PnPBIOS: Found PnP BIOS installation structure at 0x%p\n", | ||
473 | check); | ||
466 | length = check->fields.length; | 474 | length = check->fields.length; |
467 | if (!length) { | 475 | if (!length) { |
468 | printk(KERN_ERR "PnPBIOS: installation structure is invalid, skipping\n"); | 476 | printk(KERN_ERR |
477 | "PnPBIOS: installation structure is invalid, skipping\n"); | ||
469 | continue; | 478 | continue; |
470 | } | 479 | } |
471 | for (sum = 0, i = 0; i < length; i++) | 480 | for (sum = 0, i = 0; i < length; i++) |
472 | sum += check->chars[i]; | 481 | sum += check->chars[i]; |
473 | if (sum) { | 482 | if (sum) { |
474 | printk(KERN_ERR "PnPBIOS: installation structure is corrupted, skipping\n"); | 483 | printk(KERN_ERR |
484 | "PnPBIOS: installation structure is corrupted, skipping\n"); | ||
475 | continue; | 485 | continue; |
476 | } | 486 | } |
477 | if (check->fields.version < 0x10) { | 487 | if (check->fields.version < 0x10) { |
478 | printk(KERN_WARNING "PnPBIOS: PnP BIOS version %d.%d is not supported\n", | 488 | printk(KERN_WARNING |
489 | "PnPBIOS: PnP BIOS version %d.%d is not supported\n", | ||
479 | check->fields.version >> 4, | 490 | check->fields.version >> 4, |
480 | check->fields.version & 15); | 491 | check->fields.version & 15); |
481 | continue; | 492 | continue; |
482 | } | 493 | } |
483 | printk(KERN_INFO "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x\n", | 494 | printk(KERN_INFO |
484 | check->fields.version >> 4, check->fields.version & 15, | 495 | "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x\n", |
496 | check->fields.version >> 4, check->fields.version & 15, | ||
485 | check->fields.pm16cseg, check->fields.pm16offset, | 497 | check->fields.pm16cseg, check->fields.pm16offset, |
486 | check->fields.pm16dseg); | 498 | check->fields.pm16dseg); |
487 | pnp_bios_install = check; | 499 | pnp_bios_install = check; |
@@ -499,25 +511,25 @@ static int __init exploding_pnp_bios(struct dmi_system_id *d) | |||
499 | } | 511 | } |
500 | 512 | ||
501 | static struct dmi_system_id pnpbios_dmi_table[] __initdata = { | 513 | static struct dmi_system_id pnpbios_dmi_table[] __initdata = { |
502 | { /* PnPBIOS GPF on boot */ | 514 | { /* PnPBIOS GPF on boot */ |
503 | .callback = exploding_pnp_bios, | 515 | .callback = exploding_pnp_bios, |
504 | .ident = "Higraded P14H", | 516 | .ident = "Higraded P14H", |
505 | .matches = { | 517 | .matches = { |
506 | DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), | 518 | DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), |
507 | DMI_MATCH(DMI_BIOS_VERSION, "07.00T"), | 519 | DMI_MATCH(DMI_BIOS_VERSION, "07.00T"), |
508 | DMI_MATCH(DMI_SYS_VENDOR, "Higraded"), | 520 | DMI_MATCH(DMI_SYS_VENDOR, "Higraded"), |
509 | DMI_MATCH(DMI_PRODUCT_NAME, "P14H"), | 521 | DMI_MATCH(DMI_PRODUCT_NAME, "P14H"), |
510 | }, | 522 | }, |
511 | }, | 523 | }, |
512 | { /* PnPBIOS GPF on boot */ | 524 | { /* PnPBIOS GPF on boot */ |
513 | .callback = exploding_pnp_bios, | 525 | .callback = exploding_pnp_bios, |
514 | .ident = "ASUS P4P800", | 526 | .ident = "ASUS P4P800", |
515 | .matches = { | 527 | .matches = { |
516 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."), | 528 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."), |
517 | DMI_MATCH(DMI_BOARD_NAME, "P4P800"), | 529 | DMI_MATCH(DMI_BOARD_NAME, "P4P800"), |
518 | }, | 530 | }, |
519 | }, | 531 | }, |
520 | { } | 532 | {} |
521 | }; | 533 | }; |
522 | 534 | ||
523 | static int __init pnpbios_init(void) | 535 | static int __init pnpbios_init(void) |
@@ -533,7 +545,6 @@ static int __init pnpbios_init(void) | |||
533 | printk(KERN_INFO "PnPBIOS: Disabled\n"); | 545 | printk(KERN_INFO "PnPBIOS: Disabled\n"); |
534 | return -ENODEV; | 546 | return -ENODEV; |
535 | } | 547 | } |
536 | |||
537 | #ifdef CONFIG_PNPACPI | 548 | #ifdef CONFIG_PNPACPI |
538 | if (!acpi_disabled && !pnpacpi_disabled) { | 549 | if (!acpi_disabled && !pnpacpi_disabled) { |
539 | pnpbios_disabled = 1; | 550 | pnpbios_disabled = 1; |
@@ -552,14 +563,16 @@ static int __init pnpbios_init(void) | |||
552 | /* read the node info */ | 563 | /* read the node info */ |
553 | ret = pnp_bios_dev_node_info(&node_info); | 564 | ret = pnp_bios_dev_node_info(&node_info); |
554 | if (ret) { | 565 | if (ret) { |
555 | printk(KERN_ERR "PnPBIOS: Unable to get node info. Aborting.\n"); | 566 | printk(KERN_ERR |
567 | "PnPBIOS: Unable to get node info. Aborting.\n"); | ||
556 | return ret; | 568 | return ret; |
557 | } | 569 | } |
558 | 570 | ||
559 | /* register with the pnp layer */ | 571 | /* register with the pnp layer */ |
560 | ret = pnp_register_protocol(&pnpbios_protocol); | 572 | ret = pnp_register_protocol(&pnpbios_protocol); |
561 | if (ret) { | 573 | if (ret) { |
562 | printk(KERN_ERR "PnPBIOS: Unable to register driver. Aborting.\n"); | 574 | printk(KERN_ERR |
575 | "PnPBIOS: Unable to register driver. Aborting.\n"); | ||
563 | return ret; | 576 | return ret; |
564 | } | 577 | } |
565 | 578 | ||
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 | } |
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 3c2ab8394e3f..54c34d4d4f44 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -12,7 +12,9 @@ | |||
12 | #ifdef CONFIG_PCI | 12 | #ifdef CONFIG_PCI |
13 | #include <linux/pci.h> | 13 | #include <linux/pci.h> |
14 | #else | 14 | #else |
15 | inline void pcibios_penalize_isa_irq(int irq, int active) {} | 15 | inline void pcibios_penalize_isa_irq(int irq, int active) |
16 | { | ||
17 | } | ||
16 | #endif /* CONFIG_PCI */ | 18 | #endif /* CONFIG_PCI */ |
17 | 19 | ||
18 | #include "pnpbios.h" | 20 | #include "pnpbios.h" |
@@ -53,74 +55,85 @@ inline void pcibios_penalize_isa_irq(int irq, int active) {} | |||
53 | */ | 55 | */ |
54 | 56 | ||
55 | static void | 57 | static void |
56 | pnpbios_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) | 58 | pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res, int irq) |
57 | { | 59 | { |
58 | int i = 0; | 60 | int i = 0; |
59 | while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_IRQ) i++; | 61 | while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) |
62 | && i < PNP_MAX_IRQ) | ||
63 | i++; | ||
60 | if (i < PNP_MAX_IRQ) { | 64 | if (i < PNP_MAX_IRQ) { |
61 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag | 65 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag |
62 | if (irq == -1) { | 66 | if (irq == -1) { |
63 | res->irq_resource[i].flags |= IORESOURCE_DISABLED; | 67 | res->irq_resource[i].flags |= IORESOURCE_DISABLED; |
64 | return; | 68 | return; |
65 | } | 69 | } |
66 | res->irq_resource[i].start = | 70 | res->irq_resource[i].start = |
67 | res->irq_resource[i].end = (unsigned long) irq; | 71 | res->irq_resource[i].end = (unsigned long)irq; |
68 | pcibios_penalize_isa_irq(irq, 1); | 72 | pcibios_penalize_isa_irq(irq, 1); |
69 | } | 73 | } |
70 | } | 74 | } |
71 | 75 | ||
72 | static void | 76 | static void |
73 | pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) | 77 | pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res, int dma) |
74 | { | 78 | { |
75 | int i = 0; | 79 | int i = 0; |
76 | while (i < PNP_MAX_DMA && | 80 | while (i < PNP_MAX_DMA && |
77 | !(res->dma_resource[i].flags & IORESOURCE_UNSET)) | 81 | !(res->dma_resource[i].flags & IORESOURCE_UNSET)) |
78 | i++; | 82 | i++; |
79 | if (i < PNP_MAX_DMA) { | 83 | if (i < PNP_MAX_DMA) { |
80 | res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag | 84 | res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag |
81 | if (dma == -1) { | 85 | if (dma == -1) { |
82 | res->dma_resource[i].flags |= IORESOURCE_DISABLED; | 86 | res->dma_resource[i].flags |= IORESOURCE_DISABLED; |
83 | return; | 87 | return; |
84 | } | 88 | } |
85 | res->dma_resource[i].start = | 89 | res->dma_resource[i].start = |
86 | res->dma_resource[i].end = (unsigned long) dma; | 90 | res->dma_resource[i].end = (unsigned long)dma; |
87 | } | 91 | } |
88 | } | 92 | } |
89 | 93 | ||
90 | static void | 94 | static void |
91 | pnpbios_parse_allocated_ioresource(struct pnp_resource_table * res, int io, int len) | 95 | pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res, int io, |
96 | int len) | ||
92 | { | 97 | { |
93 | int i = 0; | 98 | int i = 0; |
94 | while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_PORT) i++; | 99 | while (!(res->port_resource[i].flags & IORESOURCE_UNSET) |
100 | && i < PNP_MAX_PORT) | ||
101 | i++; | ||
95 | if (i < PNP_MAX_PORT) { | 102 | if (i < PNP_MAX_PORT) { |
96 | res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag | 103 | res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag |
97 | if (len <= 0 || (io + len -1) >= 0x10003) { | 104 | if (len <= 0 || (io + len - 1) >= 0x10003) { |
98 | res->port_resource[i].flags |= IORESOURCE_DISABLED; | 105 | res->port_resource[i].flags |= IORESOURCE_DISABLED; |
99 | return; | 106 | return; |
100 | } | 107 | } |
101 | res->port_resource[i].start = (unsigned long) io; | 108 | res->port_resource[i].start = (unsigned long)io; |
102 | res->port_resource[i].end = (unsigned long)(io + len - 1); | 109 | res->port_resource[i].end = (unsigned long)(io + len - 1); |
103 | } | 110 | } |
104 | } | 111 | } |
105 | 112 | ||
106 | static void | 113 | static void |
107 | pnpbios_parse_allocated_memresource(struct pnp_resource_table * res, int mem, int len) | 114 | pnpbios_parse_allocated_memresource(struct pnp_resource_table *res, int mem, |
115 | int len) | ||
108 | { | 116 | { |
109 | int i = 0; | 117 | int i = 0; |
110 | while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_MEM) i++; | 118 | while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) |
119 | && i < PNP_MAX_MEM) | ||
120 | i++; | ||
111 | if (i < PNP_MAX_MEM) { | 121 | if (i < PNP_MAX_MEM) { |
112 | res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag | 122 | res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag |
113 | if (len <= 0) { | 123 | if (len <= 0) { |
114 | res->mem_resource[i].flags |= IORESOURCE_DISABLED; | 124 | res->mem_resource[i].flags |= IORESOURCE_DISABLED; |
115 | return; | 125 | return; |
116 | } | 126 | } |
117 | res->mem_resource[i].start = (unsigned long) mem; | 127 | res->mem_resource[i].start = (unsigned long)mem; |
118 | res->mem_resource[i].end = (unsigned long)(mem + len - 1); | 128 | res->mem_resource[i].end = (unsigned long)(mem + len - 1); |
119 | } | 129 | } |
120 | } | 130 | } |
121 | 131 | ||
122 | static unsigned char * | 132 | static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, |
123 | pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) | 133 | unsigned char *end, |
134 | struct | ||
135 | pnp_resource_table | ||
136 | *res) | ||
124 | { | 137 | { |
125 | unsigned int len, tag; | 138 | unsigned int len, tag; |
126 | int io, size, mask, i; | 139 | int io, size, mask, i; |
@@ -134,12 +147,12 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
134 | while ((char *)p < (char *)end) { | 147 | while ((char *)p < (char *)end) { |
135 | 148 | ||
136 | /* determine the type of tag */ | 149 | /* determine the type of tag */ |
137 | if (p[0] & LARGE_TAG) { /* large tag */ | 150 | if (p[0] & LARGE_TAG) { /* large tag */ |
138 | len = (p[2] << 8) | p[1]; | 151 | len = (p[2] << 8) | p[1]; |
139 | tag = p[0]; | 152 | tag = p[0]; |
140 | } else { /* small tag */ | 153 | } else { /* small tag */ |
141 | len = p[0] & 0x07; | 154 | len = p[0] & 0x07; |
142 | tag = ((p[0]>>3) & 0x0f); | 155 | tag = ((p[0] >> 3) & 0x0f); |
143 | } | 156 | } |
144 | 157 | ||
145 | switch (tag) { | 158 | switch (tag) { |
@@ -147,8 +160,8 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
147 | case LARGE_TAG_MEM: | 160 | case LARGE_TAG_MEM: |
148 | if (len != 9) | 161 | if (len != 9) |
149 | goto len_err; | 162 | goto len_err; |
150 | io = *(short *) &p[4]; | 163 | io = *(short *)&p[4]; |
151 | size = *(short *) &p[10]; | 164 | size = *(short *)&p[10]; |
152 | pnpbios_parse_allocated_memresource(res, io, size); | 165 | pnpbios_parse_allocated_memresource(res, io, size); |
153 | break; | 166 | break; |
154 | 167 | ||
@@ -163,16 +176,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
163 | case LARGE_TAG_MEM32: | 176 | case LARGE_TAG_MEM32: |
164 | if (len != 17) | 177 | if (len != 17) |
165 | goto len_err; | 178 | goto len_err; |
166 | io = *(int *) &p[4]; | 179 | io = *(int *)&p[4]; |
167 | size = *(int *) &p[16]; | 180 | size = *(int *)&p[16]; |
168 | pnpbios_parse_allocated_memresource(res, io, size); | 181 | pnpbios_parse_allocated_memresource(res, io, size); |
169 | break; | 182 | break; |
170 | 183 | ||
171 | case LARGE_TAG_FIXEDMEM32: | 184 | case LARGE_TAG_FIXEDMEM32: |
172 | if (len != 9) | 185 | if (len != 9) |
173 | goto len_err; | 186 | goto len_err; |
174 | io = *(int *) &p[4]; | 187 | io = *(int *)&p[4]; |
175 | size = *(int *) &p[8]; | 188 | size = *(int *)&p[8]; |
176 | pnpbios_parse_allocated_memresource(res, io, size); | 189 | pnpbios_parse_allocated_memresource(res, io, size); |
177 | break; | 190 | break; |
178 | 191 | ||
@@ -180,9 +193,10 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
180 | if (len < 2 || len > 3) | 193 | if (len < 2 || len > 3) |
181 | goto len_err; | 194 | goto len_err; |
182 | io = -1; | 195 | io = -1; |
183 | mask= p[1] + p[2]*256; | 196 | mask = p[1] + p[2] * 256; |
184 | for (i=0;i<16;i++, mask=mask>>1) | 197 | for (i = 0; i < 16; i++, mask = mask >> 1) |
185 | if(mask & 0x01) io=i; | 198 | if (mask & 0x01) |
199 | io = i; | ||
186 | pnpbios_parse_allocated_irqresource(res, io); | 200 | pnpbios_parse_allocated_irqresource(res, io); |
187 | break; | 201 | break; |
188 | 202 | ||
@@ -191,15 +205,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
191 | goto len_err; | 205 | goto len_err; |
192 | io = -1; | 206 | io = -1; |
193 | mask = p[1]; | 207 | mask = p[1]; |
194 | for (i=0;i<8;i++, mask = mask>>1) | 208 | for (i = 0; i < 8; i++, mask = mask >> 1) |
195 | if(mask & 0x01) io=i; | 209 | if (mask & 0x01) |
210 | io = i; | ||
196 | pnpbios_parse_allocated_dmaresource(res, io); | 211 | pnpbios_parse_allocated_dmaresource(res, io); |
197 | break; | 212 | break; |
198 | 213 | ||
199 | case SMALL_TAG_PORT: | 214 | case SMALL_TAG_PORT: |
200 | if (len != 7) | 215 | if (len != 7) |
201 | goto len_err; | 216 | goto len_err; |
202 | io = p[2] + p[3] *256; | 217 | io = p[2] + p[3] * 256; |
203 | size = p[7]; | 218 | size = p[7]; |
204 | pnpbios_parse_allocated_ioresource(res, io, size); | 219 | pnpbios_parse_allocated_ioresource(res, io, size); |
205 | break; | 220 | break; |
@@ -218,12 +233,14 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
218 | 233 | ||
219 | case SMALL_TAG_END: | 234 | case SMALL_TAG_END: |
220 | p = p + 2; | 235 | p = p + 2; |
221 | return (unsigned char *)p; | 236 | return (unsigned char *)p; |
222 | break; | 237 | break; |
223 | 238 | ||
224 | default: /* an unkown tag */ | 239 | default: /* an unkown tag */ |
225 | len_err: | 240 | len_err: |
226 | printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); | 241 | printk(KERN_ERR |
242 | "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", | ||
243 | tag, len); | ||
227 | break; | 244 | break; |
228 | } | 245 | } |
229 | 246 | ||
@@ -234,12 +251,12 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
234 | p += len + 1; | 251 | p += len + 1; |
235 | } | 252 | } |
236 | 253 | ||
237 | printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); | 254 | printk(KERN_ERR |
255 | "PnPBIOS: Resource structure does not contain an end tag.\n"); | ||
238 | 256 | ||
239 | return NULL; | 257 | return NULL; |
240 | } | 258 | } |
241 | 259 | ||
242 | |||
243 | /* | 260 | /* |
244 | * Resource Configuration Options | 261 | * Resource Configuration Options |
245 | */ | 262 | */ |
@@ -247,7 +264,7 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st | |||
247 | static void | 264 | static void |
248 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) | 265 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) |
249 | { | 266 | { |
250 | struct pnp_mem * mem; | 267 | struct pnp_mem *mem; |
251 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 268 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
252 | if (!mem) | 269 | if (!mem) |
253 | return; | 270 | return; |
@@ -256,14 +273,15 @@ pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) | |||
256 | mem->align = (p[9] << 8) | p[8]; | 273 | mem->align = (p[9] << 8) | p[8]; |
257 | mem->size = ((p[11] << 8) | p[10]) << 8; | 274 | mem->size = ((p[11] << 8) | p[10]) << 8; |
258 | mem->flags = p[3]; | 275 | mem->flags = p[3]; |
259 | pnp_register_mem_resource(option,mem); | 276 | pnp_register_mem_resource(option, mem); |
260 | return; | 277 | return; |
261 | } | 278 | } |
262 | 279 | ||
263 | static void | 280 | static void |
264 | pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 281 | pnpbios_parse_mem32_option(unsigned char *p, int size, |
282 | struct pnp_option *option) | ||
265 | { | 283 | { |
266 | struct pnp_mem * mem; | 284 | struct pnp_mem *mem; |
267 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 285 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
268 | if (!mem) | 286 | if (!mem) |
269 | return; | 287 | return; |
@@ -272,14 +290,15 @@ pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option | |||
272 | mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; | 290 | mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; |
273 | mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; | 291 | mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; |
274 | mem->flags = p[3]; | 292 | mem->flags = p[3]; |
275 | pnp_register_mem_resource(option,mem); | 293 | pnp_register_mem_resource(option, mem); |
276 | return; | 294 | return; |
277 | } | 295 | } |
278 | 296 | ||
279 | static void | 297 | static void |
280 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 298 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, |
299 | struct pnp_option *option) | ||
281 | { | 300 | { |
282 | struct pnp_mem * mem; | 301 | struct pnp_mem *mem; |
283 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 302 | mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); |
284 | if (!mem) | 303 | if (!mem) |
285 | return; | 304 | return; |
@@ -287,14 +306,14 @@ pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option * | |||
287 | mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; | 306 | mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; |
288 | mem->align = 0; | 307 | mem->align = 0; |
289 | mem->flags = p[3]; | 308 | mem->flags = p[3]; |
290 | pnp_register_mem_resource(option,mem); | 309 | pnp_register_mem_resource(option, mem); |
291 | return; | 310 | return; |
292 | } | 311 | } |
293 | 312 | ||
294 | static void | 313 | static void |
295 | pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) | 314 | pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) |
296 | { | 315 | { |
297 | struct pnp_irq * irq; | 316 | struct pnp_irq *irq; |
298 | unsigned long bits; | 317 | unsigned long bits; |
299 | 318 | ||
300 | irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); | 319 | irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); |
@@ -306,27 +325,27 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) | |||
306 | irq->flags = p[3]; | 325 | irq->flags = p[3]; |
307 | else | 326 | else |
308 | irq->flags = IORESOURCE_IRQ_HIGHEDGE; | 327 | irq->flags = IORESOURCE_IRQ_HIGHEDGE; |
309 | pnp_register_irq_resource(option,irq); | 328 | pnp_register_irq_resource(option, irq); |
310 | return; | 329 | return; |
311 | } | 330 | } |
312 | 331 | ||
313 | static void | 332 | static void |
314 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) | 333 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) |
315 | { | 334 | { |
316 | struct pnp_dma * dma; | 335 | struct pnp_dma *dma; |
317 | dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); | 336 | dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); |
318 | if (!dma) | 337 | if (!dma) |
319 | return; | 338 | return; |
320 | dma->map = p[1]; | 339 | dma->map = p[1]; |
321 | dma->flags = p[2]; | 340 | dma->flags = p[2]; |
322 | pnp_register_dma_resource(option,dma); | 341 | pnp_register_dma_resource(option, dma); |
323 | return; | 342 | return; |
324 | } | 343 | } |
325 | 344 | ||
326 | static void | 345 | static void |
327 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) | 346 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) |
328 | { | 347 | { |
329 | struct pnp_port * port; | 348 | struct pnp_port *port; |
330 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); | 349 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
331 | if (!port) | 350 | if (!port) |
332 | return; | 351 | return; |
@@ -335,14 +354,15 @@ pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) | |||
335 | port->align = p[6]; | 354 | port->align = p[6]; |
336 | port->size = p[7]; | 355 | port->size = p[7]; |
337 | port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; | 356 | port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; |
338 | pnp_register_port_resource(option,port); | 357 | pnp_register_port_resource(option, port); |
339 | return; | 358 | return; |
340 | } | 359 | } |
341 | 360 | ||
342 | static void | 361 | static void |
343 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) | 362 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, |
363 | struct pnp_option *option) | ||
344 | { | 364 | { |
345 | struct pnp_port * port; | 365 | struct pnp_port *port; |
346 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); | 366 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
347 | if (!port) | 367 | if (!port) |
348 | return; | 368 | return; |
@@ -350,12 +370,13 @@ pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *o | |||
350 | port->size = p[3]; | 370 | port->size = p[3]; |
351 | port->align = 0; | 371 | port->align = 0; |
352 | port->flags = PNP_PORT_FLAG_FIXED; | 372 | port->flags = PNP_PORT_FLAG_FIXED; |
353 | pnp_register_port_resource(option,port); | 373 | pnp_register_port_resource(option, port); |
354 | return; | 374 | return; |
355 | } | 375 | } |
356 | 376 | ||
357 | static unsigned char * | 377 | static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p, |
358 | pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struct pnp_dev *dev) | 378 | unsigned char *end, |
379 | struct pnp_dev *dev) | ||
359 | { | 380 | { |
360 | unsigned int len, tag; | 381 | unsigned int len, tag; |
361 | int priority = 0; | 382 | int priority = 0; |
@@ -371,12 +392,12 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc | |||
371 | while ((char *)p < (char *)end) { | 392 | while ((char *)p < (char *)end) { |
372 | 393 | ||
373 | /* determine the type of tag */ | 394 | /* determine the type of tag */ |
374 | if (p[0] & LARGE_TAG) { /* large tag */ | 395 | if (p[0] & LARGE_TAG) { /* large tag */ |
375 | len = (p[2] << 8) | p[1]; | 396 | len = (p[2] << 8) | p[1]; |
376 | tag = p[0]; | 397 | tag = p[0]; |
377 | } else { /* small tag */ | 398 | } else { /* small tag */ |
378 | len = p[0] & 0x07; | 399 | len = p[0] & 0x07; |
379 | tag = ((p[0]>>3) & 0x0f); | 400 | tag = ((p[0] >> 3) & 0x0f); |
380 | } | 401 | } |
381 | 402 | ||
382 | switch (tag) { | 403 | switch (tag) { |
@@ -442,16 +463,19 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc | |||
442 | if (len != 0) | 463 | if (len != 0) |
443 | goto len_err; | 464 | goto len_err; |
444 | if (option_independent == option) | 465 | if (option_independent == option) |
445 | printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n"); | 466 | printk(KERN_WARNING |
467 | "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n"); | ||
446 | option = option_independent; | 468 | option = option_independent; |
447 | break; | 469 | break; |
448 | 470 | ||
449 | case SMALL_TAG_END: | 471 | case SMALL_TAG_END: |
450 | return p + 2; | 472 | return p + 2; |
451 | 473 | ||
452 | default: /* an unkown tag */ | 474 | default: /* an unkown tag */ |
453 | len_err: | 475 | len_err: |
454 | printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); | 476 | printk(KERN_ERR |
477 | "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", | ||
478 | tag, len); | ||
455 | break; | 479 | break; |
456 | } | 480 | } |
457 | 481 | ||
@@ -462,12 +486,12 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc | |||
462 | p += len + 1; | 486 | p += len + 1; |
463 | } | 487 | } |
464 | 488 | ||
465 | printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); | 489 | printk(KERN_ERR |
490 | "PnPBIOS: Resource structure does not contain an end tag.\n"); | ||
466 | 491 | ||
467 | return NULL; | 492 | return NULL; |
468 | } | 493 | } |
469 | 494 | ||
470 | |||
471 | /* | 495 | /* |
472 | * Compatible Device IDs | 496 | * Compatible Device IDs |
473 | */ | 497 | */ |
@@ -483,7 +507,7 @@ void pnpid32_to_pnpid(u32 id, char *str) | |||
483 | id = be32_to_cpu(id); | 507 | id = be32_to_cpu(id); |
484 | str[0] = CHAR(id, 26); | 508 | str[0] = CHAR(id, 26); |
485 | str[1] = CHAR(id, 21); | 509 | str[1] = CHAR(id, 21); |
486 | str[2] = CHAR(id,16); | 510 | str[2] = CHAR(id, 16); |
487 | str[3] = HEX(id, 12); | 511 | str[3] = HEX(id, 12); |
488 | str[4] = HEX(id, 8); | 512 | str[4] = HEX(id, 8); |
489 | str[5] = HEX(id, 4); | 513 | str[5] = HEX(id, 4); |
@@ -492,12 +516,14 @@ void pnpid32_to_pnpid(u32 id, char *str) | |||
492 | 516 | ||
493 | return; | 517 | return; |
494 | } | 518 | } |
519 | |||
495 | // | 520 | // |
496 | #undef CHAR | 521 | #undef CHAR |
497 | #undef HEX | 522 | #undef HEX |
498 | 523 | ||
499 | static unsigned char * | 524 | static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p, |
500 | pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_dev *dev) | 525 | unsigned char *end, |
526 | struct pnp_dev *dev) | ||
501 | { | 527 | { |
502 | int len, tag; | 528 | int len, tag; |
503 | char id[8]; | 529 | char id[8]; |
@@ -509,40 +535,45 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de | |||
509 | while ((char *)p < (char *)end) { | 535 | while ((char *)p < (char *)end) { |
510 | 536 | ||
511 | /* determine the type of tag */ | 537 | /* determine the type of tag */ |
512 | if (p[0] & LARGE_TAG) { /* large tag */ | 538 | if (p[0] & LARGE_TAG) { /* large tag */ |
513 | len = (p[2] << 8) | p[1]; | 539 | len = (p[2] << 8) | p[1]; |
514 | tag = p[0]; | 540 | tag = p[0]; |
515 | } else { /* small tag */ | 541 | } else { /* small tag */ |
516 | len = p[0] & 0x07; | 542 | len = p[0] & 0x07; |
517 | tag = ((p[0]>>3) & 0x0f); | 543 | tag = ((p[0] >> 3) & 0x0f); |
518 | } | 544 | } |
519 | 545 | ||
520 | switch (tag) { | 546 | switch (tag) { |
521 | 547 | ||
522 | case LARGE_TAG_ANSISTR: | 548 | case LARGE_TAG_ANSISTR: |
523 | strncpy(dev->name, p + 3, len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len); | 549 | strncpy(dev->name, p + 3, |
524 | dev->name[len >= PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0'; | 550 | len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len); |
551 | dev->name[len >= | ||
552 | PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0'; | ||
525 | break; | 553 | break; |
526 | 554 | ||
527 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ | 555 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ |
528 | if (len != 4) | 556 | if (len != 4) |
529 | goto len_err; | 557 | goto len_err; |
530 | dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL); | 558 | dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); |
531 | if (!dev_id) | 559 | if (!dev_id) |
532 | return NULL; | 560 | return NULL; |
533 | pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,id); | 561 | pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << |
562 | 24, id); | ||
534 | memcpy(&dev_id->id, id, 7); | 563 | memcpy(&dev_id->id, id, 7); |
535 | pnp_add_id(dev_id, dev); | 564 | pnp_add_id(dev_id, dev); |
536 | break; | 565 | break; |
537 | 566 | ||
538 | case SMALL_TAG_END: | 567 | case SMALL_TAG_END: |
539 | p = p + 2; | 568 | p = p + 2; |
540 | return (unsigned char *)p; | 569 | return (unsigned char *)p; |
541 | break; | 570 | break; |
542 | 571 | ||
543 | default: /* an unkown tag */ | 572 | default: /* an unkown tag */ |
544 | len_err: | 573 | len_err: |
545 | printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); | 574 | printk(KERN_ERR |
575 | "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", | ||
576 | tag, len); | ||
546 | break; | 577 | break; |
547 | } | 578 | } |
548 | 579 | ||
@@ -553,17 +584,17 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de | |||
553 | p += len + 1; | 584 | p += len + 1; |
554 | } | 585 | } |
555 | 586 | ||
556 | printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); | 587 | printk(KERN_ERR |
588 | "PnPBIOS: Resource structure does not contain an end tag.\n"); | ||
557 | 589 | ||
558 | return NULL; | 590 | return NULL; |
559 | } | 591 | } |
560 | 592 | ||
561 | |||
562 | /* | 593 | /* |
563 | * Allocated Resource Encoding | 594 | * Allocated Resource Encoding |
564 | */ | 595 | */ |
565 | 596 | ||
566 | static void pnpbios_encode_mem(unsigned char *p, struct resource * res) | 597 | static void pnpbios_encode_mem(unsigned char *p, struct resource *res) |
567 | { | 598 | { |
568 | unsigned long base = res->start; | 599 | unsigned long base = res->start; |
569 | unsigned long len = res->end - res->start + 1; | 600 | unsigned long len = res->end - res->start + 1; |
@@ -576,7 +607,7 @@ static void pnpbios_encode_mem(unsigned char *p, struct resource * res) | |||
576 | return; | 607 | return; |
577 | } | 608 | } |
578 | 609 | ||
579 | static void pnpbios_encode_mem32(unsigned char *p, struct resource * res) | 610 | static void pnpbios_encode_mem32(unsigned char *p, struct resource *res) |
580 | { | 611 | { |
581 | unsigned long base = res->start; | 612 | unsigned long base = res->start; |
582 | unsigned long len = res->end - res->start + 1; | 613 | unsigned long len = res->end - res->start + 1; |
@@ -595,8 +626,9 @@ static void pnpbios_encode_mem32(unsigned char *p, struct resource * res) | |||
595 | return; | 626 | return; |
596 | } | 627 | } |
597 | 628 | ||
598 | static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res) | 629 | static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res) |
599 | { unsigned long base = res->start; | 630 | { |
631 | unsigned long base = res->start; | ||
600 | unsigned long len = res->end - res->start + 1; | 632 | unsigned long len = res->end - res->start + 1; |
601 | p[4] = base & 0xff; | 633 | p[4] = base & 0xff; |
602 | p[5] = (base >> 8) & 0xff; | 634 | p[5] = (base >> 8) & 0xff; |
@@ -609,7 +641,7 @@ static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res) | |||
609 | return; | 641 | return; |
610 | } | 642 | } |
611 | 643 | ||
612 | static void pnpbios_encode_irq(unsigned char *p, struct resource * res) | 644 | static void pnpbios_encode_irq(unsigned char *p, struct resource *res) |
613 | { | 645 | { |
614 | unsigned long map = 0; | 646 | unsigned long map = 0; |
615 | map = 1 << res->start; | 647 | map = 1 << res->start; |
@@ -618,7 +650,7 @@ static void pnpbios_encode_irq(unsigned char *p, struct resource * res) | |||
618 | return; | 650 | return; |
619 | } | 651 | } |
620 | 652 | ||
621 | static void pnpbios_encode_dma(unsigned char *p, struct resource * res) | 653 | static void pnpbios_encode_dma(unsigned char *p, struct resource *res) |
622 | { | 654 | { |
623 | unsigned long map = 0; | 655 | unsigned long map = 0; |
624 | map = 1 << res->start; | 656 | map = 1 << res->start; |
@@ -626,7 +658,7 @@ static void pnpbios_encode_dma(unsigned char *p, struct resource * res) | |||
626 | return; | 658 | return; |
627 | } | 659 | } |
628 | 660 | ||
629 | static void pnpbios_encode_port(unsigned char *p, struct resource * res) | 661 | static void pnpbios_encode_port(unsigned char *p, struct resource *res) |
630 | { | 662 | { |
631 | unsigned long base = res->start; | 663 | unsigned long base = res->start; |
632 | unsigned long len = res->end - res->start + 1; | 664 | unsigned long len = res->end - res->start + 1; |
@@ -638,7 +670,7 @@ static void pnpbios_encode_port(unsigned char *p, struct resource * res) | |||
638 | return; | 670 | return; |
639 | } | 671 | } |
640 | 672 | ||
641 | static void pnpbios_encode_fixed_port(unsigned char *p, struct resource * res) | 673 | static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res) |
642 | { | 674 | { |
643 | unsigned long base = res->start; | 675 | unsigned long base = res->start; |
644 | unsigned long len = res->end - res->start + 1; | 676 | unsigned long len = res->end - res->start + 1; |
@@ -648,8 +680,11 @@ static void pnpbios_encode_fixed_port(unsigned char *p, struct resource * res) | |||
648 | return; | 680 | return; |
649 | } | 681 | } |
650 | 682 | ||
651 | static unsigned char * | 683 | static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p, |
652 | pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) | 684 | unsigned char *end, |
685 | struct | ||
686 | pnp_resource_table | ||
687 | *res) | ||
653 | { | 688 | { |
654 | unsigned int len, tag; | 689 | unsigned int len, tag; |
655 | int port = 0, irq = 0, dma = 0, mem = 0; | 690 | int port = 0, irq = 0, dma = 0, mem = 0; |
@@ -660,12 +695,12 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s | |||
660 | while ((char *)p < (char *)end) { | 695 | while ((char *)p < (char *)end) { |
661 | 696 | ||
662 | /* determine the type of tag */ | 697 | /* determine the type of tag */ |
663 | if (p[0] & LARGE_TAG) { /* large tag */ | 698 | if (p[0] & LARGE_TAG) { /* large tag */ |
664 | len = (p[2] << 8) | p[1]; | 699 | len = (p[2] << 8) | p[1]; |
665 | tag = p[0]; | 700 | tag = p[0]; |
666 | } else { /* small tag */ | 701 | } else { /* small tag */ |
667 | len = p[0] & 0x07; | 702 | len = p[0] & 0x07; |
668 | tag = ((p[0]>>3) & 0x0f); | 703 | tag = ((p[0] >> 3) & 0x0f); |
669 | } | 704 | } |
670 | 705 | ||
671 | switch (tag) { | 706 | switch (tag) { |
@@ -725,12 +760,14 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s | |||
725 | 760 | ||
726 | case SMALL_TAG_END: | 761 | case SMALL_TAG_END: |
727 | p = p + 2; | 762 | p = p + 2; |
728 | return (unsigned char *)p; | 763 | return (unsigned char *)p; |
729 | break; | 764 | break; |
730 | 765 | ||
731 | default: /* an unkown tag */ | 766 | default: /* an unkown tag */ |
732 | len_err: | 767 | len_err: |
733 | printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); | 768 | printk(KERN_ERR |
769 | "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", | ||
770 | tag, len); | ||
734 | break; | 771 | break; |
735 | } | 772 | } |
736 | 773 | ||
@@ -741,28 +778,27 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s | |||
741 | p += len + 1; | 778 | p += len + 1; |
742 | } | 779 | } |
743 | 780 | ||
744 | printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); | 781 | printk(KERN_ERR |
782 | "PnPBIOS: Resource structure does not contain an end tag.\n"); | ||
745 | 783 | ||
746 | return NULL; | 784 | return NULL; |
747 | } | 785 | } |
748 | 786 | ||
749 | |||
750 | /* | 787 | /* |
751 | * Core Parsing Functions | 788 | * Core Parsing Functions |
752 | */ | 789 | */ |
753 | 790 | ||
754 | int | 791 | int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node) |
755 | pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node) | ||
756 | { | 792 | { |
757 | unsigned char * p = (char *)node->data; | 793 | unsigned char *p = (char *)node->data; |
758 | unsigned char * end = (char *)(node->data + node->size); | 794 | unsigned char *end = (char *)(node->data + node->size); |
759 | p = pnpbios_parse_allocated_resource_data(p,end,&dev->res); | 795 | p = pnpbios_parse_allocated_resource_data(p, end, &dev->res); |
760 | if (!p) | 796 | if (!p) |
761 | return -EIO; | 797 | return -EIO; |
762 | p = pnpbios_parse_resource_option_data(p,end,dev); | 798 | p = pnpbios_parse_resource_option_data(p, end, dev); |
763 | if (!p) | 799 | if (!p) |
764 | return -EIO; | 800 | return -EIO; |
765 | p = pnpbios_parse_compatible_ids(p,end,dev); | 801 | p = pnpbios_parse_compatible_ids(p, end, dev); |
766 | if (!p) | 802 | if (!p) |
767 | return -EIO; | 803 | return -EIO; |
768 | return 0; | 804 | return 0; |
@@ -770,11 +806,11 @@ pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node) | |||
770 | 806 | ||
771 | int | 807 | int |
772 | pnpbios_read_resources_from_node(struct pnp_resource_table *res, | 808 | pnpbios_read_resources_from_node(struct pnp_resource_table *res, |
773 | struct pnp_bios_node * node) | 809 | struct pnp_bios_node *node) |
774 | { | 810 | { |
775 | unsigned char * p = (char *)node->data; | 811 | unsigned char *p = (char *)node->data; |
776 | unsigned char * end = (char *)(node->data + node->size); | 812 | unsigned char *end = (char *)(node->data + node->size); |
777 | p = pnpbios_parse_allocated_resource_data(p,end,res); | 813 | p = pnpbios_parse_allocated_resource_data(p, end, res); |
778 | if (!p) | 814 | if (!p) |
779 | return -EIO; | 815 | return -EIO; |
780 | return 0; | 816 | return 0; |
@@ -782,11 +818,11 @@ pnpbios_read_resources_from_node(struct pnp_resource_table *res, | |||
782 | 818 | ||
783 | int | 819 | int |
784 | pnpbios_write_resources_to_node(struct pnp_resource_table *res, | 820 | pnpbios_write_resources_to_node(struct pnp_resource_table *res, |
785 | struct pnp_bios_node * node) | 821 | struct pnp_bios_node *node) |
786 | { | 822 | { |
787 | unsigned char * p = (char *)node->data; | 823 | unsigned char *p = (char *)node->data; |
788 | unsigned char * end = (char *)(node->data + node->size); | 824 | unsigned char *end = (char *)(node->data + node->size); |
789 | p = pnpbios_encode_allocated_resource_data(p,end,res); | 825 | p = pnpbios_encode_allocated_resource_data(p, end, res); |
790 | if (!p) | 826 | if (!p) |
791 | return -EIO; | 827 | return -EIO; |
792 | return 0; | 828 | return 0; |
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c index 7c3236690cc3..8e7d7738f296 100644 --- a/drivers/pnp/quirks.c +++ b/drivers/pnp/quirks.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include "base.h" | 20 | #include "base.h" |
21 | 21 | ||
22 | |||
23 | static void quirk_awe32_resources(struct pnp_dev *dev) | 22 | static void quirk_awe32_resources(struct pnp_dev *dev) |
24 | { | 23 | { |
25 | struct pnp_port *port, *port2, *port3; | 24 | struct pnp_port *port, *port2, *port3; |
@@ -31,7 +30,7 @@ static void quirk_awe32_resources(struct pnp_dev *dev) | |||
31 | * two extra ports (at offset 0x400 and 0x800 from the one given) by | 30 | * two extra ports (at offset 0x400 and 0x800 from the one given) by |
32 | * hand. | 31 | * hand. |
33 | */ | 32 | */ |
34 | for ( ; res ; res = res->next ) { | 33 | for (; res; res = res->next) { |
35 | port2 = pnp_alloc(sizeof(struct pnp_port)); | 34 | port2 = pnp_alloc(sizeof(struct pnp_port)); |
36 | if (!port2) | 35 | if (!port2) |
37 | return; | 36 | return; |
@@ -58,18 +57,19 @@ static void quirk_cmi8330_resources(struct pnp_dev *dev) | |||
58 | struct pnp_option *res = dev->dependent; | 57 | struct pnp_option *res = dev->dependent; |
59 | unsigned long tmp; | 58 | unsigned long tmp; |
60 | 59 | ||
61 | for ( ; res ; res = res->next ) { | 60 | for (; res; res = res->next) { |
62 | 61 | ||
63 | struct pnp_irq *irq; | 62 | struct pnp_irq *irq; |
64 | struct pnp_dma *dma; | 63 | struct pnp_dma *dma; |
65 | 64 | ||
66 | for( irq = res->irq; irq; irq = irq->next ) { // Valid irqs are 5, 7, 10 | 65 | for (irq = res->irq; irq; irq = irq->next) { // Valid irqs are 5, 7, 10 |
67 | tmp = 0x04A0; | 66 | tmp = 0x04A0; |
68 | bitmap_copy(irq->map, &tmp, 16); // 0000 0100 1010 0000 | 67 | bitmap_copy(irq->map, &tmp, 16); // 0000 0100 1010 0000 |
69 | } | 68 | } |
70 | 69 | ||
71 | for( dma = res->dma; dma; dma = dma->next ) // Valid 8bit dma channels are 1,3 | 70 | for (dma = res->dma; dma; dma = dma->next) // Valid 8bit dma channels are 1,3 |
72 | if( ( dma->flags & IORESOURCE_DMA_TYPE_MASK ) == IORESOURCE_DMA_8BIT ) | 71 | if ((dma->flags & IORESOURCE_DMA_TYPE_MASK) == |
72 | IORESOURCE_DMA_8BIT) | ||
73 | dma->map = 0x000A; | 73 | dma->map = 0x000A; |
74 | } | 74 | } |
75 | printk(KERN_INFO "pnp: CMI8330 quirk - fixing interrupts and dma\n"); | 75 | printk(KERN_INFO "pnp: CMI8330 quirk - fixing interrupts and dma\n"); |
@@ -79,7 +79,7 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev) | |||
79 | { | 79 | { |
80 | struct pnp_port *port; | 80 | struct pnp_port *port; |
81 | struct pnp_option *res = dev->dependent; | 81 | struct pnp_option *res = dev->dependent; |
82 | int changed = 0; | 82 | int changed = 0; |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * The default range on the mpu port for these devices is 0x388-0x388. | 85 | * The default range on the mpu port for these devices is 0x388-0x388. |
@@ -87,23 +87,24 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev) | |||
87 | * auto-configured. | 87 | * auto-configured. |
88 | */ | 88 | */ |
89 | 89 | ||
90 | for( ; res ; res = res->next ) { | 90 | for (; res; res = res->next) { |
91 | port = res->port; | 91 | port = res->port; |
92 | if(!port) | 92 | if (!port) |
93 | continue; | 93 | continue; |
94 | port = port->next; | 94 | port = port->next; |
95 | if(!port) | 95 | if (!port) |
96 | continue; | 96 | continue; |
97 | port = port->next; | 97 | port = port->next; |
98 | if(!port) | 98 | if (!port) |
99 | continue; | 99 | continue; |
100 | if(port->min != port->max) | 100 | if (port->min != port->max) |
101 | continue; | 101 | continue; |
102 | port->max += 0x70; | 102 | port->max += 0x70; |
103 | changed = 1; | 103 | changed = 1; |
104 | } | 104 | } |
105 | if(changed) | 105 | if (changed) |
106 | printk(KERN_INFO "pnp: SB audio device quirk - increasing port range\n"); | 106 | printk(KERN_INFO |
107 | "pnp: SB audio device quirk - increasing port range\n"); | ||
107 | return; | 108 | return; |
108 | } | 109 | } |
109 | 110 | ||
@@ -124,7 +125,7 @@ static int quirk_smc_fir_enabled(struct pnp_dev *dev) | |||
124 | outb(bank, firbase + 7); | 125 | outb(bank, firbase + 7); |
125 | 126 | ||
126 | high = inb(firbase + 0); | 127 | high = inb(firbase + 0); |
127 | low = inb(firbase + 1); | 128 | low = inb(firbase + 1); |
128 | chip = inb(firbase + 2); | 129 | chip = inb(firbase + 2); |
129 | 130 | ||
130 | /* This corresponds to the check in smsc_ircc_present() */ | 131 | /* This corresponds to the check in smsc_ircc_present() */ |
@@ -153,8 +154,8 @@ static void quirk_smc_enable(struct pnp_dev *dev) | |||
153 | */ | 154 | */ |
154 | dev_err(&dev->dev, "%s not responding at SIR 0x%lx, FIR 0x%lx; " | 155 | dev_err(&dev->dev, "%s not responding at SIR 0x%lx, FIR 0x%lx; " |
155 | "auto-configuring\n", dev->id->id, | 156 | "auto-configuring\n", dev->id->id, |
156 | (unsigned long) pnp_port_start(dev, 0), | 157 | (unsigned long)pnp_port_start(dev, 0), |
157 | (unsigned long) pnp_port_start(dev, 1)); | 158 | (unsigned long)pnp_port_start(dev, 1)); |
158 | 159 | ||
159 | pnp_disable_dev(dev); | 160 | pnp_disable_dev(dev); |
160 | pnp_init_resource_table(&dev->res); | 161 | pnp_init_resource_table(&dev->res); |
@@ -162,8 +163,8 @@ static void quirk_smc_enable(struct pnp_dev *dev) | |||
162 | pnp_activate_dev(dev); | 163 | pnp_activate_dev(dev); |
163 | if (quirk_smc_fir_enabled(dev)) { | 164 | if (quirk_smc_fir_enabled(dev)) { |
164 | dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n", | 165 | dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n", |
165 | (unsigned long) pnp_port_start(dev, 0), | 166 | (unsigned long)pnp_port_start(dev, 0), |
166 | (unsigned long) pnp_port_start(dev, 1)); | 167 | (unsigned long)pnp_port_start(dev, 1)); |
167 | return; | 168 | return; |
168 | } | 169 | } |
169 | 170 | ||
@@ -175,8 +176,8 @@ static void quirk_smc_enable(struct pnp_dev *dev) | |||
175 | */ | 176 | */ |
176 | dev_err(&dev->dev, "not responding at SIR 0x%lx, FIR 0x%lx; " | 177 | dev_err(&dev->dev, "not responding at SIR 0x%lx, FIR 0x%lx; " |
177 | "swapping SIR/FIR and reconfiguring\n", | 178 | "swapping SIR/FIR and reconfiguring\n", |
178 | (unsigned long) pnp_port_start(dev, 0), | 179 | (unsigned long)pnp_port_start(dev, 0), |
179 | (unsigned long) pnp_port_start(dev, 1)); | 180 | (unsigned long)pnp_port_start(dev, 1)); |
180 | 181 | ||
181 | /* | 182 | /* |
182 | * Clear IORESOURCE_AUTO so pnp_activate_dev() doesn't reassign | 183 | * Clear IORESOURCE_AUTO so pnp_activate_dev() doesn't reassign |
@@ -200,8 +201,8 @@ static void quirk_smc_enable(struct pnp_dev *dev) | |||
200 | 201 | ||
201 | if (quirk_smc_fir_enabled(dev)) { | 202 | if (quirk_smc_fir_enabled(dev)) { |
202 | dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n", | 203 | dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n", |
203 | (unsigned long) pnp_port_start(dev, 0), | 204 | (unsigned long)pnp_port_start(dev, 0), |
204 | (unsigned long) pnp_port_start(dev, 1)); | 205 | (unsigned long)pnp_port_start(dev, 1)); |
205 | return; | 206 | return; |
206 | } | 207 | } |
207 | 208 | ||
@@ -209,7 +210,6 @@ static void quirk_smc_enable(struct pnp_dev *dev) | |||
209 | "email bjorn.helgaas@hp.com\n"); | 210 | "email bjorn.helgaas@hp.com\n"); |
210 | } | 211 | } |
211 | 212 | ||
212 | |||
213 | /* | 213 | /* |
214 | * PnP Quirks | 214 | * PnP Quirks |
215 | * Cards or devices that need some tweaking due to incomplete resource info | 215 | * Cards or devices that need some tweaking due to incomplete resource info |
@@ -217,21 +217,21 @@ static void quirk_smc_enable(struct pnp_dev *dev) | |||
217 | 217 | ||
218 | static struct pnp_fixup pnp_fixups[] = { | 218 | static struct pnp_fixup pnp_fixups[] = { |
219 | /* Soundblaster awe io port quirk */ | 219 | /* Soundblaster awe io port quirk */ |
220 | { "CTL0021", quirk_awe32_resources }, | 220 | {"CTL0021", quirk_awe32_resources}, |
221 | { "CTL0022", quirk_awe32_resources }, | 221 | {"CTL0022", quirk_awe32_resources}, |
222 | { "CTL0023", quirk_awe32_resources }, | 222 | {"CTL0023", quirk_awe32_resources}, |
223 | /* CMI 8330 interrupt and dma fix */ | 223 | /* CMI 8330 interrupt and dma fix */ |
224 | { "@X@0001", quirk_cmi8330_resources }, | 224 | {"@X@0001", quirk_cmi8330_resources}, |
225 | /* Soundblaster audio device io port range quirk */ | 225 | /* Soundblaster audio device io port range quirk */ |
226 | { "CTL0001", quirk_sb16audio_resources }, | 226 | {"CTL0001", quirk_sb16audio_resources}, |
227 | { "CTL0031", quirk_sb16audio_resources }, | 227 | {"CTL0031", quirk_sb16audio_resources}, |
228 | { "CTL0041", quirk_sb16audio_resources }, | 228 | {"CTL0041", quirk_sb16audio_resources}, |
229 | { "CTL0042", quirk_sb16audio_resources }, | 229 | {"CTL0042", quirk_sb16audio_resources}, |
230 | { "CTL0043", quirk_sb16audio_resources }, | 230 | {"CTL0043", quirk_sb16audio_resources}, |
231 | { "CTL0044", quirk_sb16audio_resources }, | 231 | {"CTL0044", quirk_sb16audio_resources}, |
232 | { "CTL0045", quirk_sb16audio_resources }, | 232 | {"CTL0045", quirk_sb16audio_resources}, |
233 | { "SMCf010", quirk_smc_enable }, | 233 | {"SMCf010", quirk_smc_enable}, |
234 | { "" } | 234 | {""} |
235 | }; | 235 | }; |
236 | 236 | ||
237 | void pnp_fixup_device(struct pnp_dev *dev) | 237 | void pnp_fixup_device(struct pnp_dev *dev) |
@@ -239,9 +239,8 @@ void pnp_fixup_device(struct pnp_dev *dev) | |||
239 | int i = 0; | 239 | int i = 0; |
240 | 240 | ||
241 | while (*pnp_fixups[i].id) { | 241 | while (*pnp_fixups[i].id) { |
242 | if (compare_pnp_id(dev->id,pnp_fixups[i].id)) { | 242 | if (compare_pnp_id(dev->id, pnp_fixups[i].id)) { |
243 | pnp_dbg("Calling quirk for %s", | 243 | pnp_dbg("Calling quirk for %s", dev->dev.bus_id); |
244 | dev->dev.bus_id); | ||
245 | pnp_fixups[i].quirk_function(dev); | 244 | pnp_fixups[i].quirk_function(dev); |
246 | } | 245 | } |
247 | i++; | 246 | i++; |
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index a685fbec4604..635b11a0cf82 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c | |||
@@ -20,17 +20,16 @@ | |||
20 | #include <linux/pnp.h> | 20 | #include <linux/pnp.h> |
21 | #include "base.h" | 21 | #include "base.h" |
22 | 22 | ||
23 | static int pnp_reserve_irq[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some IRQ */ | 23 | static int pnp_reserve_irq[16] = {[0...15] = -1 }; /* reserve (don't use) some IRQ */ |
24 | static int pnp_reserve_dma[8] = { [0 ... 7] = -1 }; /* reserve (don't use) some DMA */ | 24 | static int pnp_reserve_dma[8] = {[0...7] = -1 }; /* reserve (don't use) some DMA */ |
25 | static int pnp_reserve_io[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some I/O region */ | 25 | static int pnp_reserve_io[16] = {[0...15] = -1 }; /* reserve (don't use) some I/O region */ |
26 | static int pnp_reserve_mem[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some memory region */ | 26 | static int pnp_reserve_mem[16] = {[0...15] = -1 }; /* reserve (don't use) some memory region */ |
27 | |||
28 | 27 | ||
29 | /* | 28 | /* |
30 | * option registration | 29 | * option registration |
31 | */ | 30 | */ |
32 | 31 | ||
33 | static struct pnp_option * pnp_build_option(int priority) | 32 | static struct pnp_option *pnp_build_option(int priority) |
34 | { | 33 | { |
35 | struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option)); | 34 | struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option)); |
36 | 35 | ||
@@ -46,7 +45,7 @@ static struct pnp_option * pnp_build_option(int priority) | |||
46 | return option; | 45 | return option; |
47 | } | 46 | } |
48 | 47 | ||
49 | struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) | 48 | struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) |
50 | { | 49 | { |
51 | struct pnp_option *option; | 50 | struct pnp_option *option; |
52 | if (!dev) | 51 | if (!dev) |
@@ -61,7 +60,8 @@ struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) | |||
61 | return option; | 60 | return option; |
62 | } | 61 | } |
63 | 62 | ||
64 | struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority) | 63 | struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, |
64 | int priority) | ||
65 | { | 65 | { |
66 | struct pnp_option *option; | 66 | struct pnp_option *option; |
67 | if (!dev) | 67 | if (!dev) |
@@ -222,7 +222,6 @@ void pnp_free_option(struct pnp_option *option) | |||
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | |||
226 | /* | 225 | /* |
227 | * resource validity checking | 226 | * resource validity checking |
228 | */ | 227 | */ |
@@ -236,7 +235,7 @@ void pnp_free_option(struct pnp_option *option) | |||
236 | #define cannot_compare(flags) \ | 235 | #define cannot_compare(flags) \ |
237 | ((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED)) | 236 | ((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED)) |
238 | 237 | ||
239 | int pnp_check_port(struct pnp_dev * dev, int idx) | 238 | int pnp_check_port(struct pnp_dev *dev, int idx) |
240 | { | 239 | { |
241 | int tmp; | 240 | int tmp; |
242 | struct pnp_dev *tdev; | 241 | struct pnp_dev *tdev; |
@@ -250,8 +249,8 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
250 | 249 | ||
251 | /* check if the resource is already in use, skip if the | 250 | /* check if the resource is already in use, skip if the |
252 | * device is active because it itself may be in use */ | 251 | * device is active because it itself may be in use */ |
253 | if(!dev->active) { | 252 | if (!dev->active) { |
254 | if (__check_region(&ioport_resource, *port, length(port,end))) | 253 | if (__check_region(&ioport_resource, *port, length(port, end))) |
255 | return 0; | 254 | return 0; |
256 | } | 255 | } |
257 | 256 | ||
@@ -259,7 +258,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
259 | for (tmp = 0; tmp < 8; tmp++) { | 258 | for (tmp = 0; tmp < 8; tmp++) { |
260 | int rport = pnp_reserve_io[tmp << 1]; | 259 | int rport = pnp_reserve_io[tmp << 1]; |
261 | int rend = pnp_reserve_io[(tmp << 1) + 1] + rport - 1; | 260 | int rend = pnp_reserve_io[(tmp << 1) + 1] + rport - 1; |
262 | if (ranged_conflict(port,end,&rport,&rend)) | 261 | if (ranged_conflict(port, end, &rport, &rend)) |
263 | return 0; | 262 | return 0; |
264 | } | 263 | } |
265 | 264 | ||
@@ -268,7 +267,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
268 | if (dev->res.port_resource[tmp].flags & IORESOURCE_IO) { | 267 | if (dev->res.port_resource[tmp].flags & IORESOURCE_IO) { |
269 | tport = &dev->res.port_resource[tmp].start; | 268 | tport = &dev->res.port_resource[tmp].start; |
270 | tend = &dev->res.port_resource[tmp].end; | 269 | tend = &dev->res.port_resource[tmp].end; |
271 | if (ranged_conflict(port,end,tport,tend)) | 270 | if (ranged_conflict(port, end, tport, tend)) |
272 | return 0; | 271 | return 0; |
273 | } | 272 | } |
274 | } | 273 | } |
@@ -279,11 +278,12 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
279 | continue; | 278 | continue; |
280 | for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) { | 279 | for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) { |
281 | if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) { | 280 | if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) { |
282 | if (cannot_compare(tdev->res.port_resource[tmp].flags)) | 281 | if (cannot_compare |
282 | (tdev->res.port_resource[tmp].flags)) | ||
283 | continue; | 283 | continue; |
284 | tport = &tdev->res.port_resource[tmp].start; | 284 | tport = &tdev->res.port_resource[tmp].start; |
285 | tend = &tdev->res.port_resource[tmp].end; | 285 | tend = &tdev->res.port_resource[tmp].end; |
286 | if (ranged_conflict(port,end,tport,tend)) | 286 | if (ranged_conflict(port, end, tport, tend)) |
287 | return 0; | 287 | return 0; |
288 | } | 288 | } |
289 | } | 289 | } |
@@ -292,7 +292,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx) | |||
292 | return 1; | 292 | return 1; |
293 | } | 293 | } |
294 | 294 | ||
295 | int pnp_check_mem(struct pnp_dev * dev, int idx) | 295 | int pnp_check_mem(struct pnp_dev *dev, int idx) |
296 | { | 296 | { |
297 | int tmp; | 297 | int tmp; |
298 | struct pnp_dev *tdev; | 298 | struct pnp_dev *tdev; |
@@ -306,8 +306,8 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
306 | 306 | ||
307 | /* check if the resource is already in use, skip if the | 307 | /* check if the resource is already in use, skip if the |
308 | * device is active because it itself may be in use */ | 308 | * device is active because it itself may be in use */ |
309 | if(!dev->active) { | 309 | if (!dev->active) { |
310 | if (check_mem_region(*addr, length(addr,end))) | 310 | if (check_mem_region(*addr, length(addr, end))) |
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | 313 | ||
@@ -315,7 +315,7 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
315 | for (tmp = 0; tmp < 8; tmp++) { | 315 | for (tmp = 0; tmp < 8; tmp++) { |
316 | int raddr = pnp_reserve_mem[tmp << 1]; | 316 | int raddr = pnp_reserve_mem[tmp << 1]; |
317 | int rend = pnp_reserve_mem[(tmp << 1) + 1] + raddr - 1; | 317 | int rend = pnp_reserve_mem[(tmp << 1) + 1] + raddr - 1; |
318 | if (ranged_conflict(addr,end,&raddr,&rend)) | 318 | if (ranged_conflict(addr, end, &raddr, &rend)) |
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
@@ -324,7 +324,7 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
324 | if (dev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { | 324 | if (dev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { |
325 | taddr = &dev->res.mem_resource[tmp].start; | 325 | taddr = &dev->res.mem_resource[tmp].start; |
326 | tend = &dev->res.mem_resource[tmp].end; | 326 | tend = &dev->res.mem_resource[tmp].end; |
327 | if (ranged_conflict(addr,end,taddr,tend)) | 327 | if (ranged_conflict(addr, end, taddr, tend)) |
328 | return 0; | 328 | return 0; |
329 | } | 329 | } |
330 | } | 330 | } |
@@ -335,11 +335,12 @@ int pnp_check_mem(struct pnp_dev * dev, int idx) | |||
335 | continue; | 335 | continue; |
336 | for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { | 336 | for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { |
337 | if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { | 337 | if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { |
338 | if (cannot_compare(tdev->res.mem_resource[tmp].flags)) | 338 | if (cannot_compare |
339 | (tdev->res.mem_resource[tmp].flags)) | ||
339 | continue; | 340 | continue; |
340 | taddr = &tdev->res.mem_resource[tmp].start; | 341 | taddr = &tdev->res.mem_resource[tmp].start; |
341 | tend = &tdev->res.mem_resource[tmp].end; | 342 | tend = &tdev->res.mem_resource[tmp].end; |
342 | if (ranged_conflict(addr,end,taddr,tend)) | 343 | if (ranged_conflict(addr, end, taddr, tend)) |
343 | return 0; | 344 | return 0; |
344 | } | 345 | } |
345 | } | 346 | } |
@@ -353,11 +354,11 @@ static irqreturn_t pnp_test_handler(int irq, void *dev_id) | |||
353 | return IRQ_HANDLED; | 354 | return IRQ_HANDLED; |
354 | } | 355 | } |
355 | 356 | ||
356 | int pnp_check_irq(struct pnp_dev * dev, int idx) | 357 | int pnp_check_irq(struct pnp_dev *dev, int idx) |
357 | { | 358 | { |
358 | int tmp; | 359 | int tmp; |
359 | struct pnp_dev *tdev; | 360 | struct pnp_dev *tdev; |
360 | resource_size_t * irq = &dev->res.irq_resource[idx].start; | 361 | resource_size_t *irq = &dev->res.irq_resource[idx].start; |
361 | 362 | ||
362 | /* if the resource doesn't exist, don't complain about it */ | 363 | /* if the resource doesn't exist, don't complain about it */ |
363 | if (cannot_compare(dev->res.irq_resource[idx].flags)) | 364 | if (cannot_compare(dev->res.irq_resource[idx].flags)) |
@@ -394,9 +395,9 @@ int pnp_check_irq(struct pnp_dev * dev, int idx) | |||
394 | 395 | ||
395 | /* check if the resource is already in use, skip if the | 396 | /* check if the resource is already in use, skip if the |
396 | * device is active because it itself may be in use */ | 397 | * device is active because it itself may be in use */ |
397 | if(!dev->active) { | 398 | if (!dev->active) { |
398 | if (request_irq(*irq, pnp_test_handler, | 399 | if (request_irq(*irq, pnp_test_handler, |
399 | IRQF_DISABLED|IRQF_PROBE_SHARED, "pnp", NULL)) | 400 | IRQF_DISABLED | IRQF_PROBE_SHARED, "pnp", NULL)) |
400 | return 0; | 401 | return 0; |
401 | free_irq(*irq, NULL); | 402 | free_irq(*irq, NULL); |
402 | } | 403 | } |
@@ -407,7 +408,8 @@ int pnp_check_irq(struct pnp_dev * dev, int idx) | |||
407 | continue; | 408 | continue; |
408 | for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { | 409 | for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { |
409 | if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) { | 410 | if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) { |
410 | if (cannot_compare(tdev->res.irq_resource[tmp].flags)) | 411 | if (cannot_compare |
412 | (tdev->res.irq_resource[tmp].flags)) | ||
411 | continue; | 413 | continue; |
412 | if ((tdev->res.irq_resource[tmp].start == *irq)) | 414 | if ((tdev->res.irq_resource[tmp].start == *irq)) |
413 | return 0; | 415 | return 0; |
@@ -418,12 +420,12 @@ int pnp_check_irq(struct pnp_dev * dev, int idx) | |||
418 | return 1; | 420 | return 1; |
419 | } | 421 | } |
420 | 422 | ||
421 | int pnp_check_dma(struct pnp_dev * dev, int idx) | 423 | int pnp_check_dma(struct pnp_dev *dev, int idx) |
422 | { | 424 | { |
423 | #ifndef CONFIG_IA64 | 425 | #ifndef CONFIG_IA64 |
424 | int tmp; | 426 | int tmp; |
425 | struct pnp_dev *tdev; | 427 | struct pnp_dev *tdev; |
426 | resource_size_t * dma = &dev->res.dma_resource[idx].start; | 428 | resource_size_t *dma = &dev->res.dma_resource[idx].start; |
427 | 429 | ||
428 | /* if the resource doesn't exist, don't complain about it */ | 430 | /* if the resource doesn't exist, don't complain about it */ |
429 | if (cannot_compare(dev->res.dma_resource[idx].flags)) | 431 | if (cannot_compare(dev->res.dma_resource[idx].flags)) |
@@ -449,7 +451,7 @@ int pnp_check_dma(struct pnp_dev * dev, int idx) | |||
449 | 451 | ||
450 | /* check if the resource is already in use, skip if the | 452 | /* check if the resource is already in use, skip if the |
451 | * device is active because it itself may be in use */ | 453 | * device is active because it itself may be in use */ |
452 | if(!dev->active) { | 454 | if (!dev->active) { |
453 | if (request_dma(*dma, "pnp")) | 455 | if (request_dma(*dma, "pnp")) |
454 | return 0; | 456 | return 0; |
455 | free_dma(*dma); | 457 | free_dma(*dma); |
@@ -461,7 +463,8 @@ int pnp_check_dma(struct pnp_dev * dev, int idx) | |||
461 | continue; | 463 | continue; |
462 | for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { | 464 | for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { |
463 | if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) { | 465 | if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) { |
464 | if (cannot_compare(tdev->res.dma_resource[tmp].flags)) | 466 | if (cannot_compare |
467 | (tdev->res.dma_resource[tmp].flags)) | ||
465 | continue; | 468 | continue; |
466 | if ((tdev->res.dma_resource[tmp].start == *dma)) | 469 | if ((tdev->res.dma_resource[tmp].start == *dma)) |
467 | return 0; | 470 | return 0; |
@@ -476,7 +479,6 @@ int pnp_check_dma(struct pnp_dev * dev, int idx) | |||
476 | #endif | 479 | #endif |
477 | } | 480 | } |
478 | 481 | ||
479 | |||
480 | #if 0 | 482 | #if 0 |
481 | EXPORT_SYMBOL(pnp_register_dependent_option); | 483 | EXPORT_SYMBOL(pnp_register_dependent_option); |
482 | EXPORT_SYMBOL(pnp_register_independent_option); | 484 | EXPORT_SYMBOL(pnp_register_independent_option); |
@@ -484,8 +486,7 @@ EXPORT_SYMBOL(pnp_register_irq_resource); | |||
484 | EXPORT_SYMBOL(pnp_register_dma_resource); | 486 | EXPORT_SYMBOL(pnp_register_dma_resource); |
485 | EXPORT_SYMBOL(pnp_register_port_resource); | 487 | EXPORT_SYMBOL(pnp_register_port_resource); |
486 | EXPORT_SYMBOL(pnp_register_mem_resource); | 488 | EXPORT_SYMBOL(pnp_register_mem_resource); |
487 | #endif /* 0 */ | 489 | #endif /* 0 */ |
488 | |||
489 | 490 | ||
490 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ | 491 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ |
491 | 492 | ||
@@ -494,7 +495,7 @@ static int __init pnp_setup_reserve_irq(char *str) | |||
494 | int i; | 495 | int i; |
495 | 496 | ||
496 | for (i = 0; i < 16; i++) | 497 | for (i = 0; i < 16; i++) |
497 | if (get_option(&str,&pnp_reserve_irq[i]) != 2) | 498 | if (get_option(&str, &pnp_reserve_irq[i]) != 2) |
498 | break; | 499 | break; |
499 | return 1; | 500 | return 1; |
500 | } | 501 | } |
@@ -508,7 +509,7 @@ static int __init pnp_setup_reserve_dma(char *str) | |||
508 | int i; | 509 | int i; |
509 | 510 | ||
510 | for (i = 0; i < 8; i++) | 511 | for (i = 0; i < 8; i++) |
511 | if (get_option(&str,&pnp_reserve_dma[i]) != 2) | 512 | if (get_option(&str, &pnp_reserve_dma[i]) != 2) |
512 | break; | 513 | break; |
513 | return 1; | 514 | return 1; |
514 | } | 515 | } |
@@ -522,7 +523,7 @@ static int __init pnp_setup_reserve_io(char *str) | |||
522 | int i; | 523 | int i; |
523 | 524 | ||
524 | for (i = 0; i < 16; i++) | 525 | for (i = 0; i < 16; i++) |
525 | if (get_option(&str,&pnp_reserve_io[i]) != 2) | 526 | if (get_option(&str, &pnp_reserve_io[i]) != 2) |
526 | break; | 527 | break; |
527 | return 1; | 528 | return 1; |
528 | } | 529 | } |
@@ -536,7 +537,7 @@ static int __init pnp_setup_reserve_mem(char *str) | |||
536 | int i; | 537 | int i; |
537 | 538 | ||
538 | for (i = 0; i < 16; i++) | 539 | for (i = 0; i < 16; i++) |
539 | if (get_option(&str,&pnp_reserve_mem[i]) != 2) | 540 | if (get_option(&str, &pnp_reserve_mem[i]) != 2) |
540 | break; | 541 | break; |
541 | return 1; | 542 | return 1; |
542 | } | 543 | } |
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c index 946a0dcd627d..525db2e7d6c7 100644 --- a/drivers/pnp/support.c +++ b/drivers/pnp/support.c | |||
@@ -16,17 +16,14 @@ | |||
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | 18 | ||
19 | int pnp_is_active(struct pnp_dev * dev) | 19 | int pnp_is_active(struct pnp_dev *dev) |
20 | { | 20 | { |
21 | if (!pnp_port_start(dev, 0) && pnp_port_len(dev, 0) <= 1 && | 21 | if (!pnp_port_start(dev, 0) && pnp_port_len(dev, 0) <= 1 && |
22 | !pnp_mem_start(dev, 0) && pnp_mem_len(dev, 0) <= 1 && | 22 | !pnp_mem_start(dev, 0) && pnp_mem_len(dev, 0) <= 1 && |
23 | pnp_irq(dev, 0) == -1 && | 23 | pnp_irq(dev, 0) == -1 && pnp_dma(dev, 0) == -1) |
24 | pnp_dma(dev, 0) == -1) | 24 | return 0; |
25 | return 0; | ||
26 | else | 25 | else |
27 | return 1; | 26 | return 1; |
28 | } | 27 | } |
29 | 28 | ||
30 | |||
31 | |||
32 | EXPORT_SYMBOL(pnp_is_active); | 29 | EXPORT_SYMBOL(pnp_is_active); |
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c index a8a95540b1ef..8d71008accba 100644 --- a/drivers/pnp/system.c +++ b/drivers/pnp/system.c | |||
@@ -16,13 +16,14 @@ | |||
16 | 16 | ||
17 | static const struct pnp_device_id pnp_dev_table[] = { | 17 | static const struct pnp_device_id pnp_dev_table[] = { |
18 | /* General ID for reserving resources */ | 18 | /* General ID for reserving resources */ |
19 | { "PNP0c02", 0 }, | 19 | {"PNP0c02", 0}, |
20 | /* memory controller */ | 20 | /* memory controller */ |
21 | { "PNP0c01", 0 }, | 21 | {"PNP0c01", 0}, |
22 | { "", 0 } | 22 | {"", 0} |
23 | }; | 23 | }; |
24 | 24 | ||
25 | static void reserve_range(const char *pnpid, resource_size_t start, resource_size_t end, int port) | 25 | static void reserve_range(const char *pnpid, resource_size_t start, |
26 | resource_size_t end, int port) | ||
26 | { | 27 | { |
27 | struct resource *res; | 28 | struct resource *res; |
28 | char *regionid; | 29 | char *regionid; |
@@ -32,9 +33,9 @@ static void reserve_range(const char *pnpid, resource_size_t start, resource_siz | |||
32 | return; | 33 | return; |
33 | snprintf(regionid, 16, "pnp %s", pnpid); | 34 | snprintf(regionid, 16, "pnp %s", pnpid); |
34 | if (port) | 35 | if (port) |
35 | res = request_region(start, end-start+1, regionid); | 36 | res = request_region(start, end - start + 1, regionid); |
36 | else | 37 | else |
37 | res = request_mem_region(start, end-start+1, regionid); | 38 | res = request_mem_region(start, end - start + 1, regionid); |
38 | if (res == NULL) | 39 | if (res == NULL) |
39 | kfree(regionid); | 40 | kfree(regionid); |
40 | else | 41 | else |
@@ -45,10 +46,10 @@ static void reserve_range(const char *pnpid, resource_size_t start, resource_siz | |||
45 | * have double reservations. | 46 | * have double reservations. |
46 | */ | 47 | */ |
47 | printk(KERN_INFO | 48 | printk(KERN_INFO |
48 | "pnp: %s: %s range 0x%llx-0x%llx %s reserved\n", | 49 | "pnp: %s: %s range 0x%llx-0x%llx %s reserved\n", |
49 | pnpid, port ? "ioport" : "iomem", | 50 | pnpid, port ? "ioport" : "iomem", |
50 | (unsigned long long)start, (unsigned long long)end, | 51 | (unsigned long long)start, (unsigned long long)end, |
51 | NULL != res ? "has been" : "could not be"); | 52 | NULL != res ? "has been" : "could not be"); |
52 | } | 53 | } |
53 | 54 | ||
54 | static void reserve_resources_of_dev(const struct pnp_dev *dev) | 55 | static void reserve_resources_of_dev(const struct pnp_dev *dev) |
@@ -74,7 +75,7 @@ static void reserve_resources_of_dev(const struct pnp_dev *dev) | |||
74 | continue; /* invalid */ | 75 | continue; /* invalid */ |
75 | 76 | ||
76 | reserve_range(dev->dev.bus_id, pnp_port_start(dev, i), | 77 | reserve_range(dev->dev.bus_id, pnp_port_start(dev, i), |
77 | pnp_port_end(dev, i), 1); | 78 | pnp_port_end(dev, i), 1); |
78 | } | 79 | } |
79 | 80 | ||
80 | for (i = 0; i < PNP_MAX_MEM; i++) { | 81 | for (i = 0; i < PNP_MAX_MEM; i++) { |
@@ -82,24 +83,25 @@ static void reserve_resources_of_dev(const struct pnp_dev *dev) | |||
82 | continue; | 83 | continue; |
83 | 84 | ||
84 | reserve_range(dev->dev.bus_id, pnp_mem_start(dev, i), | 85 | reserve_range(dev->dev.bus_id, pnp_mem_start(dev, i), |
85 | pnp_mem_end(dev, i), 0); | 86 | pnp_mem_end(dev, i), 0); |
86 | } | 87 | } |
87 | 88 | ||
88 | return; | 89 | return; |
89 | } | 90 | } |
90 | 91 | ||
91 | static int system_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) | 92 | static int system_pnp_probe(struct pnp_dev *dev, |
93 | const struct pnp_device_id *dev_id) | ||
92 | { | 94 | { |
93 | reserve_resources_of_dev(dev); | 95 | reserve_resources_of_dev(dev); |
94 | return 0; | 96 | return 0; |
95 | } | 97 | } |
96 | 98 | ||
97 | static struct pnp_driver system_pnp_driver = { | 99 | static struct pnp_driver system_pnp_driver = { |
98 | .name = "system", | 100 | .name = "system", |
99 | .id_table = pnp_dev_table, | 101 | .id_table = pnp_dev_table, |
100 | .flags = PNP_DRIVER_RES_DO_NOT_CHANGE, | 102 | .flags = PNP_DRIVER_RES_DO_NOT_CHANGE, |
101 | .probe = system_pnp_probe, | 103 | .probe = system_pnp_probe, |
102 | .remove = NULL, | 104 | .remove = NULL, |
103 | }; | 105 | }; |
104 | 106 | ||
105 | static int __init pnp_system_init(void) | 107 | static int __init pnp_system_init(void) |