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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jan 30 08:14:18 CST 2011


Author: tzafrir
Date: Sun Jan 30 08:14:14 2011
New Revision: 9706

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9706
Log:
xpp: phonedev: Cleanup method macros

* Caller to CALL_XMETHOD() no longer need to explicitly pass xbus
  (calculate xpd->xbus)
* Create CALL_PHONE_METHOD() similar to CALL_XMETHOD() -- inlining
  the extra parameters (more readable)
* Reverse parameter order in PHONE_METHOD() and CALL_PHONE_METHOD()
  to be consistent with XMETHOD() and CALL_XMETHOD()
* Rename XPD_STATE phonedev method to card_state:
  - Consistency with other phonedev methods.
  - These calls now Wrap internal calls to XPD_STATE protocol HOSTCMD
    in PRI, BRI, FXS, FXO

Signed-off-by: Oron Peled <oron at actcom.co.il>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

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_global.c
    linux/trunk/drivers/dahdi/xpp/card_pri.c
    linux/trunk/drivers/dahdi/xpp/xbus-core.c
    linux/trunk/drivers/dahdi/xpp/xbus-pcm.c
    linux/trunk/drivers/dahdi/xpp/xbus-pcm.h
    linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
    linux/trunk/drivers/dahdi/xpp/xproto.h

Modified: linux/trunk/drivers/dahdi/xpp/card_bri.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/card_bri.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_bri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_bri.c Sun Jan 30 08:14:14 2011
@@ -932,7 +932,7 @@
 			cur_chan->sigcap = BRI_BCHAN_SIGCAP;
 		}
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	PHONEDEV(xpd).span.ops = &BRI_span_ops;
 	return 0;
 }
@@ -950,7 +950,7 @@
 	return(0);
 }
 
-static int BRI_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
+static int BRI_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
 {
 	LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig));
 	return 0;
@@ -1154,7 +1154,7 @@
 		BIT_SET(PHONEDEV(xpd).offhook_state, 0);
 		BIT_SET(PHONEDEV(xpd).offhook_state, 1);
 		BIT_SET(PHONEDEV(xpd).offhook_state, 2);
-		PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+		CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	}
 	return 0;
 }
@@ -1176,7 +1176,7 @@
 		BIT_CLR(PHONEDEV(xpd).offhook_state, 0);
 		BIT_CLR(PHONEDEV(xpd).offhook_state, 1);
 		BIT_CLR(PHONEDEV(xpd).offhook_state, 2);
-		PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+		CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	}
 	return 0;
 }
@@ -1257,7 +1257,7 @@
 	}
 	XPD_DBG(GENERAL, xpd, "STARTUP\n");
 	// Turn on all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 1);
+	CALL_PHONE_METHOD(card_state, xpd, 1);
 	if(SPAN_REGISTERED(xpd)) {
 		dchan = XPD_CHAN(xpd, 2);
 		span->flags |= DAHDI_FLAG_RUNNING;
@@ -1293,11 +1293,11 @@
 	}
 	XPD_DBG(GENERAL, xpd, "SHUTDOWN\n");
 	// Turn off all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 0);
