diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/scsi_scan.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 588611568d14..4d273ceb1d09 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -293,6 +293,10 @@ static void scsi_target_dev_release(struct device *dev) | |||
293 | { | 293 | { |
294 | struct device *parent = dev->parent; | 294 | struct device *parent = dev->parent; |
295 | struct scsi_target *starget = to_scsi_target(dev); | 295 | struct scsi_target *starget = to_scsi_target(dev); |
296 | struct Scsi_Host *shost = dev_to_shost(parent); | ||
297 | |||
298 | if (shost->hostt->target_destroy) | ||
299 | shost->hostt->target_destroy(starget); | ||
296 | kfree(starget); | 300 | kfree(starget); |
297 | put_device(parent); | 301 | put_device(parent); |
298 | } | 302 | } |
@@ -360,9 +364,23 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, | |||
360 | list_add_tail(&starget->siblings, &shost->__targets); | 364 | list_add_tail(&starget->siblings, &shost->__targets); |
361 | spin_unlock_irqrestore(shost->host_lock, flags); | 365 | spin_unlock_irqrestore(shost->host_lock, flags); |
362 | /* allocate and add */ | 366 | /* allocate and add */ |
363 | transport_setup_device(&starget->dev); | 367 | transport_setup_device(dev); |
364 | device_add(&starget->dev); | 368 | device_add(dev); |
365 | transport_add_device(&starget->dev); | 369 | transport_add_device(dev); |
370 | if (shost->hostt->target_alloc) { | ||
371 | int error = shost->hostt->target_alloc(starget); | ||
372 | |||
373 | if(error) { | ||
374 | dev_printk(KERN_ERR, dev, "target allocation failed, error %d\n", error); | ||
375 | /* don't want scsi_target_reap to do the final | ||
376 | * put because it will be under the host lock */ | ||
377 | get_device(dev); | ||
378 | scsi_target_reap(starget); | ||
379 | put_device(dev); | ||
380 | return NULL; | ||
381 | } | ||
382 | } | ||
383 | |||
366 | return starget; | 384 | return starget; |
367 | 385 | ||
368 | found: | 386 | found: |