diff options
author | Joe Perches <joe@perches.ccom> | 2011-11-18 12:03:05 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-12-15 01:55:01 -0500 |
commit | 086b3e8a399ecd089534280597cfba45b2b55887 (patch) | |
tree | b765a9cb01a156e3cd93d40f0e79ab60b02b343e /drivers/scsi/qla2xxx/qla_dbg.c | |
parent | 98cdfb4347f5d38b97de2045d688e44e2a26ea42 (diff) |
[SCSI] qla2xxx: Use less stack to emit logging messages.
Return early when logging level too low.
Use normal kernel codeing style for function braces.
Add const where appropriate to logging functions.
Remove now unused #define QL_DBG_BUF_LEN.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_dbg.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_dbg.c | 212 |
1 files changed, 103 insertions, 109 deletions
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index f3cddd5800c3..6db16af1a446 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c | |||
@@ -1664,34 +1664,31 @@ qla81xx_fw_dump_failed: | |||
1664 | * msg: The message to be displayed. | 1664 | * msg: The message to be displayed. |
1665 | */ | 1665 | */ |
1666 | void | 1666 | void |
1667 | ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) { | 1667 | ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...) |
1668 | { | ||
1669 | va_list va; | ||
1670 | struct va_format vaf; | ||
1668 | 1671 | ||
1669 | char pbuf[QL_DBG_BUF_LEN]; | 1672 | if ((level & ql2xextended_error_logging) != level) |
1670 | va_list ap; | 1673 | return; |
1671 | uint32_t len; | ||
1672 | struct pci_dev *pdev = NULL; | ||
1673 | 1674 | ||
1674 | memset(pbuf, 0, QL_DBG_BUF_LEN); | 1675 | va_start(va, fmt); |
1675 | 1676 | ||
1676 | va_start(ap, msg); | 1677 | vaf.fmt = fmt; |
1678 | vaf.va = &va; | ||
1677 | 1679 | ||
1678 | if ((level & ql2xextended_error_logging) == level) { | 1680 | if (vha != NULL) { |
1679 | if (vha != NULL) { | 1681 | const struct pci_dev *pdev = vha->hw->pdev; |
1680 | pdev = vha->hw->pdev; | 1682 | /* <module-name> <pci-name> <msg-id>:<host> Message */ |
1681 | /* <module-name> <pci-name> <msg-id>:<host> Message */ | 1683 | pr_warn("%s [%s]-%04x:%ld: %pV", |
1682 | sprintf(pbuf, "%s [%s]-%04x:%ld: ", QL_MSGHDR, | 1684 | QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, |
1683 | dev_name(&(pdev->dev)), id + ql_dbg_offset, | 1685 | vha->host_no, &vaf); |
1684 | vha->host_no); | 1686 | } else { |
1685 | } else | 1687 | pr_warn("%s [%s]-%04x: : %pV", |
1686 | sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR, | 1688 | QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf); |
1687 | "0000:00:00.0", id + ql_dbg_offset); | ||
1688 | |||
1689 | len = strlen(pbuf); | ||
1690 | vsprintf(pbuf+len, msg, ap); | ||
1691 | pr_warning("%s", pbuf); | ||
1692 | } | 1689 | } |
1693 | 1690 | ||
1694 | va_end(ap); | 1691 | va_end(va); |
1695 | 1692 | ||
1696 | } | 1693 | } |
1697 | 1694 | ||
@@ -1710,31 +1707,27 @@ ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) { | |||
1710 | * msg: The message to be displayed. | 1707 | * msg: The message to be displayed. |
1711 | */ | 1708 | */ |
1712 | void | 1709 | void |
1713 | ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id, char *msg, ...) { | 1710 | ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id, |
1714 | 1711 | const char *fmt, ...) | |
1715 | char pbuf[QL_DBG_BUF_LEN]; | 1712 | { |
1716 | va_list ap; | 1713 | va_list va; |
1717 | uint32_t len; | 1714 | struct va_format vaf; |
1718 | 1715 | ||
1719 | if (pdev == NULL) | 1716 | if (pdev == NULL) |
1720 | return; | 1717 | return; |
1718 | if ((level & ql2xextended_error_logging) != level) | ||
1719 | return; | ||
1721 | 1720 | ||
1722 | memset(pbuf, 0, QL_DBG_BUF_LEN); | 1721 | va_start(va, fmt); |
1723 | |||
1724 | va_start(ap, msg); | ||
1725 | |||
1726 | if ((level & ql2xextended_error_logging) == level) { | ||
1727 | /* <module-name> <dev-name>:<msg-id> Message */ | ||
1728 | sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR, | ||
1729 | dev_name(&(pdev->dev)), id + ql_dbg_offset); | ||
1730 | 1722 | ||
1731 | len = strlen(pbuf); | 1723 | vaf.fmt = fmt; |
1732 | vsprintf(pbuf+len, msg, ap); | 1724 | vaf.va = &va; |
1733 | pr_warning("%s", pbuf); | ||
1734 | } | ||
1735 | 1725 | ||
1736 | va_end(ap); | 1726 | /* <module-name> <dev-name>:<msg-id> Message */ |
1727 | pr_warn("%s [%s]-%04x: : %pV", | ||
1728 | QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, &vaf); | ||
1737 | 1729 | ||
1730 | va_end(va); | ||
1738 | } | 1731 | } |
1739 | 1732 | ||
1740 | /* | 1733 | /* |
@@ -1751,47 +1744,47 @@ ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id, char *msg, ...) { | |||
1751 | * msg: The message to be displayed. | 1744 | * msg: The message to be displayed. |
1752 | */ | 1745 | */ |
1753 | void | 1746 | void |
1754 | ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) { | 1747 | ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...) |
1755 | 1748 | { | |
1756 | char pbuf[QL_DBG_BUF_LEN]; | 1749 | va_list va; |
1757 | va_list ap; | 1750 | struct va_format vaf; |
1758 | uint32_t len; | 1751 | char pbuf[128]; |
1759 | struct pci_dev *pdev = NULL; | ||
1760 | |||
1761 | memset(pbuf, 0, QL_DBG_BUF_LEN); | ||
1762 | |||
1763 | va_start(ap, msg); | ||
1764 | |||
1765 | if (level <= ql_errlev) { | ||
1766 | if (vha != NULL) { | ||
1767 | pdev = vha->hw->pdev; | ||
1768 | /* <module-name> <msg-id>:<host> Message */ | ||
1769 | sprintf(pbuf, "%s [%s]-%04x:%ld: ", QL_MSGHDR, | ||
1770 | dev_name(&(pdev->dev)), id, vha->host_no); | ||
1771 | } else | ||
1772 | sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR, | ||
1773 | "0000:00:00.0", id); | ||
1774 | 1752 | ||
1775 | len = strlen(pbuf); | 1753 | if (level > ql_errlev) |
1776 | vsprintf(pbuf+len, msg, ap); | 1754 | return; |
1777 | 1755 | ||
1778 | switch (level) { | 1756 | if (vha != NULL) { |
1779 | case 0: /* FATAL LOG */ | 1757 | const struct pci_dev *pdev = vha->hw->pdev; |
1780 | pr_crit("%s", pbuf); | 1758 | /* <module-name> <msg-id>:<host> Message */ |
1781 | break; | 1759 | snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ", |
1782 | case 1: | 1760 | QL_MSGHDR, dev_name(&(pdev->dev)), id, vha->host_no); |
1783 | pr_err("%s", pbuf); | 1761 | } else { |
1784 | break; | 1762 | snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", |
1785 | case 2: | 1763 | QL_MSGHDR, "0000:00:00.0", id); |
1786 | pr_warn("%s", pbuf); | 1764 | } |
1787 | break; | 1765 | pbuf[sizeof(pbuf) - 1] = 0; |
1788 | default: | 1766 | |
1789 | pr_info("%s", pbuf); | 1767 | va_start(va, fmt); |
1790 | break; | 1768 | |
1791 | } | 1769 | vaf.fmt = fmt; |
1770 | vaf.va = &va; | ||
1771 | |||
1772 | switch (level) { | ||
1773 | case 0: /* FATAL LOG */ | ||
1774 | pr_crit("%s%pV", pbuf, &vaf); | ||
1775 | break; | ||
1776 | case 1: | ||
1777 | pr_err("%s%pV", pbuf, &vaf); | ||
1778 | break; | ||
1779 | case 2: | ||
1780 | pr_warn("%s%pV", pbuf, &vaf); | ||
1781 | break; | ||
1782 | default: | ||
1783 | pr_info("%s%pV", pbuf, &vaf); | ||
1784 | break; | ||
1792 | } | 1785 | } |
1793 | 1786 | ||
1794 | va_end(ap); | 1787 | va_end(va); |
1795 | } | 1788 | } |
1796 | 1789 | ||
1797 | /* | 1790 | /* |
@@ -1809,43 +1802,44 @@ ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) { | |||
1809 | * msg: The message to be displayed. | 1802 | * msg: The message to be displayed. |
1810 | */ | 1803 | */ |
1811 | void | 1804 | void |
1812 | ql_log_pci(uint32_t level, struct pci_dev *pdev, int32_t id, char *msg, ...) { | 1805 | ql_log_pci(uint32_t level, struct pci_dev *pdev, int32_t id, |
1813 | 1806 | const char *fmt, ...) | |
1814 | char pbuf[QL_DBG_BUF_LEN]; | 1807 | { |
1815 | va_list ap; | 1808 | va_list va; |
1816 | uint32_t len; | 1809 | struct va_format vaf; |
1810 | char pbuf[128]; | ||
1817 | 1811 | ||
1818 | if (pdev == NULL) | 1812 | if (pdev == NULL) |
1819 | return; | 1813 | return; |
1814 | if (level > ql_errlev) | ||
1815 | return; | ||
1820 | 1816 | ||
1821 | memset(pbuf, 0, QL_DBG_BUF_LEN); | 1817 | /* <module-name> <dev-name>:<msg-id> Message */ |
1822 | 1818 | snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", | |
1823 | va_start(ap, msg); | 1819 | QL_MSGHDR, dev_name(&(pdev->dev)), id); |
1824 | 1820 | pbuf[sizeof(pbuf) - 1] = 0; | |
1825 | if (level <= ql_errlev) { | 1821 | |
1826 | /* <module-name> <dev-name>:<msg-id> Message */ | 1822 | va_start(va, fmt); |
1827 | sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR, | 1823 | |
1828 | dev_name(&(pdev->dev)), id); | 1824 | vaf.fmt = fmt; |
1829 | 1825 | vaf.va = &va; | |
1830 | len = strlen(pbuf); | 1826 | |
1831 | vsprintf(pbuf+len, msg, ap); | 1827 | switch (level) { |
1832 | switch (level) { | 1828 | case 0: /* FATAL LOG */ |
1833 | case 0: /* FATAL LOG */ | 1829 | pr_crit("%s%pV", pbuf, &vaf); |
1834 | pr_crit("%s", pbuf); | 1830 | break; |
1835 | break; | 1831 | case 1: |
1836 | case 1: | 1832 | pr_err("%s%pV", pbuf, &vaf); |
1837 | pr_err("%s", pbuf); | 1833 | break; |
1838 | break; | 1834 | case 2: |
1839 | case 2: | 1835 | pr_warn("%s%pV", pbuf, &vaf); |
1840 | pr_warn("%s", pbuf); | 1836 | break; |
1841 | break; | 1837 | default: |
1842 | default: | 1838 | pr_info("%s%pV", pbuf, &vaf); |
1843 | pr_info("%s", pbuf); | 1839 | break; |
1844 | break; | ||
1845 | } | ||
1846 | } | 1840 | } |
1847 | 1841 | ||
1848 | va_end(ap); | 1842 | va_end(va); |
1849 | } | 1843 | } |
1850 | 1844 | ||
1851 | void | 1845 | void |
@@ -1888,7 +1882,7 @@ ql_dump_buffer(uint32_t level, scsi_qla_host_t *vha, int32_t id, | |||
1888 | ql_dbg(level, vha, id, "----------------------------------" | 1882 | ql_dbg(level, vha, id, "----------------------------------" |
1889 | "----------------------------\n"); | 1883 | "----------------------------\n"); |
1890 | 1884 | ||
1891 | ql_dbg(level, vha, id, ""); | 1885 | ql_dbg(level, vha, id, " "); |
1892 | for (cnt = 0; cnt < size;) { | 1886 | for (cnt = 0; cnt < size;) { |
1893 | c = *b++; | 1887 | c = *b++; |
1894 | printk("%02x", (uint32_t) c); | 1888 | printk("%02x", (uint32_t) c); |