diff options
author | Magnus Damm <damm@opensource.se> | 2006-12-13 05:46:53 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-11-28 12:02:50 -0500 |
commit | 0bdf9b3dd3cfa5cbd5d55172c19f5dd166208e17 (patch) | |
tree | a7af14eb0601a443343240cbb11d7693db9de352 /drivers | |
parent | 16456ebabfec3f8f509fc18b45f256d066a1b360 (diff) |
pcmcia: Change window_handle_t logic to unsigned long
Logic changes based on top of the other patches:
This set of patches changed window_handle_t from being a pointer to an
unsigned long. The unsigned long is now a simple index into socket->win[].
Going from a pointer to unsigned long should leave the user space interface
unchanged unless I'm mistaken.
This change results in code that is less error prone and a user space
interface which is much cleaner and safer. A nice side effect is that we
are also are able to remove all members except one from window_t.
[ linux@dominikbrodowski.net:
Update to 2.6.31. Also, a plain "index" to socket->win[] does not
work, as several codepaths rely on "window_handle_t" being
non-zero if used. Therefore, set the window_handle_t to the
socket->win[] index + 1. ]
CC: netdev@vger.kernel.org
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/pcmcia/pcnet_cs.c | 2 | ||||
-rw-r--r-- | drivers/pcmcia/cs_internal.h | 4 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 4 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 59 |
4 files changed, 35 insertions, 34 deletions
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 75e68946455e..518b094c9f6d 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -1514,7 +1514,7 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg, | |||
1514 | if (i != (TX_PAGES<<8)) { | 1514 | if (i != (TX_PAGES<<8)) { |
1515 | iounmap(info->base); | 1515 | iounmap(info->base); |
1516 | pcmcia_release_window(link, link->win); | 1516 | pcmcia_release_window(link, link->win); |
1517 | info->base = NULL; link->win = NULL; | 1517 | info->base = NULL; link->win = 0; |
1518 | goto failed; | 1518 | goto failed; |
1519 | } | 1519 | } |
1520 | 1520 | ||
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 8e09a4998c84..6df41de39d16 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h | |||
@@ -149,8 +149,8 @@ extern struct list_head pcmcia_socket_list; | |||
149 | extern struct class pcmcia_socket_class; | 149 | extern struct class pcmcia_socket_class; |
150 | 150 | ||
151 | int pcmcia_get_window(struct pcmcia_socket *s, | 151 | int pcmcia_get_window(struct pcmcia_socket *s, |
152 | window_handle_t *handle, | 152 | window_handle_t *wh_out, |
153 | int idx, | 153 | window_handle_t wh, |
154 | win_req_t *req); | 154 | win_req_t *req); |
155 | int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); | 155 | int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); |
156 | struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); | 156 | struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); |
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index c829ead5cdb7..6245fde02b79 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -916,12 +916,12 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
916 | goto free_out; | 916 | goto free_out; |
917 | break; | 917 | break; |
918 | case DS_GET_FIRST_WINDOW: | 918 | case DS_GET_FIRST_WINDOW: |
919 | ret = pcmcia_get_window(s, &buf->win_info.handle, 0, | 919 | ret = pcmcia_get_window(s, &buf->win_info.handle, 1, |
920 | &buf->win_info.window); | 920 | &buf->win_info.window); |
921 | break; | 921 | break; |
922 | case DS_GET_NEXT_WINDOW: | 922 | case DS_GET_NEXT_WINDOW: |
923 | ret = pcmcia_get_window(s, &buf->win_info.handle, | 923 | ret = pcmcia_get_window(s, &buf->win_info.handle, |
924 | buf->win_info.handle->index + 1, &buf->win_info.window); | 924 | buf->win_info.handle + 1, &buf->win_info.window); |
925 | break; | 925 | break; |
926 | case DS_GET_MEM_PAGE: | 926 | case DS_GET_MEM_PAGE: |
927 | ret = pcmcia_get_mem_page(s, buf->win_info.handle, | 927 | ret = pcmcia_get_mem_page(s, buf->win_info.handle, |
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index a092749f79cb..ae6abc7833d4 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -187,15 +187,19 @@ EXPORT_SYMBOL(pcmcia_access_configuration_register); | |||
187 | 187 | ||
188 | /** pcmcia_get_window | 188 | /** pcmcia_get_window |
189 | */ | 189 | */ |
190 | int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, | 190 | int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *wh_out, |
191 | int idx, win_req_t *req) | 191 | window_handle_t wh, win_req_t *req) |
192 | { | 192 | { |
193 | window_t *win; | 193 | window_t *win; |
194 | int w; | 194 | window_handle_t w; |
195 | 195 | ||
196 | if (!s || !(s->state & SOCKET_PRESENT)) | 196 | if (!s || !(s->state & SOCKET_PRESENT)) |
197 | return -ENODEV; | 197 | return -ENODEV; |
198 | for (w = idx; w < MAX_WIN; w++) | 198 | |
199 | wh--; | ||
200 | if (wh >= MAX_WIN) | ||
201 | return -EINVAL; | ||
202 | for (w = wh; w < MAX_WIN; w++) | ||
199 | if (s->state & SOCKET_WIN_REQ(w)) | 203 | if (s->state & SOCKET_WIN_REQ(w)) |
200 | break; | 204 | break; |
201 | if (w == MAX_WIN) | 205 | if (w == MAX_WIN) |
@@ -213,7 +217,8 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, | |||
213 | req->Attributes |= WIN_DATA_WIDTH_16; | 217 | req->Attributes |= WIN_DATA_WIDTH_16; |
214 | if (win->ctl.flags & MAP_USE_WAIT) | 218 | if (win->ctl.flags & MAP_USE_WAIT) |
215 | req->Attributes |= WIN_USE_WAIT; | 219 | req->Attributes |= WIN_USE_WAIT; |
216 | *handle = win; | 220 | |
221 | *wh_out = w++; | ||
217 | return 0; | 222 | return 0; |
218 | } /* pcmcia_get_window */ | 223 | } /* pcmcia_get_window */ |
219 | EXPORT_SYMBOL(pcmcia_get_window); | 224 | EXPORT_SYMBOL(pcmcia_get_window); |
@@ -226,12 +231,12 @@ EXPORT_SYMBOL(pcmcia_get_window); | |||
226 | int pcmcia_get_mem_page(struct pcmcia_socket *skt, window_handle_t wh, | 231 | int pcmcia_get_mem_page(struct pcmcia_socket *skt, window_handle_t wh, |
227 | memreq_t *req) | 232 | memreq_t *req) |
228 | { | 233 | { |
229 | window_handle_t win = wh; | 234 | wh--; |
230 | 235 | if (wh >= MAX_WIN) | |
231 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) | ||
232 | return -EINVAL; | 236 | return -EINVAL; |
237 | |||
233 | req->Page = 0; | 238 | req->Page = 0; |
234 | req->CardOffset = win->ctl.card_start; | 239 | req->CardOffset = skt->win[wh].ctl.card_start; |
235 | return 0; | 240 | return 0; |
236 | } /* pcmcia_get_mem_page */ | 241 | } /* pcmcia_get_mem_page */ |
237 | EXPORT_SYMBOL(pcmcia_get_mem_page); | 242 | EXPORT_SYMBOL(pcmcia_get_mem_page); |
@@ -240,18 +245,17 @@ EXPORT_SYMBOL(pcmcia_get_mem_page); | |||
240 | int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, | 245 | int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, |
241 | memreq_t *req) | 246 | memreq_t *req) |
242 | { | 247 | { |
243 | struct pcmcia_socket *s; | 248 | struct pcmcia_socket *s = p_dev->socket; |
244 | window_handle_t win = wh; | ||
245 | 249 | ||
246 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) | 250 | wh--; |
251 | if (wh >= MAX_WIN) | ||
247 | return -EINVAL; | 252 | return -EINVAL; |
248 | s = win->sock; | ||
249 | if (req->Page != 0) { | 253 | if (req->Page != 0) { |
250 | dev_dbg(&s->dev, "failure: requested page is zero\n"); | 254 | dev_dbg(&s->dev, "failure: requested page is zero\n"); |
251 | return -EINVAL; | 255 | return -EINVAL; |
252 | } | 256 | } |
253 | win->ctl.card_start = req->CardOffset; | 257 | s->win[wh].ctl.card_start = req->CardOffset; |
254 | if (s->ops->set_mem_map(s, &win->ctl) != 0) { | 258 | if (s->ops->set_mem_map(s, &s->win[wh].ctl) != 0) { |
255 | dev_dbg(&s->dev, "failed to set_mem_map\n"); | 259 | dev_dbg(&s->dev, "failed to set_mem_map\n"); |
256 | return -EIO; | 260 | return -EIO; |
257 | } | 261 | } |
@@ -450,13 +454,16 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
450 | 454 | ||
451 | int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh) | 455 | int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh) |
452 | { | 456 | { |
453 | struct pcmcia_socket *s; | 457 | struct pcmcia_socket *s = p_dev->socket; |
454 | window_handle_t win = wh; | 458 | window_t *win; |
455 | 459 | ||
456 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) | 460 | wh--; |
461 | if (wh >= MAX_WIN) | ||
457 | return -EINVAL; | 462 | return -EINVAL; |
458 | s = win->sock; | 463 | |
459 | if (!(win->handle->_win & CLIENT_WIN_REQ(win->index))) { | 464 | win = &s->win[wh]; |
465 | |||
466 | if (!(p_dev->_win & CLIENT_WIN_REQ(wh))) { | ||
460 | dev_dbg(&s->dev, "not releasing unknown window\n"); | 467 | dev_dbg(&s->dev, "not releasing unknown window\n"); |
461 | return -EINVAL; | 468 | return -EINVAL; |
462 | } | 469 | } |
@@ -464,7 +471,7 @@ int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh) | |||
464 | /* Shut down memory window */ | 471 | /* Shut down memory window */ |
465 | win->ctl.flags &= ~MAP_ACTIVE; | 472 | win->ctl.flags &= ~MAP_ACTIVE; |
466 | s->ops->set_mem_map(s, &win->ctl); | 473 | s->ops->set_mem_map(s, &win->ctl); |
467 | s->state &= ~SOCKET_WIN_REQ(win->index); | 474 | s->state &= ~SOCKET_WIN_REQ(wh); |
468 | 475 | ||
469 | /* Release system memory */ | 476 | /* Release system memory */ |
470 | if (win->ctl.res) { | 477 | if (win->ctl.res) { |
@@ -472,9 +479,7 @@ int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh) | |||
472 | kfree(win->ctl.res); | 479 | kfree(win->ctl.res); |
473 | win->ctl.res = NULL; | 480 | win->ctl.res = NULL; |
474 | } | 481 | } |
475 | win->handle->_win &= ~CLIENT_WIN_REQ(win->index); | 482 | p_dev->_win &= ~CLIENT_WIN_REQ(wh); |
476 | |||
477 | win->magic = 0; | ||
478 | 483 | ||
479 | return 0; | 484 | return 0; |
480 | } /* pcmcia_release_window */ | 485 | } /* pcmcia_release_window */ |
@@ -847,10 +852,6 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
847 | } | 852 | } |
848 | 853 | ||
849 | win = &s->win[w]; | 854 | win = &s->win[w]; |
850 | win->magic = WINDOW_MAGIC; | ||
851 | win->index = w; | ||
852 | win->handle = *p_dev; | ||
853 | win->sock = s; | ||
854 | 855 | ||
855 | if (!(s->features & SS_CAP_STATIC_MAP)) { | 856 | if (!(s->features & SS_CAP_STATIC_MAP)) { |
856 | win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, | 857 | win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, |
@@ -887,7 +888,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
887 | } else { | 888 | } else { |
888 | req->Base = win->ctl.res->start; | 889 | req->Base = win->ctl.res->start; |
889 | } | 890 | } |
890 | *wh = win; | 891 | *wh = w + 1; |
891 | 892 | ||
892 | return 0; | 893 | return 0; |
893 | } /* pcmcia_request_window */ | 894 | } /* pcmcia_request_window */ |