This source file includes following definitions.
- qedi_dbg_err
- qedi_dbg_warn
- qedi_dbg_notice
- qedi_dbg_info
- qedi_create_sysfs_attr
- qedi_remove_sysfs_attr
1
2
3
4
5
6
7 #include "qedi_dbg.h"
8 #include <linux/vmalloc.h>
9
10 void
11 qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
12 const char *fmt, ...)
13 {
14 va_list va;
15 struct va_format vaf;
16
17 va_start(va, fmt);
18
19 vaf.fmt = fmt;
20 vaf.va = &va;
21
22 if (likely(qedi) && likely(qedi->pdev))
23 pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
24 func, line, qedi->host_no, &vaf);
25 else
26 pr_err("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
27
28 va_end(va);
29 }
30
31 void
32 qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
33 const char *fmt, ...)
34 {
35 va_list va;
36 struct va_format vaf;
37
38 va_start(va, fmt);
39
40 vaf.fmt = fmt;
41 vaf.va = &va;
42
43 if (!(qedi_dbg_log & QEDI_LOG_WARN))
44 goto ret;
45
46 if (likely(qedi) && likely(qedi->pdev))
47 pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
48 func, line, qedi->host_no, &vaf);
49 else
50 pr_warn("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
51
52 ret:
53 va_end(va);
54 }
55
56 void
57 qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
58 const char *fmt, ...)
59 {
60 va_list va;
61 struct va_format vaf;
62
63 va_start(va, fmt);
64
65 vaf.fmt = fmt;
66 vaf.va = &va;
67
68 if (!(qedi_dbg_log & QEDI_LOG_NOTICE))
69 goto ret;
70
71 if (likely(qedi) && likely(qedi->pdev))
72 pr_notice("[%s]:[%s:%d]:%d: %pV",
73 dev_name(&qedi->pdev->dev), func, line,
74 qedi->host_no, &vaf);
75 else
76 pr_notice("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
77
78 ret:
79 va_end(va);
80 }
81
82 void
83 qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
84 u32 level, const char *fmt, ...)
85 {
86 va_list va;
87 struct va_format vaf;
88
89 va_start(va, fmt);
90
91 vaf.fmt = fmt;
92 vaf.va = &va;
93
94 if (!(qedi_dbg_log & level))
95 goto ret;
96
97 if (likely(qedi) && likely(qedi->pdev))
98 pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
99 func, line, qedi->host_no, &vaf);
100 else
101 pr_info("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
102
103 ret:
104 va_end(va);
105 }
106
107 int
108 qedi_create_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
109 {
110 int ret = 0;
111
112 for (; iter->name; iter++) {
113 ret = sysfs_create_bin_file(&shost->shost_gendev.kobj,
114 iter->attr);
115 if (ret)
116 pr_err("Unable to create sysfs %s attr, err(%d).\n",
117 iter->name, ret);
118 }
119 return ret;
120 }
121
122 void
123 qedi_remove_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
124 {
125 for (; iter->name; iter++)
126 sysfs_remove_bin_file(&shost->shost_gendev.kobj, iter->attr);
127 }