From: Jeff Garzik <jgarzik@pobox.com>
To: linux-scsi@vger.kernel.org
Subject: [patch 4/6] SCSI HCIL: kill all uses of spi_scan_target()
Date: Sat, 22 Oct 2005 21:40:12 -0400 [thread overview]
Message-ID: <20051023014012.GD18279@havoc.gtf.org> (raw)
In-Reply-To: <20051023013618.GA18201@havoc.gtf.org>
Allocate a target at each callsite, then call scsi_scan_target()
Also, minor stuff:
- export scsi_alloc_target(). eventually this will wind up
renamed to spi_alloc_target(), and become a wrapper around
scsi_alloc_target().
- s/scsi_scan_channel/spi_scan_channel/
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
d35ab3386289899854cb66f877acca185eb83392
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 92fc94b..a48d958 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -326,8 +326,8 @@ static struct scsi_target *__scsi_find_t
return found_starget;
}
-static struct scsi_target *scsi_alloc_target(struct device *parent,
- int channel, uint id)
+struct scsi_target *scsi_alloc_target(struct device *parent,
+ int channel, uint id)
{
struct Scsi_Host *shost = dev_to_shost(parent);
struct device *dev = NULL;
@@ -402,6 +402,7 @@ static struct scsi_target *scsi_alloc_ta
kfree(starget);
return found_target;
}
+EXPORT_SYMBOL(scsi_alloc_target);
/**
* scsi_target_reap - check to see if target is in use and destroy if not
@@ -1414,10 +1415,11 @@ void scsi_scan_target(struct scsi_target
}
EXPORT_SYMBOL(scsi_scan_target);
-static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
- unsigned int id, unsigned int lun, int rescan)
+static void spi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
+ unsigned int id, unsigned int lun, int rescan)
{
uint order_id;
+ struct scsi_target *starget;
if (id == SCAN_WILD_CARD)
for (id = 0; id < shost->max_id; ++id) {
@@ -1437,12 +1439,23 @@ static void scsi_scan_channel(struct Scs
order_id = shost->max_id - id - 1;
else
order_id = id;
- __spi_scan_target(&shost->shost_gendev, channel,
- order_id, lun, rescan);
+
+ if (shost->this_id == order_id)
+ /*
+ * Don't scan the host adapter
+ */
+ continue;
+
+ starget = scsi_alloc_target(&shost->shost_gendev,
+ channel, order_id);
+ if (starget)
+ __scsi_scan_target(starget, lun, rescan);
}
- else
- __spi_scan_target(&shost->shost_gendev, channel,
- id, lun, rescan);
+ else {
+ starget = scsi_alloc_target(&shost->shost_gendev, channel, id);
+ if (starget)
+ __scsi_scan_target(starget, lun, rescan);
+ }
}
int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
@@ -1461,10 +1474,10 @@ int scsi_scan_host_selected(struct Scsi_
if (channel == SCAN_WILD_CARD)
for (channel = 0; channel <= shost->max_channel;
channel++)
- scsi_scan_channel(shost, channel, id, lun,
+ spi_scan_channel(shost, channel, id, lun,
rescan);
else
- scsi_scan_channel(shost, channel, id, lun, rescan);
+ spi_scan_channel(shost, channel, id, lun, rescan);
}
up(&shost->scan_mutex);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 91d23e9..f7ae486 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -1672,9 +1672,12 @@ static void
fc_scsi_scan_rport(void *data)
{
struct fc_rport *rport = (struct fc_rport *)data;
+ struct scsi_target *starget;
- spi_scan_target(&rport->dev, rport->channel, rport->scsi_target_id,
- SCAN_WILD_CARD, 1);
+ starget = scsi_alloc_target(&rport->dev, rport->channel,
+ rport->scsi_target_id);
+ if (starget)
+ scsi_scan_target(starget, SCAN_WILD_CARD, 1);
}
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index f6c1a96..cf40f74 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -578,8 +578,12 @@ int sas_rphy_add(struct sas_rphy *rphy)
spin_unlock(&sas_host->lock);
if (rphy->scsi_target_id != -1) {
- spi_scan_target(&rphy->dev, parent->number,
- rphy->scsi_target_id, ~0, 0);
+ struct scsi_target *starget;
+
+ starget = scsi_alloc_target(&rphy->dev, parent->number,
+ rphy->scsi_target_id);
+ if (starget)
+ scsi_scan_target(starget, ~0, 0);
}
return 0;
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index c7cdb23..c5e31fe 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -246,6 +246,8 @@ extern int scsi_device_set_state(struct
enum scsi_device_state state);
extern int scsi_device_quiesce(struct scsi_device *sdev);
extern void scsi_device_resume(struct scsi_device *sdev);
+extern struct scsi_target *scsi_alloc_target(struct device *parent,
+ int channel, uint id);
extern void scsi_target_quiesce(struct scsi_target *);
extern void scsi_target_resume(struct scsi_target *);
extern void spi_scan_target(struct device *parent, unsigned int channel,
next prev parent reply other threads:[~2005-10-23 1:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-23 1:36 [patch 0/6] marginalize HCIL a bit Jeff Garzik
2005-10-23 1:37 ` [patch 1/6] SCSI HCIL: s/scsi_scan_target/spi_scan_target/ Jeff Garzik
2005-10-23 1:38 ` [patch 2/6] SCSI HCIL: remove unused scsi_scan_single_target() Jeff Garzik
2005-10-23 1:53 ` Matthew Wilcox
2005-10-23 1:38 ` [patch 3/6] SCSI HCIL: add scsi_scan_target() Jeff Garzik
2005-10-23 1:50 ` Matthew Wilcox
2005-10-23 1:54 ` Jeff Garzik
2005-10-23 2:00 ` Matthew Wilcox
2005-10-23 2:42 ` Jeff Garzik
2005-10-23 2:26 ` Randy.Dunlap
2005-10-23 1:40 ` Jeff Garzik [this message]
2005-10-23 1:56 ` [patch 4/6] SCSI HCIL: kill all uses of spi_scan_target() Matthew Wilcox
2005-10-23 1:40 ` [patch 5/6] SCSI HCIL: kill spi_scan_target(), __spi_scan_target() Jeff Garzik
2005-10-23 1:41 ` [patch 6/6] SCSI HCIL: misc cleanups Jeff Garzik
2005-10-23 2:03 ` Matthew Wilcox
2005-10-23 1:45 ` [patch 0/6] marginalize HCIL a bit Jeff Garzik
2005-10-23 15:29 ` James Bottomley
2005-10-24 15:49 ` Luben Tuikov
2005-10-24 16:50 ` James Bottomley
2005-10-24 17:18 ` Luben Tuikov
2005-10-24 20:28 ` James Bottomley
2005-10-24 20:41 ` Luben Tuikov
2005-10-24 21:12 ` James Bottomley
2005-10-24 22:38 ` Luben Tuikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051023014012.GD18279@havoc.gtf.org \
--to=jgarzik@pobox.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).