summaryrefslogtreecommitdiffstats
path: root/core.c
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-09-20 12:09:20 +1000
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-26 17:27:33 +1100
commit3786b607d4dd5e738cbe491dbfb03c2283e74358 (patch)
tree83f150ee7eee8ab42d827f6a1b3c5af68ac9fcbd /core.c
parent99a09bc4fe16d275b2bf839cb8f37192b2235e24 (diff)
Add 'uid' field to AP, store AP in PCM private data, fix helper macros
We want to use a UID when registering APs, that must start with "ap_", and acts as a unique identifier for each AP. To move forward with the adoption of routing PCMs to differing APs, we now store the AP in the PCM private data - set at pcm_open. A fix to the helper macros now allows additional args to be passed in for inclusion to the debug string Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'core.c')
-rw-r--r--core.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/core.c b/core.c
index e77dfb9..360f174 100644
--- a/core.c
+++ b/core.c
@@ -8,7 +8,6 @@
*/
#include <linux/module.h>
-#include <linux/slab.h>
#include <linux/platform_device.h>
#include "avirt/core.h"
@@ -279,13 +278,13 @@ static struct kobj_type avirt_audiopath_ktype = {
/**
* create_avirt_audiopath_obj - creates an Audio Path object
- * @name: name of the Audio Path
+ * @uid: Unique ID of the Audio Path
*
* This creates an Audio Path object and assigns the kset and registers
* it with sysfs.
* @return: Pointer to the Audio Path object or NULL if it failed.
*/
-static struct avirt_audiopath_obj *create_avirt_audiopath_obj(const char *name)
+static struct avirt_audiopath_obj *create_avirt_audiopath_obj(const char *uid)
{
struct avirt_audiopath_obj *avirt_audiopath;
int retval;
@@ -295,7 +294,7 @@ static struct avirt_audiopath_obj *create_avirt_audiopath_obj(const char *name)
return NULL;
avirt_audiopath->kobj.kset = avirt_audiopath_kset;
retval = kobject_init_and_add(&avirt_audiopath->kobj,
- &avirt_audiopath_ktype, kobj, "%s", name);
+ &avirt_audiopath_ktype, kobj, "%s", uid);
if (retval) {
kobject_put(&avirt_audiopath->kobj);
return NULL;
@@ -314,14 +313,20 @@ static void destroy_avirt_audiopath_obj(struct avirt_audiopath_obj *p)
}
/**
- * avirt_get_current_audiopath - retrieves the current Audio Path
- * @return: Current Audio Path
+ * avirt_get_audiopath - retrieves the Audio Path by its UID
+ * @uid: Unique ID for the Audio Path
+ * @return: Corresponding Audio Path
*/
-struct avirt_audiopath *avirt_get_current_audiopath(void)
+struct avirt_audiopath *avirt_get_audiopath(const char *uid)
{
- struct avirt_audiopath_obj *ap_obj = list_entry(
- audiopath_list.next, struct avirt_audiopath_obj, list);
- return ap_obj->path;
+ struct avirt_audiopath_obj *ap_obj;
+ list_for_each_entry (ap_obj, &audiopath_list, list) {
+ pr_info("get_ap %s\n", ap_obj->path->uid);
+ if (!strcmp(ap_obj->path->uid, uid))
+ return ap_obj->path;
+ }
+
+ return NULL;
}
/**
@@ -340,7 +345,7 @@ int avirt_register_audiopath(struct avirt_audiopath *audiopath,
return -EINVAL;
}
- audiopath_obj = create_avirt_audiopath_obj(audiopath->name);
+ audiopath_obj = create_avirt_audiopath_obj(audiopath->uid);
if (!audiopath_obj) {
pr_info("failed to alloc driver object\n");
return -ENOMEM;
@@ -348,8 +353,8 @@ int avirt_register_audiopath(struct avirt_audiopath *audiopath,
audiopath_obj->path = audiopath;
audiopath->context = audiopath_obj;
- D_INFOK("Registered new Audio Path: %s", audiopath->name);
- D_INFOK("\tBlocksize: %d, Periods: %d", audiopath->blocksize,
+ pr_info("Registered new Audio Path: %s\n", audiopath->uid);
+ pr_info("\tBlocksize: %d, Periods: %d\n", audiopath->blocksize,
audiopath->hw->periods_max);
list_add_tail(&audiopath_obj->list, &audiopath_list);
@@ -382,7 +387,7 @@ int avirt_deregister_audiopath(struct avirt_audiopath *audiopath)
list_del(&audiopath_obj->list);
destroy_avirt_audiopath_obj(audiopath_obj);
- pr_info("Deregistered Audio Path %s\n", audiopath->name);
+ pr_info("Deregistered Audio Path %s\n", audiopath->uid);
return 0;
}