[svn-commits] tzafrir: linux/trunk r9710 - /linux/trunk/drivers/dahdi/xpp/xproto.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jan 30 12:12:06 CST 2011


Author: tzafrir
Date: Sun Jan 30 12:12:02 2011
New Revision: 9710

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9710
Log:
xpp: Add fixed runtime checks for the PHONEDEV code

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/xproto.c

Modified: linux/trunk/drivers/dahdi/xpp/xproto.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xproto.c?view=diff&rev=9710&r1=9709&r2=9710
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xproto.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xproto.c Sun Jan 30 12:12:02 2011
@@ -420,11 +420,18 @@
 			return -EINVAL;	\
 		}
 
+#define	CHECK_PHONEOP(phoneops, f)	\
+		if(!(phoneops)->f) { \
+			ERR("%s: missing phone method %s [%s (%d)]\n", __FUNCTION__, #f, name, type);	\
+			return -EINVAL;	\
+		}
+
 int xproto_register(const xproto_table_t *proto_table)
 {
 	int			type;
 	const char		*name;
 	const struct xops	*xops;
+	const struct phoneops	*phoneops;
 	
 	BUG_ON(!proto_table);
 	type = proto_table->type;
@@ -441,17 +448,18 @@
 	CHECK_XOP(xops, card_init);
 	CHECK_XOP(xops, card_remove);
 	CHECK_XOP(xops, card_tick);
-#if 0
-	/* FIXME: check PHONE_METHOD() */
-	CHECK_XOP(card_pcm_recompute);
-	CHECK_XOP(card_pcm_fromspan);
-	CHECK_XOP(card_pcm_tospan);
-	CHECK_XOP(card_dahdi_preregistration);
-	CHECK_XOP(card_dahdi_postregistration);
-	// CHECK_XOP(card_ioctl);	// optional method -- call after testing
-	CHECK_XOP(card_register_reply);
-	CHECK_XOP(XPD_STATE);
-#endif
+	CHECK_XOP(xops, card_register_reply);
+
+	phoneops = proto_table->phoneops;
+	if (phoneops) {
+		CHECK_PHONEOP(phoneops, card_pcm_recompute);
+		CHECK_PHONEOP(phoneops, card_pcm_fromspan);
+		CHECK_PHONEOP(phoneops, card_pcm_tospan);
+		CHECK_PHONEOP(phoneops, card_dahdi_preregistration);
+		CHECK_PHONEOP(phoneops, card_dahdi_postregistration);
+		/* optional method -- call after testing: */
+		/*CHECK_PHONEOP(phoneops, card_ioctl);*/
+	}
 
 	xprotocol_tables[type] = proto_table;
 	return 0;




More information about the svn-commits mailing list