-	return 0;
-}
-
-static void BRI_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd,
+	CALL_PHONE_METHOD(card_state, xpd, 0);
+	return 0;
+}
+
+static void BRI_card_pcm_recompute(xpd_t *xpd,
 		xpp_line_t dont_care)
 {
 	int		i;
@@ -1308,7 +1308,7 @@
 	unsigned long	flags;
 
 	BUG_ON(!xpd);
-	main_xpd = xpd_byaddr(xbus, xpd->addr.unit, 0);
+	main_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, 0);
 	if(!main_xpd) {
 		XPD_DBG(DEVICES, xpd, "Unit 0 is already gone. Ignore request\n");
 		return;
@@ -1321,7 +1321,7 @@
 	line_count = 0;
 	pcm_mask = 0;
 	for(i = 0; i < MAX_SUBUNIT; i++) {
-		xpd_t		*sub_xpd = xpd_byaddr(xbus, main_xpd->addr.unit, i);
+		xpd_t		*sub_xpd = xpd_byaddr(xpd->xbus, main_xpd->addr.unit, i);
 
 		if(sub_xpd) {
 			xpp_line_t	lines =
@@ -1355,7 +1355,7 @@
 	spin_unlock_irqrestore(&PHONEDEV(main_xpd).lock_recompute_pcm, flags);
 }
 
-static void BRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void BRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	unsigned long	flags;
@@ -1365,14 +1365,13 @@
 	xpp_line_t	wanted_lines;
 
 
-	BUG_ON(!xbus);
 	BUG_ON(!xpd);
 	BUG_ON(!pack);
 	pcm = RPACKET_FIELD(pack, GLOBAL, PCM_WRITE, pcm);
 	for(subunit = 0; subunit < MAX_SUBUNIT; subunit++) {
 		xpd_t		*tmp_xpd;
 
-		tmp_xpd = xpd_byaddr(xbus, xpd->addr.unit, subunit);
+		tmp_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, subunit);
 		if(!tmp_xpd || !tmp_xpd->card_present)
 			continue;
 		spin_lock_irqsave(&tmp_xpd->lock, flags);
@@ -1402,7 +1401,7 @@
 	RPACKET_FIELD(pack, GLOBAL, PCM_WRITE, lines) = pcm_mask;
 }
 
-static void BRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void BRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	xpp_line_t	pcm_mask;
@@ -1424,7 +1423,7 @@
 
 		if(!pcm_mask)
 			break;	/* optimize */
-		tmp_xpd = xpd_byaddr(xbus, xpd->addr.unit, subunit);
+		tmp_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, subunit);
 		if(!tmp_xpd || !tmp_xpd->card_present || !SPAN_REGISTERED(tmp_xpd))
 			continue;
 		spin_lock_irqsave(&tmp_xpd->lock, flags);
@@ -1670,6 +1669,11 @@
 	return 0;
 }
 
+static int BRI_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(BRI, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	bri_xops = {
 	.card_new	= BRI_card_new,
 	.card_init	= BRI_card_init,
@@ -1689,8 +1693,7 @@
 	.card_ioctl	= BRI_card_ioctl,
 	.card_open	= BRI_card_open,
 	.card_close	= BRI_card_close,
-
-	.XPD_STATE	= XPROTO_CALLER(BRI, XPD_STATE),
+	.card_state	= BRI_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(BRI) = {

Modified: linux/trunk/drivers/dahdi/xpp/card_fxo.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxo.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxo.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxo.c Sun Jan 30 08:14:14 2011
@@ -482,7 +482,7 @@
 		do_led(xpd, i, LED_GREEN, 0);
 		msleep(50);
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	return 0;
 }
 
@@ -555,7 +555,7 @@
 	return 0;
 }
 
-static int FXO_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
+static int FXO_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
 {
 	struct FXO_priv_data	*priv;
 	int			ret = 0;
@@ -1111,6 +1111,11 @@
 	return 0;
 }
 
+static int FXO_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(FXO, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	fxo_xops = {
 	.card_new	= FXO_card_new,
 	.card_init	= FXO_card_init,
@@ -1129,8 +1134,7 @@
 	.card_timing_priority	= generic_timing_priority,
 	.card_ioctl	= FXO_card_ioctl,
 	.card_open	= FXO_card_open,
-
-	.XPD_STATE	= XPROTO_CALLER(FXO, XPD_STATE),
+	.card_state	= FXO_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(FXO) = {

Modified: linux/trunk/drivers/dahdi/xpp/card_fxs.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxs.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxs.c Sun Jan 30 08:14:14 2011
@@ -455,7 +455,7 @@
 		msleep(50);
 	}
 	restore_leds(xpd);
-	PHONE_METHOD(xpd, card_pcm_recompute)(xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	/*
 	 * We should query our offhook state long enough time after we
 	 * set the linefeed_control()
@@ -559,7 +559,7 @@
 		BIT_SET(PHONEDEV(xpd).mute_dtmf, pos);
 	else
 		BIT_CLR(PHONEDEV(xpd).mute_dtmf, pos);
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);	/* already spinlocked */
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);	/* already spinlocked */
 }
 
 static int set_vm_led_mode(xbus_t *xbus, xpd_t *xpd, int pos,
@@ -661,7 +661,7 @@
 	return ret;
 }
 
-static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
+static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
 {
 	struct FXS_priv_data	*priv;
 	int			ret = 0;
@@ -698,13 +698,13 @@
 				 * Restore state after KEWL hangup.
 				 */
 				LINE_DBG(SIGNAL, xpd, pos, "KEWL STOP\n");
-				linefeed_control(xbus, xpd, pos, FXS_LINE_POL_ACTIVE);
+				linefeed_control(xpd->xbus, xpd, pos, FXS_LINE_POL_ACTIVE);
 				if(IS_OFFHOOK(xpd, pos))
 					MARK_ON(priv, pos, LED_GREEN);
 			}
 			ret = send_ring(xpd, pos, 0);			// RING off
 			if (!IS_OFFHOOK(xpd, pos))
-				start_stop_vm_led(xbus, xpd, pos);
+				start_stop_vm_led(xpd->xbus, xpd, pos);
 			txhook = priv->lasttxhook[pos];
 			if(chan) {
 				switch(chan->sig) {
@@ -718,7 +718,7 @@
 						break;
 				}
 			}
-			ret = linefeed_control(xbus, xpd, pos, txhook);
+			ret = linefeed_control(xpd->xbus, xpd, pos, txhook);
 			break;
 		case DAHDI_TXSIG_OFFHOOK:
 			if(IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
@@ -741,7 +741,7 @@
 						break;
 				}
 			}
-			ret = linefeed_control(xbus, xpd, pos, txhook);
+			ret = linefeed_control(xpd->xbus, xpd, pos, txhook);
 			break;
 		case DAHDI_TXSIG_START:
 			PHONEDEV(xpd).ringing[pos] = 1;
@@ -759,7 +759,7 @@
 				LINE_DBG(SIGNAL, xpd, pos, "%s -> Is digital output. Ignored\n", txsig2str(txsig));
 				return -EINVAL;
 			}
