aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-01-10 15:20:36 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:02:19 -0500
commit7fe908dd11e0c947bb72baa5b001d7abe5a420d5 (patch)
treedbd6db7a79476aee256a453f33bbe08c6b3a0cc1 /drivers/pcmcia/cs.c
parentcbbddd1046d44d90d31c7f246ed0207117602b89 (diff)
[PATCH] pcmcia: use mutexes instead of semaphores
Use mutexes in the PCMICA core, as they suffice for what needs to be done. Includes a bugfix from and Signed-off-by Andrew Morton. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/cs.c')
-rw-r--r--drivers/pcmcia/cs.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 45cffbf285c2..907a6768e994 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -111,9 +111,9 @@ int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state)
111 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) { 111 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
112 if (socket->dev.dev != dev) 112 if (socket->dev.dev != dev)
113 continue; 113 continue;
114 down(&socket->skt_sem); 114 mutex_lock(&socket->skt_mutex);
115 socket_suspend(socket); 115 socket_suspend(socket);
116 up(&socket->skt_sem); 116 mutex_unlock(&socket->skt_mutex);
117 } 117 }
118 up_read(&pcmcia_socket_list_rwsem); 118 up_read(&pcmcia_socket_list_rwsem);
119 119
@@ -129,9 +129,9 @@ int pcmcia_socket_dev_resume(struct device *dev)
129 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) { 129 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
130 if (socket->dev.dev != dev) 130 if (socket->dev.dev != dev)
131 continue; 131 continue;
132 down(&socket->skt_sem); 132 mutex_lock(&socket->skt_mutex);
133 socket_resume(socket); 133 socket_resume(socket);
134 up(&socket->skt_sem); 134 mutex_unlock(&socket->skt_mutex);
135 } 135 }
136 up_read(&pcmcia_socket_list_rwsem); 136 up_read(&pcmcia_socket_list_rwsem);
137 137
@@ -237,7 +237,7 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
237 init_completion(&socket->socket_released); 237 init_completion(&socket->socket_released);
238 init_completion(&socket->thread_done); 238 init_completion(&socket->thread_done);
239 init_waitqueue_head(&socket->thread_wait); 239 init_waitqueue_head(&socket->thread_wait);
240 init_MUTEX(&socket->skt_sem); 240 mutex_init(&socket->skt_mutex);
241 spin_lock_init(&socket->thread_lock); 241 spin_lock_init(&socket->thread_lock);
242 242
243 ret = kernel_thread(pccardd, socket, CLONE_KERNEL); 243 ret = kernel_thread(pccardd, socket, CLONE_KERNEL);
@@ -662,7 +662,7 @@ static int pccardd(void *__skt)
662 spin_unlock_irqrestore(&skt->thread_lock, flags); 662 spin_unlock_irqrestore(&skt->thread_lock, flags);
663 663
664 if (events) { 664 if (events) {
665 down(&skt->skt_sem); 665 mutex_lock(&skt->skt_mutex);
666 if (events & SS_DETECT) 666 if (events & SS_DETECT)
667 socket_detect_change(skt); 667 socket_detect_change(skt);
668 if (events & SS_BATDEAD) 668 if (events & SS_BATDEAD)
@@ -671,7 +671,7 @@ static int pccardd(void *__skt)
671 send_event(skt, CS_EVENT_BATTERY_LOW, CS_EVENT_PRI_LOW); 671 send_event(skt, CS_EVENT_BATTERY_LOW, CS_EVENT_PRI_LOW);
672 if (events & SS_READY) 672 if (events & SS_READY)
673 send_event(skt, CS_EVENT_READY_CHANGE, CS_EVENT_PRI_LOW); 673 send_event(skt, CS_EVENT_READY_CHANGE, CS_EVENT_PRI_LOW);
674 up(&skt->skt_sem); 674 mutex_unlock(&skt->skt_mutex);
675 continue; 675 continue;
676 } 676 }
677 677
@@ -715,8 +715,8 @@ int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c)
715{ 715{
716 int ret = 0; 716 int ret = 0;
717 717
718 /* s->skt_sem also protects s->callback */ 718 /* s->skt_mutex also protects s->callback */
719 down(&s->skt_sem); 719 mutex_lock(&s->skt_mutex);
720 720
721 if (c) { 721 if (c) {
722 /* registration */ 722 /* registration */
@@ -732,7 +732,7 @@ int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c)
732 } else 732 } else
733 s->callback = NULL; 733 s->callback = NULL;
734 err: 734 err:
735 up(&s->skt_sem); 735 mutex_unlock(&s->skt_mutex);
736 736
737 return ret; 737 return ret;
738} 738}
@@ -750,7 +750,7 @@ int pccard_reset_card(struct pcmcia_socket *skt)
750 750
751 cs_dbg(skt, 1, "resetting socket\n"); 751 cs_dbg(skt, 1, "resetting socket\n");
752 752
753 down(&skt->skt_sem); 753 mutex_lock(&skt->skt_mutex);
754 do { 754 do {
755 if (!(skt->state & SOCKET_PRESENT)) { 755 if (!(skt->state & SOCKET_PRESENT)) {
756 ret = CS_NO_CARD; 756 ret = CS_NO_CARD;
@@ -779,7 +779,7 @@ int pccard_reset_card(struct pcmcia_socket *skt)
779 779
780 ret = CS_SUCCESS; 780 ret = CS_SUCCESS;
781 } while (0); 781 } while (0);
782 up(&skt->skt_sem); 782 mutex_unlock(&skt->skt_mutex);
783 783
784 return ret; 784 return ret;
785} /* reset_card */ 785} /* reset_card */
@@ -795,7 +795,7 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt)
795 795
796 cs_dbg(skt, 1, "suspending socket\n"); 796 cs_dbg(skt, 1, "suspending socket\n");
797 797
798 down(&skt->skt_sem); 798 mutex_lock(&skt->skt_mutex);
799 do { 799 do {
800 if (!(skt->state & SOCKET_PRESENT)) { 800 if (!(skt->state & SOCKET_PRESENT)) {
801 ret = CS_NO_CARD; 801 ret = CS_NO_CARD;
@@ -812,7 +812,7 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt)
812 } 812 }
813 ret = socket_suspend(skt); 813 ret = socket_suspend(skt);
814 } while (0); 814 } while (0);
815 up(&skt->skt_sem); 815 mutex_unlock(&skt->skt_mutex);
816 816
817 return ret; 817 return ret;
818} /* suspend_card */ 818} /* suspend_card */
@@ -825,7 +825,7 @@ int pcmcia_resume_card(struct pcmcia_socket *skt)
825 825
826 cs_dbg(skt, 1, "waking up socket\n"); 826 cs_dbg(skt, 1, "waking up socket\n");
827 827
828 down(&skt->skt_sem); 828 mutex_lock(&skt->skt_mutex);
829 do { 829 do {
830 if (!(skt->state & SOCKET_PRESENT)) { 830 if (!(skt->state & SOCKET_PRESENT)) {
831 ret = CS_NO_CARD; 831 ret = CS_NO_CARD;
@@ -839,7 +839,7 @@ int pcmcia_resume_card(struct pcmcia_socket *skt)
839 if (!ret && skt->callback) 839 if (!ret && skt->callback)
840 skt->callback->resume(skt); 840 skt->callback->resume(skt);
841 } while (0); 841 } while (0);
842 up(&skt->skt_sem); 842 mutex_unlock(&skt->skt_mutex);
843 843
844 return ret; 844 return ret;
845} /* resume_card */ 845} /* resume_card */
@@ -853,7 +853,7 @@ int pcmcia_eject_card(struct pcmcia_socket *skt)
853 853
854 cs_dbg(skt, 1, "user eject request\n"); 854 cs_dbg(skt, 1, "user eject request\n");
855 855
856 down(&skt->skt_sem); 856 mutex_lock(&skt->skt_mutex);
857 do { 857 do {
858 if (!(skt->state & SOCKET_PRESENT)) { 858 if (!(skt->state & SOCKET_PRESENT)) {
859 ret = -ENODEV; 859 ret = -ENODEV;
@@ -869,7 +869,7 @@ int pcmcia_eject_card(struct pcmcia_socket *skt)
869 socket_remove(skt); 869 socket_remove(skt);
870 ret = 0; 870 ret = 0;
871 } while (0); 871 } while (0);
872 up(&skt->skt_sem); 872 mutex_unlock(&skt->skt_mutex);
873 873
874 return ret; 874 return ret;
875} /* eject_card */ 875} /* eject_card */
@@ -882,7 +882,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
882 882
883 cs_dbg(skt, 1, "user insert request\n"); 883 cs_dbg(skt, 1, "user insert request\n");
884 884
885 down(&skt->skt_sem); 885 mutex_lock(&skt->skt_mutex);
886 do { 886 do {
887 if (skt->state & SOCKET_PRESENT) { 887 if (skt->state & SOCKET_PRESENT) {
888 ret = -EBUSY; 888 ret = -EBUSY;
@@ -894,7 +894,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
894 } 894 }
895 ret = 0; 895 ret = 0;
896 } while (0); 896 } while (0);
897 up(&skt->skt_sem); 897 mutex_unlock(&skt->skt_mutex);
898 898
899 return ret; 899 return ret;
900} /* insert_card */ 900} /* insert_card */