Commit 3889b26b authored by Jeff Garzik's avatar Jeff Garzik Committed by Linus Torvalds

[PATCH] I2O: more error checking

i2o_scsi: handle sysfs failure

i2o_device:
 * convert i2o_device_add() to return integer error code
   rather than pointer.  Fortunately -nobody- checks the return code of
   this function, so changing has nil impact.
 * handle errors thrown by device_register()

More work in i2o_device remains.
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 07354a00
...@@ -214,18 +214,17 @@ static struct i2o_device *i2o_device_alloc(void) ...@@ -214,18 +214,17 @@ static struct i2o_device *i2o_device_alloc(void)
* Allocate a new I2O device and initialize it with the LCT entry. The * Allocate a new I2O device and initialize it with the LCT entry. The
* device is appended to the device list of the controller. * device is appended to the device list of the controller.
* *
* Returns a pointer to the I2O device on success or negative error code * Returns zero on success, or a -ve errno.
* on failure.
*/ */
static struct i2o_device *i2o_device_add(struct i2o_controller *c, static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
i2o_lct_entry * entry)
{ {
struct i2o_device *i2o_dev, *tmp; struct i2o_device *i2o_dev, *tmp;
int rc;
i2o_dev = i2o_device_alloc(); i2o_dev = i2o_device_alloc();
if (IS_ERR(i2o_dev)) { if (IS_ERR(i2o_dev)) {
printk(KERN_ERR "i2o: unable to allocate i2o device\n"); printk(KERN_ERR "i2o: unable to allocate i2o device\n");
return i2o_dev; return PTR_ERR(i2o_dev);
} }
i2o_dev->lct_data = *entry; i2o_dev->lct_data = *entry;
...@@ -236,7 +235,9 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c, ...@@ -236,7 +235,9 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
i2o_dev->iop = c; i2o_dev->iop = c;
i2o_dev->device.parent = &c->device; i2o_dev->device.parent = &c->device;
device_register(&i2o_dev->device); rc = device_register(&i2o_dev->device);
if (rc)
goto err;
list_add_tail(&i2o_dev->list, &c->devices); list_add_tail(&i2o_dev->list, &c->devices);
...@@ -270,7 +271,11 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c, ...@@ -270,7 +271,11 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id); pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
return i2o_dev; return 0;
err:
kfree(i2o_dev);
return rc;
} }
/** /**
......
...@@ -220,7 +220,7 @@ static int i2o_scsi_probe(struct device *dev) ...@@ -220,7 +220,7 @@ static int i2o_scsi_probe(struct device *dev)
u32 id = -1; u32 id = -1;
u64 lun = -1; u64 lun = -1;
int channel = -1; int channel = -1;
int i; int i, rc;
i2o_shost = i2o_scsi_get_host(c); i2o_shost = i2o_scsi_get_host(c);
if (!i2o_shost) if (!i2o_shost)
...@@ -304,14 +304,20 @@ static int i2o_scsi_probe(struct device *dev) ...@@ -304,14 +304,20 @@ static int i2o_scsi_probe(struct device *dev)
return PTR_ERR(scsi_dev); return PTR_ERR(scsi_dev);
} }
sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj, rc = sysfs_create_link(&i2o_dev->device.kobj,
"scsi"); &scsi_dev->sdev_gendev.kobj, "scsi");
if (rc)
goto err;
osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n", osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
i2o_dev->lct_data.tid, channel, le32_to_cpu(id), i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
(long unsigned int)le64_to_cpu(lun)); (long unsigned int)le64_to_cpu(lun));
return 0; return 0;
err:
scsi_remove_device(scsi_dev);
return rc;
}; };
static const char *i2o_scsi_info(struct Scsi_Host *SChost) static const char *i2o_scsi_info(struct Scsi_Host *SChost)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment