aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/cs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
commit2be4ff2f084842839b041b793ed6237e8d1d315a (patch)
tree1d776ac1717edeff4ee7d59ab0aea2782cb86dba /drivers/pcmcia/cs.c
parentcf2fa66055d718ae13e62451bb546505f63906a2 (diff)
parenta45b3fb19ba1e4dfc3fc53563a072612092930a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (49 commits) pcmcia: ioctl-internal definitions pcmcia: cistpl header cleanup pcmcia: remove unused argument to pcmcia_parse_tuple() pcmcia: card services header cleanup pcmcia: device_id header cleanup pcmcia: encapsulate ioaddr_t pcmcia: cleanup device driver header file pcmcia: cleanup socket services header file pcmcia: merge ds_internal.h into cs_internal.h pcmcia: cleanup cs_internal.h pcmcia: cs_internal.h is internal pcmcia: use dev_printk for cs_error() pcmcia: remove CS_ error codes alltogether pcmcia: deprecate CS_BAD_TUPLE pcmcia: deprecate CS_BAD_ARGS pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE pcmcia: deprecate CS_NO_MORE_ITEMS pcmcia: deprecate CS_IN_USE pcmcia: deprecate CS_CONFIGURATION_LOCKED ... Fix trivial conflict in drivers/pcmcia/ds.c manually
Diffstat (limited to 'drivers/pcmcia/cs.c')
-rw-r--r--drivers/pcmcia/cs.c78
1 files changed, 41 insertions, 37 deletions
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index d1207393fc3e..c68c5d338285 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -61,7 +61,7 @@ INT_MODULE_PARM(unreset_limit, 30); /* unreset_check's */
61/* Access speed for attribute memory windows */ 61/* Access speed for attribute memory windows */
62INT_MODULE_PARM(cis_speed, 300); /* ns */ 62INT_MODULE_PARM(cis_speed, 300); /* ns */
63 63
64#ifdef DEBUG 64#ifdef CONFIG_PCMCIA_DEBUG
65static int pc_debug; 65static int pc_debug;
66 66
67module_param(pc_debug, int, 0644); 67module_param(pc_debug, int, 0644);
@@ -247,7 +247,8 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
247 247
248 wait_for_completion(&socket->thread_done); 248 wait_for_completion(&socket->thread_done);
249 if (!socket->thread) { 249 if (!socket->thread) {
250 printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket); 250 dev_printk(KERN_WARNING, &socket->dev,
251 "PCMCIA: warning: socket thread did not start\n");
251 return -EIO; 252 return -EIO;
252 } 253 }
253 254
@@ -366,16 +367,16 @@ static int socket_reset(struct pcmcia_socket *skt)
366 skt->ops->get_status(skt, &status); 367 skt->ops->get_status(skt, &status);
367 368
368 if (!(status & SS_DETECT)) 369 if (!(status & SS_DETECT))
369 return CS_NO_CARD; 370 return -ENODEV;
370 371
371 if (status & SS_READY) 372 if (status & SS_READY)
372 return CS_SUCCESS; 373 return 0;
373 374
374 msleep(unreset_check * 10); 375 msleep(unreset_check * 10);
375 } 376 }
376 377
377 cs_err(skt, "time out after reset.\n"); 378 cs_err(skt, "time out after reset.\n");
378 return CS_GENERAL_FAILURE; 379 return -ETIMEDOUT;
379} 380}
380 381
381/* 382/*
@@ -412,7 +413,8 @@ static void socket_shutdown(struct pcmcia_socket *s)
412 413
413 s->ops->get_status(s, &status); 414 s->ops->get_status(s, &status);
414 if (status & SS_POWERON) { 415 if (status & SS_POWERON) {
415 printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); 416 dev_printk(KERN_ERR, &s->dev,
417 "*** DANGER *** unable to remove socket power\n");
416 } 418 }
417 419
418 cs_socket_put(s); 420 cs_socket_put(s);
@@ -426,14 +428,14 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
426 428
427 skt->ops->get_status(skt, &status); 429 skt->ops->get_status(skt, &status);
428 if (!(status & SS_DETECT)) 430 if (!(status & SS_DETECT))
429 return CS_NO_CARD; 431 return -ENODEV;
430 432
431 msleep(initial_delay * 10); 433 msleep(initial_delay * 10);
432 434
433 for (i = 0; i < 100; i++) { 435 for (i = 0; i < 100; i++) {
434 skt->ops->get_status(skt, &status); 436 skt->ops->get_status(skt, &status);
435 if (!(status & SS_DETECT)) 437 if (!(status & SS_DETECT))
436 return CS_NO_CARD; 438 return -ENODEV;
437 439
438 if (!(status & SS_PENDING)) 440 if (!(status & SS_PENDING))
439 break; 441 break;
@@ -443,13 +445,13 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
443 445
444 if (status & SS_PENDING) { 446 if (status & SS_PENDING) {
445 cs_err(skt, "voltage interrogation timed out.\n"); 447 cs_err(skt, "voltage interrogation timed out.\n");
446 return CS_GENERAL_FAILURE; 448 return -ETIMEDOUT;
447 } 449 }
448 450
449 if (status & SS_CARDBUS) { 451 if (status & SS_CARDBUS) {
450 if (!(skt->features & SS_CAP_CARDBUS)) { 452 if (!(skt->features & SS_CAP_CARDBUS)) {
451 cs_err(skt, "cardbus cards are not supported.\n"); 453 cs_err(skt, "cardbus cards are not supported.\n");
452 return CS_BAD_TYPE; 454 return -EINVAL;
453 } 455 }
454 skt->state |= SOCKET_CARDBUS; 456 skt->state |= SOCKET_CARDBUS;
455 } 457 }
@@ -463,7 +465,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
463 skt->socket.Vcc = skt->socket.Vpp = 50; 465 skt->socket.Vcc = skt->socket.Vpp = 50;
464 else { 466 else {
465 cs_err(skt, "unsupported voltage key.\n"); 467 cs_err(skt, "unsupported voltage key.\n");
466 return CS_BAD_TYPE; 468 return -EIO;
467 } 469 }
468 470
469 if (skt->power_hook) 471 if (skt->power_hook)
@@ -480,7 +482,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
480 skt->ops->get_status(skt, &status); 482 skt->ops->get_status(skt, &status);
481 if (!(status & SS_POWERON)) { 483 if (!(status & SS_POWERON)) {
482 cs_err(skt, "unable to apply power.\n"); 484 cs_err(skt, "unable to apply power.\n");
483 return CS_BAD_TYPE; 485 return -EIO;
484 } 486 }
485 487
486 status = socket_reset(skt); 488 status = socket_reset(skt);
@@ -502,15 +504,16 @@ static int socket_insert(struct pcmcia_socket *skt)
502 cs_dbg(skt, 4, "insert\n"); 504 cs_dbg(skt, 4, "insert\n");
503 505
504 if (!cs_socket_get(skt)) 506 if (!cs_socket_get(skt))
505 return CS_NO_CARD; 507 return -ENODEV;
506 508
507 ret = socket_setup(skt, setup_delay); 509 ret = socket_setup(skt, setup_delay);
508 if (ret == CS_SUCCESS) { 510 if (ret == 0) {
509 skt->state |= SOCKET_PRESENT; 511 skt->state |= SOCKET_PRESENT;
510 512
511 printk(KERN_NOTICE "pccard: %s card inserted into slot %d\n", 513 dev_printk(KERN_NOTICE, &skt->dev,
512 (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", 514 "pccard: %s card inserted into slot %d\n",
513 skt->sock); 515 (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA",
516 skt->sock);
514 517
515#ifdef CONFIG_CARDBUS 518#ifdef CONFIG_CARDBUS
516 if (skt->state & SOCKET_CARDBUS) { 519 if (skt->state & SOCKET_CARDBUS) {
@@ -531,7 +534,7 @@ static int socket_insert(struct pcmcia_socket *skt)
531static int socket_suspend(struct pcmcia_socket *skt) 534static int socket_suspend(struct pcmcia_socket *skt)
532{ 535{
533 if (skt->state & SOCKET_SUSPEND) 536 if (skt->state & SOCKET_SUSPEND)
534 return CS_IN_USE; 537 return -EBUSY;
535 538
536 send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); 539 send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW);
537 skt->socket = dead_socket; 540 skt->socket = dead_socket;
@@ -540,7 +543,7 @@ static int socket_suspend(struct pcmcia_socket *skt)
540 skt->ops->suspend(skt); 543 skt->ops->suspend(skt);
541 skt->state |= SOCKET_SUSPEND; 544 skt->state |= SOCKET_SUSPEND;
542 545
543 return CS_SUCCESS; 546 return 0;
544} 547}
545 548
546/* 549/*
@@ -553,7 +556,7 @@ static int socket_resume(struct pcmcia_socket *skt)
553 int ret; 556 int ret;
554 557
555 if (!(skt->state & SOCKET_SUSPEND)) 558 if (!(skt->state & SOCKET_SUSPEND))
556 return CS_IN_USE; 559 return -EBUSY;
557 560
558 skt->socket = dead_socket; 561 skt->socket = dead_socket;
559 skt->ops->init(skt); 562 skt->ops->init(skt);
@@ -565,7 +568,7 @@ static int socket_resume(struct pcmcia_socket *skt)
565 } 568 }
566 569
567 ret = socket_setup(skt, resume_delay); 570 ret = socket_setup(skt, resume_delay);
568 if (ret == CS_SUCCESS) { 571 if (ret == 0) {
569 /* 572 /*
570 * FIXME: need a better check here for cardbus cards. 573 * FIXME: need a better check here for cardbus cards.
571 */ 574 */
@@ -590,12 +593,13 @@ static int socket_resume(struct pcmcia_socket *skt)
590 593
591 skt->state &= ~SOCKET_SUSPEND; 594 skt->state &= ~SOCKET_SUSPEND;
592 595
593 return CS_SUCCESS; 596 return 0;
594} 597}
595 598
596static void socket_remove(struct pcmcia_socket *skt) 599static void socket_remove(struct pcmcia_socket *skt)
597{ 600{
598 printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock); 601 dev_printk(KERN_NOTICE, &skt->dev,
602 "pccard: card ejected from slot %d\n", skt->sock);
599 socket_shutdown(skt); 603 socket_shutdown(skt);
600} 604}
601 605
@@ -641,8 +645,8 @@ static int pccardd(void *__skt)
641 /* register with the device core */ 645 /* register with the device core */
642 ret = device_register(&skt->dev); 646 ret = device_register(&skt->dev);
643 if (ret) { 647 if (ret) {
644 printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n", 648 dev_printk(KERN_WARNING, &skt->dev,
645 skt); 649 "PCMCIA: unable to register socket\n");
646 skt->thread = NULL; 650 skt->thread = NULL;
647 complete(&skt->thread_done); 651 complete(&skt->thread_done);
648 return 0; 652 return 0;
@@ -748,7 +752,7 @@ EXPORT_SYMBOL(pccard_register_pcmcia);
748 * CIS register. 752 * CIS register.
749 */ 753 */
750 754
751int pccard_reset_card(struct pcmcia_socket *skt) 755int pcmcia_reset_card(struct pcmcia_socket *skt)
752{ 756{
753 int ret; 757 int ret;
754 758
@@ -757,15 +761,15 @@ int pccard_reset_card(struct pcmcia_socket *skt)
757 mutex_lock(&skt->skt_mutex); 761 mutex_lock(&skt->skt_mutex);
758 do { 762 do {
759 if (!(skt->state & SOCKET_PRESENT)) { 763 if (!(skt->state & SOCKET_PRESENT)) {
760 ret = CS_NO_CARD; 764 ret = -ENODEV;
761 break; 765 break;
762 } 766 }
763 if (skt->state & SOCKET_SUSPEND) { 767 if (skt->state & SOCKET_SUSPEND) {
764 ret = CS_IN_USE; 768 ret = -EBUSY;
765 break; 769 break;
766 } 770 }
767 if (skt->state & SOCKET_CARDBUS) { 771 if (skt->state & SOCKET_CARDBUS) {
768 ret = CS_UNSUPPORTED_FUNCTION; 772 ret = -EPERM;
769 break; 773 break;
770 } 774 }
771 775
@@ -774,20 +778,20 @@ int pccard_reset_card(struct pcmcia_socket *skt)
774 send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); 778 send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW);
775 if (skt->callback) 779 if (skt->callback)
776 skt->callback->suspend(skt); 780 skt->callback->suspend(skt);
777 if (socket_reset(skt) == CS_SUCCESS) { 781 if (socket_reset(skt) == 0) {
778 send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); 782 send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW);
779 if (skt->callback) 783 if (skt->callback)
780 skt->callback->resume(skt); 784 skt->callback->resume(skt);
781 } 785 }
782 } 786 }
783 787
784 ret = CS_SUCCESS; 788 ret = 0;
785 } while (0); 789 } while (0);
786 mutex_unlock(&skt->skt_mutex); 790 mutex_unlock(&skt->skt_mutex);
787 791
788 return ret; 792 return ret;
789} /* reset_card */ 793} /* reset_card */
790EXPORT_SYMBOL(pccard_reset_card); 794EXPORT_SYMBOL(pcmcia_reset_card);
791 795
792 796
793/* These shut down or wake up a socket. They are sort of user 797/* These shut down or wake up a socket. They are sort of user
@@ -802,11 +806,11 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt)
802 mutex_lock(&skt->skt_mutex); 806 mutex_lock(&skt->skt_mutex);
803 do { 807 do {
804 if (!(skt->state & SOCKET_PRESENT)) { 808 if (!(skt->state & SOCKET_PRESENT)) {
805 ret = CS_NO_CARD; 809 ret = -ENODEV;
806 break; 810 break;
807 } 811 }
808 if (skt->state & SOCKET_CARDBUS) { 812 if (skt->state & SOCKET_CARDBUS) {
809 ret = CS_UNSUPPORTED_FUNCTION; 813 ret = -EPERM;
810 break; 814 break;
811 } 815 }
812 if (skt->callback) { 816 if (skt->callback) {
@@ -832,11 +836,11 @@ int pcmcia_resume_card(struct pcmcia_socket *skt)
832 mutex_lock(&skt->skt_mutex); 836 mutex_lock(&skt->skt_mutex);
833 do { 837 do {
834 if (!(skt->state & SOCKET_PRESENT)) { 838 if (!(skt->state & SOCKET_PRESENT)) {
835 ret = CS_NO_CARD; 839 ret = -ENODEV;
836 break; 840 break;
837 } 841 }
838 if (skt->state & SOCKET_CARDBUS) { 842 if (skt->state & SOCKET_CARDBUS) {
839 ret = CS_UNSUPPORTED_FUNCTION; 843 ret = -EPERM;
840 break; 844 break;
841 } 845 }
842 ret = socket_resume(skt); 846 ret = socket_resume(skt);
@@ -892,7 +896,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
892 ret = -EBUSY; 896 ret = -EBUSY;
893 break; 897 break;
894 } 898 }
895 if (socket_insert(skt) == CS_NO_CARD) { 899 if (socket_insert(skt) == -ENODEV) {
896 ret = -ENODEV; 900 ret = -ENODEV;
897 break; 901 break;
898 } 902 }