diff options
Diffstat (limited to 'drivers/rapidio/rio-scan.c')
-rw-r--r-- | drivers/rapidio/rio-scan.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 3b78540288c7..45415096c294 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
@@ -263,15 +263,21 @@ static void rio_route_set_ops(struct rio_dev *rdev) | |||
263 | * device to the RIO device list. Creates the generic sysfs nodes | 263 | * device to the RIO device list. Creates the generic sysfs nodes |
264 | * for an RIO device. | 264 | * for an RIO device. |
265 | */ | 265 | */ |
266 | static void __devinit rio_add_device(struct rio_dev *rdev) | 266 | static int __devinit rio_add_device(struct rio_dev *rdev) |
267 | { | 267 | { |
268 | device_add(&rdev->dev); | 268 | int err; |
269 | |||
270 | err = device_add(&rdev->dev); | ||
271 | if (err) | ||
272 | return err; | ||
269 | 273 | ||
270 | spin_lock(&rio_global_list_lock); | 274 | spin_lock(&rio_global_list_lock); |
271 | list_add_tail(&rdev->global_list, &rio_devices); | 275 | list_add_tail(&rdev->global_list, &rio_devices); |
272 | spin_unlock(&rio_global_list_lock); | 276 | spin_unlock(&rio_global_list_lock); |
273 | 277 | ||
274 | rio_create_sysfs_dev_files(rdev); | 278 | rio_create_sysfs_dev_files(rdev); |
279 | |||
280 | return 0; | ||
275 | } | 281 | } |
276 | 282 | ||
277 | /** | 283 | /** |
@@ -294,13 +300,14 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
294 | struct rio_mport *port, u16 destid, | 300 | struct rio_mport *port, u16 destid, |
295 | u8 hopcount, int do_enum) | 301 | u8 hopcount, int do_enum) |
296 | { | 302 | { |
303 | int ret = 0; | ||
297 | struct rio_dev *rdev; | 304 | struct rio_dev *rdev; |
298 | struct rio_switch *rswitch; | 305 | struct rio_switch *rswitch = NULL; |
299 | int result, rdid; | 306 | int result, rdid; |
300 | 307 | ||
301 | rdev = kzalloc(sizeof(struct rio_dev), GFP_KERNEL); | 308 | rdev = kzalloc(sizeof(struct rio_dev), GFP_KERNEL); |
302 | if (!rdev) | 309 | if (!rdev) |
303 | goto out; | 310 | return NULL; |
304 | 311 | ||
305 | rdev->net = net; | 312 | rdev->net = net; |
306 | rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR, | 313 | rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR, |
@@ -343,23 +350,16 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
343 | rio_mport_read_config_32(port, destid, hopcount, | 350 | rio_mport_read_config_32(port, destid, hopcount, |
344 | RIO_SWP_INFO_CAR, &rdev->swpinfo); | 351 | RIO_SWP_INFO_CAR, &rdev->swpinfo); |
345 | rswitch = kmalloc(sizeof(struct rio_switch), GFP_KERNEL); | 352 | rswitch = kmalloc(sizeof(struct rio_switch), GFP_KERNEL); |
346 | if (!rswitch) { | 353 | if (!rswitch) |
347 | kfree(rdev); | 354 | goto cleanup; |
348 | rdev = NULL; | ||
349 | goto out; | ||
350 | } | ||
351 | rswitch->switchid = next_switchid; | 355 | rswitch->switchid = next_switchid; |
352 | rswitch->hopcount = hopcount; | 356 | rswitch->hopcount = hopcount; |
353 | rswitch->destid = destid; | 357 | rswitch->destid = destid; |
354 | rswitch->route_table = kzalloc(sizeof(u8)* | 358 | rswitch->route_table = kzalloc(sizeof(u8)* |
355 | RIO_MAX_ROUTE_ENTRIES(port->sys_size), | 359 | RIO_MAX_ROUTE_ENTRIES(port->sys_size), |
356 | GFP_KERNEL); | 360 | GFP_KERNEL); |
357 | if (!rswitch->route_table) { | 361 | if (!rswitch->route_table) |
358 | kfree(rdev); | 362 | goto cleanup; |
359 | rdev = NULL; | ||
360 | kfree(rswitch); | ||
361 | goto out; | ||
362 | } | ||
363 | /* Initialize switch route table */ | 363 | /* Initialize switch route table */ |
364 | for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES(port->sys_size); | 364 | for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES(port->sys_size); |
365 | rdid++) | 365 | rdid++) |
@@ -390,10 +390,19 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
390 | rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE], | 390 | rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE], |
391 | 0, 0xffff); | 391 | 0, 0xffff); |
392 | 392 | ||
393 | rio_add_device(rdev); | 393 | ret = rio_add_device(rdev); |
394 | if (ret) | ||
395 | goto cleanup; | ||
394 | 396 | ||
395 | out: | ||
396 | return rdev; | 397 | return rdev; |
398 | |||
399 | cleanup: | ||
400 | if (rswitch) { | ||
401 | kfree(rswitch->route_table); | ||
402 | kfree(rswitch); | ||
403 | } | ||
404 | kfree(rdev); | ||
405 | return NULL; | ||
397 | } | 406 | } |
398 | 407 | ||
399 | /** | 408 | /** |