diff options
author | Kalle Valo <kvalo@codeaurora.org> | 2018-03-27 04:26:50 -0400 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2018-03-29 04:54:25 -0400 |
commit | 10c2288430817981cab70fc4b78e405765be93b1 (patch) | |
tree | b2b9235e6438fa64dd8648da3e39812f95b9de81 | |
parent | 606204bb863fa3b0bb54929d79b4dc46338f9180 (diff) |
ath10k: refactor ath10k_pci_dump_memory() in preparation for QCA9984 support
As QCA9984 needs two region types refactor the code to make it easier add the
new types. No functional changes.
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
-rw-r--r-- | drivers/net/wireless/ath/ath10k/pci.c | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 561c722979ec..ad2a14678be7 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c | |||
@@ -1584,6 +1584,36 @@ static int ath10k_pci_set_ram_config(struct ath10k *ar, u32 config) | |||
1584 | return 0; | 1584 | return 0; |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | /* if an error happened returns < 0, otherwise the length */ | ||
1588 | static int ath10k_pci_dump_memory_generic(struct ath10k *ar, | ||
1589 | const struct ath10k_mem_region *current_region, | ||
1590 | u8 *buf) | ||
1591 | { | ||
1592 | int ret; | ||
1593 | |||
1594 | if (current_region->section_table.size > 0) | ||
1595 | /* Copy each section individually. */ | ||
1596 | return ath10k_pci_dump_memory_section(ar, | ||
1597 | current_region, | ||
1598 | buf, | ||
1599 | current_region->len); | ||
1600 | |||
1601 | /* No individiual memory sections defined so we can | ||
1602 | * copy the entire memory region. | ||
1603 | */ | ||
1604 | ret = ath10k_pci_diag_read_mem(ar, | ||
1605 | current_region->start, | ||
1606 | buf, | ||
1607 | current_region->len); | ||
1608 | if (ret) { | ||
1609 | ath10k_warn(ar, "failed to copy ramdump region %s: %d\n", | ||
1610 | current_region->name, ret); | ||
1611 | return ret; | ||
1612 | } | ||
1613 | |||
1614 | return current_region->len; | ||
1615 | } | ||
1616 | |||
1587 | static void ath10k_pci_dump_memory(struct ath10k *ar, | 1617 | static void ath10k_pci_dump_memory(struct ath10k *ar, |
1588 | struct ath10k_fw_crash_data *crash_data) | 1618 | struct ath10k_fw_crash_data *crash_data) |
1589 | { | 1619 | { |
@@ -1642,27 +1672,14 @@ static void ath10k_pci_dump_memory(struct ath10k *ar, | |||
1642 | buf += sizeof(*hdr); | 1672 | buf += sizeof(*hdr); |
1643 | buf_len -= sizeof(*hdr); | 1673 | buf_len -= sizeof(*hdr); |
1644 | 1674 | ||
1645 | if (current_region->section_table.size > 0) { | 1675 | switch (current_region->type) { |
1646 | /* Copy each section individually. */ | 1676 | default: |
1647 | count = ath10k_pci_dump_memory_section(ar, | 1677 | ret = ath10k_pci_dump_memory_generic(ar, current_region, buf); |
1648 | current_region, | 1678 | if (ret < 0) |
1649 | buf, | ||
1650 | current_region->len); | ||
1651 | } else { | ||
1652 | /* No individiual memory sections defined so we can | ||
1653 | * copy the entire memory region. | ||
1654 | */ | ||
1655 | ret = ath10k_pci_diag_read_mem(ar, | ||
1656 | current_region->start, | ||
1657 | buf, | ||
1658 | current_region->len); | ||
1659 | if (ret) { | ||
1660 | ath10k_warn(ar, "failed to copy ramdump region %s: %d\n", | ||
1661 | current_region->name, ret); | ||
1662 | break; | 1679 | break; |
1663 | } | ||
1664 | 1680 | ||
1665 | count = current_region->len; | 1681 | count = ret; |
1682 | break; | ||
1666 | } | 1683 | } |
1667 | 1684 | ||
1668 | hdr->region_type = cpu_to_le32(current_region->type); | 1685 | hdr->region_type = cpu_to_le32(current_region->type); |