[PATCH 04/04] pcmcia: Change window_handle_t logic to unsigned long
Magnus Damm
damm at opensource.se
Wed Dec 13 05:46:53 EST 2006
pcmcia: Change window_handle_t logic to unsigned long
Logic changes based on top of the other patches.
Signed-off-by: Magnus Damm <damm at opensource.se>
---
Applies to 2.6.19-git19
drivers/pcmcia/cs_internal.h | 2 -
drivers/pcmcia/pcmcia_ioctl.c | 2 -
drivers/pcmcia/pcmcia_resource.c | 53 +++++++++++++++++---------------------
include/pcmcia/cs_types.h | 3 --
include/pcmcia/ss.h | 5 ---
5 files changed, 27 insertions(+), 38 deletions(-)
--- 0008/drivers/pcmcia/cs_internal.h
+++ work/drivers/pcmcia/cs_internal.h 2006-12-13 13:07:05.000000000 +0900
@@ -114,7 +114,7 @@ extern struct class_interface pccard_sys
/* In cs.c */
extern struct rw_semaphore pcmcia_socket_list_rwsem;
extern struct list_head pcmcia_socket_list;
-int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req);
+int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *wh_out, window_handle_t wh, win_req_t *req);
int pcmcia_get_mem_page(struct pcmcia_socket *s, window_handle_t wh, memreq_t *req);
int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config);
int pccard_reset_card(struct pcmcia_socket *skt);
--- 0008/drivers/pcmcia/pcmcia_ioctl.c
+++ work/drivers/pcmcia/pcmcia_ioctl.c 2006-12-13 13:06:22.000000000 +0900
@@ -687,7 +687,7 @@ static int ds_ioctl(struct inode * inode
break;
case DS_GET_NEXT_WINDOW:
ret = pcmcia_get_window(s, &buf->win_info.handle,
- buf->win_info.handle->index + 1, &buf->win_info.window);
+ buf->win_info.handle + 1, &buf->win_info.window);
break;
case DS_GET_MEM_PAGE:
ret = pcmcia_get_mem_page(s, buf->win_info.handle,
--- 0008/drivers/pcmcia/pcmcia_resource.c
+++ work/drivers/pcmcia/pcmcia_resource.c 2006-12-13 13:10:15.000000000 +0900
@@ -279,15 +279,17 @@ EXPORT_SYMBOL(pcmcia_get_configuration_i
/** pcmcia_get_window
*/
-int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle,
- int idx, win_req_t *req)
+int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *wh_out,
+ window_handle_t wh, win_req_t *req)
{
window_t *win;
- int w;
+ window_handle_t w;
if (!s || !(s->state & SOCKET_PRESENT))
return CS_NO_CARD;
- for (w = idx; w < MAX_WIN; w++)
+ if (wh > MAX_WIN)
+ return CS_BAD_HANDLE;
+ for (w = wh; w < MAX_WIN; w++)
if (s->state & SOCKET_WIN_REQ(w))
break;
if (w == MAX_WIN)
@@ -305,7 +307,8 @@ int pcmcia_get_window(struct pcmcia_sock
req->Attributes |= WIN_DATA_WIDTH_16;
if (win->ctl.flags & MAP_USE_WAIT)
req->Attributes |= WIN_USE_WAIT;
- *handle = win;
+
+ *wh_out = w;
return CS_SUCCESS;
} /* pcmcia_get_window */
EXPORT_SYMBOL(pcmcia_get_window);
@@ -386,12 +389,10 @@ EXPORT_SYMBOL(pcmcia_get_status);
int pcmcia_get_mem_page(struct pcmcia_socket *s,
window_handle_t wh, memreq_t *req);
{
- window_handle_t win = wh;
-
- if ((win == NULL) || (win->magic != WINDOW_MAGIC))
+ if (wh >= MAX_WIN)
return CS_BAD_HANDLE;
req->Page = 0;
- req->CardOffset = win->ctl.card_start;
+ req->CardOffset = s->win[wh].ctl.card_start;
return CS_SUCCESS;
} /* pcmcia_get_mem_page */
EXPORT_SYMBOL(pcmcia_get_mem_page);
@@ -400,16 +401,14 @@ EXPORT_SYMBOL(pcmcia_get_mem_page);
int pcmcia_map_mem_page(struct pcmcia_device *p_dev,
window_handle_t wh, memreq_t *req)
{
- struct pcmcia_socket *s;
- window_handle_t win = wh;
+ struct pcmcia_socket *s = p_dev->socket;
- if ((win == NULL) || (win->magic != WINDOW_MAGIC))
+ if (wh >= MAX_WIN)
return CS_BAD_HANDLE;
if (req->Page != 0)
return CS_BAD_PAGE;
- s = win->sock;
- win->ctl.card_start = req->CardOffset;
- if (s->ops->set_mem_map(s, &win->ctl) != 0)
+ s->win[wh].ctl.card_start = req->CardOffset;
+ if (s->ops->set_mem_map(s, &s->win[wh].ctl) != 0)
return CS_BAD_OFFSET;
return CS_SUCCESS;
} /* pcmcia_map_mem_page */
@@ -589,19 +588,21 @@ static int pcmcia_release_irq(struct pcm
int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh)
{
- struct pcmcia_socket *s;
- window_handle_t win = wh;
+ struct pcmcia_socket *s = p_dev->socket;
+ window_t *win;
- if ((win == NULL) || (win->magic != WINDOW_MAGIC))
+ if (wh >= MAX_WIN)
return CS_BAD_HANDLE;
- s = win->sock;
- if (!(win->handle->_win & CLIENT_WIN_REQ(win->index)))
+
+ win = &s->win[wh];
+
+ if (!(p_dev->_win & CLIENT_WIN_REQ(wh)))
return CS_BAD_HANDLE;
/* Shut down memory window */
win->ctl.flags &= ~MAP_ACTIVE;
s->ops->set_mem_map(s, &win->ctl);
- s->state &= ~SOCKET_WIN_REQ(win->index);
+ s->state &= ~SOCKET_WIN_REQ(wh);
/* Release system memory */
if (win->ctl.res) {
@@ -609,9 +610,7 @@ int pcmcia_release_window(struct pcmcia_
kfree(win->ctl.res);
win->ctl.res = NULL;
}
- win->handle->_win &= ~CLIENT_WIN_REQ(win->index);
-
- win->magic = 0;
+ p_dev->_win &= ~CLIENT_WIN_REQ(wh);
return CS_SUCCESS;
} /* pcmcia_release_window */
@@ -927,10 +926,6 @@ int pcmcia_request_window(struct pcmcia_
return CS_OUT_OF_RESOURCE;
win = &s->win[w];
- win->magic = WINDOW_MAGIC;
- win->index = w;
- win->handle = *p_dev;
- win->sock = s;
if (!(s->features & SS_CAP_STATIC_MAP)) {
win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align,
@@ -963,7 +958,7 @@ int pcmcia_request_window(struct pcmcia_
} else {
req->Base = win->ctl.res->start;
}
- *wh = win;
+ *wh = w;
return CS_SUCCESS;
} /* pcmcia_request_window */
--- 0005/include/pcmcia/cs_types.h
+++ work/include/pcmcia/cs_types.h 2006-12-13 13:02:37.000000000 +0900
@@ -34,8 +34,7 @@ typedef u_int event_t;
typedef u_char cisdata_t;
typedef u_short page_t;
-struct window_t;
-typedef struct window_t *window_handle_t;
+typedef unsigned long window_handle_t;
#ifndef DEV_NAME_LEN
#define DEV_NAME_LEN 32
--- 0005/include/pcmcia/ss.h
+++ work/include/pcmcia/ss.h 2006-12-13 13:02:37.000000000 +0900
@@ -158,12 +158,7 @@ typedef struct io_window_t {
struct resource *res;
} io_window_t;
-#define WINDOW_MAGIC 0xB35C
typedef struct window_t {
- u_short magic;
- u_short index;
- struct pcmcia_device *handle;
- struct pcmcia_socket *sock;
pccard_mem_map ctl;
} window_t;
More information about the linux-pcmcia
mailing list