summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-04-03 17:37:54 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-04-03 17:37:54 +1100
commite152900bc73f1f7d3b33aa5369c36da762b0b042 (patch)
treefa43c9a1454bb2ce41e6b653abe0ca8923fd8502
parent9e19ac94121963f26f85df1685ac346cc698fe4b (diff)
Refactor 'sealed' to 'configured'
Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
-rw-r--r--configfs.c27
-rw-r--r--core.c30
-rw-r--r--core.h12
-rw-r--r--docs/3.Usage.md4
-rw-r--r--pcm.c4
-rwxr-xr-xscripts/test_configfs_run.sh2
6 files changed, 44 insertions, 35 deletions
diff --git a/configfs.c b/configfs.c
index 2751d66..4f88bf8 100644
--- a/configfs.c
+++ b/configfs.c
@@ -148,9 +148,10 @@ static ssize_t cfg_snd_avirt_stream_map_store(struct config_item *item,
map = strsep((char **)&page, "\n");
- /* If already sealed, we cannot create the stream */
- if (snd_avirt_streams_sealed()) {
- D_ERRORK("Streams already sealed. Cannot set map: '%s'", map);
+ /* If already configured, we cannot create the stream */
+ if (snd_avirt_streams_configured()) {
+ D_ERRORK("Streams already configured. Cannot set map: '%s'",
+ map);
return -EPERM;
}
@@ -296,8 +297,9 @@ static void cfg_snd_avirt_route_release(struct config_item *item)
return;
}
- D_INFOK("Release route: %s", route->uid);
kfree(route);
+
+ D_INFOK("Release route: %s", route->uid);
}
static struct configfs_item_operations cfg_snd_avirt_stream_ops = {
@@ -402,15 +404,16 @@ cfg_snd_avirt_route_make_item(struct config_group *group, const char *name)
return &route->item;
}
-static ssize_t cfg_snd_avirt_stream_group_sealed_show(struct config_item *item,
- char *page)
+static ssize_t
+cfg_snd_avirt_stream_group_configured_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%d\n", snd_avirt_streams_sealed());
+ return snprintf(page, PAGE_SIZE, "%d\n",
+ snd_avirt_streams_configured());
}
-static ssize_t cfg_snd_avirt_stream_group_sealed_store(struct config_item *item,
- const char *page,
- size_t count)
+static ssize_t
+cfg_snd_avirt_stream_group_configured_store(struct config_item *item,
+ const char *page, size_t count)
{
unsigned long tmp;
char *p = (char *)page;
@@ -426,10 +429,10 @@ static ssize_t cfg_snd_avirt_stream_group_sealed_store(struct config_item *item,
return count;
}
-CONFIGFS_ATTR(cfg_snd_avirt_stream_group_, sealed);
+CONFIGFS_ATTR(cfg_snd_avirt_stream_group_, configured);
static struct configfs_attribute *cfg_snd_avirt_stream_group_attrs[] = {
- &cfg_snd_avirt_stream_group_attr_sealed,
+ &cfg_snd_avirt_stream_group_attr_configured,
NULL,
};
diff --git a/core.c b/core.c
index d66ee2a..d9e264c 100644
--- a/core.c
+++ b/core.c
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL v2");
static struct snd_avirt_core core = {
.version = { 0, 0, 1 },
.stream_count = 0,
- .streams_sealed = false,
+ .streams_configured = false,
};
static LIST_HEAD(audiopath_list);
@@ -153,7 +153,7 @@ int snd_avirt_stream_try_complete(struct snd_avirt_stream *stream)
struct snd_avirt_route *route;
struct snd_pcm_ops *pcm_ops_ap;
- if (snd_avirt_streams_sealed())
+ if (snd_avirt_streams_configured())
return -EPERM;
if ((stream->channels == 0) || (!strcmp(stream->map, "none")))
@@ -475,8 +475,8 @@ int snd_avirt_audiopath_register(struct snd_avirt_audiopath *audiopath)
list_add_tail(&audiopath_obj->list, &audiopath_list);
- // If we have already sealed the streams, configure this AP
- if (core.streams_sealed) {
+ // If we have already configured the streams, configure this AP
+ if (core.streams_configured) {
stream_array.count = 0;
if (snd_avirt_streams_get(audiopath->uid, &stream_array) > 0)
audiopath->configure(core.card, &stream_array);
@@ -585,14 +585,14 @@ struct snd_avirt_stream *snd_avirt_stream_create(const char *name,
return stream;
}
-int snd_avirt_streams_seal(void)
+int snd_avirt_streams_configure(void)
{
int err = 0, i = 0;
struct snd_avirt_audiopath_obj *ap_obj;
struct snd_avirt_stream_array stream_array;
- if (core.streams_sealed) {
- D_ERRORK("streams are already sealed!");
+ if (core.streams_configured) {
+ D_ERRORK("streams are already configured!");
return -1;
}
@@ -604,19 +604,25 @@ int snd_avirt_streams_seal(void)
0)
continue;
- D_INFOK("Do configure for AP: %s streams:%d", ap_obj->path->uid,
- stream_array.count);
+ if (!ap_obj->path->configure) {
+ D_ERRORK("Cannot do 'configure' for AP: %s",
+ ap_obj->path->uid);
+ return -EFAULT;
+ }
+
+ D_INFOK("Do 'configure' for AP: %s streams:%d",
+ ap_obj->path->uid, stream_array.count);
ap_obj->path->configure(core.card, &stream_array);
}
- core.streams_sealed = true;
+ core.streams_configured = true;
return err;
}
-bool snd_avirt_streams_sealed(void)
+bool snd_avirt_streams_configured(void)
{
- return core.streams_sealed;
+ return core.streams_configured;
}
struct snd_avirt_stream *snd_avirt_stream_find_by_device(unsigned int device)
diff --git a/core.h b/core.h
index 38fee35..6f63e8c 100644
--- a/core.h
+++ b/core.h
@@ -25,7 +25,7 @@ struct snd_avirt_core {
struct config_group *stream_group;
struct config_group *route_group;
unsigned int stream_count;
- bool streams_sealed;
+ bool streams_configured;
};
struct snd_avirt_audiopath_obj {
@@ -76,16 +76,16 @@ struct snd_avirt_audiopath_obj *snd_avirt_audiopath_create_obj(const char *uid);
void snd_avirt_audiopath_destroy_obj(struct snd_avirt_audiopath_obj *p);
/**
- * snd_avirt_streams_seal - Register the sound card to user space
+ * snd_avirt_streams_configure - Register the sound card to user space
* @return: 0 on success, negative ERRNO on failure
*/
-int snd_avirt_streams_seal(void);
+int snd_avirt_streams_configure(void);
/**
- * snd_avirt_streams_sealed - Check if the streams have been sealed or not
- * @return: true if sealed, false otherwise
+ * snd_avirt_streams_configured - Check if streams have been configured or not
+ * @return: true if configured, false otherwise
*/
-bool snd_avirt_streams_sealed(void);
+bool snd_avirt_streams_configured(void);
/**
* snd_avirt_stream_find_by_device - Get audio stream from device number
diff --git a/docs/3.Usage.md b/docs/3.Usage.md
index ba5c3e6..e66b66d 100644
--- a/docs/3.Usage.md
+++ b/docs/3.Usage.md
@@ -110,8 +110,8 @@ mkdir /config/snd-avirt/streams/capture_voice
echo "1">/config/snd-avirt/streams/capture_voice/channels
echo "ap_dummy">/config/snd-avirt/streams/capture_voice/map
-# Finally, seal the card, and initiate configuration
-echo "1">/config/snd-avirt/streams/sealed
+# Finally, set the card to 'configured', and initiate Audio Path configuration
+echo "1">/config/snd-avirt/streams/configured
```
Alternatively, the test script at `scripts/test_configfs.sh` can be used.
diff --git a/pcm.c b/pcm.c
index 32456cd..8fec3f0 100644
--- a/pcm.c
+++ b/pcm.c
@@ -90,8 +90,8 @@ static int pcm_open(struct snd_pcm_substream *substream)
struct snd_pcm_hardware *hw;
unsigned int chans = 0;
- if (!snd_avirt_streams_sealed()) {
- D_ERRORK("Cannot open PCM. Card is not sealed");
+ if (!snd_avirt_streams_configured()) {
+ D_ERRORK("Cannot open PCM. Card is not configured");
return -EPERM;
}
diff --git a/scripts/test_configfs_run.sh b/scripts/test_configfs_run.sh
index b6a56f6..a215b33 100755
--- a/scripts/test_configfs_run.sh
+++ b/scripts/test_configfs_run.sh
@@ -18,4 +18,4 @@ mkdir /config/snd-avirt/streams/capture_voice
echo "1">/config/snd-avirt/streams/capture_voice/channels
echo "ap_loopback">/config/snd-avirt/streams/capture_voice/map
-echo "1">/config/snd-avirt/streams/sealed
+echo "1">/config/snd-avirt/streams/configured