-			linefeed_control(xbus, xpd, pos, FXS_LINE_OPEN);
+			linefeed_control(xpd->xbus, xpd, pos, FXS_LINE_OPEN);
 			MARK_OFF(priv, pos, LED_GREEN);
 			break;
 		default:
@@ -847,7 +847,7 @@
 				priv->ohttimer[pos] = val;
 				priv->idletxhookstate[pos] = FXS_LINE_POL_OHTRANS;
 				vmwi_search(xpd, pos, 1);
-				PHONE_METHOD(xpd, card_pcm_recompute)(xbus, xpd, priv->search_fsk_pattern);
+				CALL_PHONE_METHOD(card_pcm_recompute, xpd, priv->search_fsk_pattern);
 				LINE_DBG(SIGNAL, xpd, pos, "Start OHT_TIMER. wanted_pcm_mask=0x%X\n", PHONEDEV(xpd).wanted_pcm_mask);
 			}
 			if (VMWI_NEON(priv, pos) && !IS_OFFHOOK(xpd, pos))
@@ -1394,6 +1394,11 @@
 	return 0;
 }
 
+static int FXS_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(FXS, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	fxs_xops = {
 	.card_new	= FXS_card_new,
 	.card_init	= FXS_card_init,
@@ -1413,8 +1418,7 @@
 	.card_open	= FXS_card_open,
 	.card_close	= FXS_card_close,
 	.card_ioctl	= FXS_card_ioctl,
-
-	.XPD_STATE	= XPROTO_CALLER(FXS, XPD_STATE),
+	.card_state	= FXS_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(FXS) = {

Modified: linux/trunk/drivers/dahdi/xpp/card_global.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/card_global.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_global.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_global.c Sun Jan 30 08:14:14 2011
@@ -685,7 +685,11 @@
 		dump_reg_cmd("REG_REPLY", 0, xbus, xpd->addr.unit, reg->portnum, reg);
 		dump_packet("REG_REPLY", pack, 1);
 	}
-	return CALL_XMETHOD(card_register_reply, xbus, xpd, reg);
+	if (! XMETHOD(card_register_reply, xpd)) {
+		XPD_ERR(xpd, "REGISTER_REPLY: without card_register_reply() method\n");
+		return -EINVAL;
+	}
+	return CALL_XMETHOD(card_register_reply, xpd, reg);
 }
 
 HANDLER_DEF(GLOBAL, SYNC_REPLY)

Modified: linux/trunk/drivers/dahdi/xpp/card_pri.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/card_pri.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_pri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_pri.c Sun Jan 30 08:14:14 2011
@@ -552,7 +552,7 @@
 	return 1;
 }
 
