[svn-commits] tzafrir: branch linux/2.5 r10393 - /linux/branches/2.5/drivers/dahdi/xpp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jan 3 08:42:51 CST 2012


Author: tzafrir
Date: Tue Jan  3 08:42:47 2012
New Revision: 10393

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10393
Log:
xpp: BRI: split multibyte functionality

* The zero lenth case (Magic request) was split into
  send_magic_request() function. It was not possible
  to move it into card_bri.c, because it is called
  directly from the general interface we provide for
  register read/write via sysfs/proc.

* The normal case (send_multibyte_request) was moved from
  card_global.c into card_bri.c

* This sets the stage to enable bundling of multibyte
  packets into frames (like we do for PCM).

Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-By: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

Modified:
    linux/branches/2.5/drivers/dahdi/xpp/card_bri.c
    linux/branches/2.5/drivers/dahdi/xpp/card_global.c

Modified: linux/branches/2.5/drivers/dahdi/xpp/card_bri.c
URL: http://svnview.digium.com/svn/dahdi/linux/branches/2.5/drivers/dahdi/xpp/card_bri.c?view=diff&rev=10393&r1=10392&r2=10393
==============================================================================
--- linux/branches/2.5/drivers/dahdi/xpp/card_bri.c (original)
+++ linux/branches/2.5/drivers/dahdi/xpp/card_bri.c Tue Jan  3 08:42:47 2012
@@ -512,6 +512,41 @@
 	if (dchan == chan) {
 		atomic_inc(&priv->hdlc_pending);
 	}
+}
+
+int send_multibyte_request(xbus_t *xbus,
+	unsigned unit, xportno_t portno,
+	bool eoftx, byte *buf, unsigned len)
+{
+	xframe_t	*xframe;
+	xpacket_t	*pack;
+	reg_cmd_t	*reg_cmd;
+	int		ret;
+
+	if (!len) {
+		PORT_ERR(xbus, unit, portno,
+			"%s: zero length request. dropping.\n", __func__);
+		return -EINVAL;
+	}
+	if (len > MULTIBYTE_MAX_LEN) {
+		PORT_ERR(xbus, unit, portno,
+			"%s: len=%d is too long. dropping.\n", __func__, len);
+		return -EINVAL;
+	}
+	XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST, unit);
+	reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd);
+	reg_cmd->bytes = len;
+	reg_cmd->is_multibyte = 1;
+	reg_cmd->portnum = portno;
+	reg_cmd->eoframe = eoftx;
+	memcpy(REG_XDATA(reg_cmd), (byte *)buf, len);
+	if (debug & DBG_REGS)
+		dump_xframe(__func__, xbus, xframe, debug);
+	ret = send_cmd_frame(xbus, xframe);
+	if (ret < 0)
+		PORT_ERR(xbus, unit, portno,
+			"%s: failed sending xframe\n", __func__);
+	return ret;
 }
 
 static int tx_dchan(xpd_t *xpd)

Modified: linux/branches/2.5/drivers/dahdi/xpp/card_global.c
URL: http://svnview.digium.com/svn/dahdi/linux/branches/2.5/drivers/dahdi/xpp/card_global.c?view=diff&rev=10393&r1=10392&r2=10393
==============================================================================
--- linux/branches/2.5/drivers/dahdi/xpp/card_global.c (original)
+++ linux/branches/2.5/drivers/dahdi/xpp/card_global.c Tue Jan  3 08:42:47 2012
@@ -39,6 +39,36 @@
 extern	int debug;
 
 /*---------------- GLOBAL PROC handling -----------------------------------*/
+
+static int send_magic_request(xbus_t *xbus,
+	unsigned unit, xportno_t portno, bool eoftx)
+{
+	xframe_t	*xframe;
+	xpacket_t	*pack;
+	reg_cmd_t	*reg_cmd;
+	int		ret;
+
+	/*
+	 * Zero length multibyte is legal and has special meaning for the
+	 * firmware:
+	 *   eoftx==1: Start sending us D-channel packets.
+	 *   eoftx==0: Stop sending us D-channel packets.
+	 */
+	XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST, unit);
+	reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd);
+	reg_cmd->bytes = 0;
+	reg_cmd->is_multibyte = 1;
+	reg_cmd->portnum = portno;
+	reg_cmd->eoframe = eoftx;
+	PORT_DBG(REGS, xbus, unit, portno, "Magic Packet (eoftx=%d)\n", eoftx);
+	if (debug & DBG_REGS)
+		dump_xframe(__func__, xbus, xframe, debug);
+	ret = send_cmd_frame(xbus, xframe);
+	if (ret < 0)
+		PORT_ERR(xbus, unit, portno,
+			"%s: failed sending xframe\n", __func__);
+	return ret;
+}
 
 static int parse_hexbyte(const char *buf)
 {
@@ -155,8 +185,8 @@
 					addr_mode, argc - argno);
 			goto out;
 		}
-		ret = send_multibyte_request(xpd->xbus, xpd->addr.unit, portno,
-			addr_mode == 'm', NULL, 0);
+		ret = send_magic_request(xpd->xbus, xpd->addr.unit, portno,
+			addr_mode == 'm');
 		goto out;
 	}
 	/* Normal (non-Magic) register commands */
@@ -367,44 +397,6 @@
 			xframe->usec_towait = 1000;
 	}
 	ret = send_cmd_frame(xbus, xframe);
-	return ret;
-}
-
-int send_multibyte_request(xbus_t *xbus,
-	unsigned unit, xportno_t portno,
-	bool eoftx, byte *buf, unsigned len)
-{
-	xframe_t	*xframe;
-	xpacket_t	*pack;
-	reg_cmd_t	*reg_cmd;
-	int		ret;
-
-	/*
-	 * Zero length multibyte is legal and has special meaning for the
-	 * firmware:
-	 *   eoftx==1: Start sending us D-channel packets.
-	 *   eoftx==0: Stop sending us D-channel packets.
-	 */
-	if(len > MULTIBYTE_MAX_LEN) {
-		PORT_ERR(xbus, unit, portno, "%s: len=%d is too long. dropping.\n", __FUNCTION__, len);
-		return -EINVAL;
-	}
-	XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST, unit);
-	reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd);
-	reg_cmd->bytes = len;
-	reg_cmd->is_multibyte = 1;
-	reg_cmd->portnum = portno;
-	reg_cmd->eoframe = eoftx;
-	if(len > 0) {
-		memcpy(REG_XDATA(reg_cmd), (byte *)buf, len);
-	} else {
-		PORT_DBG(REGS, xbus, unit, portno, "Magic Packet (eoftx=%d)\n", eoftx);
-	}
-	if(debug & DBG_REGS)
-		dump_xframe(__FUNCTION__, xbus, xframe, debug);
-	ret = send_cmd_frame(xbus, xframe);
-	if(ret < 0)
-		PORT_ERR(xbus, unit, portno, "%s: failed sending xframe\n", __FUNCTION__);
 	return ret;
 }
 
@@ -752,4 +744,3 @@
 EXPORT_SYMBOL(sync_mode_name);
 EXPORT_SYMBOL(run_initialize_registers);
 EXPORT_SYMBOL(xpp_register_request);
-EXPORT_SYMBOL(send_multibyte_request);




More information about the svn-commits mailing list