diff options
author | Matthew Wilcox <matthew@wil.cx> | 2006-11-22 15:24:54 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-11-22 17:42:42 -0500 |
commit | 1aa8fab2acf1cb8b341131b726773fcff0abc707 (patch) | |
tree | 27590ddf03adce3b6244d60d4a818d9bdbbe85b0 /drivers/scsi | |
parent | 93b45af5c6b9d41bbe9da11442291ac4eefc15b4 (diff) |
[SCSI] Make scsi_scan_host work for drivers which find their own targets
If a driver can find its own targets, it can now fill in scan_finished and
(optionally) scan_start in the scsi_host_template. Then, when it calls
scsi_scan_host(), it will be called back (from a thread if asynchronous
discovery is enabled), first to start the scan, and then at intervals to
check if the scan is completed.
Also make scsi_prep_async_scan and scsi_finish_async_scan static.
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsi_scan.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 3ccaa4be92d8..4d656148bd67 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -1642,7 +1642,7 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost) | |||
1642 | * that other asynchronous scans started after this one won't affect the | 1642 | * that other asynchronous scans started after this one won't affect the |
1643 | * ordering of the discovered devices. | 1643 | * ordering of the discovered devices. |
1644 | */ | 1644 | */ |
1645 | struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost) | 1645 | static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost) |
1646 | { | 1646 | { |
1647 | struct async_scan_data *data; | 1647 | struct async_scan_data *data; |
1648 | 1648 | ||
@@ -1686,7 +1686,7 @@ struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost) | |||
1686 | * This function announces all the devices it has found to the rest | 1686 | * This function announces all the devices it has found to the rest |
1687 | * of the system. | 1687 | * of the system. |
1688 | */ | 1688 | */ |
1689 | void scsi_finish_async_scan(struct async_scan_data *data) | 1689 | static void scsi_finish_async_scan(struct async_scan_data *data) |
1690 | { | 1690 | { |
1691 | struct Scsi_Host *shost; | 1691 | struct Scsi_Host *shost; |
1692 | 1692 | ||
@@ -1719,12 +1719,25 @@ void scsi_finish_async_scan(struct async_scan_data *data) | |||
1719 | kfree(data); | 1719 | kfree(data); |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | static int do_scan_async(void *_data) | 1722 | static void do_scsi_scan_host(struct Scsi_Host *shost) |
1723 | { | 1723 | { |
1724 | struct async_scan_data *data = _data; | 1724 | if (shost->hostt->scan_finished) { |
1725 | scsi_scan_host_selected(data->shost, SCAN_WILD_CARD, SCAN_WILD_CARD, | 1725 | unsigned long start = jiffies; |
1726 | if (shost->hostt->scan_start) | ||
1727 | shost->hostt->scan_start(shost); | ||
1728 | |||
1729 | while (!shost->hostt->scan_finished(shost, jiffies - start)) | ||
1730 | msleep(10); | ||
1731 | } else { | ||
1732 | scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, | ||
1726 | SCAN_WILD_CARD, 0); | 1733 | SCAN_WILD_CARD, 0); |
1734 | } | ||
1735 | } | ||
1727 | 1736 | ||
1737 | static int do_scan_async(void *_data) | ||
1738 | { | ||
1739 | struct async_scan_data *data = _data; | ||
1740 | do_scsi_scan_host(data->shost); | ||
1728 | scsi_finish_async_scan(data); | 1741 | scsi_finish_async_scan(data); |
1729 | return 0; | 1742 | return 0; |
1730 | } | 1743 | } |
@@ -1742,10 +1755,10 @@ void scsi_scan_host(struct Scsi_Host *shost) | |||
1742 | 1755 | ||
1743 | data = scsi_prep_async_scan(shost); | 1756 | data = scsi_prep_async_scan(shost); |
1744 | if (!data) { | 1757 | if (!data) { |
1745 | scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, | 1758 | do_scsi_scan_host(shost); |
1746 | SCAN_WILD_CARD, 0); | ||
1747 | return; | 1759 | return; |
1748 | } | 1760 | } |
1761 | |||
1749 | kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no); | 1762 | kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no); |
1750 | } | 1763 | } |
1751 | EXPORT_SYMBOL(scsi_scan_host); | 1764 | EXPORT_SYMBOL(scsi_scan_host); |