-static void PRI_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd,
+static void PRI_card_pcm_recompute(xpd_t *xpd,
 		xpp_line_t pcm_mask)
 {
 	struct PRI_priv_data	*priv;
@@ -652,7 +652,7 @@
 	priv->is_cas = -1;
 	PHONEDEV(xpd).channels = pri_num_channels(set_proto);
 	PHONEDEV(xpd).offhook_state = BITMASK(PHONEDEV(xpd).channels);
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	priv->deflaw = deflaw;
 	priv->dchan_num = dchan_num;
 	priv->local_loopback = 0;
@@ -1037,7 +1037,7 @@
 		force_cas = 1;
 		set_mode_cas(xpd, 1);
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	/*
 	 * E1's can enable CRC checking
 	 * CRC4 is legal only for E1, and it is checked by pri_linecompat()
@@ -1545,7 +1545,7 @@
 	}
 	XPD_DBG(GENERAL, xpd, "STARTUP\n");
 	// Turn on all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 1);
+	CALL_PHONE_METHOD(card_state, xpd, 1);
 	set_rbslines(xpd, 0);
 	write_subunit(xpd, REG_XPM2, 0x00);
 	return 0;
@@ -1569,7 +1569,7 @@
 	}
 	XPD_DBG(GENERAL, xpd, "SHUTDOWN\n");
 	// Turn off all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_state, xpd, 0);
 	return 0;
 }
 
@@ -1728,7 +1728,7 @@
  * send 31 channels to the device, but they should be called 1-31 rather
  * than 0-30 .
  */
-static void PRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void PRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
 {
 	struct PRI_priv_data	*priv;
 	byte			*pcm;
@@ -1738,7 +1738,6 @@
 	int			physical_chan;
 	int			physical_mask = 0;
 
-	BUG_ON(!xbus);
 	BUG_ON(!xpd);
 	BUG_ON(!pack);
 	priv = xpd->priv;
@@ -1802,7 +1801,7 @@
  *
  * \see PRI_card_pcm_fromspan
  */
-static void PRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void PRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
 {
 	struct PRI_priv_data	*priv;
 	byte			*pcm;
@@ -1855,7 +1854,7 @@
 	spin_unlock_irqrestore(&xpd->lock, flags);
 }
 
-int PRI_timing_priority(xbus_t *xbus, xpd_t *xpd)
+int PRI_timing_priority(xpd_t *xpd)
 {
 	struct PRI_priv_data	*priv;
 
@@ -2169,6 +2168,11 @@
 	return 0;
 }
 
+static int PRI_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(PRI, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	pri_xops = {
 	.card_new	= PRI_card_new,
 	.card_init	= PRI_card_init,
@@ -2186,8 +2190,7 @@
 	.card_timing_priority	= PRI_timing_priority,
 	.card_ioctl	= PRI_card_ioctl,
 	.card_close	= PRI_card_close,
-
-	.XPD_STATE	= XPROTO_CALLER(PRI, XPD_STATE),
+	.card_state	= PRI_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(PRI) = {

Modified: linux/trunk/drivers/dahdi/xpp/xbus-core.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-core.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-core.c Sun Jan 30 08:14:14 2011
@@ -900,14 +900,13 @@
 {
 	int	ret = -ENODEV;
 
-	if(CALL_XMETHOD(card_init, xpd->xbus, xpd) < 0) {
+	if(CALL_XMETHOD(card_init, xpd) < 0) {
 		XPD_ERR(xpd, "Card Initialization failed\n");
 		goto out;
 	}
-	//CALL_XMETHOD(XPD_STATE, xpd->xbus, xpd, 0);	/* Turn off all channels */
 	xpd->card_present = 1;
 	if (IS_PHONEDEV(xpd)) {
-		PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 1);	/* Turn on all channels */
+		CALL_PHONE_METHOD(card_state, xpd, 1);	/* Turn on all channels */
 	}
 	if(!xpd_setstate(xpd, XPD_STATE_READY)) {
 		goto out;

Modified: linux/trunk/drivers/dahdi/xpp/xbus-pcm.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-pcm.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-pcm.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-pcm.c Sun Jan 30 08:14:14 2011
@@ -630,7 +630,7 @@
 
 				if(!xpd || !xpd->card_present || !IS_PHONEDEV(xpd))
 					continue;
-				prio = PHONE_METHOD(xpd, card_timing_priority)(xbus, xpd);
+				prio = CALL_PHONE_METHOD(card_timing_priority, xpd);
 				if (prio < 0) {
 					DBG(SYNC, "%s/%s: skip sync\n",
 						xbus->busname, xpd->xpdname);
@@ -679,7 +679,7 @@
  * channels which should be *added* to the automatic calculation.
  * Normally, this argument is 0.
  */
-void generic_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd, xpp_line_t pcm_mask)
+void generic_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask)
 {
 	int		i;
 	int		line_count = 0;
@@ -854,14 +854,13 @@
  * Generic implementations of card_pcmfromspan()/card_pcmtospan()
  * For FXS/FXO
  */
-void generic_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+void generic_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	unsigned long	flags;
 	xpp_line_t	wanted_lines;
 	int		i;
 
-	BUG_ON(!xbus);
 	BUG_ON(!xpd);
 	BUG_ON(!pack);
 	wanted_lines = PHONEDEV(xpd).wanted_pcm_mask;
@@ -890,7 +889,7 @@
 	spin_unlock_irqrestore(&xpd->lock, flags);
 }
 
-void generic_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+void generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	xpp_line_t	pcm_mask;
@@ -993,7 +992,7 @@
 			goto out;
 		if(SPAN_REGISTERED(xpd)) {
 			XBUS_COUNTER(xbus, RX_PACK_PCM)++;
-			PHONE_METHOD(xpd, card_pcm_tospan)(xbus, xpd, pack);
+			CALL_PHONE_METHOD(card_pcm_tospan, xpd, pack);
 		}
 	} while(p < xframe_end);
 	ret = 0;	/* all good */
@@ -1003,7 +1002,7 @@
 	return ret;
 }
 
-int generic_timing_priority(xbus_t *xbus, xpd_t *xpd)
+int generic_timing_priority(xpd_t *xpd)
 {
 	return PHONEDEV(xpd).timing_priority;
 }
@@ -1080,7 +1079,7 @@
 					XPACKET_ADDR_SYNC(pack) = 1;
 					sent_sync_bit = 1;
 				}
-				PHONE_METHOD(xpd, card_pcm_fromspan)(xbus, xpd, pack);
+				CALL_PHONE_METHOD(card_pcm_fromspan, xpd, pack);
 				XBUS_COUNTER(xbus, TX_PACK_PCM)++;
 			}
 		}
@@ -1131,7 +1130,7 @@
 		 * Must be called *after* tx/rx so
 		 * D-Chan counters may be cleared
 		 */
-		CALL_XMETHOD(card_tick, xbus, xpd);
+		CALL_XMETHOD(card_tick, xpd);
 	}
 }
 

