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/serial/serial_cs.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 7ce0c7e66d37..3487ee9eab1d 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -159,8 +159,9 @@ static void serial_remove(dev_link_t *link) } } -static void serial_suspend(dev_link_t *link) +static int serial_suspend(struct pcmcia_device *dev) { + dev_link_t *link = dev_to_instance(dev); link->state |= DEV_SUSPEND; if (link->state & DEV_CONFIG) { @@ -173,10 +174,13 @@ static void serial_suspend(dev_link_t *link) if (!info->slave) pcmcia_release_configuration(link->handle); } + + return 0; } -static void serial_resume(dev_link_t *link) +static int serial_resume(struct pcmcia_device *dev) { + dev_link_t *link = dev_to_instance(dev); link->state &= ~DEV_SUSPEND; if (DEV_OK(link)) { @@ -189,6 +193,8 @@ static void serial_resume(dev_link_t *link) for (i = 0; i < info->ndev; i++) serial8250_resume_port(info->line[i]); } + + return 0; } /*====================================================================== @@ -731,7 +737,6 @@ static int serial_event(event_t event, int priority, event_callback_args_t * args) { dev_link_t *link = args->client_data; - struct serial_info *info = link->priv; DEBUG(1, "serial_event(0x%06x)\n", event); @@ -744,24 +749,6 @@ serial_event(event_t event, int priority, event_callback_args_t * args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; serial_config(link); break; - - case CS_EVENT_PM_SUSPEND: - serial_suspend(link); - break; - - case CS_EVENT_RESET_PHYSICAL: - if ((link->state & DEV_CONFIG) && !info->slave) - pcmcia_release_configuration(link->handle); - break; - - case CS_EVENT_PM_RESUME: - serial_resume(link); - break; - - case CS_EVENT_CARD_RESET: - if (DEV_OK(link) && !info->slave) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; } @@ -881,6 +868,8 @@ static struct pcmcia_driver serial_cs_driver = { .event = serial_event, .detach = serial_detach, .id_table = serial_ids, + .suspend = serial_suspend, + .resume = serial_resume, }; static int __init init_serial_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/serial/serial_cs.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 3487ee9eab1d..a95366366504 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -120,7 +120,7 @@ static int serial_event(event_t event, int priority, static dev_info_t dev_info = "serial_cs"; static dev_link_t *serial_attach(void); -static void serial_detach(dev_link_t *); +static void serial_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -242,7 +242,7 @@ static dev_link_t *serial_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - serial_detach(link); + serial_detach(link->handle); return NULL; } @@ -258,11 +258,11 @@ static dev_link_t *serial_attach(void) ======================================================================*/ -static void serial_detach(dev_link_t * link) +static void serial_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct serial_info *info = link->priv; dev_link_t **linkp; - int ret; DEBUG(0, "serial_detach(0x%p)\n", link); @@ -283,12 +283,6 @@ static void serial_detach(dev_link_t * link) */ serial_remove(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; kfree(info); @@ -741,9 +735,6 @@ serial_event(event_t event, int priority, event_callback_args_t * args) DEBUG(1, "serial_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - serial_remove(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; @@ -866,7 +857,7 @@ static struct pcmcia_driver serial_cs_driver = { }, .attach = serial_attach, .event = serial_event, - .detach = serial_detach, + .remove = serial_detach, .id_table = serial_ids, .suspend = serial_suspend, .resume = serial_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/serial/serial_cs.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index a95366366504..6e7a1a0ae015 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -122,8 +122,6 @@ static dev_info_t dev_info = "serial_cs"; static dev_link_t *serial_attach(void); static void serial_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - /*====================================================================== After a card is removed, serial_remove() will unregister @@ -234,8 +232,7 @@ static dev_link_t *serial_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; /* not needed */ client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -262,17 +259,9 @@ static void serial_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct serial_info *info = link->priv; - dev_link_t **linkp; DEBUG(0, "serial_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp == NULL) - return; - /* * Ensure any outstanding scheduled tasks are completed. */ @@ -283,8 +272,7 @@ static void serial_detach(struct pcmcia_device *p_dev) */ serial_remove(link); - /* Unlink device structure, free bits */ - *linkp = link->next; + /* free bits */ kfree(info); } @@ -871,7 +859,6 @@ static int __init init_serial_cs(void) static void __exit exit_serial_cs(void) { pcmcia_unregister_driver(&serial_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_serial_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/serial/serial_cs.c | 58 +++++++--------------------------------------- 1 file changed, 8 insertions(+), 50 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 6e7a1a0ae015..96969cb960a9 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -114,13 +114,7 @@ struct serial_cfg_mem { static void serial_config(dev_link_t * link); -static int serial_event(event_t event, int priority, - event_callback_args_t * args); -static dev_info_t dev_info = "serial_cs"; - -static dev_link_t *serial_attach(void); -static void serial_detach(struct pcmcia_device *p_dev); /*====================================================================== @@ -203,19 +197,17 @@ static int serial_resume(struct pcmcia_device *dev) ======================================================================*/ -static dev_link_t *serial_attach(void) +static int serial_probe(struct pcmcia_device *p_dev) { struct serial_info *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "serial_attach()\n"); /* Create new serial device */ info = kmalloc(sizeof (*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; memset(info, 0, sizeof (*info)); link = &info->link; link->priv = info; @@ -231,19 +223,12 @@ static dev_link_t *serial_attach(void) } link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; /* not needed */ - 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 != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - serial_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + serial_config(link); - return link; + return 0; } /*====================================================================== @@ -706,32 +691,6 @@ void serial_config(dev_link_t * link) kfree(cfg_mem); } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the serial drivers from - talking to the ports. - -======================================================================*/ - -static int -serial_event(event_t event, int priority, event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "serial_event(0x%06x)\n", event); - - switch (event) { - - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - serial_config(link); - break; - } - return 0; -} - static struct pcmcia_device_id serial_ids[] = { PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), @@ -843,8 +802,7 @@ static struct pcmcia_driver serial_cs_driver = { .drv = { .name = "serial_cs", }, - .attach = serial_attach, - .event = serial_event, + .probe = serial_probe, .remove = serial_detach, .id_table = serial_ids, .suspend = serial_suspend, -- cgit v1.2.3 From 2d8179c0b77b54e27321944e16f65defeda81e27 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:31 -0800 Subject: [PATCH] ppc32/serial: Fix compiler errors with GCC 4.x in mpc52xx_uart.c Signed-off-by: Wolfgang Denk Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/mpc52xx_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/serial') diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index b8727d9bf690..4dcf0310bef5 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c @@ -668,7 +668,7 @@ mpc52xx_console_setup(struct console *co, char *options) } -extern struct uart_driver mpc52xx_uart_driver; +static struct uart_driver mpc52xx_uart_driver; static struct console mpc52xx_console = { .name = "ttyS", -- cgit v1.2.3 From d62de3aa8ac762c09845aa38634a845da55f31dc Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:32 -0800 Subject: [PATCH] ppc32/serial: Change mpc52xx_uart.c to use the Low Density Serial port major Before this patch we were just using the "classic" /dev/ttySx devices. However when another on the system is loaded that uses those (like drivers for serial PCMCIA), that creates a conflict for the minors. Therefore, we now use /dev/ttyPSC[0:5] (note the 0-based numbering !) with some minors we've been assigned in the "Low Density Serial port major" Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/mpc52xx_uart.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 4dcf0310bef5..1288d6203e94 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c @@ -37,11 +37,11 @@ * by the bootloader or in the platform init code. * * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, - * and so on). So the PSC1 is mapped to /dev/ttyS0, PSC2 to /dev/ttyS1 and so - * on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly for - * the console code : without this 1:1 mapping, at early boot time, when we are - * parsing the kernel args console=ttyS?, we wouldn't know wich PSC it will be - * mapped to. + * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and + * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly + * fpr the console code : without this 1:1 mapping, at early boot time, when we + * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it + * will be mapped to. */ #include @@ -65,6 +65,10 @@ #include +/* We've been assigned a range on the "Low-density serial ports" major */ +#define SERIAL_PSC_MAJOR 204 +#define SERIAL_PSC_MINOR 148 + #define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */ @@ -671,12 +675,12 @@ mpc52xx_console_setup(struct console *co, char *options) static struct uart_driver mpc52xx_uart_driver; static struct console mpc52xx_console = { - .name = "ttyS", + .name = "ttyPSC", .write = mpc52xx_console_write, .device = uart_console_device, .setup = mpc52xx_console_setup, .flags = CON_PRINTBUFFER, - .index = -1, /* Specified on the cmdline (e.g. console=ttyS0 ) */ + .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */ .data = &mpc52xx_uart_driver, }; @@ -703,10 +707,10 @@ console_initcall(mpc52xx_console_init); static struct uart_driver mpc52xx_uart_driver = { .owner = THIS_MODULE, .driver_name = "mpc52xx_psc_uart", - .dev_name = "ttyS", - .devfs_name = "ttyS", - .major = TTY_MAJOR, - .minor = 64, + .dev_name = "ttyPSC", + .devfs_name = "ttyPSC", + .major = SERIAL_PSC_MAJOR, + .minor = SERIAL_PSC_MINOR, .nr = MPC52xx_PSC_MAXNUM, .cons = MPC52xx_PSC_CONSOLE, }; -- cgit v1.2.3