diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-11-14 21:25:51 +0100 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-06 00:03:24 +0100 |
commit | f8cfa618dccbdc6dab5297f75779566a388a98fd (patch) | |
tree | b91e0952038dafc6e03bf8b1d8948b1fdefec031 /drivers/scsi | |
parent | b463581154f3f3eecda27cae60df813fefcd84d3 (diff) | |
download | kernel-crypto-f8cfa618dccbdc6dab5297f75779566a388a98fd.tar.gz kernel-crypto-f8cfa618dccbdc6dab5297f75779566a388a98fd.tar.xz kernel-crypto-f8cfa618dccbdc6dab5297f75779566a388a98fd.zip |
[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/scsi')
-rw-r--r-- | drivers/scsi/pcmcia/aha152x_stub.c | 52 | ||||
-rw-r--r-- | drivers/scsi/pcmcia/fdomain_stub.c | 56 | ||||
-rw-r--r-- | drivers/scsi/pcmcia/nsp_cs.c | 67 | ||||
-rw-r--r-- | drivers/scsi/pcmcia/nsp_cs.h | 2 | ||||
-rw-r--r-- | drivers/scsi/pcmcia/qlogic_stub.c | 49 | ||||
-rw-r--r-- | drivers/scsi/pcmcia/sym53c500_cs.c | 53 |
6 files changed, 51 insertions, 228 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 3128ba8c57a..0c9edb7051f 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -95,27 +95,21 @@ typedef struct scsi_info_t { } scsi_info_t; static void aha152x_release_cs(dev_link_t *link); -static int aha152x_event(event_t event, int priority, - event_callback_args_t *args); - -static dev_link_t *aha152x_attach(void); static void aha152x_detach(struct pcmcia_device *p_dev); +static void aha152x_config_cs(dev_link_t *link); static dev_link_t *dev_list; -static dev_info_t dev_info = "aha152x_cs"; -static dev_link_t *aha152x_attach(void) +static int aha152x_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "aha152x_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -129,20 +123,13 @@ static dev_link_t *aha152x_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - link->next = dev_list; - dev_list = link; - 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); - aha152x_detach(link->handle); - return NULL; - } - - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + aha152x_config_cs(link); + + return 0; } /* aha152x_attach */ /*====================================================================*/ @@ -297,22 +284,6 @@ static int aha152x_resume(struct pcmcia_device *dev) return 0; } -static int aha152x_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(0, "aha152x_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - aha152x_config_cs(link); - break; - } - return 0; -} - static struct pcmcia_device_id aha152x_ids[] = { PCMCIA_DEVICE_PROD_ID123("New Media", "SCSI", "Bus Toaster", 0xcdf7e4cc, 0x35f26476, 0xa8851d6e), PCMCIA_DEVICE_PROD_ID123("NOTEWORTHY", "SCSI", "Bus Toaster", 0xad89c6e8, 0x35f26476, 0xa8851d6e), @@ -328,8 +299,7 @@ static struct pcmcia_driver aha152x_cs_driver = { .drv = { .name = "aha152x_cs", }, - .attach = aha152x_attach, - .event = aha152x_event, + .probe = aha152x_attach, .remove = aha152x_detach, .id_table = aha152x_ids, .suspend = aha152x_suspend, diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index 538fedb9792..788c58d805f 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -80,27 +80,19 @@ typedef struct scsi_info_t { static void fdomain_release(dev_link_t *link); -static int fdomain_event(event_t event, int priority, - event_callback_args_t *args); - -static dev_link_t *fdomain_attach(void); static void fdomain_detach(struct pcmcia_device *p_dev); +static void fdomain_config(dev_link_t *link); - -static dev_info_t dev_info = "fdomain_cs"; - -static dev_link_t *fdomain_attach(void) +static int fdomain_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; - + DEBUG(0, "fdomain_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; link->io.NumPorts1 = 0x10; @@ -113,19 +105,13 @@ static dev_link_t *fdomain_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* 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); - fdomain_detach(link->handle); - return NULL; - } - - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + fdomain_config(link); + + return 0; } /* fdomain_attach */ /*====================================================================*/ @@ -265,23 +251,6 @@ static int fdomain_resume(struct pcmcia_device *dev) return 0; } -static int fdomain_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "fdomain_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - fdomain_config(link); - break; - } - return 0; -} /* fdomain_event */ - - static struct pcmcia_device_id fdomain_ids[] = { PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20), PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e), @@ -295,8 +264,7 @@ static struct pcmcia_driver fdomain_cs_driver = { .drv = { .name = "fdomain_cs", }, - .attach = fdomain_attach, - .event = fdomain_event, + .probe = fdomain_attach, .remove = fdomain_detach, .id_table = fdomain_ids, .suspend = fdomain_suspend, diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index e48e9fb3c58..9e3ab3fd535 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -104,8 +104,6 @@ static struct scsi_host_template nsp_driver_template = { #endif }; -static dev_info_t dev_info = {"nsp_cs"}; - static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ @@ -1595,19 +1593,17 @@ static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt) configure the card at this point -- we wait until we receive a card insertion event. ======================================================================*/ -static dev_link_t *nsp_cs_attach(void) +static int nsp_cs_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; nsp_hw_data *data = &nsp_data_base; nsp_dbg(NSP_DEBUG_INIT, "in"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (info == NULL) { return NULL; } + if (info == NULL) { return -ENOMEM; } memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -1635,22 +1631,14 @@ static dev_link_t *nsp_cs_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; + link->handle = p_dev; + p_dev->instance = link; - /* 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 != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - nsp_cs_detach(link->handle); - return NULL; - } - + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + nsp_cs_config(link); nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); - return link; + return 0; } /* nsp_cs_attach */ @@ -2056,44 +2044,6 @@ static int nsp_cs_resume(struct pcmcia_device *dev) return 0; } -/*====================================================================== - - 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 net drivers from trying - to talk to the card any more. - - When a CARD_REMOVAL event is received, we immediately set a flag - to block future accesses to this device. All the functions that - actually access the device should check this flag to make sure - the card is still present. - -======================================================================*/ -static int nsp_cs_event(event_t event, - int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - nsp_dbg(NSP_DEBUG_INIT, "event: insert"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) - info->bus = args->bus; -#endif - nsp_cs_config(link); - break; - default: - nsp_dbg(NSP_DEBUG_INIT, "event: unknown"); - break; - } - nsp_dbg(NSP_DEBUG_INIT, "end"); - return 0; -} /* nsp_cs_event */ - /*======================================================================* * module entry point *====================================================================*/ @@ -2115,8 +2065,7 @@ static struct pcmcia_driver nsp_driver = { .drv = { .name = "nsp_cs", }, - .attach = nsp_cs_attach, - .event = nsp_cs_event, + .probe = nsp_cs_attach, .remove = nsp_cs_detach, .id_table = nsp_cs_ids, .suspend = nsp_cs_suspend, diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index d276c469edf..b66b140a745 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -296,11 +296,9 @@ typedef struct _nsp_hw_data { */ /* Card service functions */ -static dev_link_t *nsp_cs_attach (void); static void nsp_cs_detach (struct pcmcia_device *p_dev); static void nsp_cs_release(dev_link_t *link); static void nsp_cs_config (dev_link_t *link); -static int nsp_cs_event (event_t event, int priority, event_callback_args_t *args); /* Linux SCSI subsystem specific functions */ static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht); diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index e10281a6e5f..dce7e687fd4 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -98,13 +98,8 @@ typedef struct scsi_info_t { } scsi_info_t; static void qlogic_release(dev_link_t *link); -static int qlogic_event(event_t event, int priority, event_callback_args_t * args); - -static dev_link_t *qlogic_attach(void); static void qlogic_detach(struct pcmcia_device *p_dev); - - -static dev_info_t dev_info = "qlogic_cs"; +static void qlogic_config(dev_link_t * link); static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host, dev_link_t *link, int qbase, int qlirq) @@ -161,19 +156,17 @@ free_scsi_host: err: return NULL; } -static dev_link_t *qlogic_attach(void) +static int qlogic_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "qlogic_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -187,19 +180,13 @@ static dev_link_t *qlogic_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* 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); - qlogic_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + qlogic_config(link); - return link; + return 0; } /* qlogic_attach */ /*====================================================================*/ @@ -368,21 +355,6 @@ static int qlogic_resume(struct pcmcia_device *dev) return 0; } -static int qlogic_event(event_t event, int priority, event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "qlogic_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - qlogic_config(link); - break; - } - return 0; -} /* qlogic_event */ - static struct pcmcia_device_id qlogic_ids[] = { PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6), PCMCIA_DEVICE_PROD_ID12("EPSON", "SCSI-2 PC Card SC200", 0xd361772f, 0x299d1751), @@ -410,8 +382,7 @@ static struct pcmcia_driver qlogic_cs_driver = { .drv = { .name = "qlogic_cs", }, - .attach = qlogic_attach, - .event = qlogic_event, + .probe = qlogic_attach, .remove = qlogic_detach, .id_table = qlogic_ids, .suspend = qlogic_suspend, diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 87d50b33475..3a4dd6f5b81 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -228,14 +228,6 @@ enum Phase { /* ================================================================== */ -/* -* Global (within this module) variables other than -* sym53c500_driver_template (the scsi_host_template). -*/ -static dev_info_t dev_info = "sym53c500_cs"; - -/* ================================================================== */ - static void chip_init(int io_port) { @@ -909,22 +901,6 @@ static int sym53c500_resume(struct pcmcia_device *dev) return 0; } -static int -SYM53C500_event(event_t event, int priority, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "SYM53C500_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - SYM53C500_config(link); - break; - } - return 0; -} /* SYM53C500_event */ - static void SYM53C500_detach(struct pcmcia_device *p_dev) { @@ -939,20 +915,18 @@ SYM53C500_detach(struct pcmcia_device *p_dev) link->priv = NULL; } /* SYM53C500_detach */ -static dev_link_t * -SYM53C500_attach(void) +static int +SYM53C500_attach(struct pcmcia_device *p_dev) { struct scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "SYM53C500_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -966,19 +940,13 @@ SYM53C500_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* 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); - SYM53C500_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + SYM53C500_config(link); + + return 0; } /* SYM53C500_attach */ MODULE_AUTHOR("Bob Tracy <rct@frus.com>"); @@ -998,8 +966,7 @@ static struct pcmcia_driver sym53c500_cs_driver = { .drv = { .name = "sym53c500_cs", }, - .attach = SYM53C500_attach, - .event = SYM53C500_event, + .probe = SYM53C500_attach, .remove = SYM53C500_detach, .id_table = sym53c500_ids, .suspend = sym53c500_suspend, |