dmaengine: imx-sdma: Let the core do the device node validation
[linux/fpc-iii.git] / drivers / scsi / qedf / qedf_dbg.c
blobf7d170bffc826db7c3e23b0c217499ab54e6abed
1 /*
2 * QLogic FCoE Offload Driver
3 * Copyright (c) 2016-2018 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 */
9 #include "qedf_dbg.h"
10 #include <linux/vmalloc.h>
12 void
13 qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
14 const char *fmt, ...)
16 va_list va;
17 struct va_format vaf;
19 va_start(va, fmt);
21 vaf.fmt = fmt;
22 vaf.va = &va;
24 if (likely(qedf) && likely(qedf->pdev))
25 pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
26 func, line, qedf->host_no, &vaf);
27 else
28 pr_err("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
30 va_end(va);
33 void
34 qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
35 const char *fmt, ...)
37 va_list va;
38 struct va_format vaf;
40 va_start(va, fmt);
42 vaf.fmt = fmt;
43 vaf.va = &va;
45 if (!(qedf_debug & QEDF_LOG_WARN))
46 goto ret;
48 if (likely(qedf) && likely(qedf->pdev))
49 pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
50 func, line, qedf->host_no, &vaf);
51 else
52 pr_warn("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
54 ret:
55 va_end(va);
58 void
59 qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
60 const char *fmt, ...)
62 va_list va;
63 struct va_format vaf;
65 va_start(va, fmt);
67 vaf.fmt = fmt;
68 vaf.va = &va;
70 if (!(qedf_debug & QEDF_LOG_NOTICE))
71 goto ret;
73 if (likely(qedf) && likely(qedf->pdev))
74 pr_notice("[%s]:[%s:%d]:%d: %pV",
75 dev_name(&(qedf->pdev->dev)), func, line,
76 qedf->host_no, &vaf);
77 else
78 pr_notice("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
80 ret:
81 va_end(va);
84 void
85 qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
86 u32 level, const char *fmt, ...)
88 va_list va;
89 struct va_format vaf;
91 va_start(va, fmt);
93 vaf.fmt = fmt;
94 vaf.va = &va;
96 if (!(qedf_debug & level))
97 goto ret;
99 if (likely(qedf) && likely(qedf->pdev))
100 pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
101 func, line, qedf->host_no, &vaf);
102 else
103 pr_info("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
105 ret:
106 va_end(va);
110 qedf_alloc_grc_dump_buf(u8 **buf, uint32_t len)
112 *buf = vmalloc(len);
113 if (!(*buf))
114 return -ENOMEM;
116 memset(*buf, 0, len);
117 return 0;
120 void
121 qedf_free_grc_dump_buf(uint8_t **buf)
123 vfree(*buf);
124 *buf = NULL;
128 qedf_get_grc_dump(struct qed_dev *cdev, const struct qed_common_ops *common,
129 u8 **buf, uint32_t *grcsize)
131 if (!*buf)
132 return -EINVAL;
134 return common->dbg_all_data(cdev, *buf);
137 void
138 qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg)
140 char event_string[40];
141 char *envp[] = {event_string, NULL};
143 memset(event_string, 0, sizeof(event_string));
144 switch (code) {
145 case QEDF_UEVENT_CODE_GRCDUMP:
146 if (msg)
147 strscpy(event_string, msg, sizeof(event_string));
148 else
149 sprintf(event_string, "GRCDUMP=%u", shost->host_no);
150 break;
151 default:
152 /* do nothing */
153 break;
156 kobject_uevent_env(&shost->shost_gendev.kobj, KOBJ_CHANGE, envp);
160 qedf_create_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
162 int ret = 0;
164 for (; iter->name; iter++) {
165 ret = sysfs_create_bin_file(&shost->shost_gendev.kobj,
166 iter->attr);
167 if (ret)
168 pr_err("Unable to create sysfs %s attr, err(%d).\n",
169 iter->name, ret);
171 return ret;
174 void
175 qedf_remove_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
177 for (; iter->name; iter++)
178 sysfs_remove_bin_file(&shost->shost_gendev.kobj, iter->attr);