aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
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/mtd
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/mtd')
-rw-r--r--drivers/mtd/maps/pcmciamtd.c54
1 files changed, 9 insertions, 45 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 93c05dfa030d..f0f8916da7ad 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -66,8 +66,6 @@ struct pcmciamtd_dev {
66}; 66};
67 67
68 68
69static dev_info_t dev_info = "pcmciamtd";
70
71/* Module parameters */ 69/* Module parameters */
72 70
73/* 2 = do 16-bit transfers, 1 = do 8-bit transfers */ 71/* 2 = do 16-bit transfers, 1 = do 8-bit transfers */
@@ -708,30 +706,6 @@ static int pcmciamtd_resume(struct pcmcia_device *dev)
708 return 0; 706 return 0;
709} 707}
710 708
711/* The card status event handler. Mostly, this schedules other
712 * stuff to run after an event is received. A CARD_REMOVAL event
713 * also sets some flags to discourage the driver from trying
714 * to talk to the card any more.
715 */
716
717static int pcmciamtd_event(event_t event, int priority,
718 event_callback_args_t *args)
719{
720 dev_link_t *link = args->client_data;
721
722 DEBUG(1, "event=0x%06x", event);
723 switch (event) {
724 case CS_EVENT_CARD_INSERTION:
725 DEBUG(2, "EVENT_CARD_INSERTION");
726 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
727 pcmciamtd_config(link);
728 break;
729 default:
730 DEBUG(2, "Unknown event %d", event);
731 }
732 return 0;
733}
734
735 709
736/* This deletes a driver "instance". The device is de-registered 710/* This deletes a driver "instance". The device is de-registered
737 * with Card Services. If it has been released, all local data 711 * with Card Services. If it has been released, all local data
@@ -762,16 +736,14 @@ static void pcmciamtd_detach(struct pcmcia_device *p_dev)
762 * with Card Services. 736 * with Card Services.
763 */ 737 */
764 738
765static dev_link_t *pcmciamtd_attach(void) 739static int pcmciamtd_attach(struct pcmcia_device *p_dev)
766{ 740{
767 struct pcmciamtd_dev *dev; 741 struct pcmciamtd_dev *dev;
768 dev_link_t *link; 742 dev_link_t *link;
769 client_reg_t client_reg;
770 int ret;
771 743
772 /* Create new memory card device */ 744 /* Create new memory card device */
773 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 745 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
774 if (!dev) return NULL; 746 if (!dev) return -ENOMEM;
775 DEBUG(1, "dev=0x%p", dev); 747 DEBUG(1, "dev=0x%p", dev);
776 748
777 memset(dev, 0, sizeof(*dev)); 749 memset(dev, 0, sizeof(*dev));
@@ -782,20 +754,13 @@ static dev_link_t *pcmciamtd_attach(void)
782 link->conf.IntType = INT_MEMORY; 754 link->conf.IntType = INT_MEMORY;
783 755
784 link->next = NULL; 756 link->next = NULL;
757 link->handle = p_dev;
758 p_dev->instance = link;
785 759
786 /* Register with Card Services */ 760 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
787 client_reg.dev_info = &dev_info; 761 pcmciamtd_config(link);
788 client_reg.Version = 0x0210; 762
789 client_reg.event_callback_args.client_data = link; 763 return 0;
790 DEBUG(2, "Calling RegisterClient");
791 ret = pcmcia_register_client(&link->handle, &client_reg);
792 if (ret != 0) {
793 cs_error(link->handle, RegisterClient, ret);
794 pcmciamtd_detach(link->handle);
795 return NULL;
796 }
797 DEBUG(2, "link = %p", link);
798 return link;
799} 764}
800 765
801static struct pcmcia_device_id pcmciamtd_ids[] = { 766static struct pcmcia_device_id pcmciamtd_ids[] = {
@@ -829,8 +794,7 @@ static struct pcmcia_driver pcmciamtd_driver = {
829 .drv = { 794 .drv = {
830 .name = "pcmciamtd" 795 .name = "pcmciamtd"
831 }, 796 },
832 .attach = pcmciamtd_attach, 797 .probe = pcmciamtd_attach,
833 .event = pcmciamtd_event,
834 .remove = pcmciamtd_detach, 798 .remove = pcmciamtd_detach,
835 .owner = THIS_MODULE, 799 .owner = THIS_MODULE,
836 .id_table = pcmciamtd_ids, 800 .id_table = pcmciamtd_ids,