void release_cis_mem(struct pcmcia_socket *s)
{
+ mutex_lock(&s->ops_mutex);
if (s->cis_mem.flags & MAP_ACTIVE) {
s->cis_mem.flags &= ~MAP_ACTIVE;
s->ops->set_mem_map(s, &s->cis_mem);
iounmap(s->cis_virt);
s->cis_virt = NULL;
}
+ mutex_unlock(&s->ops_mutex);
}
/*
pccard_mem_map *mem = &s->cis_mem;
int ret;
+ mutex_lock(&s->ops_mutex);
if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) {
mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s);
if (mem->res == NULL) {
dev_printk(KERN_NOTICE, &s->dev,
"cs: unable to map card memory!\n");
+ mutex_unlock(&s->ops_mutex);
return NULL;
}
s->cis_virt = NULL;
if (ret) {
iounmap(s->cis_virt);
s->cis_virt = NULL;
+ mutex_unlock(&s->ops_mutex);
return NULL;
}
s->cis_virt = ioremap(mem->static_start, s->map_size);
}
+ mutex_unlock(&s->ops_mutex);
return s->cis_virt;
}
init_completion(&socket->socket_released);
init_completion(&socket->thread_done);
mutex_init(&socket->skt_mutex);
+ mutex_init(&socket->ops_mutex);
spin_lock_init(&socket->thread_lock);
if (socket->resource_ops->init) {
memreq_t *req)
{
struct pcmcia_socket *s = p_dev->socket;
+ int ret;
wh--;
if (wh >= MAX_WIN)
dev_dbg(&s->dev, "failure: requested page is zero\n");
return -EINVAL;
}
+ mutex_lock(&s->ops_mutex);
s->win[wh].card_start = req->CardOffset;
- if (s->ops->set_mem_map(s, &s->win[wh]) != 0) {
- dev_dbg(&s->dev, "failed to set_mem_map\n");
- return -EIO;
- }
- return 0;
+ ret = s->ops->set_mem_map(s, &s->win[wh]);
+ if (ret)
+ dev_warn(&s->dev, "failed to set_mem_map\n");
+ mutex_unlock(&s->ops_mutex);
+ return ret;
} /* pcmcia_map_mem_page */
EXPORT_SYMBOL(pcmcia_map_mem_page);
if (wh >= MAX_WIN)
return -EINVAL;
+ mutex_lock(&s->ops_mutex);
win = &s->win[wh];
if (!(p_dev->_win & CLIENT_WIN_REQ(wh))) {
dev_dbg(&s->dev, "not releasing unknown window\n");
+ mutex_unlock(&s->ops_mutex);
return -EINVAL;
}
win->res = NULL;
}
p_dev->_win &= ~CLIENT_WIN_REQ(wh);
+ mutex_unlock(&s->ops_mutex);
return 0;
} /* pcmcia_release_window */
return -EINVAL;
}
+ mutex_lock(&s->ops_mutex);
win = &s->win[w];
if (!(s->features & SS_CAP_STATIC_MAP)) {
(req->Attributes & WIN_MAP_BELOW_1MB), s);
if (!win->res) {
dev_dbg(&s->dev, "allocating mem region failed\n");
+ mutex_unlock(&s->ops_mutex);
return -EINVAL;
}
}
if (req->Attributes & WIN_USE_WAIT)
win->flags |= MAP_USE_WAIT;
win->card_start = 0;
+
if (s->ops->set_mem_map(s, win) != 0) {
dev_dbg(&s->dev, "failed to set memory mapping\n");
+ mutex_unlock(&s->ops_mutex);
return -EIO;
}
s->state |= SOCKET_WIN_REQ(w);
else
req->Base = win->res->start;
+ mutex_unlock(&s->ops_mutex);
*wh = w + 1;
return 0;
{
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) {
+ mutex_unlock(&s->ops_mutex);
/* as we're only called from pcmcia.c, we're safe */
if (s->callback->validate)
ret = s->callback->validate(s, count);
/* invalidate mapping */
+ mutex_lock(&s->ops_mutex);
iounmap(s->cis_virt);
s->cis_virt = NULL;
}
s->cis_mem.res = NULL;
+ mutex_unlock(&s->ops_mutex);
if ((ret) || (*count == 0))
return -EINVAL;
return 0;
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;
iounmap(virt);
}
+ mutex_unlock(&s->ops_mutex);
+
if (b == -1)
return -EINVAL;
unsigned int thread_events;
/* protects socket h/w state */
struct mutex skt_mutex;
+ /* protects PCMCIA state */
+ struct mutex ops_mutex;
/* protects thread_events */
spinlock_t thread_lock;