[dahdi-commits] kpfleming: branch linux/kpfleming/modular_ec r4403 - /linux/team/kpfleming/mo...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Wed Jun 18 20:48:08 CDT 2008
Author: kpfleming
Date: Wed Jun 18 20:48:08 2008
New Revision: 4403
URL: http://svn.digium.com/view/dahdi?view=rev&rev=4403
Log:
add functions for searching for an echocan by name (autoloading if necessary) and releasing a reference to an echocan
Modified:
linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c
Modified: linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c?view=diff&rev=4403&r1=4402&r2=4403
==============================================================================
--- linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c Wed Jun 18 20:48:08 2008
@@ -3474,6 +3474,61 @@
#ifdef CONFIG_DAHDI_DEBUG
printk("Done Recalculating slaves on %s (last is %s)\n", chan->name, last->name);
#endif
+}
+
+static const struct dahdi_echocan *find_echocan(const char *name)
+{
+ struct echocan *cur;
+ char name_upper[strlen(name) + 1];
+ char *c;
+ const char *d;
+ char modname_buf[128] = "dahdi_echocan_";
+ unsigned int tried_once = 0;
+
+ for (c = name_upper, d = name; *d; c++, d++) {
+ *c = toupper(*d);
+ }
+
+ *c = '\0';
+
+retry:
+ read_lock(&echocan_list_lock);
+
+ list_for_each_entry(cur, &echocan_list, list) {
+ if (!strcmp(name_upper, cur->ec->name)) {
+ if (try_module_get(cur->owner)) {
+ read_unlock(&echocan_list_lock);
+ return cur->ec;
+ } else {
+ read_unlock(&echocan_list_lock);
+ return NULL;
+ }
+ }
+ }
+
+ read_unlock(&echocan_list_lock);
+
+ if (tried_once) {
+ return NULL;
+ }
+
+ /* couldn't find it, let's try to load it */
+
+ for (c = &modname_buf[strlen(modname_buf)], d = name; *d; c++, d++) {
+ *c = tolower(*d);
+ }
+
+ request_module(modname_buf);
+
+ tried_once = 1;
+
+ /* and try one more time */
+ goto retry;
+}
+
+static void release_echocan(const struct dahdi_echocan *ec)
+{
+ module_put(ec->owner);
}
static int dahdi_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data)
More information about the dahdi-commits
mailing list