aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-08 11:42:14 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:39 +1100
commit470fdcb5f773ab45f715a665af6cb35a79ef38ce (patch)
treeec86f3f7f11c71b30ad7828e2d769a3ae3504ca5
parent931ac3b329c106c9058250b994e6a150c977b606 (diff)
Refactor to use new DINFO macros
Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
-rw-r--r--alsa-pcm.c10
-rw-r--r--configfs.c24
-rw-r--r--core.c36
-rw-r--r--core.h11
4 files changed, 51 insertions, 30 deletions
diff --git a/alsa-pcm.c b/alsa-pcm.c
index 958ccbb..efa0a15 100644
--- a/alsa-pcm.c
+++ b/alsa-pcm.c
@@ -9,6 +9,12 @@
#include "core_internal.h"
+#define D_LOGNAME "pcm"
+
+#define D_INFOK(fmt, args...) DINFO(D_LOGNAME, fmt, ##args)
+#define D_PRINTK(fmt, args...) DDEBUG(D_LOGNAME, fmt, ##args)
+#define D_ERRORK(fmt, args...) DERROR(D_LOGNAME, fmt, ##args)
+
#define DO_AUDIOPATH_CB(ap, callback, substream, ...) \
do { \
if ((ap)->pcm_ops->callback) { \
@@ -31,7 +37,6 @@ void avirt_pcm_period_elapsed(struct snd_pcm_substream *substream)
}
EXPORT_SYMBOL_GPL(avirt_pcm_period_elapsed);
-
/*******************************************************************************
* ALSA PCM Callbacks
******************************************************************************/
@@ -90,7 +95,6 @@ static int pcm_open(struct snd_pcm_substream *substream)
*/
static int pcm_close(struct snd_pcm_substream *substream)
{
- DINFO(AP_LOGNAME, "");
// Do additional Audio Path 'close' callback
DO_AUDIOPATH_CB(((struct avirt_audiopath *)substream->private_data),
close, substream);
@@ -199,7 +203,7 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
case SNDRV_PCM_TRIGGER_SUSPEND:
break;
default:
- pr_err("trigger must be START or STOP");
+ D_ERRORK("Invalid trigger cmd: %d", cmd);
return -EINVAL;
}
diff --git a/configfs.c b/configfs.c
index 7e820c6..6a82b0b 100644
--- a/configfs.c
+++ b/configfs.c
@@ -10,6 +10,12 @@
#include <sound/core.h>
#include "core_internal.h"
+#define D_LOGNAME "configfs"
+
+#define D_INFOK(fmt, args...) DINFO(D_LOGNAME, fmt, ##args)
+#define D_PRINTK(fmt, args...) DDEBUG(D_LOGNAME, fmt, ##args)
+#define D_ERRORK(fmt, args...) DERROR(D_LOGNAME, fmt, ##args)
+
static ssize_t cfg_avirt_stream_direction_show(struct config_item *item,
char *page)
{
@@ -70,7 +76,7 @@ static ssize_t cfg_avirt_stream_channels_store(struct config_item *item,
stream->channels = tmp;
- pr_info("%s [ARGS] channels: %d\n", __func__, stream->channels);
+ D_INFOK("channels: %d", stream->channels);
return count;
}
@@ -85,7 +91,7 @@ static struct configfs_attribute *cfg_avirt_stream_attrs[] = {
static void cfg_avirt_stream_release(struct config_item *item)
{
- pr_info("%s [ARGS] item->name:%s\n", __func__, item->ci_namebuf);
+ D_INFOK("item->name:%s", item->ci_namebuf);
kfree(avirt_stream_from_config_item(item));
}
@@ -109,8 +115,8 @@ cfg_avirt_stream_make_item(struct config_group *group, const char *name)
// Get prefix (playback_ or capture_)
split = strsep((char **)&name, "_");
if (!split) {
- pr_err("Stream name: '%s' invalid!\n", split);
- pr_err("Must begin with playback_ * or capture_ *\n");
+ D_ERRORK("Stream name: '%s' invalid!", split);
+ D_ERRORK("Must begin with playback_ * or capture_ *");
return ERR_PTR(-EINVAL);
}
if (!strcmp(split, "playback")) {
@@ -118,8 +124,8 @@ cfg_avirt_stream_make_item(struct config_group *group, const char *name)
} else if (!strcmp(split, "capture")) {
direction = SNDRV_PCM_STREAM_CAPTURE;
} else {
- pr_err("Stream name: '%s' invalid!\n", split);
- pr_err("Must begin with playback_ * or capture_ *\n");
+ D_ERRORK("Stream name: '%s' invalid!", split);
+ D_ERRORK("Must begin with playback_ * or capture_ ");
return ERR_PTR(-EINVAL);
}
@@ -155,7 +161,7 @@ static ssize_t cfg_avirt_stream_group_sealed_store(struct config_item *item,
CHK_ERR(kstrtoul(p, 10, &tmp));
if (tmp != 1) {
- pr_err("AVIRT streams can only be sealed, not unsealed!\n");
+ D_ERRORK("streams can only be sealed, not unsealed!");
return -ERANGE;
}
@@ -203,14 +209,14 @@ int __init __avirt_configfs_init(struct avirt_core *core)
mutex_init(&cfg_subsys.su_mutex);
err = configfs_register_subsystem(&cfg_subsys);
if (err) {
- pr_err("Cannot register configfs subsys!\n");
+ D_ERRORK("Cannot register configfs subsys!");
return err;
}
core->stream_group = configfs_register_default_group(
&cfg_subsys.su_group, "streams", &cfg_stream_group_type);
if (IS_ERR(core->stream_group)) {
err = PTR_ERR(core->stream_group);
- pr_err("Cannot register configfs default group 'streams'!\n");
+ D_ERRORK("Cannot register configfs default group 'streams'!");
goto exit_configfs;
}
diff --git a/core.c b/core.c
index 567021e..cdc7556 100644
--- a/core.c
+++ b/core.c
@@ -20,11 +20,11 @@ MODULE_AUTHOR("MFARRUGI <mark.farrugia@fiberdyne.com.au>");
MODULE_DESCRIPTION("A configurable virtual soundcard");
MODULE_LICENSE("GPL v2");
-#define AP_LOGNAME "CORE"
+#define D_LOGNAME "core"
-#define D_INFOK(fmt, args...) DINFO(AP_LOGNAME, fmt, ##args)
-#define D_PRINTK(fmt, args...) DPRINT(AP_LOGNAME, fmt, ##args)
-#define D_ERRORK(fmt, args...) DERROR(AP_LOGNAME, fmt, ##args)
+#define D_INFOK(fmt, args...) DINFO(D_LOGNAME, fmt, ##args)
+#define D_PRINTK(fmt, args...) DDEBUG(D_LOGNAME, fmt, ##args)
+#define D_ERRORK(fmt, args...) DERROR(D_LOGNAME, fmt, ##args)
#define SND_AVIRTUAL_DRIVER "snd_avirt"
@@ -229,13 +229,13 @@ int avirt_audiopath_register(struct avirt_audiopath *audiopath,
struct avirt_audiopath_obj *audiopath_obj;
if (!audiopath) {
- pr_err("Bad audio path\n");
+ D_ERRORK("Audio Path is NULL!");
return -EINVAL;
}
audiopath_obj = create_avirt_audiopath_obj(audiopath->uid);
if (!audiopath_obj) {
- pr_info("failed to alloc driver object\n");
+ D_INFOK("Failed to alloc driver object");
return -ENOMEM;
}
audiopath_obj->path = audiopath;
@@ -267,19 +267,19 @@ int avirt_audiopath_deregister(struct avirt_audiopath *audiopath)
// Check if audio path is registered
if (!audiopath) {
- pr_err("Bad Audio Path Driver\n");
+ D_ERRORK("Bad Audio Path Driver");
return -EINVAL;
}
audiopath_obj = audiopath->context;
if (!audiopath_obj) {
- pr_info("driver not registered.\n");
+ D_INFOK("driver not registered");
return -EINVAL;
}
list_del(&audiopath_obj->list);
destroy_avirt_audiopath_obj(audiopath_obj);
- pr_info("Deregistered Audio Path %s\n", audiopath->uid);
+ D_INFOK("Deregistered Audio Path %s", audiopath->uid);
return 0;
}
@@ -364,19 +364,19 @@ int __avirt_card_register(void)
struct avirt_audiopath_obj *ap_obj;
if (core.streams_sealed) {
- pr_err("Streams already sealed!\n");
+ D_ERRORK("streams are already sealed!");
return -1;
}
list_for_each_entry (ap_obj, &audiopath_list, list) {
- pr_info("Calling configure for AP uid: %s\n",
- ap_obj->path->uid);
- ap_obj->path->configure(core.stream_group, core.stream_count);
+ D_INFOK("configure() AP uid: %s", ap_obj->path->uid);
+ ap_obj->path->configure(core.card, core.stream_group,
+ core.stream_count);
}
err = snd_card_register(core.card);
if (err < 0) {
- pr_err("Sound card registration failed!");
+ D_ERRORK("Sound card registration failed!");
snd_card_free(core.card);
}
@@ -397,7 +397,7 @@ struct avirt_stream *__avirt_stream_find_by_device(unsigned int device)
struct list_head *entry;
if (device >= core.stream_count) {
- pr_err("Stream device number is greater than number streams available\n");
+ D_ERRORK("Stream device number is larger than stream count");
return ERR_PTR(-EINVAL);
}
@@ -420,13 +420,13 @@ struct avirt_stream *__avirt_stream_find_by_device(unsigned int device)
static int __init core_init(void)
{
int err;
- D_INFOK("Starting new core\n\n\n\n");
+
D_INFOK("Alsa Virtual Sound Driver avirt-%d.%d.%d", coreinfo.version[0],
coreinfo.version[1], coreinfo.version[2]);
core.avirt_class = class_create(THIS_MODULE, SND_AVIRTUAL_DRIVER);
if (IS_ERR(core.avirt_class)) {
- pr_err("No udev support\n");
+ D_ERRORK("No udev support");
return PTR_ERR(core.avirt_class);
}
@@ -440,7 +440,7 @@ static int __init core_init(void)
err = snd_card_new(core.dev, SNDRV_DEFAULT_IDX1, "avirt", THIS_MODULE,
0, &core.card);
if (err < 0) {
- pr_err("Failed to create sound card");
+ D_ERRORK("Failed to create sound card");
goto exit_class_container;
}
diff --git a/core.h b/core.h
index d9b1382..ec44081 100644
--- a/core.h
+++ b/core.h
@@ -16,6 +16,17 @@
#define MAX_STREAMS 16
#define MAX_NAME_LEN 80
+#define DINFO(logname, fmt, args...) \
+ printk(KERN_INFO "[AVIRT][%s]: " fmt "\n", logname, ##args)
+
+#define DERROR(logname, fmt, args...) \
+ printk(KERN_ERR "[AVIRT][%s]: %d:%s " fmt "\n", logname, __LINE__, \
+ __func__, ##args)
+
+#define DDEBUG(logname, fmt, args...) \
+ printk(KERN_DEBUG "[AVIRT][%s]: %d:%s " fmt "\n", logname, __LINE__, \
+ __func__, ##args)
+
/**
* AVIRT Audio Path configure function type
* Each Audio Path registers this at avirt_audiopath_register time.