aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/ds.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r--drivers/pcmcia/ds.c35
1 files changed, 13 insertions, 22 deletions
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 {