Lines 319-326
static int flexcop_pci_init(struct flexc
Link Here
|
319 |
pci_read_config_byte(fc_pci->pdev, PCI_CLASS_REVISION, &card_rev); |
319 |
pci_read_config_byte(fc_pci->pdev, PCI_CLASS_REVISION, &card_rev); |
320 |
info("card revision %x", card_rev); |
320 |
info("card revision %x", card_rev); |
321 |
|
321 |
|
322 |
if ((ret = pci_enable_device(fc_pci->pdev)) != 0) |
|
|
323 |
return ret; |
324 |
pci_set_master(fc_pci->pdev); |
322 |
pci_set_master(fc_pci->pdev); |
325 |
|
323 |
|
326 |
if ((ret = pci_request_regions(fc_pci->pdev, DRIVER_NAME)) != 0) |
324 |
if ((ret = pci_request_regions(fc_pci->pdev, DRIVER_NAME)) != 0) |
Lines 334-340
static int flexcop_pci_init(struct flexc
Link Here
|
334 |
goto err_pci_release_regions; |
332 |
goto err_pci_release_regions; |
335 |
} |
333 |
} |
336 |
|
334 |
|
337 |
pci_set_drvdata(fc_pci->pdev, fc_pci); |
|
|
338 |
spin_lock_init(&fc_pci->irq_lock); |
335 |
spin_lock_init(&fc_pci->irq_lock); |
339 |
if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_isr, |
336 |
if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_isr, |
340 |
IRQF_SHARED, DRIVER_NAME, fc_pci)) != 0) |
337 |
IRQF_SHARED, DRIVER_NAME, fc_pci)) != 0) |
Lines 345-351
static int flexcop_pci_init(struct flexc
Link Here
|
345 |
|
342 |
|
346 |
err_pci_iounmap: |
343 |
err_pci_iounmap: |
347 |
pci_iounmap(fc_pci->pdev, fc_pci->io_mem); |
344 |
pci_iounmap(fc_pci->pdev, fc_pci->io_mem); |
348 |
pci_set_drvdata(fc_pci->pdev, NULL); |
|
|
349 |
err_pci_release_regions: |
345 |
err_pci_release_regions: |
350 |
pci_release_regions(fc_pci->pdev); |
346 |
pci_release_regions(fc_pci->pdev); |
351 |
err_pci_disable_device: |
347 |
err_pci_disable_device: |
Lines 358-366
static void flexcop_pci_exit(struct flex
Link Here
|
358 |
if (fc_pci->init_state & FC_PCI_INIT) { |
354 |
if (fc_pci->init_state & FC_PCI_INIT) { |
359 |
free_irq(fc_pci->pdev->irq, fc_pci); |
355 |
free_irq(fc_pci->pdev->irq, fc_pci); |
360 |
pci_iounmap(fc_pci->pdev, fc_pci->io_mem); |
356 |
pci_iounmap(fc_pci->pdev, fc_pci->io_mem); |
361 |
pci_set_drvdata(fc_pci->pdev, NULL); |
|
|
362 |
pci_release_regions(fc_pci->pdev); |
357 |
pci_release_regions(fc_pci->pdev); |
363 |
pci_disable_device(fc_pci->pdev); |
|
|
364 |
} |
358 |
} |
365 |
fc_pci->init_state &= ~FC_PCI_INIT; |
359 |
fc_pci->init_state &= ~FC_PCI_INIT; |
366 |
} |
360 |
} |
Lines 399-404
static int flexcop_pci_probe(struct pci_
Link Here
|
399 |
|
393 |
|
400 |
/* bus specific part */ |
394 |
/* bus specific part */ |
401 |
fc_pci->pdev = pdev; |
395 |
fc_pci->pdev = pdev; |
|
|
396 |
ret = pci_enable_device(pdev); |
397 |
if (ret != 0) |
398 |
goto err_kfree; |
399 |
|
400 |
pci_set_drvdata(pdev, fc_pci); |
402 |
if ((ret = flexcop_pci_init(fc_pci)) != 0) |
401 |
if ((ret = flexcop_pci_init(fc_pci)) != 0) |
403 |
goto err_kfree; |
402 |
goto err_kfree; |
404 |
|
403 |
|
Lines 428-433
err_fc_exit:
Link Here
|
428 |
err_pci_exit: |
427 |
err_pci_exit: |
429 |
flexcop_pci_exit(fc_pci); |
428 |
flexcop_pci_exit(fc_pci); |
430 |
err_kfree: |
429 |
err_kfree: |
|
|
430 |
pci_set_drvdata(pdev, NULL); |
431 |
flexcop_device_kfree(fc); |
431 |
flexcop_device_kfree(fc); |
432 |
return ret; |
432 |
return ret; |
433 |
} |
433 |
} |
Lines 445-453
static void flexcop_pci_remove(struct pc
Link Here
|
445 |
flexcop_pci_dma_exit(fc_pci); |
445 |
flexcop_pci_dma_exit(fc_pci); |
446 |
flexcop_device_exit(fc_pci->fc_dev); |
446 |
flexcop_device_exit(fc_pci->fc_dev); |
447 |
flexcop_pci_exit(fc_pci); |
447 |
flexcop_pci_exit(fc_pci); |
|
|
448 |
pci_set_drvdata(pdev, NULL); |
449 |
pci_disable_device(pdev); |
448 |
flexcop_device_kfree(fc_pci->fc_dev); |
450 |
flexcop_device_kfree(fc_pci->fc_dev); |
449 |
} |
451 |
} |
450 |
|
452 |
|
|
|
453 |
#ifdef CONFIG_PM |
454 |
static int flexcop_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) |
455 |
{ |
456 |
struct flexcop_pci *fc_pci = pci_get_drvdata(pdev); |
457 |
struct flexcop_device *fc = fc_pci->fc_dev; |
458 |
|
459 |
/* most parts are from flexcop_pci_remove */ |
460 |
|
461 |
if (irq_chk_intv > 0) |
462 |
cancel_delayed_work(&fc_pci->irq_check_work); |
463 |
|
464 |
flexcop_pci_dma_exit(fc_pci); |
465 |
flexcop_device_suspend(fc); |
466 |
flexcop_pci_exit(fc_pci); |
467 |
|
468 |
pci_save_state(pdev); |
469 |
|
470 |
pci_disable_device(pdev); |
471 |
pci_set_power_state(pdev, pci_choose_state(pdev, mesg)); |
472 |
|
473 |
return 0; |
474 |
} |
475 |
|
476 |
static int flexcop_pci_resume(struct pci_dev *pdev) |
477 |
{ |
478 |
int ret; |
479 |
struct flexcop_pci *fc_pci = pci_get_drvdata(pdev); |
480 |
struct flexcop_device *fc = fc_pci->fc_dev; |
481 |
|
482 |
/* restore power state 0 */ |
483 |
pci_set_power_state(pdev, PCI_D0); |
484 |
pci_restore_state(pdev); |
485 |
|
486 |
ret = pci_enable_device(pdev); |
487 |
if (ret < 0) { |
488 |
err("unable to enable device in resume\n"); |
489 |
return ret; |
490 |
} |
491 |
|
492 |
/* from flexcop_pci_probe */ |
493 |
ret = flexcop_pci_init(fc_pci); |
494 |
if (ret < 0) { |
495 |
err("could not allocate pci resources in resume\n"); |
496 |
return ret; |
497 |
} |
498 |
|
499 |
/* init flexcop */ |
500 |
flexcop_device_resume(fc); /* instead of flexcop_device_initialize */ |
501 |
|
502 |
/* init dma */ |
503 |
flexcop_pci_dma_init(fc_pci); |
504 |
|
505 |
/* last step: restart watchdog */ |
506 |
if (irq_chk_intv > 0) |
507 |
schedule_delayed_work(&fc_pci->irq_check_work, |
508 |
msecs_to_jiffies(irq_chk_intv < 100 ? |
509 |
100 : |
510 |
irq_chk_intv)); |
511 |
|
512 |
return 0; |
513 |
} |
514 |
#endif |
515 |
|
451 |
static struct pci_device_id flexcop_pci_tbl[] = { |
516 |
static struct pci_device_id flexcop_pci_tbl[] = { |
452 |
{ PCI_DEVICE(0x13d0, 0x2103) }, |
517 |
{ PCI_DEVICE(0x13d0, 0x2103) }, |
453 |
{ }, |
518 |
{ }, |
Lines 460-465
static struct pci_driver flexcop_pci_dri
Link Here
|
460 |
.id_table = flexcop_pci_tbl, |
525 |
.id_table = flexcop_pci_tbl, |
461 |
.probe = flexcop_pci_probe, |
526 |
.probe = flexcop_pci_probe, |
462 |
.remove = flexcop_pci_remove, |
527 |
.remove = flexcop_pci_remove, |
|
|
528 |
#ifdef CONFIG_PM |
529 |
.suspend = flexcop_pci_suspend, |
530 |
.resume = flexcop_pci_resume, |
531 |
#endif |
463 |
}; |
532 |
}; |
464 |
|
533 |
|
465 |
static int __init flexcop_pci_module_init(void) |
534 |
static int __init flexcop_pci_module_init(void) |