Modified: linux/trunk/drivers/dahdi/xpp/xbus-pcm.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-pcm.h?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-pcm.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-pcm.h Sun Jan 30 08:14:14 2011
@@ -105,10 +105,10 @@
 void		pcm_recompute(xpd_t *xpd, xpp_line_t tmp_pcm_mask);
 void		xframe_receive_pcm(xbus_t *xbus, xframe_t *xframe);
 void		update_wanted_pcm_mask(xpd_t *xpd, xpp_line_t new_mask, uint new_pcm_len);
-void		generic_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd, xpp_line_t pcm_mask);
-void		generic_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
-void		generic_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
-int		generic_timing_priority(xbus_t *xbus, xpd_t *xpd);
+void		generic_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask);
+void		generic_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack);
+void		generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack);
+int		generic_timing_priority(xpd_t *xpd);
 void		fill_beep(u_char *buf, int num, int duration);
 const char	*sync_mode_name(enum sync_mode mode);
 void		xbus_set_command_timer(xbus_t *xbus, bool on);

Modified: linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c Sun Jan 30 08:14:14 2011
@@ -661,7 +661,7 @@
 	xbus = xpd->xbus;
 	XPD_INFO(xpd, "Remove\n");
 	dahdi_unregister_xpd(xpd);
-	CALL_XMETHOD(card_remove, xbus, xpd);
+	CALL_XMETHOD(card_remove, xpd);
 	xpd_free(xpd);
 }
 
