From 9797b2b5ea58fe183b5d836954798fa0b3e39a08 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Mon, 10 Dec 2007 15:49:31 -0800 Subject: [PATCH] --- yaml --- r: 74782 b: refs/heads/master c: 522939d45c293388e6a360210905f9230298df16 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/scsi/esp_scsi.c | 4 ++-- trunk/drivers/scsi/scsi.c | 31 +++++++++++++++++++++++++++++-- trunk/include/scsi/scsi_device.h | 3 +++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 507531f5be52..2390c4196424 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 794e64d5e9c7f088378e093a48eb36a30091d82d +refs/heads/master: 522939d45c293388e6a360210905f9230298df16 diff --git a/trunk/drivers/scsi/esp_scsi.c b/trunk/drivers/scsi/esp_scsi.c index 4ed3a5297066..bfdee5968892 100644 --- a/trunk/drivers/scsi/esp_scsi.c +++ b/trunk/drivers/scsi/esp_scsi.c @@ -2026,8 +2026,8 @@ static void esp_reset_cleanup(struct esp *esp) tp->flags |= ESP_TGT_CHECK_NEGO; if (tp->starget) - starget_for_each_device(tp->starget, NULL, - esp_clear_hold); + __starget_for_each_device(tp->starget, NULL, + esp_clear_hold); } esp->flags &= ~ESP_FLAG_RESETTING; } diff --git a/trunk/drivers/scsi/scsi.c b/trunk/drivers/scsi/scsi.c index 192948822455..0fb1709ce5e3 100644 --- a/trunk/drivers/scsi/scsi.c +++ b/trunk/drivers/scsi/scsi.c @@ -896,11 +896,11 @@ EXPORT_SYMBOL(__scsi_iterate_devices); * starget_for_each_device - helper to walk all devices of a target * @starget: target whose devices we want to iterate over. * - * This traverses over each devices of @shost. The devices have + * This traverses over each device of @starget. The devices have * a reference that must be released by scsi_host_put when breaking * out of the loop. */ -void starget_for_each_device(struct scsi_target *starget, void * data, +void starget_for_each_device(struct scsi_target *starget, void *data, void (*fn)(struct scsi_device *, void *)) { struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); @@ -914,6 +914,33 @@ void starget_for_each_device(struct scsi_target *starget, void * data, } EXPORT_SYMBOL(starget_for_each_device); +/** + * __starget_for_each_device - helper to walk all devices of a target + * (UNLOCKED) + * @starget: target whose devices we want to iterate over. + * + * This traverses over each device of @starget. It does _not_ + * take a reference on the scsi_device, so the whole loop must be + * protected by shost->host_lock. + * + * Note: The only reason why drivers would want to use this is because + * they need to access the device list in irq context. Otherwise you + * really want to use starget_for_each_device instead. + **/ +void __starget_for_each_device(struct scsi_target *starget, void *data, + void (*fn)(struct scsi_device *, void *)) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct scsi_device *sdev; + + __shost_for_each_device(sdev, shost) { + if ((sdev->channel == starget->channel) && + (sdev->id == starget->id)) + fn(sdev, data); + } +} +EXPORT_SYMBOL(__starget_for_each_device); + /** * __scsi_device_lookup_by_target - find a device given the target (UNLOCKED) * @starget: SCSI target pointer diff --git a/trunk/include/scsi/scsi_device.h b/trunk/include/scsi/scsi_device.h index 66e9058357e0..6c2d80b36aa1 100644 --- a/trunk/include/scsi/scsi_device.h +++ b/trunk/include/scsi/scsi_device.h @@ -242,6 +242,9 @@ extern struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *, uint); extern void starget_for_each_device(struct scsi_target *, void *, void (*fn)(struct scsi_device *, void *)); +extern void __starget_for_each_device(struct scsi_target *, void *, + void (*fn)(struct scsi_device *, + void *)); /* only exposed to implement shost_for_each_device */ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,