From 98e4c28b7ec390c2dad6a4c69d69629c0f7e8b10 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:21:18 +0100 Subject: [PATCH] pcmcia: new suspend core Move the suspend and resume methods out of the event handler, and into special functions. Also use these functions for pre- and post-reset, as almost all drivers already do, and the remaining ones can easily be converted. Bugfix to include/pcmcia/ds.c Signed-off-by: Andrew Morton Signed-off-by: Dominik Brodowski --- drivers/net/pcmcia/fmvj18x_cs.c | 57 +++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'drivers/net/pcmcia/fmvj18x_cs.c') diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 356f5090922..388ecade13d 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -713,6 +713,39 @@ static void fmvj18x_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int fmvj18x_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + + return 0; +} + +static int fmvj18x_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + fjn_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + /*====================================================================*/ static int fmvj18x_event(event_t event, int priority, @@ -733,28 +766,6 @@ static int fmvj18x_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; fmvj18x_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - fjn_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; } /* fmvj18x_event */ @@ -793,6 +804,8 @@ static struct pcmcia_driver fmvj18x_cs_driver = { .event = fmvj18x_event, .detach = fmvj18x_detach, .id_table = fmvj18x_ids, + .suspend = fmvj18x_suspend, + .resume = fmvj18x_resume, }; static int __init init_fmvj18x_cs(void) -- cgit v1.2.3 From cc3b4866bee996c922e875b8c8efe9f0d8803aae Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:23:14 +0100 Subject: [PATCH] pcmcia: unify detach, REMOVAL_EVENT handlers into one remove callback Unify the "detach" and REMOVAL_EVENT handlers to one "remove" function. Old functionality is preserved, for the moment. Signed-off-by: Dominik Brodowski --- drivers/net/pcmcia/fmvj18x_cs.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'drivers/net/pcmcia/fmvj18x_cs.c') diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 388ecade13d..560d4ee2280 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -91,7 +91,7 @@ static void fmvj18x_release(dev_link_t *link); static int fmvj18x_event(event_t event, int priority, event_callback_args_t *args); static dev_link_t *fmvj18x_attach(void); -static void fmvj18x_detach(dev_link_t *); +static void fmvj18x_detach(struct pcmcia_device *p_dev); /* LAN controller(MBH86960A) specific routines @@ -291,7 +291,7 @@ static dev_link_t *fmvj18x_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - fmvj18x_detach(link); + fmvj18x_detach(link->handle); return NULL; } @@ -300,8 +300,9 @@ static dev_link_t *fmvj18x_attach(void) /*====================================================================*/ -static void fmvj18x_detach(dev_link_t *link) +static void fmvj18x_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -319,10 +320,6 @@ static void fmvj18x_detach(dev_link_t *link) if (link->state & DEV_CONFIG) fmvj18x_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free pieces */ *linkp = link->next; free_netdev(dev); @@ -752,16 +749,10 @@ static int fmvj18x_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(1, "fmvj18x_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; fmvj18x_config(link); @@ -802,7 +793,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = { }, .attach = fmvj18x_attach, .event = fmvj18x_event, - .detach = fmvj18x_detach, + .remove = fmvj18x_detach, .id_table = fmvj18x_ids, .suspend = fmvj18x_suspend, .resume = fmvj18x_resume, -- cgit v1.2.3 From b463581154f3f3eecda27cae60df813fefcd84d3 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:25:35 +0100 Subject: [PATCH] pcmcia: remove dev_list from drivers The linked list of devices managed by each PCMCIA driver is, in very most cases, unused. Therefore, remove it from many drivers. Signed-off-by: Dominik Brodowski --- drivers/net/pcmcia/fmvj18x_cs.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'drivers/net/pcmcia/fmvj18x_cs.c') diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 560d4ee2280..dad6393052f 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -109,7 +109,6 @@ static void fjn_tx_timeout(struct net_device *dev); static struct ethtool_ops netdev_ethtool_ops; static dev_info_t dev_info = "fmvj18x_cs"; -static dev_link_t *dev_list; /* card type @@ -283,8 +282,7 @@ static dev_link_t *fmvj18x_attach(void) SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -304,15 +302,8 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; - + DEBUG(0, "fmvj18x_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; if (link->dev) unregister_netdev(dev); @@ -320,8 +311,6 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev) if (link->state & DEV_CONFIG) fmvj18x_release(link); - /* Unlink device structure, free pieces */ - *linkp = link->next; free_netdev(dev); } /* fmvj18x_detach */ @@ -807,7 +796,6 @@ static int __init init_fmvj18x_cs(void) static void __exit exit_fmvj18x_cs(void) { pcmcia_unregister_driver(&fmvj18x_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_fmvj18x_cs); -- cgit v1.2.3 From f8cfa618dccbdc6dab5297f75779566a388a98fd Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:25:51 +0100 Subject: [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 --- drivers/net/pcmcia/fmvj18x_cs.c | 54 +++++++++-------------------------------- 1 file changed, 12 insertions(+), 42 deletions(-) (limited to 'drivers/net/pcmcia/fmvj18x_cs.c') diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index dad6393052f..28fe2fb4d6c 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -88,9 +88,6 @@ static void fmvj18x_config(dev_link_t *link); static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id); static int fmvj18x_setup_mfc(dev_link_t *link); static void fmvj18x_release(dev_link_t *link); -static int fmvj18x_event(event_t event, int priority, - event_callback_args_t *args); -static dev_link_t *fmvj18x_attach(void); static void fmvj18x_detach(struct pcmcia_device *p_dev); /* @@ -108,8 +105,6 @@ static void set_rx_mode(struct net_device *dev); static void fjn_tx_timeout(struct net_device *dev); static struct ethtool_ops netdev_ethtool_ops; -static dev_info_t dev_info = "fmvj18x_cs"; - /* card type */ @@ -233,20 +228,18 @@ typedef struct local_info_t { #define BANK_1U 0x24 /* bank 1 (CONFIG_1) */ #define BANK_2U 0x28 /* bank 2 (CONFIG_1) */ -static dev_link_t *fmvj18x_attach(void) +static int fmvj18x_attach(struct pcmcia_device *p_dev) { local_info_t *lp; dev_link_t *link; struct net_device *dev; - client_reg_t client_reg; - int ret; - + DEBUG(0, "fmvj18x_attach()\n"); /* Make up a FMVJ18x specific data structure */ dev = alloc_etherdev(sizeof(local_info_t)); if (!dev) - return NULL; + return -ENOMEM; lp = netdev_priv(dev); link = &lp->link; link->priv = dev; @@ -261,7 +254,7 @@ static dev_link_t *fmvj18x_attach(void) link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &fjn_interrupt; link->irq.Instance = dev; - + /* General socket configuration */ link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Vcc = 50; @@ -280,20 +273,14 @@ static dev_link_t *fmvj18x_attach(void) dev->watchdog_timeo = TX_TIMEOUT; #endif SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - fmvj18x_detach(link->handle); - return NULL; - } - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + fmvj18x_config(link); + + return 0; } /* fmvj18x_attach */ /*====================================================================*/ @@ -734,22 +721,6 @@ static int fmvj18x_resume(struct pcmcia_device *p_dev) /*====================================================================*/ -static int fmvj18x_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "fmvj18x_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - fmvj18x_config(link); - break; - } - return 0; -} /* fmvj18x_event */ - static struct pcmcia_device_id fmvj18x_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004), PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59), @@ -780,8 +751,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = { .drv = { .name = "fmvj18x_cs", }, - .attach = fmvj18x_attach, - .event = fmvj18x_event, + .probe = fmvj18x_attach, .remove = fmvj18x_detach, .id_table = fmvj18x_ids, .suspend = fmvj18x_suspend, -- cgit v1.2.3