summaryrefslogtreecommitdiff
path: root/drivers/scsi
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 17:26:06 +0200
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 17:26:06 +0200
commit15b99ac1729503db9e6dc642a50b9b6cb3bf51f9 (patch)
treecfb8897487beba502aac2b28bc35066a87e34299 /drivers/scsi
parentfba395eee7d3f342ca739c20f5b3ee635d0420a0 (diff)
[PATCH] pcmcia: add return value to _config() functions
Most of the driver initialization isn't done in the .probe function, but in the internal _config() functions. Make them return a value, so that .probe can properly report whether the probing of the device succeeded or not. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c19
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c73
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c21
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h2
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c19
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c19
6 files changed, 74 insertions, 79 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 21c6b1014535..7caa700cf189 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -96,11 +96,11 @@ typedef struct scsi_info_t {
static void aha152x_release_cs(struct pcmcia_device *link);
static void aha152x_detach(struct pcmcia_device *p_dev);
-static void aha152x_config_cs(struct pcmcia_device *link);
+static int aha152x_config_cs(struct pcmcia_device *link);
static struct pcmcia_device *dev_list;
-static int aha152x_attach(struct pcmcia_device *link)
+static int aha152x_probe(struct pcmcia_device *link)
{
scsi_info_t *info;
@@ -123,9 +123,7 @@ static int aha152x_attach(struct pcmcia_device *link)
link->conf.Present = PRESENT_OPTION;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
- aha152x_config_cs(link);
-
- return 0;
+ return aha152x_config_cs(link);
} /* aha152x_attach */
/*====================================================================*/
@@ -146,7 +144,7 @@ static void aha152x_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
-static void aha152x_config_cs(struct pcmcia_device *link)
+static int aha152x_config_cs(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
struct aha152x_setup s;
@@ -219,12 +217,12 @@ static void aha152x_config_cs(struct pcmcia_device *link)
info->host = host;
link->state &= ~DEV_CONFIG_PENDING;
- return;
-
+ return 0;
+
cs_failed:
cs_error(link, last_fn, last_ret);
aha152x_release_cs(link);
- return;
+ return -ENODEV;
}
static void aha152x_release_cs(struct pcmcia_device *link)
@@ -259,7 +257,7 @@ static struct pcmcia_driver aha152x_cs_driver = {
.drv = {
.name = "aha152x_cs",
},
- .probe = aha152x_attach,
+ .probe = aha152x_probe,
.remove = aha152x_detach,
.id_table = aha152x_ids,
.resume = aha152x_resume,
@@ -278,4 +276,3 @@ static void __exit exit_aha152x_cs(void)
module_init(init_aha152x_cs);
module_exit(exit_aha152x_cs);
-
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 4e6927112c05..80afd3e879cc 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -81,33 +81,32 @@ typedef struct scsi_info_t {
static void fdomain_release(struct pcmcia_device *link);
static void fdomain_detach(struct pcmcia_device *p_dev);
-static void fdomain_config(struct pcmcia_device *link);
+static int fdomain_config(struct pcmcia_device *link);
-static int fdomain_attach(struct pcmcia_device *link)
+static int fdomain_probe(struct pcmcia_device *link)
{
- scsi_info_t *info;
-
- DEBUG(0, "fdomain_attach()\n");
-
- /* Create new SCSI device */
- info = kmalloc(sizeof(*info), GFP_KERNEL);
- if (!info) return -ENOMEM;
- memset(info, 0, sizeof(*info));
- info->p_dev = link;
- link->priv = info;
- link->io.NumPorts1 = 0x10;
- link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
- link->io.IOAddrLines = 10;
- link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
- link->irq.IRQInfo1 = IRQ_LEVEL_ID;
- link->conf.Attributes = CONF_ENABLE_IRQ;
- link->conf.IntType = INT_MEMORY_AND_IO;
- link->conf.Present = PRESENT_OPTION;
-
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
- fdomain_config(link);
-
- return 0;
+ scsi_info_t *info;
+
+ DEBUG(0, "fdomain_attach()\n");
+
+ /* Create new SCSI device */
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ info->p_dev = link;
+ link->priv = info;
+ link->io.NumPorts1 = 0x10;
+ link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
+ link->io.IOAddrLines = 10;
+ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
+ link->irq.IRQInfo1 = IRQ_LEVEL_ID;
+ link->conf.Attributes = CONF_ENABLE_IRQ;
+ link->conf.IntType = INT_MEMORY_AND_IO;
+ link->conf.Present = PRESENT_OPTION;
+
+ link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+ return fdomain_config(link);
} /* fdomain_attach */
/*====================================================================*/
@@ -127,7 +126,7 @@ static void fdomain_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
-static void fdomain_config(struct pcmcia_device *link)
+static int fdomain_config(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
tuple_t tuple;
@@ -150,7 +149,7 @@ static void fdomain_config(struct pcmcia_device *link)
/* Configure card */
link->state |= DEV_CONFIG;
-
+
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
while (1) {
@@ -167,35 +166,35 @@ static void fdomain_config(struct pcmcia_device *link)
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
-
+
/* A bad hack... */
release_region(link->io.BasePort1, link->io.NumPorts1);
/* Set configuration options for the fdomain driver */
sprintf(str, "%d,%d", link->io.BasePort1, link->irq.AssignedIRQ);
fdomain_setup(str);
-
+
host = __fdomain_16x0_detect(&fdomain_driver_template);
if (!host) {
printk(KERN_INFO "fdomain_cs: no SCSI devices found\n");
goto cs_failed;
}
-
- scsi_add_host(host, NULL); /* XXX handle failure */
+
+ if (scsi_add_host(host, NULL))
+ goto cs_failed;
scsi_scan_host(host);
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev_node = &info->node;
info->host = host;
-
+
link->state &= ~DEV_CONFIG_PENDING;
- return;
-
+ return 0;
+
cs_failed:
cs_error(link, last_fn, last_ret);
fdomain_release(link);
- return;
-
+ return -ENODEV;
} /* fdomain_config */
/*====================================================================*/
@@ -234,7 +233,7 @@ static struct pcmcia_driver fdomain_cs_driver = {
.drv = {
.name = "fdomain_cs",
},
- .probe = fdomain_attach,
+ .probe = fdomain_probe,
.remove = fdomain_detach,
.id_table = fdomain_ids,
.resume = fdomain_resume,
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index ce4d7d868d27..deec1c3a2619 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1593,10 +1593,11 @@ 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 int nsp_cs_attach(struct pcmcia_device *link)
+static int nsp_cs_probe(struct pcmcia_device *link)
{
scsi_info_t *info;
nsp_hw_data *data = &nsp_data_base;
+ int ret;
nsp_dbg(NSP_DEBUG_INIT, "in");
@@ -1630,10 +1631,10 @@ static int nsp_cs_attach(struct pcmcia_device *link)
link->conf.Present = PRESENT_OPTION;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
- nsp_cs_config(link);
+ ret = nsp_cs_config(link);
nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link);
- return 0;
+ return ret;
} /* nsp_cs_attach */
@@ -1665,8 +1666,9 @@ static void nsp_cs_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
/*====================================================================*/
-static void nsp_cs_config(struct pcmcia_device *link)
+static int nsp_cs_config(struct pcmcia_device *link)
{
+ int ret;
scsi_info_t *info = link->priv;
tuple_t tuple;
cisparse_t parse;
@@ -1842,7 +1844,10 @@ static void nsp_cs_config(struct pcmcia_device *link)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74))
- scsi_add_host (host, NULL);
+ ret = scsi_add_host (host, NULL);
+ if (ret)
+ goto cs_failed;
+
scsi_scan_host(host);
snprintf(info->node.dev_name, sizeof(info->node.dev_name), "scsi%d", host->host_no);
@@ -1917,14 +1922,14 @@ static void nsp_cs_config(struct pcmcia_device *link)
printk("\n");
link->state &= ~DEV_CONFIG_PENDING;
- return;
+ return 0;
cs_failed:
nsp_dbg(NSP_DEBUG_INIT, "config fail");
cs_error(link, last_fn, last_ret);
nsp_cs_release(link);
- return;
+ return -ENODEV;
} /* nsp_cs_config */
#undef CS_CHECK
@@ -2033,7 +2038,7 @@ static struct pcmcia_driver nsp_driver = {
.drv = {
.name = "nsp_cs",
},
- .probe = nsp_cs_attach,
+ .probe = nsp_cs_probe,
.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 ce348b379f22..8908b8e5b78a 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -298,7 +298,7 @@ typedef struct _nsp_hw_data {
/* Card service functions */
static void nsp_cs_detach (struct pcmcia_device *p_dev);
static void nsp_cs_release(struct pcmcia_device *link);
-static void nsp_cs_config (struct pcmcia_device *link);
+static int nsp_cs_config (struct pcmcia_device *link);
/* 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 a2a1c4b318e6..61c2eb03a9b5 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -99,7 +99,7 @@ typedef struct scsi_info_t {
static void qlogic_release(struct pcmcia_device *link);
static void qlogic_detach(struct pcmcia_device *p_dev);
-static void qlogic_config(struct pcmcia_device * link);
+static int qlogic_config(struct pcmcia_device * link);
static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,
struct pcmcia_device *link, int qbase, int qlirq)
@@ -156,7 +156,7 @@ free_scsi_host:
err:
return NULL;
}
-static int qlogic_attach(struct pcmcia_device *link)
+static int qlogic_probe(struct pcmcia_device *link)
{
scsi_info_t *info;
@@ -179,9 +179,7 @@ static int qlogic_attach(struct pcmcia_device *link)
link->conf.Present = PRESENT_OPTION;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
- qlogic_config(link);
-
- return 0;
+ return qlogic_config(link);
} /* qlogic_attach */
/*====================================================================*/
@@ -202,7 +200,7 @@ static void qlogic_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
-static void qlogic_config(struct pcmcia_device * link)
+static int qlogic_config(struct pcmcia_device * link)
{
scsi_info_t *info = link->priv;
tuple_t tuple;
@@ -267,21 +265,20 @@ static void qlogic_config(struct pcmcia_device * link)
if (!host) {
printk(KERN_INFO "%s: no SCSI devices found\n", qlogic_name);
- goto out;
+ goto cs_failed;
}
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev_node = &info->node;
info->host = host;
-out:
link->state &= ~DEV_CONFIG_PENDING;
- return;
+ return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
pcmcia_disable_device(link);
- return;
+ return -ENODEV;
} /* qlogic_config */
@@ -350,7 +347,7 @@ static struct pcmcia_driver qlogic_cs_driver = {
.drv = {
.name = "qlogic_cs",
},
- .probe = qlogic_attach,
+ .probe = qlogic_probe,
.remove = qlogic_detach,
.id_table = qlogic_ids,
.resume = qlogic_resume,
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 49a37de68758..b4432206a881 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -707,7 +707,7 @@ static struct scsi_host_template sym53c500_driver_template = {
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
-static void
+static int
SYM53C500_config(struct pcmcia_device *link)
{
struct scsi_info_t *info = link->priv;
@@ -836,7 +836,8 @@ next_entry:
scsi_scan_host(host);
- goto out; /* SUCCESS */
+ link->state &= ~DEV_CONFIG_PENDING;
+ return 0;
err_free_irq:
free_irq(irq_level, host);
@@ -845,15 +846,13 @@ err_free_scsi:
err_release:
release_region(port_base, 0x10);
printk(KERN_INFO "sym53c500_cs: no SCSI devices found\n");
-
-out:
link->state &= ~DEV_CONFIG_PENDING;
- return;
+ return -ENODEV;
cs_failed:
cs_error(link, last_fn, last_ret);
SYM53C500_release(link);
- return;
+ return -ENODEV;
} /* SYM53C500_config */
static int sym53c500_resume(struct pcmcia_device *link)
@@ -892,7 +891,7 @@ SYM53C500_detach(struct pcmcia_device *link)
} /* SYM53C500_detach */
static int
-SYM53C500_attach(struct pcmcia_device *link)
+SYM53C500_probe(struct pcmcia_device *link)
{
struct scsi_info_t *info;
@@ -915,9 +914,7 @@ SYM53C500_attach(struct pcmcia_device *link)
link->conf.Present = PRESENT_OPTION;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
- SYM53C500_config(link);
-
- return 0;
+ return SYM53C500_config(link);
} /* SYM53C500_attach */
MODULE_AUTHOR("Bob Tracy <rct@frus.com>");
@@ -937,7 +934,7 @@ static struct pcmcia_driver sym53c500_cs_driver = {
.drv = {
.name = "sym53c500_cs",
},
- .probe = SYM53C500_attach,
+ .probe = SYM53C500_probe,
.remove = SYM53C500_detach,
.id_table = sym53c500_ids,
.resume = sym53c500_resume,