diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2009-04-20 10:26:35 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2009-04-20 10:26:35 +0000 |
commit | 5af88c77e19a108eb1fe9144d157d72e03551309 (patch) | |
tree | a5a8674452a1d33e0b8e2be6770322bd4c4f62b1 /drivers/dahdi/xpp/xbus-core.c | |
parent | 104115d00a132f3cb751991af70a1d90fdd98fe8 (diff) |
xpp: Do use information about number of ports the Astribank provides
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@6408 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/xbus-core.c')
-rw-r--r-- | drivers/dahdi/xpp/xbus-core.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c index b4716a4..f65d0b1 100644 --- a/drivers/dahdi/xpp/xbus-core.c +++ b/drivers/dahdi/xpp/xbus-core.c @@ -728,6 +728,7 @@ static int new_card(xbus_t *xbus, int i; int subunits; int ret = 0; + int remaining_ports; proto_table = xproto_get(type); if(!proto_table) { @@ -736,6 +737,7 @@ static int new_card(xbus_t *xbus, unit, type); return -EINVAL; } + remaining_ports = ports; subunits = (ports + proto_table->ports_per_subunit - 1) / proto_table->ports_per_subunit; XBUS_DBG(DEVICES, xbus, "CARD %d type=%d.%d ports=%d (%dx%d), %d subunits, port-dir=0x%02X\n", @@ -752,6 +754,21 @@ static int new_card(xbus_t *xbus, BUG_ON(!xops); xbus->worker->num_units += subunits - 1; for(i = 0; i < subunits; i++) { + int subunit_ports = proto_table->ports_per_subunit; + + if(subunit_ports > remaining_ports) + subunit_ports = remaining_ports; + remaining_ports -= proto_table->ports_per_subunit; + if(subunit_ports <= 0) { + XBUS_NOTICE(xbus, + "Subunit XPD=%d%d without ports (%d of %d)\n", + unit, + i, + subunit_ports, + ports); + ret = -ENODEV; + goto out; + } if(!XBUS_IS(xbus, RECVD_DESC)) { XBUS_NOTICE(xbus, "Cannot create XPD=%d%d in state %s\n", @@ -761,18 +778,18 @@ static int new_card(xbus_t *xbus, ret = -ENODEV; goto out; } - XBUS_DBG(DEVICES, xbus, "Creating XPD=%d%d type=%d.%d\n", + XBUS_DBG(DEVICES, xbus, "Creating XPD=%d%d type=%d.%d (%d ports)\n", unit, i, type, - subtype); + subtype, subunit_ports); if(!XBUS_IS(xbus, RECVD_DESC)) { XBUS_ERR(xbus, "Aborting creation -- In bad state %s\n", xbus_statename(XBUS_STATE(xbus))); ret = -ENODEV; goto out; } - ret = create_xpd(xbus, proto_table, unit, i, type, subtype, subunits, port_dir); + ret = create_xpd(xbus, proto_table, unit, i, type, subtype, subunits, subunit_ports, port_dir); if(ret < 0) { XBUS_ERR(xbus, "Creation of XPD=%d%d failed %d\n", unit, i, ret); |