WIP FPC-III support
[linux/fpc-iii.git] / drivers / scsi / qedi / qedi_dbg.c
blob2ebef4d20b5b95ff169b771e33c519a035981e7b
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * QLogic iSCSI Offload Driver
4 * Copyright (c) 2016 Cavium Inc.
5 */
7 #include "qedi_dbg.h"
8 #include <linux/vmalloc.h>
10 void
11 qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
12 const char *fmt, ...)
14 va_list va;
15 struct va_format vaf;
17 va_start(va, fmt);
19 vaf.fmt = fmt;
20 vaf.va = &va;
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);
28 va_end(va);
31 void
32 qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
33 const char *fmt, ...)
35 va_list va;
36 struct va_format vaf;
38 va_start(va, fmt);
40 vaf.fmt = fmt;
41 vaf.va = &va;
43 if (!(qedi_dbg_log & QEDI_LOG_WARN))
44 goto ret;
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);
52 ret:
53 va_end(va);
56 void
57 qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
58 const char *fmt, ...)
60 va_list va;
61 struct va_format vaf;
63 va_start(va, fmt);
65 vaf.fmt = fmt;
66 vaf.va = &va;
68 if (!(qedi_dbg_log & QEDI_LOG_NOTICE))
69 goto ret;
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);
78 ret:
79 va_end(va);
82 void
83 qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
84 u32 level, const char *fmt, ...)
86 va_list va;
87 struct va_format vaf;
89 va_start(va, fmt);
91 vaf.fmt = fmt;
92 vaf.va = &va;
94 if (!(qedi_dbg_log & level))
95 goto ret;
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);
103 ret:
104 va_end(va);
108 qedi_create_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
110 int ret = 0;
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);
119 return ret;
122 void
123 qedi_remove_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
125 for (; iter->name; iter++)
126 sysfs_remove_bin_file(&shost->shost_gendev.kobj, iter->attr);