Commit 086b3e8a authored by Joe Perches's avatar Joe Perches Committed by James Bottomley

[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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarSaurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: default avatarChad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 98cdfb43
......@@ -1664,34 +1664,31 @@ qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
* msg: The message to be displayed.
*/
void
ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) {
ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...)
{
va_list va;
struct va_format vaf;
char pbuf[QL_DBG_BUF_LEN];
va_list ap;
uint32_t len;
struct pci_dev *pdev = NULL;
if ((level & ql2xextended_error_logging) != level)
return;
memset(pbuf, 0, QL_DBG_BUF_LEN);
va_start(va, fmt);
va_start(ap, msg);
vaf.fmt = fmt;
vaf.va = &va;
if ((level & ql2xextended_error_logging) == level) {
if (vha != NULL) {
pdev = vha->hw->pdev;
const struct pci_dev *pdev = vha->hw->pdev;
/* <module-name> <pci-name> <msg-id>:<host> Message */
sprintf(pbuf, "%s [%s]-%04x:%ld: ", QL_MSGHDR,
dev_name(&(pdev->dev)), id + ql_dbg_offset,
vha->host_no);
} else
sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR,
"0000:00:00.0", id + ql_dbg_offset);
len = strlen(pbuf);
vsprintf(pbuf+len, msg, ap);
pr_warning("%s", pbuf);
pr_warn("%s [%s]-%04x:%ld: %pV",
QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset,
vha->host_no, &vaf);
} else {
pr_warn("%s [%s]-%04x: : %pV",
QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf);
}
va_end(ap);
va_end(va);
}
......@@ -1710,31 +1707,27 @@ ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) {
* msg: The message to be displayed.
*/
void
ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id, char *msg, ...) {
char pbuf[QL_DBG_BUF_LEN];
va_list ap;
uint32_t len;
ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id,
const char *fmt, ...)
{
va_list va;
struct va_format vaf;
if (pdev == NULL)
return;
if ((level & ql2xextended_error_logging) != level)
return;
memset(pbuf, 0, QL_DBG_BUF_LEN);
va_start(va, fmt);
va_start(ap, msg);
vaf.fmt = fmt;
vaf.va = &va;
if ((level & ql2xextended_error_logging) == level) {
/* <module-name> <dev-name>:<msg-id> Message */
sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR,
dev_name(&(pdev->dev)), id + ql_dbg_offset);
len = strlen(pbuf);
vsprintf(pbuf+len, msg, ap);
pr_warning("%s", pbuf);
}
va_end(ap);
pr_warn("%s [%s]-%04x: : %pV",
QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, &vaf);
va_end(va);
}
/*
......@@ -1751,47 +1744,47 @@ ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id, char *msg, ...) {
* msg: The message to be displayed.
*/
void
ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) {
char pbuf[QL_DBG_BUF_LEN];
va_list ap;
uint32_t len;
struct pci_dev *pdev = NULL;
memset(pbuf, 0, QL_DBG_BUF_LEN);
ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...)
{
va_list va;
struct va_format vaf;
char pbuf[128];
va_start(ap, msg);
if (level > ql_errlev)
return;
if (level <= ql_errlev) {
if (vha != NULL) {
pdev = vha->hw->pdev;
const struct pci_dev *pdev = vha->hw->pdev;
/* <module-name> <msg-id>:<host> Message */
sprintf(pbuf, "%s [%s]-%04x:%ld: ", QL_MSGHDR,
dev_name(&(pdev->dev)), id, vha->host_no);
} else
sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR,
"0000:00:00.0", id);
snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ",
QL_MSGHDR, dev_name(&(pdev->dev)), id, vha->host_no);
} else {
snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
QL_MSGHDR, "0000:00:00.0", id);
}
pbuf[sizeof(pbuf) - 1] = 0;
va_start(va, fmt);
len = strlen(pbuf);
vsprintf(pbuf+len, msg, ap);
vaf.fmt = fmt;
vaf.va = &va;
switch (level) {
case 0: /* FATAL LOG */
pr_crit("%s", pbuf);
pr_crit("%s%pV", pbuf, &vaf);
break;
case 1:
pr_err("%s", pbuf);
pr_err("%s%pV", pbuf, &vaf);
break;
case 2:
pr_warn("%s", pbuf);
pr_warn("%s%pV", pbuf, &vaf);
break;
default:
pr_info("%s", pbuf);
pr_info("%s%pV", pbuf, &vaf);
break;
}
}
va_end(ap);
va_end(va);
}
/*
......@@ -1809,43 +1802,44 @@ ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, char *msg, ...) {
* msg: The message to be displayed.
*/
void
ql_log_pci(uint32_t level, struct pci_dev *pdev, int32_t id, char *msg, ...) {
char pbuf[QL_DBG_BUF_LEN];
va_list ap;
uint32_t len;
ql_log_pci(uint32_t level, struct pci_dev *pdev, int32_t id,
const char *fmt, ...)
{
va_list va;
struct va_format vaf;
char pbuf[128];
if (pdev == NULL)
return;
if (level > ql_errlev)
return;
memset(pbuf, 0, QL_DBG_BUF_LEN);
/* <module-name> <dev-name>:<msg-id> Message */
snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
QL_MSGHDR, dev_name(&(pdev->dev)), id);
pbuf[sizeof(pbuf) - 1] = 0;
va_start(ap, msg);
va_start(va, fmt);
if (level <= ql_errlev) {
/* <module-name> <dev-name>:<msg-id> Message */
sprintf(pbuf, "%s [%s]-%04x: : ", QL_MSGHDR,
dev_name(&(pdev->dev)), id);
vaf.fmt = fmt;
vaf.va = &va;
len = strlen(pbuf);
vsprintf(pbuf+len, msg, ap);
switch (level) {
case 0: /* FATAL LOG */
pr_crit("%s", pbuf);
pr_crit("%s%pV", pbuf, &vaf);
break;
case 1:
pr_err("%s", pbuf);
pr_err("%s%pV", pbuf, &vaf);
break;
case 2:
pr_warn("%s", pbuf);
pr_warn("%s%pV", pbuf, &vaf);
break;
default:
pr_info("%s", pbuf);
pr_info("%s%pV", pbuf, &vaf);
break;
}
}
va_end(ap);
va_end(va);
}
void
......@@ -1888,7 +1882,7 @@ ql_dump_buffer(uint32_t level, scsi_qla_host_t *vha, int32_t id,
ql_dbg(level, vha, id, "----------------------------------"
"----------------------------\n");
ql_dbg(level, vha, id, "");
ql_dbg(level, vha, id, " ");
for (cnt = 0; cnt < size;) {
c = *b++;
printk("%02x", (uint32_t) c);
......
......@@ -245,14 +245,14 @@ struct qla2xxx_fw_dump {
extern int ql_errlev;
void
ql_dbg(uint32_t, scsi_qla_host_t *vha, int32_t, char *, ...);
ql_dbg(uint32_t, scsi_qla_host_t *vha, int32_t, const char *fmt, ...);
void
ql_dbg_pci(uint32_t, struct pci_dev *pdev, int32_t, char *, ...);
ql_dbg_pci(uint32_t, struct pci_dev *pdev, int32_t, const char *fmt, ...);
void
ql_log(uint32_t, scsi_qla_host_t *vha, int32_t, char *, ...);
ql_log(uint32_t, scsi_qla_host_t *vha, int32_t, const char *fmt, ...);
void
ql_log_pci(uint32_t, struct pci_dev *pdev, int32_t, char *, ...);
ql_log_pci(uint32_t, struct pci_dev *pdev, int32_t, const char *fmt, ...);
/* Debug Levels */
/* The 0x40000000 is the max value any debug level can have
......@@ -275,5 +275,3 @@ ql_log_pci(uint32_t, struct pci_dev *pdev, int32_t, char *, ...);
#define ql_dbg_misc 0x00010000 /* For dumping everything that is not
* not covered by upper categories
*/
#define QL_DBG_BUF_LEN 512
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment