diff options
Diffstat (limited to 'drivers/pcmcia/pcmcia_resource.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 8ceb7abc580a..f31ba89e40d3 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -223,6 +223,7 @@ int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, | |||
223 | memreq_t *req) | 223 | memreq_t *req) |
224 | { | 224 | { |
225 | struct pcmcia_socket *s = p_dev->socket; | 225 | struct pcmcia_socket *s = p_dev->socket; |
226 | int ret; | ||
226 | 227 | ||
227 | wh--; | 228 | wh--; |
228 | if (wh >= MAX_WIN) | 229 | if (wh >= MAX_WIN) |
@@ -231,12 +232,13 @@ int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, | |||
231 | dev_dbg(&s->dev, "failure: requested page is zero\n"); | 232 | dev_dbg(&s->dev, "failure: requested page is zero\n"); |
232 | return -EINVAL; | 233 | return -EINVAL; |
233 | } | 234 | } |
235 | mutex_lock(&s->ops_mutex); | ||
234 | s->win[wh].card_start = req->CardOffset; | 236 | s->win[wh].card_start = req->CardOffset; |
235 | if (s->ops->set_mem_map(s, &s->win[wh]) != 0) { | 237 | ret = s->ops->set_mem_map(s, &s->win[wh]); |
236 | dev_dbg(&s->dev, "failed to set_mem_map\n"); | 238 | if (ret) |
237 | return -EIO; | 239 | dev_warn(&s->dev, "failed to set_mem_map\n"); |
238 | } | 240 | mutex_unlock(&s->ops_mutex); |
239 | return 0; | 241 | return ret; |
240 | } /* pcmcia_map_mem_page */ | 242 | } /* pcmcia_map_mem_page */ |
241 | EXPORT_SYMBOL(pcmcia_map_mem_page); | 243 | EXPORT_SYMBOL(pcmcia_map_mem_page); |
242 | 244 | ||
@@ -437,10 +439,12 @@ int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh) | |||
437 | if (wh >= MAX_WIN) | 439 | if (wh >= MAX_WIN) |
438 | return -EINVAL; | 440 | return -EINVAL; |
439 | 441 | ||
442 | mutex_lock(&s->ops_mutex); | ||
440 | win = &s->win[wh]; | 443 | win = &s->win[wh]; |
441 | 444 | ||
442 | if (!(p_dev->_win & CLIENT_WIN_REQ(wh))) { | 445 | if (!(p_dev->_win & CLIENT_WIN_REQ(wh))) { |
443 | dev_dbg(&s->dev, "not releasing unknown window\n"); | 446 | dev_dbg(&s->dev, "not releasing unknown window\n"); |
447 | mutex_unlock(&s->ops_mutex); | ||
444 | return -EINVAL; | 448 | return -EINVAL; |
445 | } | 449 | } |
446 | 450 | ||
@@ -456,6 +460,7 @@ int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh) | |||
456 | win->res = NULL; | 460 | win->res = NULL; |
457 | } | 461 | } |
458 | p_dev->_win &= ~CLIENT_WIN_REQ(wh); | 462 | p_dev->_win &= ~CLIENT_WIN_REQ(wh); |
463 | mutex_unlock(&s->ops_mutex); | ||
459 | 464 | ||
460 | return 0; | 465 | return 0; |
461 | } /* pcmcia_release_window */ | 466 | } /* pcmcia_release_window */ |
@@ -829,6 +834,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
829 | return -EINVAL; | 834 | return -EINVAL; |
830 | } | 835 | } |
831 | 836 | ||
837 | mutex_lock(&s->ops_mutex); | ||
832 | win = &s->win[w]; | 838 | win = &s->win[w]; |
833 | 839 | ||
834 | if (!(s->features & SS_CAP_STATIC_MAP)) { | 840 | if (!(s->features & SS_CAP_STATIC_MAP)) { |
@@ -836,6 +842,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
836 | (req->Attributes & WIN_MAP_BELOW_1MB), s); | 842 | (req->Attributes & WIN_MAP_BELOW_1MB), s); |
837 | if (!win->res) { | 843 | if (!win->res) { |
838 | dev_dbg(&s->dev, "allocating mem region failed\n"); | 844 | dev_dbg(&s->dev, "allocating mem region failed\n"); |
845 | mutex_unlock(&s->ops_mutex); | ||
839 | return -EINVAL; | 846 | return -EINVAL; |
840 | } | 847 | } |
841 | } | 848 | } |
@@ -854,8 +861,10 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
854 | if (req->Attributes & WIN_USE_WAIT) | 861 | if (req->Attributes & WIN_USE_WAIT) |
855 | win->flags |= MAP_USE_WAIT; | 862 | win->flags |= MAP_USE_WAIT; |
856 | win->card_start = 0; | 863 | win->card_start = 0; |
864 | |||
857 | if (s->ops->set_mem_map(s, win) != 0) { | 865 | if (s->ops->set_mem_map(s, win) != 0) { |
858 | dev_dbg(&s->dev, "failed to set memory mapping\n"); | 866 | dev_dbg(&s->dev, "failed to set memory mapping\n"); |
867 | mutex_unlock(&s->ops_mutex); | ||
859 | return -EIO; | 868 | return -EIO; |
860 | } | 869 | } |
861 | s->state |= SOCKET_WIN_REQ(w); | 870 | s->state |= SOCKET_WIN_REQ(w); |
@@ -866,6 +875,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
866 | else | 875 | else |
867 | req->Base = win->res->start; | 876 | req->Base = win->res->start; |
868 | 877 | ||
878 | mutex_unlock(&s->ops_mutex); | ||
869 | *wh = w + 1; | 879 | *wh = w + 1; |
870 | 880 | ||
871 | return 0; | 881 | return 0; |