|
40 | 40 | #include <scsi/scsi_transport_sas.h>
|
41 | 41 |
|
42 | 42 | #include "scsi_sas_internal.h"
|
| 43 | +#include "scsi_priv.h" |
| 44 | + |
43 | 45 | struct sas_host_attrs {
|
44 | 46 | struct list_head rphy_list;
|
45 | 47 | struct mutex lock;
|
@@ -1683,32 +1685,66 @@ int scsi_is_sas_rphy(const struct device *dev)
|
1683 | 1685 | }
|
1684 | 1686 | EXPORT_SYMBOL(scsi_is_sas_rphy);
|
1685 | 1687 |
|
1686 |
| - |
1687 |
| -/* |
1688 |
| - * SCSI scan helper |
1689 |
| - */ |
1690 |
| - |
1691 |
| -static int sas_user_scan(struct Scsi_Host *shost, uint channel, |
1692 |
| - uint id, u64 lun) |
| 1688 | +static void scan_channel_zero(struct Scsi_Host *shost, uint id, u64 lun) |
1693 | 1689 | {
|
1694 | 1690 | struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
|
1695 | 1691 | struct sas_rphy *rphy;
|
1696 | 1692 |
|
1697 |
| - mutex_lock(&sas_host->lock); |
1698 | 1693 | list_for_each_entry(rphy, &sas_host->rphy_list, list) {
|
1699 | 1694 | if (rphy->identify.device_type != SAS_END_DEVICE ||
|
1700 | 1695 | rphy->scsi_target_id == -1)
|
1701 | 1696 | continue;
|
1702 | 1697 |
|
1703 |
| - if ((channel == SCAN_WILD_CARD || channel == 0) && |
1704 |
| - (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) { |
| 1698 | + if (id == SCAN_WILD_CARD || id == rphy->scsi_target_id) { |
1705 | 1699 | scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id,
|
1706 | 1700 | lun, SCSI_SCAN_MANUAL);
|
1707 | 1701 | }
|
1708 | 1702 | }
|
1709 |
| - mutex_unlock(&sas_host->lock); |
| 1703 | +} |
1710 | 1704 |
|
1711 |
| - return 0; |
| 1705 | +/* |
| 1706 | + * SCSI scan helper |
| 1707 | + */ |
| 1708 | + |
| 1709 | +static int sas_user_scan(struct Scsi_Host *shost, uint channel, |
| 1710 | + uint id, u64 lun) |
| 1711 | +{ |
| 1712 | + struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); |
| 1713 | + int res = 0; |
| 1714 | + int i; |
| 1715 | + |
| 1716 | + switch (channel) { |
| 1717 | + case 0: |
| 1718 | + mutex_lock(&sas_host->lock); |
| 1719 | + scan_channel_zero(shost, id, lun); |
| 1720 | + mutex_unlock(&sas_host->lock); |
| 1721 | + break; |
| 1722 | + |
| 1723 | + case SCAN_WILD_CARD: |
| 1724 | + mutex_lock(&sas_host->lock); |
| 1725 | + scan_channel_zero(shost, id, lun); |
| 1726 | + mutex_unlock(&sas_host->lock); |
| 1727 | + |
| 1728 | + for (i = 1; i <= shost->max_channel; i++) { |
| 1729 | + res = scsi_scan_host_selected(shost, i, id, lun, |
| 1730 | + SCSI_SCAN_MANUAL); |
| 1731 | + if (res) |
| 1732 | + goto exit_scan; |
| 1733 | + } |
| 1734 | + break; |
| 1735 | + |
| 1736 | + default: |
| 1737 | + if (channel < shost->max_channel) { |
| 1738 | + res = scsi_scan_host_selected(shost, channel, id, lun, |
| 1739 | + SCSI_SCAN_MANUAL); |
| 1740 | + } else { |
| 1741 | + res = -EINVAL; |
| 1742 | + } |
| 1743 | + break; |
| 1744 | + } |
| 1745 | + |
| 1746 | +exit_scan: |
| 1747 | + return res; |
1712 | 1748 | }
|
1713 | 1749 |
|
1714 | 1750 |
|
|
0 commit comments