aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-07-07 20:59:01 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:24:06 -0400
commite12a9a93a8417c4f2aa46ce8346c2d27e656b9a2 (patch)
treeca4295237f29c54901c199b322e504f89a45c902 /drivers
parent1e212f3645a6b355de8c43a23376bc0e2ac49a63 (diff)
[PATCH] pcmcia: remove client_t usage
Reduce the occurences of "client_handle_t" which is nothing else than a pointer to struct pcmcia_device by now. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pcmcia/cs_internal.h13
-rw-r--r--drivers/pcmcia/ds.c35
-rw-r--r--drivers/pcmcia/pcmcia_compat.c19
-rw-r--r--drivers/pcmcia/pcmcia_resource.c31
4 files changed, 27 insertions, 71 deletions
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index e0ba4b5daa13..6bbfbd0e02a5 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -99,20 +99,11 @@ static inline void cs_socket_put(struct pcmcia_socket *skt)
99 } 99 }
100} 100}
101 101
102#define CHECK_HANDLE(h) \
103 (((h) == NULL) || ((h)->client_magic != CLIENT_MAGIC))
104
105#define CHECK_SOCKET(s) \ 102#define CHECK_SOCKET(s) \
106 (((s) >= sockets) || (socket_table[s]->ops == NULL)) 103 (((s) >= sockets) || (socket_table[s]->ops == NULL))
107 104
108#define SOCKET(h) (h->Socket) 105#define SOCKET(h) (h->socket)
109#define CONFIG(h) (&SOCKET(h)->config[(h)->Function]) 106#define CONFIG(h) (&SOCKET(h)->config[(h)->func])
110
111#define CHECK_REGION(r) \
112 (((r) == NULL) || ((r)->region_magic != REGION_MAGIC))
113
114#define CHECK_ERASEQ(q) \
115 (((q) == NULL) || ((q)->eraseq_magic != ERASEQ_MAGIC))
116 107
117/* In cardbus.c */ 108/* In cardbus.c */
118int cb_alloc(struct pcmcia_socket *s); 109int cb_alloc(struct pcmcia_socket *s);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 367ebf75beeb..1cae9fda4e47 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -163,7 +163,7 @@ static int pcmcia_report_error(client_handle_t handle, error_info_t *err)
163 int i; 163 int i;
164 char *serv; 164 char *serv;
165 165
166 if (CHECK_HANDLE(handle)) 166 if (!handle)
167 printk(KERN_NOTICE); 167 printk(KERN_NOTICE);
168 else { 168 else {
169 struct pcmcia_device *p_dev = handle_to_pdev(handle); 169 struct pcmcia_device *p_dev = handle_to_pdev(handle);
@@ -380,7 +380,7 @@ static int pcmcia_device_probe(struct device * dev)
380 380
381 if (p_drv->attach) { 381 if (p_drv->attach) {
382 p_dev->instance = p_drv->attach(); 382 p_dev->instance = p_drv->attach();
383 if ((!p_dev->instance) || (p_dev->client.state & CLIENT_UNBOUND)) { 383 if ((!p_dev->instance) || (p_dev->state & CLIENT_UNBOUND)) {
384 printk(KERN_NOTICE "ds: unable to create instance " 384 printk(KERN_NOTICE "ds: unable to create instance "
385 "of '%s'!\n", p_drv->drv.name); 385 "of '%s'!\n", p_drv->drv.name);
386 ret = -EINVAL; 386 ret = -EINVAL;
@@ -520,10 +520,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
520 sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); 520 sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no);
521 521
522 /* compat */ 522 /* compat */
523 p_dev->client.client_magic = CLIENT_MAGIC; 523 p_dev->state = CLIENT_UNBOUND;
524 p_dev->client.Socket = s;
525 p_dev->client.Function = function;
526 p_dev->client.state = CLIENT_UNBOUND;
527 524
528 /* Add to the list in pcmcia_bus_socket */ 525 /* Add to the list in pcmcia_bus_socket */
529 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 526 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
@@ -930,7 +927,7 @@ static int send_event_callback(struct device *dev, void * _data)
930 if (!p_drv) 927 if (!p_drv)
931 return 0; 928 return 0;
932 929
933 if (p_dev->client.state & (CLIENT_UNBOUND|CLIENT_STALE)) 930 if (p_dev->state & (CLIENT_UNBOUND|CLIENT_STALE))
934 return 0; 931 return 0;
935 932
936 if (p_drv->event) 933 if (p_drv->event)
@@ -999,7 +996,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
999 996
1000int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) 997int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
1001{ 998{
1002 client_t *client = NULL; 999 struct pcmcia_device *client = NULL;
1003 struct pcmcia_socket *s = NULL; 1000 struct pcmcia_socket *s = NULL;
1004 struct pcmcia_device *p_dev = NULL; 1001 struct pcmcia_device *p_dev = NULL;
1005 struct pcmcia_driver *p_drv = NULL; 1002 struct pcmcia_driver *p_drv = NULL;
@@ -1020,14 +1017,14 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
1020 p_dev = pcmcia_get_dev(p_dev); 1017 p_dev = pcmcia_get_dev(p_dev);
1021 if (!p_dev) 1018 if (!p_dev)
1022 continue; 1019 continue;
1023 if (!(p_dev->client.state & CLIENT_UNBOUND) || 1020 if (!(p_dev->state & CLIENT_UNBOUND) ||
1024 (!p_dev->dev.driver)) { 1021 (!p_dev->dev.driver)) {
1025 pcmcia_put_dev(p_dev); 1022 pcmcia_put_dev(p_dev);
1026 continue; 1023 continue;
1027 } 1024 }
1028 p_drv = to_pcmcia_drv(p_dev->dev.driver); 1025 p_drv = to_pcmcia_drv(p_dev->dev.driver);
1029 if (!strncmp(p_drv->drv.name, (char *)req->dev_info, DEV_NAME_LEN)) { 1026 if (!strncmp(p_drv->drv.name, (char *)req->dev_info, DEV_NAME_LEN)) {
1030 client = &p_dev->client; 1027 client = p_dev;
1031 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 1028 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1032 goto found; 1029 goto found;
1033 } 1030 }
@@ -1043,20 +1040,18 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
1043 1040
1044 pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */ 1041 pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */
1045 1042
1046 *handle = client; 1043 *handle = p_dev;
1047 client->state &= ~CLIENT_UNBOUND; 1044 p_dev->state &= ~CLIENT_UNBOUND;
1048 client->Socket = s;
1049 p_dev->event_callback_args = req->event_callback_args; 1045 p_dev->event_callback_args = req->event_callback_args;
1050 p_dev->event_callback_args.client_handle = client; 1046 p_dev->event_callback_args.client_handle = p_dev;
1051 1047
1052 1048
1053 if (s->state & SOCKET_CARDBUS) 1049 if (s->state & SOCKET_CARDBUS)
1054 client->state |= CLIENT_CARDBUS; 1050 client->state |= CLIENT_CARDBUS;
1055 1051
1056 if ((!(s->state & SOCKET_CARDBUS)) && (s->functions == 0) && 1052 if ((!(s->state & SOCKET_CARDBUS)) && (s->functions == 0)) {
1057 (client->Function != BIND_FN_ALL)) {
1058 cistpl_longlink_mfc_t mfc; 1053 cistpl_longlink_mfc_t mfc;
1059 if (pccard_read_tuple(s, client->Function, CISTPL_LONGLINK_MFC, &mfc) 1054 if (pccard_read_tuple(s, client->func, CISTPL_LONGLINK_MFC, &mfc)
1060 == CS_SUCCESS) 1055 == CS_SUCCESS)
1061 s->functions = mfc.nfn; 1056 s->functions = mfc.nfn;
1062 else 1057 else
@@ -1108,7 +1103,7 @@ static int unbind_request(struct pcmcia_socket *s)
1108 } 1103 }
1109 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list); 1104 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list);
1110 list_del(&p_dev->socket_device_list); 1105 list_del(&p_dev->socket_device_list);
1111 p_dev->client.state |= CLIENT_STALE; 1106 p_dev->state |= CLIENT_STALE;
1112 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 1107 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1113 1108
1114 device_unregister(&p_dev->dev); 1109 device_unregister(&p_dev->dev);
@@ -1123,9 +1118,6 @@ int pcmcia_deregister_client(client_handle_t handle)
1123 int i; 1118 int i;
1124 struct pcmcia_device *p_dev = handle_to_pdev(handle); 1119 struct pcmcia_device *p_dev = handle_to_pdev(handle);
1125 1120
1126 if (CHECK_HANDLE(handle))
1127 return CS_BAD_HANDLE;
1128
1129 s = SOCKET(handle); 1121 s = SOCKET(handle);
1130 ds_dbg(1, "deregister_client(%p)\n", handle); 1122 ds_dbg(1, "deregister_client(%p)\n", handle);
1131 1123
@@ -1136,7 +1128,6 @@ int pcmcia_deregister_client(client_handle_t handle)
1136 goto warn_out; 1128 goto warn_out;
1137 1129
1138 if (handle->state & CLIENT_STALE) { 1130 if (handle->state & CLIENT_STALE) {
1139 handle->client_magic = 0;
1140 handle->state &= ~CLIENT_STALE; 1131 handle->state &= ~CLIENT_STALE;
1141 pcmcia_put_dev(p_dev); 1132 pcmcia_put_dev(p_dev);
1142 } else { 1133 } else {
diff --git a/drivers/pcmcia/pcmcia_compat.c b/drivers/pcmcia/pcmcia_compat.c
index 1cc83317e7e3..916de6f85a2f 100644
--- a/drivers/pcmcia/pcmcia_compat.c
+++ b/drivers/pcmcia/pcmcia_compat.c
@@ -31,28 +31,22 @@
31int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple) 31int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple)
32{ 32{
33 struct pcmcia_socket *s; 33 struct pcmcia_socket *s;
34 if (CHECK_HANDLE(handle))
35 return CS_BAD_HANDLE;
36 s = SOCKET(handle); 34 s = SOCKET(handle);
37 return pccard_get_first_tuple(s, handle->Function, tuple); 35 return pccard_get_first_tuple(s, handle->func, tuple);
38} 36}
39EXPORT_SYMBOL(pcmcia_get_first_tuple); 37EXPORT_SYMBOL(pcmcia_get_first_tuple);
40 38
41int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple) 39int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple)
42{ 40{
43 struct pcmcia_socket *s; 41 struct pcmcia_socket *s;
44 if (CHECK_HANDLE(handle))
45 return CS_BAD_HANDLE;
46 s = SOCKET(handle); 42 s = SOCKET(handle);
47 return pccard_get_next_tuple(s, handle->Function, tuple); 43 return pccard_get_next_tuple(s, handle->func, tuple);
48} 44}
49EXPORT_SYMBOL(pcmcia_get_next_tuple); 45EXPORT_SYMBOL(pcmcia_get_next_tuple);
50 46
51int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple) 47int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple)
52{ 48{
53 struct pcmcia_socket *s; 49 struct pcmcia_socket *s;
54 if (CHECK_HANDLE(handle))
55 return CS_BAD_HANDLE;
56 s = SOCKET(handle); 50 s = SOCKET(handle);
57 return pccard_get_tuple_data(s, tuple); 51 return pccard_get_tuple_data(s, tuple);
58} 52}
@@ -67,10 +61,8 @@ EXPORT_SYMBOL(pcmcia_parse_tuple);
67int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info) 61int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info)
68{ 62{
69 struct pcmcia_socket *s; 63 struct pcmcia_socket *s;
70 if (CHECK_HANDLE(handle))
71 return CS_BAD_HANDLE;
72 s = SOCKET(handle); 64 s = SOCKET(handle);
73 return pccard_validate_cis(s, handle->Function, info); 65 return pccard_validate_cis(s, handle->func, info);
74} 66}
75EXPORT_SYMBOL(pcmcia_validate_cis); 67EXPORT_SYMBOL(pcmcia_validate_cis);
76 68
@@ -78,9 +70,7 @@ EXPORT_SYMBOL(pcmcia_validate_cis);
78int pcmcia_reset_card(client_handle_t handle, client_req_t *req) 70int pcmcia_reset_card(client_handle_t handle, client_req_t *req)
79{ 71{
80 struct pcmcia_socket *skt; 72 struct pcmcia_socket *skt;
81 73
82 if (CHECK_HANDLE(handle))
83 return CS_BAD_HANDLE;
84 skt = SOCKET(handle); 74 skt = SOCKET(handle);
85 if (!skt) 75 if (!skt)
86 return CS_BAD_HANDLE; 76 return CS_BAD_HANDLE;
@@ -88,4 +78,3 @@ int pcmcia_reset_card(client_handle_t handle, client_req_t *req)
88 return pccard_reset_card(skt); 78 return pccard_reset_card(skt);
89} 79}
90EXPORT_SYMBOL(pcmcia_reset_card); 80EXPORT_SYMBOL(pcmcia_reset_card);
91
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index c01dc6bf1526..ac5c3abe70c0 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -206,10 +206,8 @@ int pcmcia_access_configuration_register(client_handle_t handle,
206 conf_reg_t *reg) 206 conf_reg_t *reg)
207{ 207{
208 struct pcmcia_socket *s; 208 struct pcmcia_socket *s;
209 if (CHECK_HANDLE(handle))
210 return CS_BAD_HANDLE;
211 s = SOCKET(handle); 209 s = SOCKET(handle);
212 return pccard_access_configuration_register(s, handle->Function, reg); 210 return pccard_access_configuration_register(s, handle->func, reg);
213} 211}
214EXPORT_SYMBOL(pcmcia_access_configuration_register); 212EXPORT_SYMBOL(pcmcia_access_configuration_register);
215 213
@@ -276,12 +274,12 @@ int pcmcia_get_configuration_info(client_handle_t handle,
276{ 274{
277 struct pcmcia_socket *s; 275 struct pcmcia_socket *s;
278 276
279 if ((CHECK_HANDLE(handle)) || !config) 277 if (!config)
280 return CS_BAD_HANDLE; 278 return CS_BAD_HANDLE;
281 s = SOCKET(handle); 279 s = SOCKET(handle);
282 if (!s) 280 if (!s)
283 return CS_BAD_HANDLE; 281 return CS_BAD_HANDLE;
284 return pccard_get_configuration_info(s, handle->Function, config); 282 return pccard_get_configuration_info(s, handle->func, config);
285} 283}
286EXPORT_SYMBOL(pcmcia_get_configuration_info); 284EXPORT_SYMBOL(pcmcia_get_configuration_info);
287 285
@@ -382,10 +380,8 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
382int pcmcia_get_status(client_handle_t handle, cs_status_t *status) 380int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
383{ 381{
384 struct pcmcia_socket *s; 382 struct pcmcia_socket *s;
385 if (CHECK_HANDLE(handle))
386 return CS_BAD_HANDLE;
387 s = SOCKET(handle); 383 s = SOCKET(handle);
388 return pccard_get_status(s, handle->Function, status); 384 return pccard_get_status(s, handle->func, status);
389} 385}
390EXPORT_SYMBOL(pcmcia_get_status); 386EXPORT_SYMBOL(pcmcia_get_status);
391 387
@@ -432,8 +428,6 @@ int pcmcia_modify_configuration(client_handle_t handle,
432 struct pcmcia_socket *s; 428 struct pcmcia_socket *s;
433 config_t *c; 429 config_t *c;
434 430
435 if (CHECK_HANDLE(handle))
436 return CS_BAD_HANDLE;
437 s = SOCKET(handle); 431 s = SOCKET(handle);
438 c = CONFIG(handle); 432 c = CONFIG(handle);
439 if (!(s->state & SOCKET_PRESENT)) 433 if (!(s->state & SOCKET_PRESENT))
@@ -478,8 +472,7 @@ int pcmcia_release_configuration(client_handle_t handle)
478 struct pcmcia_socket *s; 472 struct pcmcia_socket *s;
479 int i; 473 int i;
480 474
481 if (CHECK_HANDLE(handle) || 475 if (!(handle->state & CLIENT_CONFIG_LOCKED))
482 !(handle->state & CLIENT_CONFIG_LOCKED))
483 return CS_BAD_HANDLE; 476 return CS_BAD_HANDLE;
484 handle->state &= ~CLIENT_CONFIG_LOCKED; 477 handle->state &= ~CLIENT_CONFIG_LOCKED;
485 s = SOCKET(handle); 478 s = SOCKET(handle);
@@ -527,7 +520,7 @@ int pcmcia_release_io(client_handle_t handle, io_req_t *req)
527{ 520{
528 struct pcmcia_socket *s; 521 struct pcmcia_socket *s;
529 522
530 if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IO_REQ)) 523 if (!(handle->state & CLIENT_IO_REQ))
531 return CS_BAD_HANDLE; 524 return CS_BAD_HANDLE;
532 handle->state &= ~CLIENT_IO_REQ; 525 handle->state &= ~CLIENT_IO_REQ;
533 s = SOCKET(handle); 526 s = SOCKET(handle);
@@ -561,7 +554,7 @@ EXPORT_SYMBOL(pcmcia_release_io);
561int pcmcia_release_irq(client_handle_t handle, irq_req_t *req) 554int pcmcia_release_irq(client_handle_t handle, irq_req_t *req)
562{ 555{
563 struct pcmcia_socket *s; 556 struct pcmcia_socket *s;
564 if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IRQ_REQ)) 557 if (!(handle->state & CLIENT_IRQ_REQ))
565 return CS_BAD_HANDLE; 558 return CS_BAD_HANDLE;
566 handle->state &= ~CLIENT_IRQ_REQ; 559 handle->state &= ~CLIENT_IRQ_REQ;
567 s = SOCKET(handle); 560 s = SOCKET(handle);
@@ -632,8 +625,6 @@ int pcmcia_request_configuration(client_handle_t handle,
632 config_t *c; 625 config_t *c;
633 pccard_io_map iomap; 626 pccard_io_map iomap;
634 627
635 if (CHECK_HANDLE(handle))
636 return CS_BAD_HANDLE;
637 s = SOCKET(handle); 628 s = SOCKET(handle);
638 if (!(s->state & SOCKET_PRESENT)) 629 if (!(s->state & SOCKET_PRESENT))
639 return CS_NO_CARD; 630 return CS_NO_CARD;
@@ -762,8 +753,6 @@ int pcmcia_request_io(client_handle_t handle, io_req_t *req)
762 struct pcmcia_socket *s; 753 struct pcmcia_socket *s;
763 config_t *c; 754 config_t *c;
764 755
765 if (CHECK_HANDLE(handle))
766 return CS_BAD_HANDLE;
767 s = SOCKET(handle); 756 s = SOCKET(handle);
768 if (!(s->state & SOCKET_PRESENT)) 757 if (!(s->state & SOCKET_PRESENT))
769 return CS_NO_CARD; 758 return CS_NO_CARD;
@@ -834,8 +823,6 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req)
834 int ret = CS_IN_USE, irq = 0; 823 int ret = CS_IN_USE, irq = 0;
835 struct pcmcia_device *p_dev = handle_to_pdev(handle); 824 struct pcmcia_device *p_dev = handle_to_pdev(handle);
836 825
837 if (CHECK_HANDLE(handle))
838 return CS_BAD_HANDLE;
839 s = SOCKET(handle); 826 s = SOCKET(handle);
840 if (!(s->state & SOCKET_PRESENT)) 827 if (!(s->state & SOCKET_PRESENT))
841 return CS_NO_CARD; 828 return CS_NO_CARD;
@@ -926,9 +913,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
926 u_long align; 913 u_long align;
927 int w; 914 int w;
928 915
929 if (CHECK_HANDLE(*handle)) 916 s = (*handle)->socket;
930 return CS_BAD_HANDLE;
931 s = (*handle)->Socket;
932 if (!(s->state & SOCKET_PRESENT)) 917 if (!(s->state & SOCKET_PRESENT))
933 return CS_NO_CARD; 918 return CS_NO_CARD;
934 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) 919 if (req->Attributes & (WIN_PAGED | WIN_SHARED))