aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/rsrc_nonstatic.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-01-17 13:31:45 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2010-02-17 11:48:24 -0500
commitcfe5d809518eda3d5e2da87c5ccbe8647143573a (patch)
treedd61ec285412fc0de8090ef5743b824447a9eeda /drivers/pcmcia/rsrc_nonstatic.c
parent3f565232c561fbd9d5e03354aac29b90cb2bc78a (diff)
pcmcia: use ops_mutex for rsrc_{mgr,nonstatic} locking
Tested-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/rsrc_nonstatic.c')
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 1de46cf2772f..c13424f7b479 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -59,7 +59,6 @@ struct socket_data {
59 unsigned int rsrc_mem_probe; 59 unsigned int rsrc_mem_probe;
60}; 60};
61 61
62static DEFINE_MUTEX(rsrc_mutex);
63#define MEM_PROBE_LOW (1 << 0) 62#define MEM_PROBE_LOW (1 << 0)
64#define MEM_PROBE_HIGH (1 << 1) 63#define MEM_PROBE_HIGH (1 << 1)
65 64
@@ -274,7 +273,6 @@ static int readable(struct pcmcia_socket *s, struct resource *res,
274{ 273{
275 int ret = -EINVAL; 274 int ret = -EINVAL;
276 275
277 mutex_lock(&s->ops_mutex);
278 s->cis_mem.res = res; 276 s->cis_mem.res = res;
279 s->cis_virt = ioremap(res->start, s->map_size); 277 s->cis_virt = ioremap(res->start, s->map_size);
280 if (s->cis_virt) { 278 if (s->cis_virt) {
@@ -288,7 +286,6 @@ static int readable(struct pcmcia_socket *s, struct resource *res,
288 s->cis_virt = NULL; 286 s->cis_virt = NULL;
289 } 287 }
290 s->cis_mem.res = NULL; 288 s->cis_mem.res = NULL;
291 mutex_unlock(&s->ops_mutex);
292 if ((ret) || (*count == 0)) 289 if ((ret) || (*count == 0))
293 return -EINVAL; 290 return -EINVAL;
294 return 0; 291 return 0;
@@ -304,8 +301,6 @@ static int checksum(struct pcmcia_socket *s, struct resource *res,
304 int i, a = 0, b = -1, d; 301 int i, a = 0, b = -1, d;
305 void __iomem *virt; 302 void __iomem *virt;
306 303
307 mutex_lock(&s->ops_mutex);
308
309 virt = ioremap(res->start, s->map_size); 304 virt = ioremap(res->start, s->map_size);
310 if (virt) { 305 if (virt) {
311 map.map = 0; 306 map.map = 0;
@@ -328,8 +323,6 @@ static int checksum(struct pcmcia_socket *s, struct resource *res,
328 iounmap(virt); 323 iounmap(virt);
329 } 324 }
330 325
331 mutex_unlock(&s->ops_mutex);
332
333 if (b == -1) 326 if (b == -1)
334 return -EINVAL; 327 return -EINVAL;
335 328
@@ -570,8 +563,6 @@ static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
570 if (!probe_mem) 563 if (!probe_mem)
571 return 0; 564 return 0;
572 565
573 mutex_lock(&rsrc_mutex);
574
575 if (s->features & SS_CAP_PAGE_REGS) 566 if (s->features & SS_CAP_PAGE_REGS)
576 probe_mask = MEM_PROBE_HIGH; 567 probe_mask = MEM_PROBE_HIGH;
577 568
@@ -583,8 +574,6 @@ static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
583 } 574 }
584 } 575 }
585 576
586 mutex_unlock(&rsrc_mutex);
587
588 return ret; 577 return ret;
589} 578}
590 579
@@ -661,7 +650,6 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
661 struct socket_data *s_data = s->resource_data; 650 struct socket_data *s_data = s->resource_data;
662 int ret = -ENOMEM; 651 int ret = -ENOMEM;
663 652
664 mutex_lock(&rsrc_mutex);
665 for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) { 653 for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) {
666 unsigned long start = m->base; 654 unsigned long start = m->base;
667 unsigned long end = m->base + m->num - 1; 655 unsigned long end = m->base + m->num - 1;
@@ -672,7 +660,6 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
672 ret = adjust_resource(res, r_start, r_end - r_start + 1); 660 ret = adjust_resource(res, r_start, r_end - r_start + 1);
673 break; 661 break;
674 } 662 }
675 mutex_unlock(&rsrc_mutex);
676 663
677 return ret; 664 return ret;
678} 665}
@@ -706,7 +693,6 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
706 data.offset = base & data.mask; 693 data.offset = base & data.mask;
707 data.map = &s_data->io_db; 694 data.map = &s_data->io_db;
708 695
709 mutex_lock(&rsrc_mutex);
710#ifdef CONFIG_PCI 696#ifdef CONFIG_PCI
711 if (s->cb_dev) { 697 if (s->cb_dev) {
712 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1, 698 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
@@ -715,7 +701,6 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
715#endif 701#endif
716 ret = allocate_resource(&ioport_resource, res, num, min, ~0UL, 702 ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
717 1, pcmcia_align, &data); 703 1, pcmcia_align, &data);
718 mutex_unlock(&rsrc_mutex);
719 704
720 if (ret != 0) { 705 if (ret != 0) {
721 kfree(res); 706 kfree(res);
@@ -748,7 +733,6 @@ static struct resource *nonstatic_find_mem_region(u_long base, u_long num,
748 min = 0x100000UL + base; 733 min = 0x100000UL + base;
749 } 734 }
750 735
751 mutex_lock(&rsrc_mutex);
752#ifdef CONFIG_PCI 736#ifdef CONFIG_PCI
753 if (s->cb_dev) { 737 if (s->cb_dev) {
754 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 738 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num,
@@ -758,7 +742,6 @@ static struct resource *nonstatic_find_mem_region(u_long base, u_long num,
758#endif 742#endif
759 ret = allocate_resource(&iomem_resource, res, num, min, 743 ret = allocate_resource(&iomem_resource, res, num, min,
760 max, 1, pcmcia_align, &data); 744 max, 1, pcmcia_align, &data);
761 mutex_unlock(&rsrc_mutex);
762 if (ret == 0 || low) 745 if (ret == 0 || low)
763 break; 746 break;
764 low = 1; 747 low = 1;
@@ -781,7 +764,6 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
781 if (end < start) 764 if (end < start)
782 return -EINVAL; 765 return -EINVAL;
783 766
784 mutex_lock(&rsrc_mutex);
785 switch (action) { 767 switch (action) {
786 case ADD_MANAGED_RESOURCE: 768 case ADD_MANAGED_RESOURCE:
787 ret = add_interval(&data->mem_db, start, size); 769 ret = add_interval(&data->mem_db, start, size);
@@ -794,7 +776,6 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
794 default: 776 default:
795 ret = -EINVAL; 777 ret = -EINVAL;
796 } 778 }
797 mutex_unlock(&rsrc_mutex);
798 779
799 return ret; 780 return ret;
800} 781}
@@ -812,7 +793,6 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
812 if (end > IO_SPACE_LIMIT) 793 if (end > IO_SPACE_LIMIT)
813 return -EINVAL; 794 return -EINVAL;
814 795
815 mutex_lock(&rsrc_mutex);
816 switch (action) { 796 switch (action) {
817 case ADD_MANAGED_RESOURCE: 797 case ADD_MANAGED_RESOURCE:
818 if (add_interval(&data->io_db, start, size) != 0) { 798 if (add_interval(&data->io_db, start, size) != 0) {
@@ -831,7 +811,6 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
831 ret = -EINVAL; 811 ret = -EINVAL;
832 break; 812 break;
833 } 813 }
834 mutex_unlock(&rsrc_mutex);
835 814
836 return ret; 815 return ret;
837} 816}
@@ -929,7 +908,6 @@ static void nonstatic_release_resource_db(struct pcmcia_socket *s)
929 struct socket_data *data = s->resource_data; 908 struct socket_data *data = s->resource_data;
930 struct resource_map *p, *q; 909 struct resource_map *p, *q;
931 910
932 mutex_lock(&rsrc_mutex);
933 for (p = data->mem_db.next; p != &data->mem_db; p = q) { 911 for (p = data->mem_db.next; p != &data->mem_db; p = q) {
934 q = p->next; 912 q = p->next;
935 kfree(p); 913 kfree(p);
@@ -938,7 +916,6 @@ static void nonstatic_release_resource_db(struct pcmcia_socket *s)
938 q = p->next; 916 q = p->next;
939 kfree(p); 917 kfree(p);
940 } 918 }
941 mutex_unlock(&rsrc_mutex);
942} 919}
943 920
944 921
@@ -965,7 +942,7 @@ static ssize_t show_io_db(struct device *dev,
965 struct resource_map *p; 942 struct resource_map *p;
966 ssize_t ret = 0; 943 ssize_t ret = 0;
967 944
968 mutex_lock(&rsrc_mutex); 945 mutex_lock(&s->ops_mutex);
969 data = s->resource_data; 946 data = s->resource_data;
970 947
971 for (p = data->io_db.next; p != &data->io_db; p = p->next) { 948 for (p = data->io_db.next; p != &data->io_db; p = p->next) {
@@ -977,7 +954,7 @@ static ssize_t show_io_db(struct device *dev,
977 ((unsigned long) p->base + p->num - 1)); 954 ((unsigned long) p->base + p->num - 1));
978 } 955 }
979 956
980 mutex_unlock(&rsrc_mutex); 957 mutex_unlock(&s->ops_mutex);
981 return ret; 958 return ret;
982} 959}
983 960
@@ -1005,9 +982,11 @@ static ssize_t store_io_db(struct device *dev,
1005 if (end_addr < start_addr) 982 if (end_addr < start_addr)
1006 return -EINVAL; 983 return -EINVAL;
1007 984
985 mutex_lock(&s->ops_mutex);
1008 ret = adjust_io(s, add, start_addr, end_addr); 986 ret = adjust_io(s, add, start_addr, end_addr);
1009 if (!ret) 987 if (!ret)
1010 s->resource_setup_new = 1; 988 s->resource_setup_new = 1;
989 mutex_unlock(&s->ops_mutex);
1011 990
1012 return ret ? ret : count; 991 return ret ? ret : count;
1013} 992}
@@ -1021,7 +1000,7 @@ static ssize_t show_mem_db(struct device *dev,
1021 struct resource_map *p; 1000 struct resource_map *p;
1022 ssize_t ret = 0; 1001 ssize_t ret = 0;
1023 1002
1024 mutex_lock(&rsrc_mutex); 1003 mutex_lock(&s->ops_mutex);
1025 data = s->resource_data; 1004 data = s->resource_data;
1026 1005
1027 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) { 1006 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) {
@@ -1033,7 +1012,7 @@ static ssize_t show_mem_db(struct device *dev,
1033 ((unsigned long) p->base + p->num - 1)); 1012 ((unsigned long) p->base + p->num - 1));
1034 } 1013 }
1035 1014
1036 mutex_unlock(&rsrc_mutex); 1015 mutex_unlock(&s->ops_mutex);
1037 return ret; 1016 return ret;
1038} 1017}
1039 1018
@@ -1061,9 +1040,11 @@ static ssize_t store_mem_db(struct device *dev,
1061 if (end_addr < start_addr) 1040 if (end_addr < start_addr)
1062 return -EINVAL; 1041 return -EINVAL;
1063 1042
1043 mutex_lock(&s->ops_mutex);
1064 ret = adjust_memory(s, add, start_addr, end_addr); 1044 ret = adjust_memory(s, add, start_addr, end_addr);
1065 if (!ret) 1045 if (!ret)
1066 s->resource_setup_new = 1; 1046 s->resource_setup_new = 1;
1047 mutex_unlock(&s->ops_mutex);
1067 1048
1068 return ret ? ret : count; 1049 return ret ? ret : count;
1069} 1050}