Linux 4.16.11
[linux/fpc-iii.git] / drivers / scsi / qedi / qedi_dbg.c
blob8fd28b056f73f389f6bb124c385f414cee28c21e
1 /*
2 * QLogic iSCSI Offload Driver
3 * Copyright (c) 2016 Cavium Inc.
5 * This software is available under the terms of the GNU General Public License
6 * (GPL) Version 2, available from the file COPYING in the main directory of
7 * this source tree.
8 */
10 #include "qedi_dbg.h"
11 #include <linux/vmalloc.h>
13 void
14 qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
15 const char *fmt, ...)
17 va_list va;
18 struct va_format vaf;
19 char nfunc[32];
21 memset(nfunc, 0, sizeof(nfunc));
22 memcpy(nfunc, func, sizeof(nfunc) - 1);
24 va_start(va, fmt);
26 vaf.fmt = fmt;
27 vaf.va = &va;
29 if (likely(qedi) && likely(qedi->pdev))
30 pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
31 nfunc, line, qedi->host_no, &vaf);
32 else
33 pr_err("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
35 va_end(va);
38 void
39 qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
40 const char *fmt, ...)
42 va_list va;
43 struct va_format vaf;
44 char nfunc[32];
46 memset(nfunc, 0, sizeof(nfunc));
47 memcpy(nfunc, func, sizeof(nfunc) - 1);
49 va_start(va, fmt);
51 vaf.fmt = fmt;
52 vaf.va = &va;
54 if (!(qedi_dbg_log & QEDI_LOG_WARN))
55 goto ret;
57 if (likely(qedi) && likely(qedi->pdev))
58 pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
59 nfunc, line, qedi->host_no, &vaf);
60 else
61 pr_warn("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
63 ret:
64 va_end(va);
67 void
68 qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
69 const char *fmt, ...)
71 va_list va;
72 struct va_format vaf;
73 char nfunc[32];
75 memset(nfunc, 0, sizeof(nfunc));
76 memcpy(nfunc, func, sizeof(nfunc) - 1);
78 va_start(va, fmt);
80 vaf.fmt = fmt;
81 vaf.va = &va;
83 if (!(qedi_dbg_log & QEDI_LOG_NOTICE))
84 goto ret;
86 if (likely(qedi) && likely(qedi->pdev))
87 pr_notice("[%s]:[%s:%d]:%d: %pV",
88 dev_name(&qedi->pdev->dev), nfunc, line,
89 qedi->host_no, &vaf);
90 else
91 pr_notice("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
93 ret:
94 va_end(va);
97 void
98 qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
99 u32 level, const char *fmt, ...)
101 va_list va;
102 struct va_format vaf;
103 char nfunc[32];
105 memset(nfunc, 0, sizeof(nfunc));
106 memcpy(nfunc, func, sizeof(nfunc) - 1);
108 va_start(va, fmt);
110 vaf.fmt = fmt;
111 vaf.va = &va;
113 if (!(qedi_dbg_log & level))
114 goto ret;
116 if (likely(qedi) && likely(qedi->pdev))
117 pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
118 nfunc, line, qedi->host_no, &vaf);
119 else
120 pr_info("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
122 ret:
123 va_end(va);
127 qedi_create_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
129 int ret = 0;
131 for (; iter->name; iter++) {
132 ret = sysfs_create_bin_file(&shost->shost_gendev.kobj,
133 iter->attr);
134 if (ret)
135 pr_err("Unable to create sysfs %s attr, err(%d).\n",
136 iter->name, ret);
138 return ret;
141 void
142 qedi_remove_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
144 for (; iter->name; iter++)
145 sysfs_remove_bin_file(&shost->shost_gendev.kobj, iter->attr);