aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/3c589_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/3c589_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/3c589_cs.c')
-rw-r--r--drivers/net/pcmcia/3c589_cs.c63
1 files changed, 12 insertions, 51 deletions
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 3516c02b9c89..1c3c9c666f74 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -143,8 +143,6 @@ DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)";
143 143
144static void tc589_config(dev_link_t *link); 144static void tc589_config(dev_link_t *link);
145static void tc589_release(dev_link_t *link); 145static void tc589_release(dev_link_t *link);
146static int tc589_event(event_t event, int priority,
147 event_callback_args_t *args);
148 146
149static u16 read_eeprom(kio_addr_t ioaddr, int index); 147static u16 read_eeprom(kio_addr_t ioaddr, int index);
150static void tc589_reset(struct net_device *dev); 148static void tc589_reset(struct net_device *dev);
@@ -161,9 +159,6 @@ static void el3_tx_timeout(struct net_device *dev);
161static void set_multicast_list(struct net_device *dev); 159static void set_multicast_list(struct net_device *dev);
162static struct ethtool_ops netdev_ethtool_ops; 160static struct ethtool_ops netdev_ethtool_ops;
163 161
164static dev_info_t dev_info = "3c589_cs";
165
166static dev_link_t *tc589_attach(void);
167static void tc589_detach(struct pcmcia_device *p_dev); 162static void tc589_detach(struct pcmcia_device *p_dev);
168 163
169/*====================================================================== 164/*======================================================================
@@ -174,20 +169,18 @@ static void tc589_detach(struct pcmcia_device *p_dev);
174 169
175======================================================================*/ 170======================================================================*/
176 171
177static dev_link_t *tc589_attach(void) 172static int tc589_attach(struct pcmcia_device *p_dev)
178{ 173{
179 struct el3_private *lp; 174 struct el3_private *lp;
180 client_reg_t client_reg;
181 dev_link_t *link; 175 dev_link_t *link;
182 struct net_device *dev; 176 struct net_device *dev;
183 int ret;
184 177
185 DEBUG(0, "3c589_attach()\n"); 178 DEBUG(0, "3c589_attach()\n");
186 179
187 /* Create new ethernet device */ 180 /* Create new ethernet device */
188 dev = alloc_etherdev(sizeof(struct el3_private)); 181 dev = alloc_etherdev(sizeof(struct el3_private));
189 if (!dev) 182 if (!dev)
190 return NULL; 183 return -ENOMEM;
191 lp = netdev_priv(dev); 184 lp = netdev_priv(dev);
192 link = &lp->link; 185 link = &lp->link;
193 link->priv = dev; 186 link->priv = dev;
@@ -204,7 +197,7 @@ static dev_link_t *tc589_attach(void)
204 link->conf.IntType = INT_MEMORY_AND_IO; 197 link->conf.IntType = INT_MEMORY_AND_IO;
205 link->conf.ConfigIndex = 1; 198 link->conf.ConfigIndex = 1;
206 link->conf.Present = PRESENT_OPTION; 199 link->conf.Present = PRESENT_OPTION;
207 200
208 /* The EL3-specific entries in the device structure. */ 201 /* The EL3-specific entries in the device structure. */
209 SET_MODULE_OWNER(dev); 202 SET_MODULE_OWNER(dev);
210 dev->hard_start_xmit = &el3_start_xmit; 203 dev->hard_start_xmit = &el3_start_xmit;
@@ -219,19 +212,13 @@ static dev_link_t *tc589_attach(void)
219#endif 212#endif
220 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 213 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
221 214
222 /* Register with Card Services */ 215 link->handle = p_dev;
223 link->next = NULL; 216 p_dev->instance = link;
224 client_reg.dev_info = &dev_info; 217
225 client_reg.Version = 0x0210; 218 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
226 client_reg.event_callback_args.client_data = link; 219 tc589_config(link);
227 ret = pcmcia_register_client(&link->handle, &client_reg); 220
228 if (ret != 0) { 221 return 0;
229 cs_error(link->handle, RegisterClient, ret);
230 tc589_detach(link->handle);
231 return NULL;
232 }
233
234 return link;
235} /* tc589_attach */ 222} /* tc589_attach */
236 223
237/*====================================================================== 224/*======================================================================
@@ -439,31 +426,6 @@ static int tc589_resume(struct pcmcia_device *p_dev)
439 return 0; 426 return 0;
440} 427}
441 428
442/*======================================================================
443
444 The card status event handler. Mostly, this schedules other
445 stuff to run after an event is received. A CARD_REMOVAL event
446 also sets some flags to discourage the net drivers from trying
447 to talk to the card any more.
448
449======================================================================*/
450
451static int tc589_event(event_t event, int priority,
452 event_callback_args_t *args)
453{
454 dev_link_t *link = args->client_data;
455
456 DEBUG(1, "3c589_event(0x%06x)\n", event);
457
458 switch (event) {
459 case CS_EVENT_CARD_INSERTION:
460 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
461 tc589_config(link);
462 break;
463 }
464 return 0;
465} /* tc589_event */
466
467/*====================================================================*/ 429/*====================================================================*/
468 430
469/* 431/*
@@ -1057,8 +1019,7 @@ static struct pcmcia_driver tc589_driver = {
1057 .drv = { 1019 .drv = {
1058 .name = "3c589_cs", 1020 .name = "3c589_cs",
1059 }, 1021 },
1060 .attach = tc589_attach, 1022 .probe = tc589_attach,
1061 .event = tc589_event,
1062 .remove = tc589_detach, 1023 .remove = tc589_detach,
1063 .id_table = tc589_ids, 1024 .id_table = tc589_ids,
1064 .suspend = tc589_suspend, 1025 .suspend = tc589_suspend,