aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/ibmtr_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 15:25:51 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-05 18:03:24 -0500
commitf8cfa618dccbdc6dab5297f75779566a388a98fd (patch)
treeb91e0952038dafc6e03bf8b1d8948b1fdefec031 /drivers/net/pcmcia/ibmtr_cs.c
parentb463581154f3f3eecda27cae60df813fefcd84d3 (diff)
[PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback
Unify the EVENT_CARD_INSERTION and "attach" callbacks to one unified probe() callback. As all in-kernel drivers are changed to this new callback, there will be no temporary backwards-compatibility. Inside a probe() function, each driver _must_ set struct pcmcia_device *p_dev->instance and instance->handle correctly. With these patches, the basic driver interface for 16-bit PCMCIA drivers now has the classic four callbacks known also from other buses: int (*probe) (struct pcmcia_device *dev); void (*remove) (struct pcmcia_device *dev); int (*suspend) (struct pcmcia_device *dev); int (*resume) (struct pcmcia_device *dev); Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/pcmcia/ibmtr_cs.c')
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c69
1 files changed, 12 insertions, 57 deletions
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 90da35d1f4a5..b9c7e39576f5 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -108,12 +108,6 @@ MODULE_LICENSE("GPL");
108static void ibmtr_config(dev_link_t *link); 108static void ibmtr_config(dev_link_t *link);
109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase); 109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase);
110static void ibmtr_release(dev_link_t *link); 110static void ibmtr_release(dev_link_t *link);
111static int ibmtr_event(event_t event, int priority,
112 event_callback_args_t *args);
113
114static dev_info_t dev_info = "ibmtr_cs";
115
116static dev_link_t *ibmtr_attach(void);
117static void ibmtr_detach(struct pcmcia_device *p_dev); 111static void ibmtr_detach(struct pcmcia_device *p_dev);
118 112
119/*====================================================================*/ 113/*====================================================================*/
@@ -144,25 +138,23 @@ static struct ethtool_ops netdev_ethtool_ops = {
144 138
145======================================================================*/ 139======================================================================*/
146 140
147static dev_link_t *ibmtr_attach(void) 141static int ibmtr_attach(struct pcmcia_device *p_dev)
148{ 142{
149 ibmtr_dev_t *info; 143 ibmtr_dev_t *info;
150 dev_link_t *link; 144 dev_link_t *link;
151 struct net_device *dev; 145 struct net_device *dev;
152 client_reg_t client_reg;
153 int ret;
154 146
155 DEBUG(0, "ibmtr_attach()\n"); 147 DEBUG(0, "ibmtr_attach()\n");
156 148
157 /* Create new token-ring device */ 149 /* Create new token-ring device */
158 info = kmalloc(sizeof(*info), GFP_KERNEL); 150 info = kmalloc(sizeof(*info), GFP_KERNEL);
159 if (!info) return NULL; 151 if (!info) return -ENOMEM;
160 memset(info,0,sizeof(*info)); 152 memset(info,0,sizeof(*info));
161 dev = alloc_trdev(sizeof(struct tok_info)); 153 dev = alloc_trdev(sizeof(struct tok_info));
162 if (!dev) { 154 if (!dev) {
163 kfree(info); 155 kfree(info);
164 return NULL; 156 return -ENOMEM;
165 } 157 }
166 158
167 link = &info->link; 159 link = &info->link;
168 link->priv = info; 160 link->priv = info;
@@ -183,24 +175,13 @@ static dev_link_t *ibmtr_attach(void)
183 175
184 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 176 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
185 177
186 /* Register with Card Services */ 178 link->handle = p_dev;
187 link->next = NULL; 179 p_dev->instance = link;
188 client_reg.dev_info = &dev_info;
189 client_reg.Version = 0x0210;
190 client_reg.event_callback_args.client_data = link;
191 ret = pcmcia_register_client(&link->handle, &client_reg);
192 if (ret != 0) {
193 cs_error(link->handle, RegisterClient, ret);
194 goto out_detach;
195 }
196 180
197out: 181 link->state |= DEV_PRESENT;
198 return link; 182 ibmtr_config(link);
199 183
200out_detach: 184 return 0;
201 ibmtr_detach(link->handle);
202 link = NULL;
203 goto out;
204} /* ibmtr_attach */ 185} /* ibmtr_attach */
205 186
206/*====================================================================== 187/*======================================================================
@@ -420,31 +401,6 @@ static int ibmtr_resume(struct pcmcia_device *p_dev)
420} 401}
421 402
422 403
423/*======================================================================
424
425 The card status event handler. Mostly, this schedules other
426 stuff to run after an event is received. A CARD_REMOVAL event
427 also sets some flags to discourage the net drivers from trying
428 to talk to the card any more.
429
430======================================================================*/
431
432static int ibmtr_event(event_t event, int priority,
433 event_callback_args_t *args)
434{
435 dev_link_t *link = args->client_data;
436
437 DEBUG(1, "ibmtr_event(0x%06x)\n", event);
438
439 switch (event) {
440 case CS_EVENT_CARD_INSERTION:
441 link->state |= DEV_PRESENT;
442 ibmtr_config(link);
443 break;
444 }
445 return 0;
446} /* ibmtr_event */
447
448/*====================================================================*/ 404/*====================================================================*/
449 405
450static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase) 406static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase)
@@ -500,8 +456,7 @@ static struct pcmcia_driver ibmtr_cs_driver = {
500 .drv = { 456 .drv = {
501 .name = "ibmtr_cs", 457 .name = "ibmtr_cs",
502 }, 458 },
503 .attach = ibmtr_attach, 459 .probe = ibmtr_attach,
504 .event = ibmtr_event,
505 .remove = ibmtr_detach, 460 .remove = ibmtr_detach,
506 .id_table = ibmtr_ids, 461 .id_table = ibmtr_ids,
507 .suspend = ibmtr_suspend, 462 .suspend = ibmtr_suspend,