aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia/synclink_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/char/pcmcia/synclink_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/char/pcmcia/synclink_cs.c')
-rw-r--r--drivers/char/pcmcia/synclink_cs.c49
1 files changed, 8 insertions, 41 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index dc38b1d0a725..cf45b100eff1 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -486,13 +486,8 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout);
486 486
487static void mgslpc_config(dev_link_t *link); 487static void mgslpc_config(dev_link_t *link);
488static void mgslpc_release(u_long arg); 488static void mgslpc_release(u_long arg);
489static int mgslpc_event(event_t event, int priority,
490 event_callback_args_t *args);
491static dev_link_t *mgslpc_attach(void);
492static void mgslpc_detach(struct pcmcia_device *p_dev); 489static void mgslpc_detach(struct pcmcia_device *p_dev);
493 490
494static dev_info_t dev_info = "synclink_cs";
495
496/* 491/*
497 * 1st function defined in .text section. Calling this function in 492 * 1st function defined in .text section. Calling this function in
498 * init_module() followed by a breakpoint allows a remote debugger 493 * init_module() followed by a breakpoint allows a remote debugger
@@ -538,12 +533,10 @@ static void ldisc_receive_buf(struct tty_struct *tty,
538 } 533 }
539} 534}
540 535
541static dev_link_t *mgslpc_attach(void) 536static int mgslpc_attach(struct pcmcia_device *p_dev)
542{ 537{
543 MGSLPC_INFO *info; 538 MGSLPC_INFO *info;
544 dev_link_t *link; 539 dev_link_t *link;
545 client_reg_t client_reg;
546 int ret;
547 540
548 if (debug_level >= DEBUG_LEVEL_INFO) 541 if (debug_level >= DEBUG_LEVEL_INFO)
549 printk("mgslpc_attach\n"); 542 printk("mgslpc_attach\n");
@@ -551,7 +544,7 @@ static dev_link_t *mgslpc_attach(void)
551 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
552 if (!info) { 545 if (!info) {
553 printk("Error can't allocate device instance data\n"); 546 printk("Error can't allocate device instance data\n");
554 return NULL; 547 return -ENOMEM;
555 } 548 }
556 549
557 memset(info, 0, sizeof(MGSLPC_INFO)); 550 memset(info, 0, sizeof(MGSLPC_INFO));
@@ -586,23 +579,15 @@ static dev_link_t *mgslpc_attach(void)
586 link->conf.Vcc = 50; 579 link->conf.Vcc = 50;
587 link->conf.IntType = INT_MEMORY_AND_IO; 580 link->conf.IntType = INT_MEMORY_AND_IO;
588 581
589 /* Register with Card Services */ 582 link->handle = p_dev;
590 link->next = NULL; 583 p_dev->instance = link;
591
592 client_reg.dev_info = &dev_info;
593 client_reg.Version = 0x0210;
594 client_reg.event_callback_args.client_data = link;
595 584
596 ret = pcmcia_register_client(&link->handle, &client_reg); 585 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
597 if (ret != CS_SUCCESS) { 586 mgslpc_config(link);
598 cs_error(link->handle, RegisterClient, ret);
599 mgslpc_detach(link->handle);
600 return NULL;
601 }
602 587
603 mgslpc_add_device(info); 588 mgslpc_add_device(info);
604 589
605 return link; 590 return 0;
606} 591}
607 592
608/* Card has been inserted. 593/* Card has been inserted.
@@ -778,23 +763,6 @@ static int mgslpc_resume(struct pcmcia_device *dev)
778} 763}
779 764
780 765
781static int mgslpc_event(event_t event, int priority,
782 event_callback_args_t *args)
783{
784 dev_link_t *link = args->client_data;
785
786 if (debug_level >= DEBUG_LEVEL_INFO)
787 printk("mgslpc_event(0x%06x)\n", event);
788
789 switch (event) {
790 case CS_EVENT_CARD_INSERTION:
791 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
792 mgslpc_config(link);
793 break;
794 }
795 return 0;
796}
797
798static inline int mgslpc_paranoia_check(MGSLPC_INFO *info, 766static inline int mgslpc_paranoia_check(MGSLPC_INFO *info,
799 char *name, const char *routine) 767 char *name, const char *routine)
800{ 768{
@@ -3071,8 +3039,7 @@ static struct pcmcia_driver mgslpc_driver = {
3071 .drv = { 3039 .drv = {
3072 .name = "synclink_cs", 3040 .name = "synclink_cs",
3073 }, 3041 },
3074 .attach = mgslpc_attach, 3042 .probe = mgslpc_attach,
3075 .event = mgslpc_event,
3076 .remove = mgslpc_detach, 3043 .remove = mgslpc_detach,
3077 .id_table = mgslpc_ids, 3044 .id_table = mgslpc_ids,
3078 .suspend = mgslpc_suspend, 3045 .suspend = mgslpc_suspend,