[svn-commits] tzafrir: linux/trunk r6408 - /linux/trunk/drivers/dahdi/xpp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Apr 20 05:26:39 CDT 2009


Author: tzafrir
Date: Mon Apr 20 05:26:35 2009
New Revision: 6408

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6408
Log:
xpp: Do use information about number of ports the Astribank provides

Modified:
    linux/trunk/drivers/dahdi/xpp/card_bri.c
    linux/trunk/drivers/dahdi/xpp/card_fxo.c
    linux/trunk/drivers/dahdi/xpp/card_fxs.c
    linux/trunk/drivers/dahdi/xpp/card_pri.c
    linux/trunk/drivers/dahdi/xpp/xbus-core.c
    linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
    linux/trunk/drivers/dahdi/xpp/xpp_dahdi.h
    linux/trunk/drivers/dahdi/xpp/xproto.h

Modified: linux/trunk/drivers/dahdi/xpp/card_bri.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/card_bri.c?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_bri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_bri.c Mon Apr 20 05:26:35 2009
@@ -610,11 +610,16 @@
 	return -EINVAL;
 }
 
-static xpd_t *BRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, byte subtype, int subunits, bool to_phone)
+static xpd_t *BRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table,
+	byte subtype, int subunits, int subunit_ports, bool to_phone)
 {
 	xpd_t		*xpd = NULL;
 	int		channels = min(3, CHANNELS_PERXPD);
 
+	if(subunit_ports != 1) {
+		XBUS_ERR(xbus, "Bad subunit_ports=%d\n", subunit_ports);
+		return NULL;
+	}
 	XBUS_DBG(GENERAL, xbus, "\n");
 	xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct BRI_priv_data), proto_table, channels);
 	if(!xpd)

Modified: linux/trunk/drivers/dahdi/xpp/card_fxo.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxo.c?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxo.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxo.c Mon Apr 20 05:26:35 2009
@@ -422,7 +422,8 @@
 	return -EINVAL;
 }
 
-static xpd_t *FXO_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, byte subtype, int subunits, bool to_phone)
+static xpd_t *FXO_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table,
+	byte subtype, int subunits, int subunit_ports, bool to_phone)
 {
 	xpd_t		*xpd = NULL;
 	int		channels;
@@ -434,9 +435,9 @@
 		return NULL;
 	}
 	if(subtype == 2)
-		channels = min(2, CHANNELS_PERXPD);
+		channels = min(2, subunit_ports);
 	else
-		channels = min(8, CHANNELS_PERXPD);
+		channels = min(8, subunit_ports);
 	xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct FXO_priv_data), proto_table, channels);
 	if(!xpd)
 		return NULL;

Modified: linux/trunk/drivers/dahdi/xpp/card_fxs.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxs.c?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxs.c Mon Apr 20 05:26:35 2009
@@ -377,7 +377,8 @@
 	return -EINVAL;
 }
 
-static xpd_t *FXS_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, byte subtype, int subunits, bool to_phone)
+static xpd_t *FXS_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table,
+	byte subtype, int subunits, int subunit_ports, bool to_phone)
 {
 	xpd_t			*xpd = NULL;
 	int			channels;
@@ -392,9 +393,9 @@
 		return NULL;
 	}
 	if(subtype == 2)
-		regular_channels = min(6, CHANNELS_PERXPD);
+		regular_channels = min(6, subunit_ports);
 	else
-		regular_channels = min(8, CHANNELS_PERXPD);
+		regular_channels = min(8, subunit_ports);
 	channels = regular_channels;
 	if(unit == 0)
 		channels += 6;	/* 2 DIGITAL OUTPUTS, 4 DIGITAL INPUTS */

Modified: linux/trunk/drivers/dahdi/xpp/card_pri.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/card_pri.c?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_pri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_pri.c Mon Apr 20 05:26:35 2009
@@ -909,12 +909,17 @@
 	return 0;
 }
 
