diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2012-01-19 15:01:14 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-02-19 09:08:56 -0500 |
commit | 1f310bde4631185d4462dbd544b3fa82513cdb6f (patch) | |
tree | 3bfbc50ae3f87a7c73e69b2e929c676e3115c117 /drivers/scsi/hpsa.c | |
parent | bbef6c0ce8046114c07f5b6a62ce6a239503dd61 (diff) |
[SCSI] hpsa: refactor hpsa_figure_bus_target_lun
It should call hpsa_set_bus_target_lun rather
than individually setting bus, target and lun.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r-- | drivers/scsi/hpsa.c | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 264c1764befe..5a795e6e9947 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -1630,35 +1630,30 @@ static int is_msa2xxx(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) | |||
1630 | * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.) | 1630 | * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.) |
1631 | */ | 1631 | */ |
1632 | static void figure_bus_target_lun(struct ctlr_info *h, | 1632 | static void figure_bus_target_lun(struct ctlr_info *h, |
1633 | u8 *lunaddrbytes, int *bus, int *target, int *lun, | 1633 | u8 *lunaddrbytes, struct hpsa_scsi_dev_t *device) |
1634 | struct hpsa_scsi_dev_t *device) | 1634 | { |
1635 | { | 1635 | u32 lunid = le32_to_cpu(*((__le32 *) lunaddrbytes)); |
1636 | u32 lunid; | 1636 | |
1637 | 1637 | if (!is_logical_dev_addr_mode(lunaddrbytes)) { | |
1638 | if (is_logical_dev_addr_mode(lunaddrbytes)) { | 1638 | /* physical device, target and lun filled in later */ |
1639 | /* logical device */ | ||
1640 | lunid = le32_to_cpu(*((__le32 *) lunaddrbytes)); | ||
1641 | if (is_msa2xxx(h, device)) { | ||
1642 | /* msa2xxx way, put logicals on bus 1 | ||
1643 | * and match target/lun numbers box | ||
1644 | * reports. | ||
1645 | */ | ||
1646 | *bus = 1; | ||
1647 | *target = (lunid >> 16) & 0x3fff; | ||
1648 | *lun = lunid & 0x00ff; | ||
1649 | } else { | ||
1650 | *bus = 0; | ||
1651 | *target = 0; | ||
1652 | *lun = (lunid & 0x3fff); | ||
1653 | } | ||
1654 | } else { | ||
1655 | if (is_hba_lunid(lunaddrbytes)) | 1639 | if (is_hba_lunid(lunaddrbytes)) |
1656 | *bus = 3; /* controller */ | 1640 | hpsa_set_bus_target_lun(device, 3, 0, lunid & 0x3fff); |
1657 | else | 1641 | else |
1658 | *bus = 2; /* physical device */ | 1642 | /* defer target, lun assignment for physical devices */ |
1659 | *target = -1; | 1643 | hpsa_set_bus_target_lun(device, 2, -1, -1); |
1660 | *lun = -1; /* we will fill these in later. */ | 1644 | return; |
1645 | } | ||
1646 | /* It's a logical device */ | ||
1647 | if (is_msa2xxx(h, device)) { | ||
1648 | /* msa2xxx way, put logicals on bus 1 | ||
1649 | * and match target/lun numbers box | ||
1650 | * reports, other smart array, bus 0, target 0, match lunid | ||
1651 | */ | ||
1652 | hpsa_set_bus_target_lun(device, | ||
1653 | 1, (lunid >> 16) & 0x3fff, lunid & 0x00ff); | ||
1654 | return; | ||
1661 | } | 1655 | } |
1656 | hpsa_set_bus_target_lun(device, 0, 0, lunid & 0x3fff); | ||
1662 | } | 1657 | } |
1663 | 1658 | ||
1664 | /* | 1659 | /* |
@@ -1675,12 +1670,11 @@ static void figure_bus_target_lun(struct ctlr_info *h, | |||
1675 | static int add_msa2xxx_enclosure_device(struct ctlr_info *h, | 1670 | static int add_msa2xxx_enclosure_device(struct ctlr_info *h, |
1676 | struct hpsa_scsi_dev_t *tmpdevice, | 1671 | struct hpsa_scsi_dev_t *tmpdevice, |
1677 | struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes, | 1672 | struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes, |
1678 | int bus, int target, int lun, unsigned long lunzerobits[], | 1673 | unsigned long lunzerobits[], int *nmsa2xxx_enclosures) |
1679 | int *nmsa2xxx_enclosures) | ||
1680 | { | 1674 | { |
1681 | unsigned char scsi3addr[8]; | 1675 | unsigned char scsi3addr[8]; |
1682 | 1676 | ||
1683 | if (test_bit(target, lunzerobits)) | 1677 | if (test_bit(tmpdevice->target, lunzerobits)) |
1684 | return 0; /* There is already a lun 0 on this target. */ | 1678 | return 0; /* There is already a lun 0 on this target. */ |
1685 | 1679 | ||
1686 | if (!is_logical_dev_addr_mode(lunaddrbytes)) | 1680 | if (!is_logical_dev_addr_mode(lunaddrbytes)) |
@@ -1689,11 +1683,11 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h, | |||
1689 | if (!is_msa2xxx(h, tmpdevice)) | 1683 | if (!is_msa2xxx(h, tmpdevice)) |
1690 | return 0; /* It's only the MSA2xxx that have this problem. */ | 1684 | return 0; /* It's only the MSA2xxx that have this problem. */ |
1691 | 1685 | ||
1692 | if (lun == 0) /* if lun is 0, then obviously we have a lun 0. */ | 1686 | if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */ |
1693 | return 0; | 1687 | return 0; |
1694 | 1688 | ||
1695 | memset(scsi3addr, 0, 8); | 1689 | memset(scsi3addr, 0, 8); |
1696 | scsi3addr[3] = target; | 1690 | scsi3addr[3] = tmpdevice->target; |
1697 | if (is_hba_lunid(scsi3addr)) | 1691 | if (is_hba_lunid(scsi3addr)) |
1698 | return 0; /* Don't add the RAID controller here. */ | 1692 | return 0; /* Don't add the RAID controller here. */ |
1699 | 1693 | ||
@@ -1710,8 +1704,9 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h, | |||
1710 | if (hpsa_update_device_info(h, scsi3addr, this_device, NULL)) | 1704 | if (hpsa_update_device_info(h, scsi3addr, this_device, NULL)) |
1711 | return 0; | 1705 | return 0; |
1712 | (*nmsa2xxx_enclosures)++; | 1706 | (*nmsa2xxx_enclosures)++; |
1713 | hpsa_set_bus_target_lun(this_device, bus, target, 0); | 1707 | hpsa_set_bus_target_lun(this_device, |
1714 | set_bit(target, lunzerobits); | 1708 | tmpdevice->bus, tmpdevice->target, 0); |
1709 | set_bit(tmpdevice->target, lunzerobits); | ||
1715 | return 1; | 1710 | return 1; |
1716 | } | 1711 | } |
1717 | 1712 | ||
@@ -1806,7 +1801,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno) | |||
1806 | int ncurrent = 0; | 1801 | int ncurrent = 0; |
1807 | int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8; | 1802 | int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8; |
1808 | int i, nmsa2xxx_enclosures, ndevs_to_allocate; | 1803 | int i, nmsa2xxx_enclosures, ndevs_to_allocate; |
1809 | int bus, target, lun; | ||
1810 | int raid_ctlr_position; | 1804 | int raid_ctlr_position; |
1811 | DECLARE_BITMAP(lunzerobits, HPSA_MAX_TARGETS_PER_CTLR); | 1805 | DECLARE_BITMAP(lunzerobits, HPSA_MAX_TARGETS_PER_CTLR); |
1812 | 1806 | ||
@@ -1871,8 +1865,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno) | |||
1871 | if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice, | 1865 | if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice, |
1872 | &is_OBDR)) | 1866 | &is_OBDR)) |
1873 | continue; /* skip it if we can't talk to it. */ | 1867 | continue; /* skip it if we can't talk to it. */ |
1874 | figure_bus_target_lun(h, lunaddrbytes, &bus, &target, &lun, | 1868 | figure_bus_target_lun(h, lunaddrbytes, tmpdevice); |
1875 | tmpdevice); | ||
1876 | this_device = currentsd[ncurrent]; | 1869 | this_device = currentsd[ncurrent]; |
1877 | 1870 | ||
1878 | /* | 1871 | /* |
@@ -1883,14 +1876,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno) | |||
1883 | * there is no lun 0. | 1876 | * there is no lun 0. |
1884 | */ | 1877 | */ |
1885 | if (add_msa2xxx_enclosure_device(h, tmpdevice, this_device, | 1878 | if (add_msa2xxx_enclosure_device(h, tmpdevice, this_device, |
1886 | lunaddrbytes, bus, target, lun, lunzerobits, | 1879 | lunaddrbytes, lunzerobits, |
1887 | &nmsa2xxx_enclosures)) { | 1880 | &nmsa2xxx_enclosures)) { |
1888 | ncurrent++; | 1881 | ncurrent++; |
1889 | this_device = currentsd[ncurrent]; | 1882 | this_device = currentsd[ncurrent]; |
1890 | } | 1883 | } |
1891 | 1884 | ||
1892 | *this_device = *tmpdevice; | 1885 | *this_device = *tmpdevice; |
1893 | hpsa_set_bus_target_lun(this_device, bus, target, lun); | ||
1894 | 1886 | ||
1895 | switch (this_device->devtype) { | 1887 | switch (this_device->devtype) { |
1896 | case TYPE_ROM: | 1888 | case TYPE_ROM: |