summaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/rsrc_nonstatic.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-01-17 19:31:45 +0100
committerDominik Brodowski <linux@dominikbrodowski.net>2010-02-17 17:48:24 +0100
commitcfe5d809518eda3d5e2da87c5ccbe8647143573a (patch)
treedd61ec285412fc0de8090ef5743b824447a9eeda /drivers/pcmcia/rsrc_nonstatic.c
parent3f565232c561fbd9d5e03354aac29b90cb2bc78a (diff)
downloadblackbird-op-linux-cfe5d809518eda3d5e2da87c5ccbe8647143573a.tar.gz
blackbird-op-linux-cfe5d809518eda3d5e2da87c5ccbe8647143573a.zip
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 {
unsigned int rsrc_mem_probe;
};
-static DEFINE_MUTEX(rsrc_mutex);
#define MEM_PROBE_LOW (1 << 0)
#define MEM_PROBE_HIGH (1 << 1)
@@ -274,7 +273,6 @@ static int readable(struct pcmcia_socket *s, struct resource *res,
{
int ret = -EINVAL;
- mutex_lock(&s->ops_mutex);
s->cis_mem.res = res;
s->cis_virt = ioremap(res->start, s->map_size);
if (s->cis_virt) {
@@ -288,7 +286,6 @@ static int readable(struct pcmcia_socket *s, struct resource *res,
s->cis_virt = NULL;
}
s->cis_mem.res = NULL;
- mutex_unlock(&s->ops_mutex);
if ((ret) || (*count == 0))
return -EINVAL;
return 0;
@@ -304,8 +301,6 @@ static int checksum(struct pcmcia_socket *s, struct resource *res,
int i, a = 0, b = -1, d;
void __iomem *virt;
- mutex_lock(&s->ops_mutex);
-
virt = ioremap(res->start, s->map_size);
if (virt) {
map.map = 0;
@@ -328,8 +323,6 @@ static int checksum(struct pcmcia_socket *s, struct resource *res,
iounmap(virt);
}
- mutex_unlock(&s->ops_mutex);
-
if (b == -1)
return -EINVAL;
@@ -570,8 +563,6 @@ static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
if (!probe_mem)
return 0;
- mutex_lock(&rsrc_mutex);
-
if (s->features & SS_CAP_PAGE_REGS)
probe_mask = MEM_PROBE_HIGH;
@@ -583,8 +574,6 @@ static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
}
}
- mutex_unlock(&rsrc_mutex);
-
return ret;
}
@@ -661,7 +650,6 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
struct socket_data *s_data = s->resource_data;
int ret = -ENOMEM;
- mutex_lock(&rsrc_mutex);
for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) {
unsigned long start = m->base;
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
ret = adjust_resource(res, r_start, r_end - r_start + 1);
break;
}
- mutex_unlock(&rsrc_mutex);
return ret;
}
@@ -706,7 +693,6 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
data.offset = base & data.mask;
data.map = &s_data->io_db;
- mutex_lock(&rsrc_mutex);
#ifdef CONFIG_PCI
if (s->cb_dev) {
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,
#endif
ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
1, pcmcia_align, &data);
- mutex_unlock(&rsrc_mutex);
if (ret != 0) {
kfree(res);
@@ -748,7 +733,6 @@ static struct resource *nonstatic_find_mem_region(u_long base, u_long num,
min = 0x100000UL + base;
}
- mutex_lock(&rsrc_mutex);
#ifdef CONFIG_PCI
if (s->cb_dev) {
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,
#endif
ret = allocate_resource(&iomem_resource, res, num, min,
max, 1, pcmcia_align, &data);
- mutex_unlock(&rsrc_mutex);
if (ret == 0 || low)
break;
low = 1;
@@ -781,7 +764,6 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
if (end < start)
return -EINVAL;
- mutex_lock(&rsrc_mutex);
switch (action) {
case ADD_MANAGED_RESOURCE:
ret = add_interval(&data->mem_db, start, size);
@@ -794,7 +776,6 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
default:
ret = -EINVAL;
}
- mutex_unlock(&rsrc_mutex);
return ret;
}
@@ -812,7 +793,6 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
if (end > IO_SPACE_LIMIT)
return -EINVAL;
- mutex_lock(&rsrc_mutex);
switch (action) {
case ADD_MANAGED_RESOURCE:
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
ret = -EINVAL;
break;
}
- mutex_unlock(&rsrc_mutex);
return ret;
}
@@ -929,7 +908,6 @@ static void nonstatic_release_resource_db(struct pcmcia_socket *s)
struct socket_data *data = s->resource_data;
struct resource_map *p, *q;
- mutex_lock(&rsrc_mutex);
for (p = data->mem_db.next; p != &data->mem_db; p = q) {
q = p->next;
kfree(p);
@@ -938,7 +916,6 @@ static void nonstatic_release_resource_db(struct pcmcia_socket *s)
q = p->next;
kfree(p);
}
- mutex_unlock(&rsrc_mutex);
}
@@ -965,7 +942,7 @@ static ssize_t show_io_db(struct device *dev,
struct resource_map *p;
ssize_t ret = 0;
- mutex_lock(&rsrc_mutex);
+ mutex_lock(&s->ops_mutex);
data = s->resource_data;
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,
((unsigned long) p->base + p->num - 1));
}
- mutex_unlock(&rsrc_mutex);
+ mutex_unlock(&s->ops_mutex);
return ret;
}
@@ -1005,9 +982,11 @@ static ssize_t store_io_db(struct device *dev,
if (end_addr < start_addr)
return -EINVAL;
+ mutex_lock(&s->ops_mutex);
ret = adjust_io(s, add, start_addr, end_addr);
if (!ret)
s->resource_setup_new = 1;
+ mutex_unlock(&s->ops_mutex);
return ret ? ret : count;
}
@@ -1021,7 +1000,7 @@ static ssize_t show_mem_db(struct device *dev,
struct resource_map *p;
ssize_t ret = 0;
- mutex_lock(&rsrc_mutex);
+ mutex_lock(&s->ops_mutex);
data = s->resource_data;
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,
((unsigned long) p->base + p->num - 1));
}
- mutex_unlock(&rsrc_mutex);
+ mutex_unlock(&s->ops_mutex);
return ret;
}
@@ -1061,9 +1040,11 @@ static ssize_t store_mem_db(struct device *dev,
if (end_addr < start_addr)
return -EINVAL;
+ mutex_lock(&s->ops_mutex);
ret = adjust_memory(s, add, start_addr, end_addr);
if (!ret)
s->resource_setup_new = 1;
+ mutex_unlock(&s->ops_mutex);
return ret ? ret : count;
}
OpenPOWER on IntegriCloud