summaryrefslogtreecommitdiffstats
path: root/utils.h
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-09-20 17:23:42 +1000
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:34 +1100
commitc032639678c494710f685612acffeae9b0f603f3 (patch)
treedb5336923253e43bf717caead3a42ab21295b975 /utils.h
parent3786b607d4dd5e738cbe491dbfb03c2283e74358 (diff)
Create avirt_stream structure in place of old config structures
Remove unnecessary extra memory allocation with the old config structures. We can store the snd_pcm pointer, which contains lots of info already. Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/utils.h b/utils.h
new file mode 100644
index 0000000..b449938
--- /dev/null
+++ b/utils.h
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ALSA Virtual Soundcard
+ *
+ * utils.h - Some useful utilities for AVIRT
+ *
+ * Copyright (C) 2010-2018 Fiberdyne Systems Pty Ltd
+ */
+
+#ifndef __AVIRT_UTILS_H__
+#define __AVIRT_UTILS_H__
+
+#include <linux/slab.h>
+
+#define PRINT_ERR(errno, errmsg) \
+ pr_err("[%s]:[ERRNO:%d]: %s ", __func__, errno, (errmsg));
+
+#define CHK_ERR(errno) \
+ do { \
+ if ((errno) < 0) \
+ return (errno); \
+ } while (0)
+
+#define CHK_ERR_V(errno, errmsg, ...) \
+ do { \
+ if ((errno) < 0) { \
+ PRINT_ERR((errno), (errmsg), ##__VA_ARGS__) \
+ return (errno); \
+ } \
+ } while (0)
+
+#define CHK_NULL(x) \
+ do { \
+ if (!(x)) \
+ return -EFAULT; \
+ } while (0)
+
+#define CHK_NULL_V(x, errmsg, ...) \
+ do { \
+ if (!(x)) { \
+ char *errmsg_done = \
+ kasprintf(GFP_KERNEL, errmsg, ##__VA_ARGS__); \
+ PRINT_ERR(EFAULT, errmsg_done); \
+ kfree(errmsg_done); \
+ return -EFAULT; \
+ } \
+ } while (0)
+
+#endif