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