aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/i2o/device.c')
-rw-r--r--drivers/message/i2o/device.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index ee183053fa23..b9df143e4ff1 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -54,8 +54,8 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
54 * @dev: I2O device to claim 54 * @dev: I2O device to claim
55 * @drv: I2O driver which wants to claim the device 55 * @drv: I2O driver which wants to claim the device
56 * 56 *
57 * Do the leg work to assign a device to a given OSM. If the claim succeed 57 * Do the leg work to assign a device to a given OSM. If the claim succeeds,
58 * the owner of the rimary. If the attempt fails a negative errno code 58 * the owner is the primary. If the attempt fails a negative errno code
59 * is returned. On success zero is returned. 59 * is returned. On success zero is returned.
60 */ 60 */
61int i2o_device_claim(struct i2o_device *dev) 61int i2o_device_claim(struct i2o_device *dev)
@@ -208,24 +208,23 @@ static struct i2o_device *i2o_device_alloc(void)
208 208
209/** 209/**
210 * i2o_device_add - allocate a new I2O device and add it to the IOP 210 * i2o_device_add - allocate a new I2O device and add it to the IOP
211 * @iop: I2O controller where the device is on 211 * @c: I2O controller that the device is on
212 * @entry: LCT entry of the I2O device 212 * @entry: LCT entry of the I2O device
213 * 213 *
214 * Allocate a new I2O device and initialize it with the LCT entry. The 214 * Allocate a new I2O device and initialize it with the LCT entry. The
215 * device is appended to the device list of the controller. 215 * device is appended to the device list of the controller.
216 * 216 *
217 * Returns a pointer to the I2O device on success or negative error code 217 * Returns zero on success, or a -ve errno.
218 * on failure.
219 */ 218 */
220static struct i2o_device *i2o_device_add(struct i2o_controller *c, 219static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
221 i2o_lct_entry * entry)
222{ 220{
223 struct i2o_device *i2o_dev, *tmp; 221 struct i2o_device *i2o_dev, *tmp;
222 int rc;
224 223
225 i2o_dev = i2o_device_alloc(); 224 i2o_dev = i2o_device_alloc();
226 if (IS_ERR(i2o_dev)) { 225 if (IS_ERR(i2o_dev)) {
227 printk(KERN_ERR "i2o: unable to allocate i2o device\n"); 226 printk(KERN_ERR "i2o: unable to allocate i2o device\n");
228 return i2o_dev; 227 return PTR_ERR(i2o_dev);
229 } 228 }
230 229
231 i2o_dev->lct_data = *entry; 230 i2o_dev->lct_data = *entry;
@@ -236,7 +235,9 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
236 i2o_dev->iop = c; 235 i2o_dev->iop = c;
237 i2o_dev->device.parent = &c->device; 236 i2o_dev->device.parent = &c->device;
238 237
239 device_register(&i2o_dev->device); 238 rc = device_register(&i2o_dev->device);
239 if (rc)
240 goto err;
240 241
241 list_add_tail(&i2o_dev->list, &c->devices); 242 list_add_tail(&i2o_dev->list, &c->devices);
242 243
@@ -270,12 +271,16 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
270 271
271 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id); 272 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
272 273
273 return i2o_dev; 274 return 0;
275
276err:
277 kfree(i2o_dev);
278 return rc;
274} 279}
275 280
276/** 281/**
277 * i2o_device_remove - remove an I2O device from the I2O core 282 * i2o_device_remove - remove an I2O device from the I2O core
278 * @dev: I2O device which should be released 283 * @i2o_dev: I2O device which should be released
279 * 284 *
280 * Is used on I2O controller removal or LCT modification, when the device 285 * Is used on I2O controller removal or LCT modification, when the device
281 * is removed from the system. Note that the device could still hang 286 * is removed from the system. Note that the device could still hang