@@ -702,7 +702,7 @@
 		LINE_DBG(SIGNAL, xpd, pos, "OHT PCM: block\n");
 		BIT_CLR(PHONEDEV(xpd).oht_pcm_pass, pos);
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 }
 
 /*
@@ -717,7 +717,7 @@
 		LINE_DBG(SIGNAL, xpd, pos, "ONHOOK\n");
 		BIT_CLR(PHONEDEV(xpd).offhook_state, pos);
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 }
 
 /*
@@ -907,8 +907,8 @@
 		current->comm, current->pid,
 		atomic_read(&PHONEDEV(xpd).open_counter));
 	spin_unlock_irqrestore(&xbus->lock, flags);
-	if(PHONE_METHOD(xpd, card_open))
-		PHONE_METHOD(xpd, card_open)(xpd, pos);
+	if(PHONE_METHOD(card_open, xpd))
+		CALL_PHONE_METHOD(card_open, xpd, pos);
 	return 0;
 }
 
@@ -921,8 +921,8 @@
 
 	spin_lock_irqsave(&xbus->lock, flags);
 	spin_unlock_irqrestore(&xbus->lock, flags);
-	if(PHONE_METHOD(xpd, card_close))
-		PHONE_METHOD(xpd, card_close)(xpd, pos);
+	if(PHONE_METHOD(card_close, xpd))
+		CALL_PHONE_METHOD(card_close, xpd, pos);
 	LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n",
 		current->comm, current->pid,
 		atomic_read(&PHONEDEV(xpd).open_counter));
@@ -958,8 +958,8 @@
 	switch (cmd) {
 		default:
 			/* Some span-specific commands before we give up: */
-			if (PHONE_METHOD(xpd, card_ioctl)) {
-				return PHONE_METHOD(xpd, card_ioctl)(xpd, pos, cmd, arg);
+			if (PHONE_METHOD(card_ioctl, xpd)) {
+				return CALL_PHONE_METHOD(card_ioctl, xpd, pos, cmd, arg);
 			}
 			report_bad_ioctl(THIS_MODULE->name, xpd, pos, cmd);
 			return -ENOTTY;
@@ -978,7 +978,7 @@
 			__FUNCTION__, pos);
 		return -ENODEV;
 	}
-	if(!PHONE_METHOD(xpd, card_hooksig)) {
+	if(!PHONE_METHOD(card_hooksig, xpd)) {
 		LINE_ERR(xpd, pos,
 			"%s: No hooksig method for this channel. Ignore.\n",
 			__FUNCTION__);
@@ -987,7 +987,7 @@
 	xbus = xpd->xbus;
 	BUG_ON(!xbus);
 	DBG(SIGNAL, "Setting %s to %s (%d)\n", chan->name, txsig2str(txsig), txsig);
-	return PHONE_METHOD(xpd, card_hooksig)(xbus, xpd, pos, txsig);
+	return CALL_PHONE_METHOD(card_hooksig, xpd, pos, txsig);
 }
 EXPORT_SYMBOL(xpp_hooksig);
 
@@ -1018,7 +1018,6 @@
 			break;
 		case DAHDI_MAINT_LOOPUP:
 			INFO("XXX Send loopup code XXX\n");
-			// CALL_XMETHOD(LOOPBACK_AX, xpd->xbus, xpd, loopback_data, ARRAY_SIZE(loopback_data));
 			break;
 		case DAHDI_MAINT_LOOPDOWN:
 			INFO("XXX Send loopdown code XXX\n");
@@ -1085,12 +1084,12 @@
 	mdelay(2);	// FIXME: This is to give chance for transmit/receiveprep to finish.
 	spin_unlock_irqrestore(&xpd->lock, flags);
 	if(xpd->card_present)
-		PHONE_METHOD(xpd, card_dahdi_preregistration)(xpd, 0);
+		CALL_PHONE_METHOD(card_dahdi_preregistration, xpd, 0);
 	atomic_dec(&PHONEDEV(xpd).dahdi_registered);
 	atomic_dec(&num_registered_spans);
 	dahdi_unregister(&PHONEDEV(xpd).span);
 	if(xpd->card_present)
-		PHONE_METHOD(xpd, card_dahdi_postregistration)(xpd, 0);
+		CALL_PHONE_METHOD(card_dahdi_postregistration, xpd, 0);
 	return 0;
 }
 
