diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-05-03 23:06:02 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-05-03 23:06:02 +0000 |
commit | 2dd60aaf18e98b0e9d3c06bd9dce5f1128fa55ad (patch) | |
tree | 1a1cd28888f191e6ce83bcbbe539124e2529c90b /xpp/xproto.c | |
parent | 8c4db4e3acd9a7626e709af0494055487b589719 (diff) |
xpp driver release 1.1.0 (first part of commit)
* FPGA firmware now loaded from PC (for newer models)
* Driver for the FXO module
* Moved most userspace files to the subdirectory utils (see also next commit)
* Explicit license for firmware files
* Optionally avoid auto-registration
* Initializations parameters to chips given from userspace
* And did I mention bugfixes?
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1021 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xproto.c')
-rw-r--r-- | xpp/xproto.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/xpp/xproto.c b/xpp/xproto.c index 5a0d5c6..1fb28c5 100644 --- a/xpp/xproto.c +++ b/xpp/xproto.c @@ -1,6 +1,6 @@ /* * Written by Oron Peled <oron@actcom.co.il> - * Copyright (C) 2004-2005, Xorcom + * Copyright (C) 2004-2006, Xorcom * * All rights reserved. * @@ -23,6 +23,8 @@ #include "xpd.h" #include "xproto.h" #include "xpp_zap.h" +#include "xbus-core.h" +#include "zap_debug.h" #include <linux/module.h> static const char rcsid[] = "$Id$"; @@ -75,7 +77,7 @@ const xproto_entry_t *xproto_global_entry(byte opcode) return xe; } -const xproto_handler_t xproto_global_handler(byte opcode) +xproto_handler_t xproto_global_handler(byte opcode) { return xproto_card_handler(&PROTO_TABLE(GLOBAL), opcode); } @@ -87,7 +89,7 @@ const xproto_table_t *xproto_table(xpd_type_t cardtype) return xprotocol_tables[cardtype]; } -const xproto_table_t *get_xproto_table(xpd_type_t cardtype) +const xproto_table_t *xproto_get(xpd_type_t cardtype) { const xproto_table_t *xtable; @@ -95,18 +97,34 @@ const xproto_table_t *get_xproto_table(xpd_type_t cardtype) return NULL; xtable = xprotocol_tables[cardtype]; if(!xtable) { /* Try to load the relevant module */ - int ret = request_module("xpd-type-%d", cardtype); + int ret = request_module(XPD_TYPE_PREFIX "%d", cardtype); if(ret != 0) { NOTICE("%s: Failed to load module for type=%d. exit status=%d.\n", __FUNCTION__, cardtype, ret); - /* Drop through: we may be luck... */ + /* Drop through: we may be lucky... */ } xtable = xprotocol_tables[cardtype]; } + if(xtable) { + BUG_ON(!xtable->owner); + DBG("%s refcount was %d\n", xtable->name, module_refcount(xtable->owner)); + if(!try_module_get(xtable->owner)) { + ERR("%s: try_module_get for %s failed.\n", __FUNCTION__, xtable->name); + return NULL; + } + } return xtable; } -const xproto_handler_t xproto_card_handler(const xproto_table_t *table, byte opcode) +void xproto_put(const xproto_table_t *xtable) +{ + BUG_ON(!xtable); + DBG("%s refcount was %d\n", xtable->name, module_refcount(xtable->owner)); + BUG_ON(module_refcount(xtable->owner) <= 0); + module_put(xtable->owner); +} + +xproto_handler_t xproto_card_handler(const xproto_table_t *table, byte opcode) { const xproto_entry_t *xe; @@ -115,7 +133,7 @@ const xproto_handler_t xproto_card_handler(const xproto_table_t *table, byte opc return xe->handler; } -const xproto_entry_t *find_xproto_entry(xpd_t *xpd, byte opcode) +static const xproto_entry_t *find_xproto_entry(xpd_t *xpd, byte opcode) { const xproto_entry_t *xe; @@ -136,18 +154,6 @@ const xproto_entry_t *find_xproto_entry(xpd_t *xpd, byte opcode) return xe; } -const xops_t *get_xops(xpd_type_t xpd_type) -{ - const xproto_table_t *proto_table; - - if(xpd_type >= XPD_TYPE_NOMODULE) - return NULL; - proto_table = xprotocol_tables[xpd_type]; - if(!proto_table) - return NULL; - return &proto_table->xops; -} - int packet_receive(xbus_t *xbus, xpacket_t *pack) { int xpd_num; @@ -161,7 +167,7 @@ int packet_receive(xbus_t *xbus, xpacket_t *pack) return -EPROTO; } xpd_num = XPD_NUM(pack->content.addr); -#if SOFT_SIMULATOR +#ifdef SOFT_SIMULATOR if(xbus->sim[xpd_num].simulated) { //dump_packet("packet_receive -> simulate", pack, print_dbg); return simulate_xpd(xbus, xpd_num, pack); @@ -256,7 +262,7 @@ const char *xproto_name(xpd_type_t xpd_type) { const xproto_table_t *proto_table; - BUG_ON(xpd_type >= XPD_TYPE(NOMODULE)); + BUG_ON(xpd_type >= XPD_TYPE_NOMODULE); proto_table = xprotocol_tables[xpd_type]; if(!proto_table) return NULL; @@ -278,7 +284,7 @@ int xproto_register(const xproto_table_t *proto_table) BUG_ON(!proto_table); type = proto_table->type; name = proto_table->name; - if(type >= XPD_TYPE(NOMODULE)) { + if(type >= XPD_TYPE_NOMODULE) { NOTICE("%s: Bad xproto type %d\n", __FUNCTION__, type); return -EINVAL; } @@ -290,14 +296,14 @@ int xproto_register(const xproto_table_t *proto_table) CHECK_XOP(card_init); CHECK_XOP(card_remove); CHECK_XOP(card_tick); + CHECK_XOP(card_zaptel_registration); + CHECK_XOP(card_sethook); CHECK_XOP(SYNC_SOURCE); CHECK_XOP(PCM_WRITE); CHECK_XOP(CHAN_ENABLE); - CHECK_XOP(CHAN_POWER); CHECK_XOP(CHAN_CID); CHECK_XOP(RING); CHECK_XOP(SETHOOK); - CHECK_XOP(LED); CHECK_XOP(RELAY_OUT); xprotocol_tables[type] = proto_table; @@ -313,7 +319,7 @@ void xproto_unregister(const xproto_table_t *proto_table) type = proto_table->type; name = proto_table->name; DBG("%s (%d)\n", name, type); - if(type >= XPD_TYPE(NOMODULE)) { + if(type >= XPD_TYPE_NOMODULE) { NOTICE("%s: Bad xproto type %s (%d)\n", __FUNCTION__, name, type); return; } |