aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@steeleye.com>2005-05-24 13:06:38 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-05-26 11:27:53 -0400
commita283bd37d00e92e8874ca6325ae071691d4db388 (patch)
tree4c436d59fc326e3545c575a88b92fd31ace841a5 /drivers
parent631e8a1398ce4cfef8b30678d51daf0c64313a09 (diff)
[SCSI] Add target alloc/destroy callbacks to the host template
This gives the HBA driver notice when a target is created and destroyed to allow it to manage its own target based allocations accordingly. This is a much reduced verson of the original patch sent in by James.Smart@Emulex.com Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_scan.c24
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: