diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-01-15 18:26:33 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-02-17 11:48:16 -0500 |
commit | 9e86749cff70fca505c7c1a9dc760d193f27a059 (patch) | |
tree | 3017dc3c22c12c7ef53fd81de6d4869f212cef02 /drivers/pcmcia/cs.c | |
parent | 8533ee31cdc08fc1f2533e5f21f8e4abf6a57dfc (diff) |
pcmcia: lock ops->set_socket
As a side effect,
socket_state_t socket;
u_int state;
u_int suspended_state;
are properly protected now.
Tested-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/cs.c')
-rw-r--r-- | drivers/pcmcia/cs.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 91aa1f284068..cc0ba8aef59e 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c | |||
@@ -383,6 +383,8 @@ static void socket_shutdown(struct pcmcia_socket *s) | |||
383 | dev_dbg(&s->dev, "shutdown\n"); | 383 | dev_dbg(&s->dev, "shutdown\n"); |
384 | 384 | ||
385 | send_event(s, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH); | 385 | send_event(s, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH); |
386 | |||
387 | mutex_lock(&s->ops_mutex); | ||
386 | s->state &= SOCKET_INUSE | SOCKET_PRESENT; | 388 | s->state &= SOCKET_INUSE | SOCKET_PRESENT; |
387 | msleep(shutdown_delay * 10); | 389 | msleep(shutdown_delay * 10); |
388 | s->state &= SOCKET_INUSE; | 390 | s->state &= SOCKET_INUSE; |
@@ -410,6 +412,7 @@ static void socket_shutdown(struct pcmcia_socket *s) | |||
410 | } | 412 | } |
411 | 413 | ||
412 | s->state &= ~SOCKET_INUSE; | 414 | s->state &= ~SOCKET_INUSE; |
415 | mutex_unlock(&s->ops_mutex); | ||
413 | } | 416 | } |
414 | 417 | ||
415 | static int socket_setup(struct pcmcia_socket *skt, int initial_delay) | 418 | static int socket_setup(struct pcmcia_socket *skt, int initial_delay) |
@@ -498,6 +501,7 @@ static int socket_insert(struct pcmcia_socket *skt) | |||
498 | 501 | ||
499 | dev_dbg(&skt->dev, "insert\n"); | 502 | dev_dbg(&skt->dev, "insert\n"); |
500 | 503 | ||
504 | mutex_lock(&skt->ops_mutex); | ||
501 | WARN_ON(skt->state & SOCKET_INUSE); | 505 | WARN_ON(skt->state & SOCKET_INUSE); |
502 | skt->state |= SOCKET_INUSE; | 506 | skt->state |= SOCKET_INUSE; |
503 | 507 | ||
@@ -517,9 +521,11 @@ static int socket_insert(struct pcmcia_socket *skt) | |||
517 | } | 521 | } |
518 | #endif | 522 | #endif |
519 | dev_dbg(&skt->dev, "insert done\n"); | 523 | dev_dbg(&skt->dev, "insert done\n"); |
524 | mutex_unlock(&skt->ops_mutex); | ||
520 | 525 | ||
521 | send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW); | 526 | send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW); |
522 | } else { | 527 | } else { |
528 | mutex_unlock(&skt->ops_mutex); | ||
523 | socket_shutdown(skt); | 529 | socket_shutdown(skt); |
524 | } | 530 | } |
525 | 531 | ||
@@ -531,6 +537,7 @@ static int socket_suspend(struct pcmcia_socket *skt) | |||
531 | if (skt->state & SOCKET_SUSPEND) | 537 | if (skt->state & SOCKET_SUSPEND) |
532 | return -EBUSY; | 538 | return -EBUSY; |
533 | 539 | ||
540 | mutex_lock(&skt->ops_mutex); | ||
534 | skt->suspended_state = skt->state; | 541 | skt->suspended_state = skt->state; |
535 | 542 | ||
536 | send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); | 543 | send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); |
@@ -539,23 +546,27 @@ static int socket_suspend(struct pcmcia_socket *skt) | |||
539 | if (skt->ops->suspend) | 546 | if (skt->ops->suspend) |
540 | skt->ops->suspend(skt); | 547 | skt->ops->suspend(skt); |
541 | skt->state |= SOCKET_SUSPEND; | 548 | skt->state |= SOCKET_SUSPEND; |
542 | 549 | mutex_unlock(&skt->ops_mutex); | |
543 | return 0; | 550 | return 0; |
544 | } | 551 | } |
545 | 552 | ||
546 | static int socket_early_resume(struct pcmcia_socket *skt) | 553 | static int socket_early_resume(struct pcmcia_socket *skt) |
547 | { | 554 | { |
555 | mutex_lock(&skt->ops_mutex); | ||
548 | skt->socket = dead_socket; | 556 | skt->socket = dead_socket; |
549 | skt->ops->init(skt); | 557 | skt->ops->init(skt); |
550 | skt->ops->set_socket(skt, &skt->socket); | 558 | skt->ops->set_socket(skt, &skt->socket); |
551 | if (skt->state & SOCKET_PRESENT) | 559 | if (skt->state & SOCKET_PRESENT) |
552 | skt->resume_status = socket_setup(skt, resume_delay); | 560 | skt->resume_status = socket_setup(skt, resume_delay); |
561 | mutex_unlock(&skt->ops_mutex); | ||
553 | return 0; | 562 | return 0; |
554 | } | 563 | } |
555 | 564 | ||
556 | static int socket_late_resume(struct pcmcia_socket *skt) | 565 | static int socket_late_resume(struct pcmcia_socket *skt) |
557 | { | 566 | { |
567 | mutex_lock(&skt->ops_mutex); | ||
558 | skt->state &= ~SOCKET_SUSPEND; | 568 | skt->state &= ~SOCKET_SUSPEND; |
569 | mutex_unlock(&skt->ops_mutex); | ||
559 | 570 | ||
560 | if (!(skt->state & SOCKET_PRESENT)) | 571 | if (!(skt->state & SOCKET_PRESENT)) |
561 | return socket_insert(skt); | 572 | return socket_insert(skt); |
@@ -795,7 +806,10 @@ int pcmcia_reset_card(struct pcmcia_socket *skt) | |||
795 | send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); | 806 | send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); |
796 | if (skt->callback) | 807 | if (skt->callback) |
797 | skt->callback->suspend(skt); | 808 | skt->callback->suspend(skt); |
798 | if (socket_reset(skt) == 0) { | 809 | mutex_lock(&skt->ops_mutex); |
810 | ret = socket_reset(skt); | ||
811 | mutex_unlock(&skt->ops_mutex); | ||
812 | if (ret == 0) { | ||
799 | send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); | 813 | send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); |
800 | if (skt->callback) | 814 | if (skt->callback) |
801 | skt->callback->resume(skt); | 815 | skt->callback->resume(skt); |