aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/cs.c')
-rw-r--r--drivers/pcmcia/cs.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 698d75cda084..790af87a922f 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -61,17 +61,6 @@ 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 CONFIG_PCMCIA_DEBUG
65static int pc_debug;
66
67module_param(pc_debug, int, 0644);
68
69int cs_debug_level(int level)
70{
71 return pc_debug > level;
72}
73#endif
74
75 64
76socket_state_t dead_socket = { 65socket_state_t dead_socket = {
77 .csc_mask = SS_DETECT, 66 .csc_mask = SS_DETECT,
@@ -190,7 +179,7 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
190 if (!socket || !socket->ops || !socket->dev.parent || !socket->resource_ops) 179 if (!socket || !socket->ops || !socket->dev.parent || !socket->resource_ops)
191 return -EINVAL; 180 return -EINVAL;
192 181
193 cs_dbg(socket, 0, "pcmcia_register_socket(0x%p)\n", socket->ops); 182 dev_dbg(&socket->dev, "pcmcia_register_socket(0x%p)\n", socket->ops);
194 183
195 spin_lock_init(&socket->lock); 184 spin_lock_init(&socket->lock);
196 185
@@ -262,6 +251,13 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
262 251
263 pcmcia_parse_events(socket, SS_DETECT); 252 pcmcia_parse_events(socket, SS_DETECT);
264 253
254 /*
255 * Let's try to get the PCMCIA module for 16-bit PCMCIA support.
256 * If it fails, it doesn't matter -- we still have 32-bit CardBus
257 * support to offer, so this is not a failure mode.
258 */
259 request_module_nowait("pcmcia");
260
265 return 0; 261 return 0;
266 262
267 err: 263 err:
@@ -282,7 +278,7 @@ void pcmcia_unregister_socket(struct pcmcia_socket *socket)
282 if (!socket) 278 if (!socket)
283 return; 279 return;
284 280
285 cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops); 281 dev_dbg(&socket->dev, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
286 282
287 if (socket->thread) 283 if (socket->thread)
288 kthread_stop(socket->thread); 284 kthread_stop(socket->thread);
@@ -335,7 +331,7 @@ static int send_event(struct pcmcia_socket *s, event_t event, int priority)
335 if (s->state & SOCKET_CARDBUS) 331 if (s->state & SOCKET_CARDBUS)
336 return 0; 332 return 0;
337 333
338 cs_dbg(s, 1, "send_event(event %d, pri %d, callback 0x%p)\n", 334 dev_dbg(&s->dev, "send_event(event %d, pri %d, callback 0x%p)\n",
339 event, priority, s->callback); 335 event, priority, s->callback);
340 336
341 if (!s->callback) 337 if (!s->callback)
@@ -352,7 +348,7 @@ static int send_event(struct pcmcia_socket *s, event_t event, int priority)
352 348
353static void socket_remove_drivers(struct pcmcia_socket *skt) 349static void socket_remove_drivers(struct pcmcia_socket *skt)
354{ 350{
355 cs_dbg(skt, 4, "remove_drivers\n"); 351 dev_dbg(&skt->dev, "remove_drivers\n");
356 352
357 send_event(skt, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH); 353 send_event(skt, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH);
358} 354}
@@ -361,7 +357,7 @@ static int socket_reset(struct pcmcia_socket *skt)
361{ 357{
362 int status, i; 358 int status, i;
363 359
364 cs_dbg(skt, 4, "reset\n"); 360 dev_dbg(&skt->dev, "reset\n");
365 361
366 skt->socket.flags |= SS_OUTPUT_ENA | SS_RESET; 362 skt->socket.flags |= SS_OUTPUT_ENA | SS_RESET;
367 skt->ops->set_socket(skt, &skt->socket); 363 skt->ops->set_socket(skt, &skt->socket);
@@ -383,7 +379,7 @@ static int socket_reset(struct pcmcia_socket *skt)
383 msleep(unreset_check * 10); 379 msleep(unreset_check * 10);
384 } 380 }
385 381
386 cs_err(skt, "time out after reset.\n"); 382 dev_printk(KERN_ERR, &skt->dev, "time out after reset.\n");
387 return -ETIMEDOUT; 383 return -ETIMEDOUT;
388} 384}
389 385
@@ -397,7 +393,7 @@ static void socket_shutdown(struct pcmcia_socket *s)
397{ 393{
398 int status; 394 int status;
399 395
400 cs_dbg(s, 4, "shutdown\n"); 396 dev_dbg(&s->dev, "shutdown\n");
401 397
402 socket_remove_drivers(s); 398 socket_remove_drivers(s);
403 s->state &= SOCKET_INUSE | SOCKET_PRESENT; 399 s->state &= SOCKET_INUSE | SOCKET_PRESENT;
@@ -432,7 +428,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
432{ 428{
433 int status, i; 429 int status, i;
434 430
435 cs_dbg(skt, 4, "setup\n"); 431 dev_dbg(&skt->dev, "setup\n");
436 432
437 skt->ops->get_status(skt, &status); 433 skt->ops->get_status(skt, &status);
438 if (!(status & SS_DETECT)) 434 if (!(status & SS_DETECT))
@@ -452,13 +448,15 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
452 } 448 }
453 449
454 if (status & SS_PENDING) { 450 if (status & SS_PENDING) {
455 cs_err(skt, "voltage interrogation timed out.\n"); 451 dev_printk(KERN_ERR, &skt->dev,
452 "voltage interrogation timed out.\n");
456 return -ETIMEDOUT; 453 return -ETIMEDOUT;
457 } 454 }
458 455
459 if (status & SS_CARDBUS) { 456 if (status & SS_CARDBUS) {
460 if (!(skt->features & SS_CAP_CARDBUS)) { 457 if (!(skt->features & SS_CAP_CARDBUS)) {
461 cs_err(skt, "cardbus cards are not supported.\n"); 458 dev_printk(KERN_ERR, &skt->dev,
459 "cardbus cards are not supported.\n");
462 return -EINVAL; 460 return -EINVAL;
463 } 461 }
464 skt->state |= SOCKET_CARDBUS; 462 skt->state |= SOCKET_CARDBUS;
@@ -472,7 +470,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
472 else if (!(status & SS_XVCARD)) 470 else if (!(status & SS_XVCARD))
473 skt->socket.Vcc = skt->socket.Vpp = 50; 471 skt->socket.Vcc = skt->socket.Vpp = 50;
474 else { 472 else {
475 cs_err(skt, "unsupported voltage key.\n"); 473 dev_printk(KERN_ERR, &skt->dev, "unsupported voltage key.\n");
476 return -EIO; 474 return -EIO;
477 } 475 }
478 476
@@ -489,7 +487,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
489 487
490 skt->ops->get_status(skt, &status); 488 skt->ops->get_status(skt, &status);
491 if (!(status & SS_POWERON)) { 489 if (!(status & SS_POWERON)) {
492 cs_err(skt, "unable to apply power.\n"); 490 dev_printk(KERN_ERR, &skt->dev, "unable to apply power.\n");
493 return -EIO; 491 return -EIO;
494 } 492 }
495 493
@@ -509,7 +507,7 @@ static int socket_insert(struct pcmcia_socket *skt)
509{ 507{
510 int ret; 508 int ret;
511 509
512 cs_dbg(skt, 4, "insert\n"); 510 dev_dbg(&skt->dev, "insert\n");
513 511
514 if (!cs_socket_get(skt)) 512 if (!cs_socket_get(skt))
515 return -ENODEV; 513 return -ENODEV;
@@ -529,7 +527,7 @@ static int socket_insert(struct pcmcia_socket *skt)
529 skt->state |= SOCKET_CARDBUS_CONFIG; 527 skt->state |= SOCKET_CARDBUS_CONFIG;
530 } 528 }
531#endif 529#endif
532 cs_dbg(skt, 4, "insert done\n"); 530 dev_dbg(&skt->dev, "insert done\n");
533 531
534 send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW); 532 send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
535 } else { 533 } else {
@@ -576,7 +574,7 @@ static int socket_late_resume(struct pcmcia_socket *skt)
576 * FIXME: need a better check here for cardbus cards. 574 * FIXME: need a better check here for cardbus cards.
577 */ 575 */
578 if (verify_cis_cache(skt) != 0) { 576 if (verify_cis_cache(skt) != 0) {
579 cs_dbg(skt, 4, "cis mismatch - different card\n"); 577 dev_dbg(&skt->dev, "cis mismatch - different card\n");
580 socket_remove_drivers(skt); 578 socket_remove_drivers(skt);
581 destroy_cis_cache(skt); 579 destroy_cis_cache(skt);
582 /* 580 /*
@@ -587,7 +585,7 @@ static int socket_late_resume(struct pcmcia_socket *skt)
587 msleep(200); 585 msleep(200);
588 send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW); 586 send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
589 } else { 587 } else {
590 cs_dbg(skt, 4, "cis matches cache\n"); 588 dev_dbg(&skt->dev, "cis matches cache\n");
591 send_event(skt, CS_EVENT_PM_RESUME, CS_EVENT_PRI_LOW); 589 send_event(skt, CS_EVENT_PM_RESUME, CS_EVENT_PRI_LOW);
592 } 590 }
593 } else { 591 } else {
@@ -723,7 +721,7 @@ static int pccardd(void *__skt)
723void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) 721void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
724{ 722{
725 unsigned long flags; 723 unsigned long flags;
726 cs_dbg(s, 4, "parse_events: events %08x\n", events); 724 dev_dbg(&s->dev, "parse_events: events %08x\n", events);
727 if (s->thread) { 725 if (s->thread) {
728 spin_lock_irqsave(&s->thread_lock, flags); 726 spin_lock_irqsave(&s->thread_lock, flags);
729 s->thread_events |= events; 727 s->thread_events |= events;
@@ -773,19 +771,22 @@ int pcmcia_reset_card(struct pcmcia_socket *skt)
773{ 771{
774 int ret; 772 int ret;
775 773
776 cs_dbg(skt, 1, "resetting socket\n"); 774 dev_dbg(&skt->dev, "resetting socket\n");
777 775
778 mutex_lock(&skt->skt_mutex); 776 mutex_lock(&skt->skt_mutex);
779 do { 777 do {
780 if (!(skt->state & SOCKET_PRESENT)) { 778 if (!(skt->state & SOCKET_PRESENT)) {
779 dev_dbg(&skt->dev, "can't reset, not present\n");
781 ret = -ENODEV; 780 ret = -ENODEV;
782 break; 781 break;
783 } 782 }
784 if (skt->state & SOCKET_SUSPEND) { 783 if (skt->state & SOCKET_SUSPEND) {
784 dev_dbg(&skt->dev, "can't reset, suspended\n");
785 ret = -EBUSY; 785 ret = -EBUSY;
786 break; 786 break;
787 } 787 }
788 if (skt->state & SOCKET_CARDBUS) { 788 if (skt->state & SOCKET_CARDBUS) {
789 dev_dbg(&skt->dev, "can't reset, is cardbus\n");
789 ret = -EPERM; 790 ret = -EPERM;
790 break; 791 break;
791 } 792 }
@@ -818,7 +819,7 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt)
818{ 819{
819 int ret; 820 int ret;
820 821
821 cs_dbg(skt, 1, "suspending socket\n"); 822 dev_dbg(&skt->dev, "suspending socket\n");
822 823
823 mutex_lock(&skt->skt_mutex); 824 mutex_lock(&skt->skt_mutex);
824 do { 825 do {
@@ -848,7 +849,7 @@ int pcmcia_resume_card(struct pcmcia_socket *skt)
848{ 849{
849 int ret; 850 int ret;
850 851
851 cs_dbg(skt, 1, "waking up socket\n"); 852 dev_dbg(&skt->dev, "waking up socket\n");
852 853
853 mutex_lock(&skt->skt_mutex); 854 mutex_lock(&skt->skt_mutex);
854 do { 855 do {
@@ -876,7 +877,7 @@ int pcmcia_eject_card(struct pcmcia_socket *skt)
876{ 877{
877 int ret; 878 int ret;
878 879
879 cs_dbg(skt, 1, "user eject request\n"); 880 dev_dbg(&skt->dev, "user eject request\n");
880 881
881 mutex_lock(&skt->skt_mutex); 882 mutex_lock(&skt->skt_mutex);
882 do { 883 do {
@@ -905,7 +906,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
905{ 906{
906 int ret; 907 int ret;
907 908
908 cs_dbg(skt, 1, "user insert request\n"); 909 dev_dbg(&skt->dev, "user insert request\n");
909 910
910 mutex_lock(&skt->skt_mutex); 911 mutex_lock(&skt->skt_mutex);
911 do { 912 do {