aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/rsrc_nonstatic.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/rsrc_nonstatic.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/rsrc_nonstatic.c')
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 5301ac60358f..6da4a03d68e4 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -61,7 +61,7 @@ struct socket_data {
61 unsigned int rsrc_mem_probe; 61 unsigned int rsrc_mem_probe;
62}; 62};
63 63
64static DECLARE_MUTEX(rsrc_sem); 64static DEFINE_MUTEX(rsrc_mutex);
65#define MEM_PROBE_LOW (1 << 0) 65#define MEM_PROBE_LOW (1 << 0)
66#define MEM_PROBE_HIGH (1 << 1) 66#define MEM_PROBE_HIGH (1 << 1)
67 67
@@ -484,7 +484,7 @@ static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
484 484
485 485
486/* 486/*
487 * Locking note: Must be called with skt_sem held! 487 * Locking note: Must be called with skt_mutex held!
488 */ 488 */
489static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s) 489static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
490{ 490{
@@ -495,7 +495,7 @@ static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
495 if (!probe_mem) 495 if (!probe_mem)
496 return 0; 496 return 0;
497 497
498 down(&rsrc_sem); 498 mutex_lock(&rsrc_mutex);
499 499
500 if (s->features & SS_CAP_PAGE_REGS) 500 if (s->features & SS_CAP_PAGE_REGS)
501 probe_mask = MEM_PROBE_HIGH; 501 probe_mask = MEM_PROBE_HIGH;
@@ -507,7 +507,7 @@ static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
507 s_data->rsrc_mem_probe |= probe_mask; 507 s_data->rsrc_mem_probe |= probe_mask;
508 } 508 }
509 509
510 up(&rsrc_sem); 510 mutex_unlock(&rsrc_mutex);
511 511
512 return ret; 512 return ret;
513} 513}
@@ -585,7 +585,7 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
585 struct socket_data *s_data = s->resource_data; 585 struct socket_data *s_data = s->resource_data;
586 int ret = -ENOMEM; 586 int ret = -ENOMEM;
587 587
588 down(&rsrc_sem); 588 mutex_lock(&rsrc_mutex);
589 for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) { 589 for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) {
590 unsigned long start = m->base; 590 unsigned long start = m->base;
591 unsigned long end = m->base + m->num - 1; 591 unsigned long end = m->base + m->num - 1;
@@ -596,7 +596,7 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
596 ret = adjust_resource(res, r_start, r_end - r_start + 1); 596 ret = adjust_resource(res, r_start, r_end - r_start + 1);
597 break; 597 break;
598 } 598 }
599 up(&rsrc_sem); 599 mutex_unlock(&rsrc_mutex);
600 600
601 return ret; 601 return ret;
602} 602}
@@ -630,7 +630,7 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
630 data.offset = base & data.mask; 630 data.offset = base & data.mask;
631 data.map = &s_data->io_db; 631 data.map = &s_data->io_db;
632 632
633 down(&rsrc_sem); 633 mutex_lock(&rsrc_mutex);
634#ifdef CONFIG_PCI 634#ifdef CONFIG_PCI
635 if (s->cb_dev) { 635 if (s->cb_dev) {
636 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1, 636 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
@@ -639,7 +639,7 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
639#endif 639#endif
640 ret = allocate_resource(&ioport_resource, res, num, min, ~0UL, 640 ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
641 1, pcmcia_align, &data); 641 1, pcmcia_align, &data);
642 up(&rsrc_sem); 642 mutex_unlock(&rsrc_mutex);
643 643
644 if (ret != 0) { 644 if (ret != 0) {
645 kfree(res); 645 kfree(res);
@@ -672,7 +672,7 @@ static struct resource * nonstatic_find_mem_region(u_long base, u_long num,
672 min = 0x100000UL + base; 672 min = 0x100000UL + base;
673 } 673 }
674 674
675 down(&rsrc_sem); 675 mutex_lock(&rsrc_mutex);
676#ifdef CONFIG_PCI 676#ifdef CONFIG_PCI
677 if (s->cb_dev) { 677 if (s->cb_dev) {
678 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 678 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num,
@@ -682,7 +682,7 @@ static struct resource * nonstatic_find_mem_region(u_long base, u_long num,
682#endif 682#endif
683 ret = allocate_resource(&iomem_resource, res, num, min, 683 ret = allocate_resource(&iomem_resource, res, num, min,
684 max, 1, pcmcia_align, &data); 684 max, 1, pcmcia_align, &data);
685 up(&rsrc_sem); 685 mutex_unlock(&rsrc_mutex);
686 if (ret == 0 || low) 686 if (ret == 0 || low)
687 break; 687 break;
688 low = 1; 688 low = 1;
@@ -705,7 +705,7 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
705 if (end < start) 705 if (end < start)
706 return -EINVAL; 706 return -EINVAL;
707 707
708 down(&rsrc_sem); 708 mutex_lock(&rsrc_mutex);
709 switch (action) { 709 switch (action) {
710 case ADD_MANAGED_RESOURCE: 710 case ADD_MANAGED_RESOURCE:
711 ret = add_interval(&data->mem_db, start, size); 711 ret = add_interval(&data->mem_db, start, size);
@@ -723,7 +723,7 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
723 default: 723 default:
724 ret = -EINVAL; 724 ret = -EINVAL;
725 } 725 }
726 up(&rsrc_sem); 726 mutex_unlock(&rsrc_mutex);
727 727
728 return ret; 728 return ret;
729} 729}
@@ -741,7 +741,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
741 if (end > IO_SPACE_LIMIT) 741 if (end > IO_SPACE_LIMIT)
742 return -EINVAL; 742 return -EINVAL;
743 743
744 down(&rsrc_sem); 744 mutex_lock(&rsrc_mutex);
745 switch (action) { 745 switch (action) {
746 case ADD_MANAGED_RESOURCE: 746 case ADD_MANAGED_RESOURCE:
747 if (add_interval(&data->io_db, start, size) != 0) { 747 if (add_interval(&data->io_db, start, size) != 0) {
@@ -760,7 +760,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
760 ret = -EINVAL; 760 ret = -EINVAL;
761 break; 761 break;
762 } 762 }
763 up(&rsrc_sem); 763 mutex_unlock(&rsrc_mutex);
764 764
765 return ret; 765 return ret;
766} 766}
@@ -867,7 +867,7 @@ static void nonstatic_release_resource_db(struct pcmcia_socket *s)
867 struct socket_data *data = s->resource_data; 867 struct socket_data *data = s->resource_data;
868 struct resource_map *p, *q; 868 struct resource_map *p, *q;
869 869
870 down(&rsrc_sem); 870 mutex_lock(&rsrc_mutex);
871 for (p = data->mem_db.next; p != &data->mem_db; p = q) { 871 for (p = data->mem_db.next; p != &data->mem_db; p = q) {
872 q = p->next; 872 q = p->next;
873 kfree(p); 873 kfree(p);
@@ -876,7 +876,7 @@ static void nonstatic_release_resource_db(struct pcmcia_socket *s)
876 q = p->next; 876 q = p->next;
877 kfree(p); 877 kfree(p);
878 } 878 }
879 up(&rsrc_sem); 879 mutex_unlock(&rsrc_mutex);
880} 880}
881 881
882 882
@@ -901,7 +901,7 @@ static ssize_t show_io_db(struct class_device *class_dev, char *buf)
901 struct resource_map *p; 901 struct resource_map *p;
902 ssize_t ret = 0; 902 ssize_t ret = 0;
903 903
904 down(&rsrc_sem); 904 mutex_lock(&rsrc_mutex);
905 data = s->resource_data; 905 data = s->resource_data;
906 906
907 for (p = data->io_db.next; p != &data->io_db; p = p->next) { 907 for (p = data->io_db.next; p != &data->io_db; p = p->next) {
@@ -913,7 +913,7 @@ static ssize_t show_io_db(struct class_device *class_dev, char *buf)
913 ((unsigned long) p->base + p->num - 1)); 913 ((unsigned long) p->base + p->num - 1));
914 } 914 }
915 915
916 up(&rsrc_sem); 916 mutex_unlock(&rsrc_mutex);
917 return (ret); 917 return (ret);
918} 918}
919 919
@@ -953,7 +953,7 @@ static ssize_t show_mem_db(struct class_device *class_dev, char *buf)
953 struct resource_map *p; 953 struct resource_map *p;
954 ssize_t ret = 0; 954 ssize_t ret = 0;
955 955
956 down(&rsrc_sem); 956 mutex_lock(&rsrc_mutex);
957 data = s->resource_data; 957 data = s->resource_data;
958 958
959 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) { 959 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) {
@@ -965,7 +965,7 @@ static ssize_t show_mem_db(struct class_device *class_dev, char *buf)
965 ((unsigned long) p->base + p->num - 1)); 965 ((unsigned long) p->base + p->num - 1));
966 } 966 }
967 967
968 up(&rsrc_sem); 968 mutex_unlock(&rsrc_mutex);
969 return (ret); 969 return (ret);
970} 970}
971 971