No subject


Thu Jan 15 22:29:28 CST 2009


Modified:
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_fxo.c
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.c
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.h
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/init_card_3_30
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.c
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.h
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-pcm.c
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-sysfs.c
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xframe_queue.c
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.c
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.h
    linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xproto.h

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_fxo.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_fxo.c?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_fxo.c (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_fxo.c Thu Mar  5 14:50:50 2009
@@ -194,6 +194,7 @@
 
 	priv->nobattery_debounce[pos] = 0;
 	priv->power_denial_delay[pos] = 0;
+	power_change(xpd, pos, POWER_UNKNOWN);
 }
 
 static const int	led_register_mask[] = { 	BIT(7),	BIT(6),	BIT(5) };
@@ -357,7 +358,6 @@
 	if(to_offhook) {
 		priv->power_denial_safezone[pos] = power_denial_safezone;
 	} else {
-		power_change(xpd, pos, POWER_UNKNOWN);
 		priv->power_denial_length[pos] = 0;
 		priv->power_denial_safezone[pos] = 0;
 	}
@@ -664,7 +664,7 @@
 			continue;
 		}
 		if(priv->power_denial_safezone[i] > 0) {
-			if(--priv->power_denial_safezone[i]) {
+			if(--priv->power_denial_safezone[i] == 0) {
 				/*
 				 * Poll current, previous answers are meaningless
 				 */
@@ -912,8 +912,7 @@
 			if(milliseconds > BAT_DEBOUNCE) {
 				LINE_DBG(SIGNAL, xpd, portno, "BATTERY OFF voltage=%d\n", volts);
 				priv->battery[portno] = BATTERY_OFF;
-				if(SPAN_REGISTERED(xpd))
-					dahdi_report_battery(xpd, portno);
+				dahdi_report_battery(xpd, portno);
 				/* What's the polarity ? */
 				priv->polarity[portno] = POL_UNKNOWN;
 				priv->polarity_debounce[portno] = 0;
@@ -931,8 +930,7 @@
 		if(priv->battery[portno] != BATTERY_ON) {
 			LINE_DBG(SIGNAL, xpd, portno, "BATTERY ON voltage=%d\n", volts);
 			priv->battery[portno] = BATTERY_ON;
-			if(SPAN_REGISTERED(xpd))
-				dahdi_report_battery(xpd, portno);
+			dahdi_report_battery(xpd, portno);
 		}
 	}
 #if 0

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.c?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.c (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.c Thu Mar  5 14:50:50 2009
@@ -484,6 +484,12 @@
 		dump_reg_cmd("REG_REQ", 1, xbus, xpd->addr.unit, reg_cmd->portnum, reg_cmd);
 		dump_packet("REG_REQ", pack, 1);
 	}
+	if(!xframe->usec_towait) {	/* default processing time of SPI */
+		if(subreg)
+			xframe->usec_towait = 2000;
+		else
+			xframe->usec_towait = 1000;
+	}
 	ret = send_cmd_frame(xbus, xframe);
 	return ret;
 }
@@ -693,34 +699,24 @@
 
 HANDLER_DEF(GLOBAL, ERROR_CODE)
 {
-	byte			errorcode;
 	char			tmp_name[TMP_NAME_LEN];
 	static long		rate_limit;
-	const char		*msg;
-	const static char	*fw_messages[] = {
-					[1] = "Packet too short",
-					[2] = "Len field is too small",
-					[3] = "Premature packet end",
-					[4] = "Invalid op code",
-					[5] = "Invalid packet len",
-					[6] = "SPI fifo full",
-				};
+	byte			category_code;
+	byte			errorbits;
 
 	BUG_ON(!xbus);
 	if((rate_limit++ % 5003) > 200)
 		return 0;
-	errorcode = RPACKET_FIELD(pack, GLOBAL, ERROR_CODE, errorcode);
-	msg = (errorcode < ARRAY_SIZE(fw_messages))
-		? fw_messages[errorcode]
-		: "UNKNOWN CODE";
+	category_code = RPACKET_FIELD(pack, GLOBAL, ERROR_CODE, category_code);
+	errorbits = RPACKET_FIELD(pack, GLOBAL, ERROR_CODE, errorbits);
 	if(!xpd) {
 		snprintf(tmp_name, TMP_NAME_LEN, "%s(%1d%1d)", xbus->busname,
 			XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack));
 	} else {
 		snprintf(tmp_name, TMP_NAME_LEN, "%s/%s", xbus->busname, xpd->xpdname);
 	}
-	NOTICE("%s: FIRMWARE: %s CODE = 0x%X (%s) (rate_limit=%ld)\n",
-			tmp_name, cmd->name, errorcode, msg, rate_limit);
+	NOTICE("%s: FIRMWARE %s: category=%d errorbits=0x%02X (rate_limit=%ld)\n",
+			tmp_name, cmd->name, category_code, errorbits, rate_limit);
 	dump_packet("FIRMWARE: ", pack, 1);
 	/*
 	 * FIXME: Should implement an error recovery plan

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.h?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.h (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/card_global.h Thu Mar  5 14:50:50 2009
@@ -91,7 +91,8 @@
 	byte		mask;
 	);
 DEF_RPACKET_DATA(GLOBAL, ERROR_CODE,
-	byte		errorcode;
+	byte		category_code;
+	byte		errorbits;
 	byte		bad_packet[0];
 	);
 

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/init_card_3_30
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/init_card_3_30?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/init_card_3_30 (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/init_card_3_30 Thu Mar  5 14:50:50 2009
@@ -398,8 +398,10 @@
 							#            in the last slot of PCM frame
 							#            V_PCM_DR, C4IO  is 16.384MHz(128 time slots) 
 
-	BRI::gen "$portnum	WD	4C	03";	# GPIOGPIO function (not PWM) on GPIO0 and GPIO1 pins
-	BRI::gen "$portnum	WD	4A	03";	# Output enable for GPIO0 and GPIO1 pins
+	BRI::gen "$portnum	WD	4C	07";	# GPIOGPIO function (not PWM) on GPIO0, GPIO1 and GPIO2 pins
+	BRI::gen "$portnum	WD	4A	07";	# Output enable for GPIO0, GPIO1 and GPIO2 pins
+	BRI::gen "$portnum	WD	48	01";	# GPIO output data bits
+
 }
 
 my @port_type = (

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.c?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.c Thu Mar  5 14:50:50 2009
@@ -61,6 +61,7 @@
 
 /* Command line parameters */
 extern int debug;
+static DEF_PARM(uint, command_queue_length, 800, 0444, "Maximal command queue length");
 static DEF_PARM(uint, poll_timeout, 1000, 0644, "Timeout (in jiffies) waiting for units to reply");
 static DEF_PARM_BOOL(rx_tasklet, 0, 0644, "Use receive tasklets");
 
@@ -503,11 +504,20 @@
 {
 	xframe_t	*frm;
 	int		ret = 0;
+	int		packno;
 
 	xbus->command_tick_counter++;
-	frm = xframe_dequeue(&xbus->command_queue);
-	if(frm) {
+	xbus->usec_nosend -= 1000;	/* That's our budget */
+	for(packno = 0; packno < 3; packno++) {
+		if(xbus->usec_nosend > 0)
+			break;
+		frm = xframe_dequeue(&xbus->command_queue);
+		if(!frm) {
+			wake_up(&xbus->command_queue_empty);
+			break;
+		}
 		BUG_ON(frm->xframe_magic != XFRAME_MAGIC);
+		xbus->usec_nosend += frm->usec_towait;
 		ret = really_send_cmd_frame(xbus, frm);
 		if(ret < 0) {
 			XBUS_ERR(xbus,
@@ -515,8 +525,9 @@
 				ret);
 			xbus_setstate(xbus, XBUS_STATE_FAIL);
 		}
-	} else
-		wake_up(&xbus->command_queue_empty);
+	}
+	if(xbus->usec_nosend < 0)
+		xbus->usec_nosend = 0;
 	return ret;
 }
 
@@ -1190,19 +1201,12 @@
 
 void xbus_deactivate(xbus_t *xbus, bool is_disconnected)
 {
-	int	i;
-
 	BUG_ON(!xbus);
 	XBUS_INFO(xbus, "[%s] Deactivating\n", xbus->label);
 	if(!xbus_setstate(xbus, XBUS_STATE_DEACTIVATING))
 		return;
 	xbus_request_sync(xbus, SYNC_MODE_NONE);	/* no more ticks */
-	for(i = 0; i < MAX_XPDS; i++) {
-		xpd_t *xpd = xpd_of(xbus, i);
-		if(xpd) {
-			xpd_unreg_request(xpd);
-		}
-	}
+	xbus_request_removal(xbus);
 	XBUS_DBG(DEVICES, xbus, "[%s] Waiting for queues\n", xbus->label);
 	xbus_command_queue_clean(xbus);
 	xbus_command_queue_waitempty(xbus);
@@ -1388,7 +1392,7 @@
 		goto nobus;
 	}
 #endif
-	xframe_queue_init(&xbus->command_queue, 10, 200, "command_queue", xbus);
+	xframe_queue_init(&xbus->command_queue, 10, command_queue_length, "command_queue", xbus);
 	xframe_queue_init(&xbus->receive_queue, 10, 50, "receive_queue", xbus);
 	xframe_queue_init(&xbus->send_pool, 10, 100, "send_pool", xbus);
 	xframe_queue_init(&xbus->receive_pool, 10, 50, "receive_pool", xbus);
@@ -1479,6 +1483,7 @@
 	len += sprintf(page + len, "self_ticking: %d (last_tick at %ld)\n",
 			xbus->self_ticking, xbus->ticker.last_sample.tv.tv_sec);
 	len += sprintf(page + len, "command_tick: %d\n", xbus->command_tick_counter);
+	len += sprintf(page + len, "usec_nosend: %d\n", xbus->usec_nosend);
 	len += sprintf(page + len, "xbus: pcm_rx_counter = %d, frag = %d\n",
 		atomic_read(&xbus->pcm_rx_counter), xbus->xbus_frag_count);
 	len += sprintf(page + len, "max_rx_process = %2ld.%ld ms\n",

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.h?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.h (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-core.h Thu Mar  5 14:50:50 2009
@@ -171,6 +171,7 @@
 	struct xpd		*xpds[MAX_XPDS];
 
 	int			command_tick_counter;
+	int			usec_nosend;		/* Firmware flow control */
 	struct xframe_queue	command_queue;
 	wait_queue_head_t	command_queue_empty;
 
@@ -261,6 +262,7 @@
 	size_t			frame_maxlen;
 	byte			*packets;	/* max XFRAME_DATASIZE */
 	byte			*first_free;
+	int			usec_towait;	/* prevent overflowing AB */
 	void			*priv;
 };
 

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-pcm.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-pcm.c?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-pcm.c (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-pcm.c Thu Mar  5 14:50:50 2009
@@ -177,7 +177,7 @@
 
 	spin_lock_irqsave(&driftinfo->lock, flags);
 	cycled = xpp_ticker_step(&xbus->ticker, tv);
-	if(ref_ticker && syncer && xbus->sync_mode == SYNC_MODE_PLL) {
+	if(ref_ticker && ref_ticker != &xbus->ticker && syncer && xbus->sync_mode == SYNC_MODE_PLL) {
 		int	new_delta_tick = ticker->count - ref_ticker->count;
 		int	lost_ticks = new_delta_tick - driftinfo->delta_tick;
 
@@ -342,6 +342,7 @@
 		XBUS_DBG(SYNC, xbus, "del_timer\n");
 		del_timer(&xbus->command_timer);
 	}
+	xbus->self_ticking = ! on;
 }
 
 /*
@@ -363,21 +364,18 @@
 	case SYNC_MODE_AB:
 		xbus->sync_mode = mode;
 		xbus_set_command_timer(xbus, 0);
-		xbus->self_ticking = 1;
 		xpp_set_syncer(xbus, 1);
 		global_ticker = xbus;
 		break;
 	case SYNC_MODE_PLL:
 		xbus->sync_mode = mode;
 		xbus_set_command_timer(xbus, 0);
-		xbus->self_ticking = 1;
 		xpp_set_syncer(xbus, 0);
 		global_ticker = xbus;
 		break;
 	case SYNC_MODE_NONE:		/* lost sync source */
 		xbus->sync_mode = mode;
 		xbus_set_command_timer(xbus, 1);
-		xbus->self_ticking = 0;
 		xpp_set_syncer(xbus, 0);
 		break;
 	case SYNC_MODE_QUERY:		/* ignore           */
@@ -395,7 +393,6 @@
 	XBUS_DBG(SYNC, xbus, "sent request (mode=%d)\n", mode);
 	CALL_PROTO(GLOBAL, SYNC_SOURCE, xbus, NULL, mode, 0);
 	if(mode == SYNC_MODE_NONE) {
-		xbus->self_ticking = 0;
 		xbus_set_command_timer(xbus, 1);
 	}
 }
@@ -528,6 +525,12 @@
 	 * This global locking protects:
 	 *   - The ref_ticker so it won't be used while we change it.
 	 *   - The xbus_drift_clear() from corrupting driftinfo data.
+	 * It's important to set ref_ticker now:
+	 *   - We cannot make the new xbus a syncer yet (until we get
+	 *     a reply from AB). Maybe it's still not self_ticking, so
+	 *     we must keep the timer for the command_queue to function.
+	 *   - However, we must not send drift commands to it, because
+	 *     they'll revert it to PLL instead of AB.
 	 */
 	spin_lock_irqsave(&ref_ticker_lock, flags);
 	if(syncer)
@@ -564,7 +567,7 @@
 {
 	int	i;
 	int	j;
-	uint	timing_priority = 0;
+	uint	timing_priority = INT_MAX;
 	xpd_t	*best_xpd = NULL;
 	xbus_t	*the_xbus = NULL;
 
@@ -580,7 +583,7 @@
 
 				if(!xpd || !xpd->card_present)
 					continue;
-				if(xpd->timing_priority > timing_priority) {
+				if(xpd->timing_priority > 0 && xpd->timing_priority < timing_priority) {
 					timing_priority = xpd->timing_priority;
 					best_xpd = xpd;
 				}
@@ -595,6 +598,7 @@
 	} else {
 		DBG(SYNC, "%s: No more syncers\n", msg);
 		xpp_set_syncer(NULL, 0);
+		the_xbus = NULL;
 	}
 	if(the_xbus != syncer)
 		update_sync_master(the_xbus, force_dahdi_sync);

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-sysfs.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-sysfs.c?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-sysfs.c (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xbus-sysfs.c Thu Mar  5 14:50:50 2009
@@ -612,6 +612,26 @@
 	return len;
 }
 
+static DEVICE_ATTR_READER(offhook_show, dev, buf)
+{
+	xpd_t		*xpd;
+	int		len = 0;
+	int		i;
+
+	BUG_ON(!dev);
+	xpd = dev_to_xpd(dev);
+	if(!xpd)
+		return -ENODEV;
+	for_each_line(xpd, i) {
+		len += sprintf(buf + len, "%d ", IS_OFFHOOK(xpd, i));
+	}
+	if(len) {
+		len--;	/* backout last space */
+		len += sprintf(buf + len, "\n");
+	}
+	return len;
+}
+
 static int xpd_match(struct device *dev, struct device_driver *driver)
 {
 	struct xpd_driver	*xpd_driver;
@@ -634,6 +654,7 @@
 	__ATTR(blink,		S_IRUGO | S_IWUSR, blink_show, blink_store),
 	__ATTR(span,		S_IRUGO | S_IWUSR, span_show, span_store),
         __ATTR_RO(type),
+        __ATTR_RO(offhook),
         __ATTR_NULL,
 };
 

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xframe_queue.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xframe_queue.c?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xframe_queue.c (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xframe_queue.c Thu Mar  5 14:50:50 2009
@@ -23,6 +23,26 @@
 	q->worst_count = 0;
 	//q->overflows = 0;	/* Never clear overflows */
 	q->worst_lag_usec = 0L;
+}
+
+static void __xframe_dump_queue(struct xframe_queue *q)
+{
+	xframe_t	*xframe;
+	int		i = 0;
+	char		prefix[30];
+	struct timeval	now;
+
+	do_gettimeofday(&now);
+	printk(KERN_DEBUG "%s: dump queue '%s' (first packet in each frame)\n",
+		THIS_MODULE->name,
+		q->name);
+	list_for_each_entry_reverse(xframe, &q->head, frame_list) {
+		xpacket_t	*pack = (xpacket_t *)&xframe->packets[0];
+		long		usec = usec_diff(&now, &xframe->tv_queued);
+		snprintf(prefix, ARRAY_SIZE(prefix), "  %3d> %5ld.%03ld msec",
+			i++, usec / 1000, usec % 1000);
+		dump_packet(prefix, pack, 1);
+	}
 }
 
 static bool __xframe_enqueue(struct xframe_queue *q, xframe_t *xframe)
@@ -44,6 +64,7 @@
 				q->overflows,
 				q->worst_lag_usec / 1000,
 				q->worst_lag_usec % 1000);
+		__xframe_dump_queue(q);
 		ret = 0;
 		goto out;
 	}

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.c?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.c (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.c Thu Mar  5 14:50:50 2009
@@ -558,28 +558,45 @@
 	return NULL;
 }
 
-void xpd_unreg_request(xpd_t *xpd)
+/*
+ * Try our best to make asterisk close all channels related to
+ * this Astribank:
+ *   - Set span state to DAHDI_ALARM_NOTOPEN in all relevant spans.
+ *   - Notify dahdi afterwards about spans (so it can see all changes at once).
+ *   - Also send DAHDI_EVENT_REMOVED on all channels.
+ */
+void xbus_request_removal(xbus_t *xbus)
 {
 	unsigned long	flags;
-
-	BUG_ON(!xpd);
-
-	XPD_DBG(DEVICES, xpd, "\n");
-	spin_lock_irqsave(&xpd->lock, flags);
-	xpd->card_present = 0;
-	xpd_setstate(xpd, XPD_STATE_NOHW);
-	if(SPAN_REGISTERED(xpd)) {
-		int i;
-
-		update_xpd_status(xpd, DAHDI_ALARM_NOTOPEN);
-		/* TODO: Should this be done before releasing the spinlock? */
-		XPD_DBG(DEVICES, xpd, "Queuing DAHDI_EVENT_REMOVED on all channels to ask user to close them\n");
-		for (i=0; i<xpd->span.channels; i++) {
-			dahdi_qevent_lock(XPD_CHAN(xpd, i),DAHDI_EVENT_REMOVED);
+	int		i;
+
+	for(i = 0; i < MAX_XPDS; i++) {
+		xpd_t *xpd = xpd_of(xbus, i);
+		if(xpd) {
+			XPD_DBG(DEVICES, xpd, "\n");
+			spin_lock_irqsave(&xpd->lock, flags);
+			xpd->card_present = 0;
+			xpd_setstate(xpd, XPD_STATE_NOHW);
+			xpd->span.alarms = DAHDI_ALARM_NOTOPEN;
+			spin_unlock_irqrestore(&xpd->lock, flags);
 		}
 	}
-	spin_unlock_irqrestore(&xpd->lock, flags);
-	xpd_device_unregister(xpd);
+	/* Now notify dahdi */
+	for(i = 0; i < MAX_XPDS; i++) {
+		xpd_t *xpd = xpd_of(xbus, i);
+		if(xpd) {
+			if(SPAN_REGISTERED(xpd)) {
+				int i;
+
+				dahdi_alarm_notify(&xpd->span);
+				XPD_DBG(DEVICES, xpd, "Queuing DAHDI_EVENT_REMOVED on all channels to ask user to release them\n");
+				for (i=0; i<xpd->span.channels; i++) {
+					dahdi_qevent_lock(XPD_CHAN(xpd, i),DAHDI_EVENT_REMOVED);
+				}
+			}
+			xpd_device_unregister(xpd);
+		}
+	}
 }
 
 /*
@@ -615,9 +632,9 @@
 	}
 	if(span->alarms == alarm_flag)
 		return;
+	XPD_DBG(GENERAL, xpd, "Update XPD alarms: %s -> %02X\n", xpd->span.name, alarm_flag);
 	span->alarms = alarm_flag;
 	dahdi_alarm_notify(span);
-	XPD_DBG(GENERAL, xpd, "Update XPD alarms: %s -> %02X\n", xpd->span.name, alarm_flag);
 }
 
 /*
@@ -1189,7 +1206,7 @@
 EXPORT_SYMBOL(put_xpd);
 EXPORT_SYMBOL(xpd_alloc);
 EXPORT_SYMBOL(xpd_free);
-EXPORT_SYMBOL(xpd_unreg_request);
+EXPORT_SYMBOL(xbus_request_removal);
 EXPORT_SYMBOL(update_xpd_status);
 EXPORT_SYMBOL(oht_pcm);
 EXPORT_SYMBOL(mark_offhook);

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.h?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.h (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xpp_dahdi.h Thu Mar  5 14:50:50 2009
@@ -27,7 +27,7 @@
 
 int dahdi_register_xpd(xpd_t *xpd);
 int dahdi_unregister_xpd(xpd_t *xpd);
-void xpd_unreg_request(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);
 void xpd_post_init(xpd_t *xpd);

Modified: linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xproto.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xproto.h?view=diff&rev=6092&r1=6091&r2=6092
==============================================================================
--- linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xproto.h (original)
+++ linux/team/tzafrir/xpp-backport-210/drivers/dahdi/xpp/xproto.h Thu Mar  5 14:50:50 2009
@@ -149,13 +149,14 @@
 								\
 		if(XBUS_IS(xbus, DISCONNECTED))			\
 			return -ENODEV;				\
-		frm = ALLOC_SEND_XFRAME(xbus);			\
-		if(!frm)					\
+		(frm) = ALLOC_SEND_XFRAME(xbus);			\
+		if(!(frm))					\
 			return -ENOMEM;				\
 		(p) = xframe_next_packet(frm, pack_len);	\
 		if(!(p))					\
 			return -ENOMEM;				\
 		XPACKET_INIT(p, card, op, to, 0, 0);		\
+		(frm)->usec_towait = 0;				\
 	} while(0)
 
 #endif




More information about the svn-commits mailing list