Linux 5.1.15
[linux/fpc-iii.git] / drivers / scsi / qedi / qedi_dbg.c
blob3383314a3882bcdbf1e0cae1d76bfc4d41cd713c
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;
20 va_start(va, fmt);
22 vaf.fmt = fmt;
23 vaf.va = &va;
25 if (likely(qedi) && likely(qedi->pdev))
26 pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
27 func, line, qedi->host_no, &vaf);
28 else
29 pr_err("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
31 va_end(va);
34 void
35 qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
36 const char *fmt, ...)
38 va_list va;
39 struct va_format vaf;
41 va_start(va, fmt);
43 vaf.fmt = fmt;
44 vaf.va = &va;
46 if (!(qedi_dbg_log & QEDI_LOG_WARN))
47 goto ret;
49 if (likely(qedi) && likely(qedi->pdev))
50 pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
51 func, line, qedi->host_no, &vaf);
52 else
53 pr_warn("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
55 ret:
56 va_end(va);
59 void
60 qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
61 const char *fmt, ...)
63 va_list va;
64 struct va_format vaf;
66 va_start(va, fmt);
68 vaf.fmt = fmt;
69 vaf.va = &va;
71 if (!(qedi_dbg_log & QEDI_LOG_NOTICE))
72 goto ret;
74 if (likely(qedi) && likely(qedi->pdev))
75 pr_notice("[%s]:[%s:%d]:%d: %pV",
76 dev_name(&qedi->pdev->dev), func, line,
77 qedi->host_no, &vaf);
78 else
79 pr_notice("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
81 ret:
82 va_end(va);
85 void
86 qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
87 u32 level, const char *fmt, ...)
89 va_list va;
90 struct va_format vaf;
92 va_start(va, fmt);
94 vaf.fmt = fmt;
95 vaf.va = &va;
97 if (!(qedi_dbg_log & level))
98 goto ret;
100 if (likely(qedi) && likely(qedi->pdev))
101 pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
102 func, line, qedi->host_no, &vaf);
103 else
104 pr_info("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
106 ret:
107 va_end(va);
111 qedi_create_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
113 int ret = 0;
115 for (; iter->name; iter++) {
116 ret = sysfs_create_bin_file(&shost->shost_gendev.kobj,
117 iter->attr);
118 if (ret)
119 pr_err("Unable to create sysfs %s attr, err(%d).\n",
120 iter->name, ret);
122 return ret;
125 void
126 qedi_remove_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
128 for (; iter->name; iter++)
129 sysfs_remove_bin_file(&shost->shost_gendev.kobj, iter->attr);