@@ -1185,14 +1184,14 @@
 	snprintf(PHONEDEV(xpd).span.desc, MAX_SPANDESC, "Xorcom XPD #%02d/%1d%1d: %s",
 			xbus->num, xpd->addr.unit, xpd->addr.subunit, xpd->type_name);
 	XPD_DBG(GENERAL, xpd, "Registering span '%s'\n", PHONEDEV(xpd).span.desc);
-	PHONE_METHOD(xpd, card_dahdi_preregistration)(xpd, 1);
+	CALL_PHONE_METHOD(card_dahdi_preregistration, xpd, 1);
 	if(dahdi_register(&PHONEDEV(xpd).span, prefmaster)) {
 		XPD_ERR(xpd, "Failed to dahdi_register span\n");
 		return -ENODEV;
 	}
 	atomic_inc(&num_registered_spans);
 	atomic_inc(&PHONEDEV(xpd).dahdi_registered);
-	PHONE_METHOD(xpd, card_dahdi_postregistration)(xpd, 1);
+	CALL_PHONE_METHOD(card_dahdi_postregistration, xpd, 1);
 	/*
 	 * Update dahdi about our state:
 	 *   - Since asterisk didn't open the channel yet,

Modified: linux/trunk/drivers/dahdi/xpp/xproto.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xproto.h?view=diff&rev=9706&r1=9705&r2=9706
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xproto.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xproto.h Sun Jan 30 08:14:14 2011
@@ -213,24 +213,34 @@
 const xproto_entry_t *xproto_global_entry(byte opcode);
 xproto_handler_t xproto_global_handler(byte opcode);
 
-#define	CALL_XMETHOD(name, xbus, xpd, ...)				\
-			(xpd)->xops->name(xbus, xpd, ## __VA_ARGS__ )
-
-#define	PHONE_METHOD(xpd, name)	PHONEDEV(xpd).phoneops->name
+/*
+ * XMETHOD() resolve to method pointer (NULL for optional methods)
+ * CALL_XMETHOD() calls the method, passing mandatory arguments
+ */
+#define	XMETHOD(name, xpd)	((xpd)->xops->name)
+#define	CALL_XMETHOD(name, xpd, ...)                              \
+		(XMETHOD(name, (xpd))((xpd)->xbus, (xpd), ## __VA_ARGS__ ))
+
+/*
+ * PHONE_METHOD() resolve to method pointer (NULL for optional methods)
+ * CALL_PHONE_METHOD() calls the method, passing mandatory arguments
+ */
+#define	PHONE_METHOD(name, xpd)	(PHONEDEV(xpd).phoneops->name)
+#define	CALL_PHONE_METHOD(name, xpd, ...)                              \
+		(PHONE_METHOD(name, (xpd))((xpd), ## __VA_ARGS__ ))
 
 struct phoneops {
-	void (*card_pcm_recompute)(xbus_t *xbus, xpd_t *xpd, xpp_line_t pcm_mask);
-	void (*card_pcm_fromspan)(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
-	void (*card_pcm_tospan)(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
-	int (*card_timing_priority)(xbus_t *xbus, xpd_t *xpd);
+	void (*card_pcm_recompute)(xpd_t *xpd, xpp_line_t pcm_mask);
+	void (*card_pcm_fromspan)(xpd_t *xpd, xpacket_t *pack);
+	void (*card_pcm_tospan)(xpd_t *xpd, xpacket_t *pack);
+	int (*card_timing_priority)(xpd_t *xpd);
 	int (*card_dahdi_preregistration)(xpd_t *xpd, bool on);
 	int (*card_dahdi_postregistration)(xpd_t *xpd, bool on);
-	int (*card_hooksig)(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig);
+	int (*card_hooksig)(xpd_t *xpd, int pos, enum dahdi_txsig txsig);
 	int (*card_ioctl)(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg);
 	int (*card_open)(xpd_t *xpd, lineno_t pos);
 	int (*card_close)(xpd_t *xpd, lineno_t pos);
-
-	int (*XPD_STATE)(xbus_t *xbus, xpd_t *xpd, bool on);
+	int (*card_state)(xpd_t *xpd, bool on);
 };
 
 struct xops {




More information about the svn-commits mailing list