aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/interface.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2008-04-30 13:59:05 -0400
committerLen Brown <len.brown@intel.com>2008-04-30 13:59:05 -0400
commit008238b54ac2350babf195084ecedbcf7851a202 (patch)
treea7cc18ea0403f4478883a3e36a6f0d2bf67eef3e /drivers/pnp/interface.c
parent96916090f488986a4ebb8e9ffa6a3b50881d5ccd (diff)
parentdfd2e1b4e6eb46ff59c7e1c1111c967b8b5981c1 (diff)
Merge branch 'pnp' into release
Diffstat (limited to 'drivers/pnp/interface.c')
-rw-r--r--drivers/pnp/interface.c111
1 files changed, 47 insertions, 64 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 982658477a58..5d9301de1778 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -248,6 +248,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
248 char *buf) 248 char *buf)
249{ 249{
250 struct pnp_dev *dev = to_pnp_dev(dmdev); 250 struct pnp_dev *dev = to_pnp_dev(dmdev);
251 struct resource *res;
251 int i, ret; 252 int i, ret;
252 pnp_info_buffer_t *buffer; 253 pnp_info_buffer_t *buffer;
253 254
@@ -267,50 +268,46 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
267 else 268 else
268 pnp_printf(buffer, "disabled\n"); 269 pnp_printf(buffer, "disabled\n");
269 270
270 for (i = 0; i < PNP_MAX_PORT; i++) { 271 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
271 if (pnp_port_valid(dev, i)) { 272 if (pnp_resource_valid(res)) {
272 pnp_printf(buffer, "io"); 273 pnp_printf(buffer, "io");
273 if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) 274 if (res->flags & IORESOURCE_DISABLED)
274 pnp_printf(buffer, " disabled\n"); 275 pnp_printf(buffer, " disabled\n");
275 else 276 else
276 pnp_printf(buffer, " 0x%llx-0x%llx\n", 277 pnp_printf(buffer, " 0x%llx-0x%llx\n",
277 (unsigned long long) 278 (unsigned long long) res->start,
278 pnp_port_start(dev, i), 279 (unsigned long long) res->end);
279 (unsigned long long)pnp_port_end(dev,
280 i));
281 } 280 }
282 } 281 }
283 for (i = 0; i < PNP_MAX_MEM; i++) { 282 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
284 if (pnp_mem_valid(dev, i)) { 283 if (pnp_resource_valid(res)) {
285 pnp_printf(buffer, "mem"); 284 pnp_printf(buffer, "mem");
286 if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) 285 if (res->flags & IORESOURCE_DISABLED)
287 pnp_printf(buffer, " disabled\n"); 286 pnp_printf(buffer, " disabled\n");
288 else 287 else
289 pnp_printf(buffer, " 0x%llx-0x%llx\n", 288 pnp_printf(buffer, " 0x%llx-0x%llx\n",
290 (unsigned long long) 289 (unsigned long long) res->start,
291 pnp_mem_start(dev, i), 290 (unsigned long long) res->end);
292 (unsigned long long)pnp_mem_end(dev,
293 i));
294 } 291 }
295 } 292 }
296 for (i = 0; i < PNP_MAX_IRQ; i++) { 293 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
297 if (pnp_irq_valid(dev, i)) { 294 if (pnp_resource_valid(res)) {
298 pnp_printf(buffer, "irq"); 295 pnp_printf(buffer, "irq");
299 if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) 296 if (res->flags & IORESOURCE_DISABLED)
300 pnp_printf(buffer, " disabled\n"); 297 pnp_printf(buffer, " disabled\n");
301 else 298 else
302 pnp_printf(buffer, " %lld\n", 299 pnp_printf(buffer, " %lld\n",
303 (unsigned long long)pnp_irq(dev, i)); 300 (unsigned long long) res->start);
304 } 301 }
305 } 302 }
306 for (i = 0; i < PNP_MAX_DMA; i++) { 303 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
307 if (pnp_dma_valid(dev, i)) { 304 if (pnp_resource_valid(res)) {
308 pnp_printf(buffer, "dma"); 305 pnp_printf(buffer, "dma");
309 if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) 306 if (res->flags & IORESOURCE_DISABLED)
310 pnp_printf(buffer, " disabled\n"); 307 pnp_printf(buffer, " disabled\n");
311 else 308 else
312 pnp_printf(buffer, " %lld\n", 309 pnp_printf(buffer, " %lld\n",
313 (unsigned long long)pnp_dma(dev, i)); 310 (unsigned long long) res->start);
314 } 311 }
315 } 312 }
316 ret = (buffer->curr - buf); 313 ret = (buffer->curr - buf);
@@ -323,8 +320,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
323 const char *ubuf, size_t count) 320 const char *ubuf, size_t count)
324{ 321{
325 struct pnp_dev *dev = to_pnp_dev(dmdev); 322 struct pnp_dev *dev = to_pnp_dev(dmdev);
323 struct pnp_resource *pnp_res;
326 char *buf = (void *)ubuf; 324 char *buf = (void *)ubuf;
327 int retval = 0; 325 int retval = 0;
326 resource_size_t start, end;
328 327
329 if (dev->status & PNP_ATTACHED) { 328 if (dev->status & PNP_ATTACHED) {
330 retval = -EBUSY; 329 retval = -EBUSY;
@@ -351,20 +350,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
351 if (!strnicmp(buf, "auto", 4)) { 350 if (!strnicmp(buf, "auto", 4)) {
352 if (dev->active) 351 if (dev->active)
353 goto done; 352 goto done;
354 pnp_init_resource_table(&dev->res); 353 pnp_init_resources(dev);
355 retval = pnp_auto_config_dev(dev); 354 retval = pnp_auto_config_dev(dev);
356 goto done; 355 goto done;
357 } 356 }
358 if (!strnicmp(buf, "clear", 5)) { 357 if (!strnicmp(buf, "clear", 5)) {
359 if (dev->active) 358 if (dev->active)
360 goto done; 359 goto done;
361 pnp_init_resource_table(&dev->res); 360 pnp_init_resources(dev);
362 goto done; 361 goto done;
363 } 362 }
364 if (!strnicmp(buf, "get", 3)) { 363 if (!strnicmp(buf, "get", 3)) {
365 mutex_lock(&pnp_res_mutex); 364 mutex_lock(&pnp_res_mutex);
366 if (pnp_can_read(dev)) 365 if (pnp_can_read(dev))
367 dev->protocol->get(dev, &dev->res); 366 dev->protocol->get(dev);
368 mutex_unlock(&pnp_res_mutex); 367 mutex_unlock(&pnp_res_mutex);
369 goto done; 368 goto done;
370 } 369 }
@@ -373,7 +372,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
373 if (dev->active) 372 if (dev->active)
374 goto done; 373 goto done;
375 buf += 3; 374 buf += 3;
376 pnp_init_resource_table(&dev->res); 375 pnp_init_resources(dev);
377 mutex_lock(&pnp_res_mutex); 376 mutex_lock(&pnp_res_mutex);
378 while (1) { 377 while (1) {
379 while (isspace(*buf)) 378 while (isspace(*buf))
@@ -382,76 +381,60 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
382 buf += 2; 381 buf += 2;
383 while (isspace(*buf)) 382 while (isspace(*buf))
384 ++buf; 383 ++buf;
385 dev->res.port_resource[nport].start = 384 start = simple_strtoul(buf, &buf, 0);
386 simple_strtoul(buf, &buf, 0);
387 while (isspace(*buf)) 385 while (isspace(*buf))
388 ++buf; 386 ++buf;
389 if (*buf == '-') { 387 if (*buf == '-') {
390 buf += 1; 388 buf += 1;
391 while (isspace(*buf)) 389 while (isspace(*buf))
392 ++buf; 390 ++buf;
393 dev->res.port_resource[nport].end = 391 end = simple_strtoul(buf, &buf, 0);
394 simple_strtoul(buf, &buf, 0);
395 } else 392 } else
396 dev->res.port_resource[nport].end = 393 end = start;
397 dev->res.port_resource[nport].start; 394 pnp_res = pnp_add_io_resource(dev, start, end,
398 dev->res.port_resource[nport].flags = 395 0);
399 IORESOURCE_IO; 396 if (pnp_res)
400 nport++; 397 pnp_res->index = nport++;
401 if (nport >= PNP_MAX_PORT)
402 break;
403 continue; 398 continue;
404 } 399 }
405 if (!strnicmp(buf, "mem", 3)) { 400 if (!strnicmp(buf, "mem", 3)) {
406 buf += 3; 401 buf += 3;
407 while (isspace(*buf)) 402 while (isspace(*buf))
408 ++buf; 403 ++buf;
409 dev->res.mem_resource[nmem].start = 404 start = simple_strtoul(buf, &buf, 0);
410 simple_strtoul(buf, &buf, 0);
411 while (isspace(*buf)) 405 while (isspace(*buf))
412 ++buf; 406 ++buf;
413 if (*buf == '-') { 407 if (*buf == '-') {
414 buf += 1; 408 buf += 1;
415 while (isspace(*buf)) 409 while (isspace(*buf))
416 ++buf; 410 ++buf;
417 dev->res.mem_resource[nmem].end = 411 end = simple_strtoul(buf, &buf, 0);
418 simple_strtoul(buf, &buf, 0);
419 } else 412 } else
420 dev->res.mem_resource[nmem].end = 413 end = start;
421 dev->res.mem_resource[nmem].start; 414 pnp_res = pnp_add_mem_resource(dev, start, end,
422 dev->res.mem_resource[nmem].flags = 415 0);
423 IORESOURCE_MEM; 416 if (pnp_res)
424 nmem++; 417 pnp_res->index = nmem++;
425 if (nmem >= PNP_MAX_MEM)
426 break;
427 continue; 418 continue;
428 } 419 }
429 if (!strnicmp(buf, "irq", 3)) { 420 if (!strnicmp(buf, "irq", 3)) {
430 buf += 3; 421 buf += 3;
431 while (isspace(*buf)) 422 while (isspace(*buf))
432 ++buf; 423 ++buf;
433 dev->res.irq_resource[nirq].start = 424 start = simple_strtoul(buf, &buf, 0);
434 dev->res.irq_resource[nirq].end = 425 pnp_res = pnp_add_irq_resource(dev, start, 0);
435 simple_strtoul(buf, &buf, 0); 426 if (pnp_res)
436 dev->res.irq_resource[nirq].flags = 427 nirq++;
437 IORESOURCE_IRQ;
438 nirq++;
439 if (nirq >= PNP_MAX_IRQ)
440 break;
441 continue; 428 continue;
442 } 429 }
443 if (!strnicmp(buf, "dma", 3)) { 430 if (!strnicmp(buf, "dma", 3)) {
444 buf += 3; 431 buf += 3;
445 while (isspace(*buf)) 432 while (isspace(*buf))
446 ++buf; 433 ++buf;
447 dev->res.dma_resource[ndma].start = 434 start = simple_strtoul(buf, &buf, 0);
448 dev->res.dma_resource[ndma].end = 435 pnp_res = pnp_add_dma_resource(dev, start, 0);
449 simple_strtoul(buf, &buf, 0); 436 if (pnp_res)
450 dev->res.dma_resource[ndma].flags = 437 pnp_res->index = ndma++;
451 IORESOURCE_DMA;
452 ndma++;
453 if (ndma >= PNP_MAX_DMA)
454 break;
455 continue; 438 continue;
456 } 439 }
457 break; 440 break;