-static xpd_t *PRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, byte subtype, int subunits, bool to_phone)
+static xpd_t *PRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table,
+	byte subtype, int subunits, int subunit_ports, bool to_phone)
 {
 	xpd_t			*xpd = NULL;
 	struct PRI_priv_data	*priv;
 	int			channels = min(31, CHANNELS_PERXPD);	/* worst case */
 
+	if(subunit_ports != 1) {
+		XBUS_ERR(xbus, "Bad subunit_ports=%d\n", subunit_ports);
+		return NULL;
+	}
 	XBUS_DBG(GENERAL, xbus, "\n");
 	xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct PRI_priv_data), proto_table, channels);
 	if(!xpd)

Modified: linux/trunk/drivers/dahdi/xpp/xbus-core.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-core.c?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-core.c Mon Apr 20 05:26:35 2009
@@ -728,6 +728,7 @@
 	int			i;
 	int			subunits;
 	int			ret = 0;
+	int			remaining_ports;
 
 	proto_table = xproto_get(type);
 	if(!proto_table) {
@@ -736,6 +737,7 @@
 			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 @@
 	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 @@
 			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);

Modified: linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c Mon Apr 20 05:26:35 2009
@@ -255,6 +255,7 @@
 		byte type,
 		byte subtype,
 		int subunits,
+		int subunit_ports,
 		byte port_dir)
 {
 	xpd_t			*xpd = NULL;
@@ -269,7 +270,12 @@
 			unit, subunit);
 		return 0;
 	}
-	xpd = proto_table->xops.card_new(xbus, unit, subunit, proto_table, subtype, subunits, to_phone);
+	if(subunit_ports <= 0 || subunit_ports > CHANNELS_PERXPD) {
+		XBUS_NOTICE(xbus, "Illegal number of ports %d for XPD %d%d\n",
+			subunit_ports, unit, subunit);
+		return 0;
+	}
+	xpd = proto_table->xops.card_new(xbus, unit, subunit, proto_table, subtype, subunits, subunit_ports, to_phone);
 	if(!xpd) {
 		XBUS_NOTICE(xbus, "card_new(%d,%d,%d,%d,%d) failed. Ignored.\n",
 			unit, subunit, proto_table->type, subtype, to_phone);

Modified: linux/trunk/drivers/dahdi/xpp/xpp_dahdi.h
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xpp_dahdi.h?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpp_dahdi.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xpp_dahdi.h Mon Apr 20 05:26:35 2009
@@ -29,7 +29,7 @@
 int dahdi_unregister_xpd(xpd_t *xpd);
 void xbus_request_removal(xbus_t *xbus);
 int create_xpd(xbus_t *xbus, const xproto_table_t *proto_table,
-		int unit, int subunit, byte type, byte subtype, int subunits, byte port_dir);
+		int unit, int subunit, byte type, byte subtype, int subunits, int subunit_ports, byte port_dir);
 void xpd_post_init(xpd_t *xpd);
 xpd_t *xpd_alloc(xbus_t *xbus, int unit, int subunit, int subtype, int subunits, size_t privsize, const xproto_table_t *proto_table, int channels);
 void xpd_free(xpd_t *xpd);

Modified: linux/trunk/drivers/dahdi/xpp/xproto.h
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xproto.h?view=diff&rev=6408&r1=6407&r2=6408
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xproto.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xproto.h Mon Apr 20 05:26:35 2009
@@ -218,7 +218,8 @@
 
 struct xops {
 	 xpd_t *(*card_new)(xbus_t *xbus, int unit, int subunit,
-		 const xproto_table_t *proto_table, byte subtype, int subunits, bool to_phone);
+		const xproto_table_t *proto_table, byte subtype,
+		int subunits, int subunit_ports, bool to_phone);
 	int (*card_init)(xbus_t *xbus, xpd_t *xpd);
 	int (*card_remove)(xbus_t *xbus, xpd_t *xpd);
 	int (*card_tick)(xbus_t *xbus, xpd_t *xpd);




More information about the svn-commits mailing list