From duncan at infradead.org  Wed Oct  4 04:35:36 2006
From: duncan at infradead.org (Duncan Sands)
Date: Wed, 04 Oct 2006 09:35:36 +0100
Subject: speedtch speedtch.c,1.77,1.78
Message-ID: <E1GV2E4-0003Qt-Rt@phoenix.infradead.org>

Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv13143

Modified Files:
	speedtch.c 
Log Message:
Add BMaxDSL, ModemMode and ModemOption parameters, with defaults as in the
windows registry.  Perform extra initialization using them as with windows.
Note: even quite old windows drivers do this extra initialization, not just
the extended reach (er) driver, so probably the better performance with the
er driver comes from the next firmware.  Lightly tested, but seems to work.


Index: speedtch.c
===================================================================
RCS file: /home/cvs/speedtch/speedtch.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- speedtch.c	23 Mar 2006 16:59:55 -0000	1.77
+++ speedtch.c	4 Oct 2006 08:35:33 -0000	1.78
@@ -55,7 +55,6 @@
 #define OFFSET_d	9		/* size 4 */
 #define OFFSET_e	13		/* size 1 */
 #define OFFSET_f	14		/* size 1 */
-#define TOTAL		15
 
 #define SIZE_7		1
 #define SIZE_b		8
@@ -79,6 +78,16 @@
 static int enable_isoc = DEFAULT_ENABLE_ISOC;
 static int sw_buffering = DEFAULT_SW_BUFFERING;
 
+#define DEFAULT_B_MAX_DSL	8128
+#define DEFAULT_MODEM_MODE	11
+
+static unsigned int BMaxDSL = DEFAULT_B_MAX_DSL;
+static unsigned char ModemMode = DEFAULT_MODEM_MODE;
+static unsigned char ModemOption[16] = {
+	0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+static int num_ModemOption;
+
 module_param(altsetting, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(altsetting,
 		"Alternative setting for data interface (bulk_default: "
@@ -100,6 +109,17 @@
 		 "Enable software buffering (default: "
 		 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")");
 
+module_param(BMaxDSL, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(BMaxDSL,
+		"default: " __MODULE_STRING(DEFAULT_B_MAX_DSL));
+
+module_param(ModemMode, byte, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(ModemMode,
+		"default: " __MODULE_STRING(DEFAULT_MODEM_MODE));
+
+module_param_array(ModemOption, byte, &num_ModemOption, S_IRUGO);
+MODULE_PARM_DESC(ModemOption, "default: 0x10,0x00,0x00,0x00,0x20");
+
 #define INTERFACE_DATA		1
 #define ENDPOINT_INT		0x81
 #define ENDPOINT_BULK_DATA	0x07
@@ -108,10 +128,17 @@
 
 #define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
 
+struct speedtch_params {
+	unsigned int altsetting;
+	unsigned int BMaxDSL;
+	unsigned char ModemMode;
+	unsigned char ModemOption[16];
+};
+
 struct speedtch_instance_data {
 	struct usbatm_data *usbatm;
 
-	unsigned int altsetting;
+	struct speedtch_params params; /* set in probe, constant afterwards */
 
 	struct work_struct status_checker;
 
@@ -123,7 +150,7 @@
 	struct urb *int_urb;
 	unsigned char int_data[16];
 
-	unsigned char scratch_buffer[TOTAL];
+	unsigned char scratch_buffer[16];
 };
 
 /***************
@@ -186,6 +213,32 @@
 			      0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT);
 	if (ret < 0)
 		usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret);
+
+	/* Extra initialisation in recent drivers - gives higher speeds */
+
+	/* URBext1 */
+	buf[0] = instance->params.ModemMode;
+	ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
+			      0x01, 0x40, 0x11, 0x00, buf, 1, CTRL_TIMEOUT);
+	if (ret < 0)
+		usb_warn(usbatm, "%s failed on URBext1: %d\n", __func__, ret);
+
+	/* URBext2 */
+	/* This seems to be the one which actually triggers the higher sync 
+	   rate -- it does require the new firmware too, although it works OK
+	   with older firmware */
+	ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
+			      0x01, 0x40, 0x14, 0x00, instance->params.ModemOption, 0x10, CTRL_TIMEOUT);
+	if (ret < 0)
+		usb_warn(usbatm, "%s failed on URBext2: %d\n", __func__, ret);
+
+	/* URBext3 */
+	buf[0] = instance->params.BMaxDSL & 0xff;
+	buf[1] = instance->params.BMaxDSL >> 8;
+	ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
+			      0x01, 0x40, 0x12, 0x00, buf, 2, CTRL_TIMEOUT);
+	if (ret < 0)
+		usb_warn(usbatm, "%s failed on URBext3: %d\n", __func__, ret);
 }
 
 static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
@@ -285,8 +338,8 @@
 	   because we're in our own kernel thread anyway. */
 	msleep_interruptible(1000);
 
-	if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) {
-		usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->altsetting, ret);
+	if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
+		usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->params.altsetting, ret);
 		goto out_free;
 	}
 
@@ -372,7 +425,7 @@
 	unsigned char *buf = instance->scratch_buffer;
 	int ret;
 
-	memset(buf, 0, TOTAL);
+	memset(buf, 0, 16);
 
 	ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
 			      0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7,
@@ -746,17 +799,21 @@
 
 	instance->usbatm = usbatm;
 
-	/* altsetting and enable_isoc may change at any moment, so take a snapshot */
-	instance->altsetting = altsetting;
+	/* module parameters may change at any moment, so take a snapshot */
+	instance->params.altsetting = altsetting;
+	instance->params.BMaxDSL = BMaxDSL;
+	instance->params.ModemMode = ModemMode;
+	memset(instance->params.ModemOption, 0, sizeof(instance->params.ModemOption));
+	memcpy(instance->params.ModemOption, ModemOption, num_ModemOption);
 	use_isoc = enable_isoc;
 
-	if (instance->altsetting)
-		if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) {
-			usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->altsetting, ret);
-			instance->altsetting = 0; /* fall back to default */
+	if (instance->params.altsetting)
+		if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
+			usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetting, ret);
+			instance->params.altsetting = 0; /* fall back to default */
 		}
 
-	if (!instance->altsetting && use_isoc)
+	if (!instance->params.altsetting && use_isoc)
 		if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) {
 			usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret);
 			use_isoc = 0; /* fall back to bulk */
@@ -783,14 +840,14 @@
 			usb_info(usbatm, "isochronous transfer not supported - using bulk\n");
 	}
 
-	if (!use_isoc && !instance->altsetting)
+	if (!use_isoc && !instance->params.altsetting)
 		if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) {
 			usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret);
 			goto fail_free;
 		}
 
-	if (!instance->altsetting)
-		instance->altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
+	if (!instance->params.altsetting)
+		instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
 
 	usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
 



From duncan at infradead.org  Wed Oct  4 16:38:01 2006
From: duncan at infradead.org (Duncan Sands)
Date: Wed, 04 Oct 2006 21:38:01 +0100
Subject: speedtch speedtch.c,1.78,1.79
Message-ID: <E1GVDVB-000406-LF@phoenix.infradead.org>

Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv15365

Modified Files:
	speedtch.c 
Log Message:
If no value is supplied for ModemOption, then num_ModemOption is 0, causing
us to set instance->params->ModemOption to all zeros, wiping out the default
value.  Fix this, and introduce MODEM_OPTION_LENGTH (=16) while there.


Index: speedtch.c
===================================================================
RCS file: /home/cvs/speedtch/speedtch.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- speedtch.c	4 Oct 2006 08:35:33 -0000	1.78
+++ speedtch.c	4 Oct 2006 20:37:58 -0000	1.79
@@ -80,12 +80,14 @@
 
 #define DEFAULT_B_MAX_DSL	8128
 #define DEFAULT_MODEM_MODE	11
+#define MODEM_OPTION_LENGTH	16
+static const unsigned char DEFAULT_MODEM_OPTION[MODEM_OPTION_LENGTH] = {
+	0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
 
 static unsigned int BMaxDSL = DEFAULT_B_MAX_DSL;
 static unsigned char ModemMode = DEFAULT_MODEM_MODE;
-static unsigned char ModemOption[16] = {
-	0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
+static unsigned char ModemOption[MODEM_OPTION_LENGTH];
 static int num_ModemOption;
 
 module_param(altsetting, uint, S_IRUGO | S_IWUSR);
@@ -132,7 +134,7 @@
 	unsigned int altsetting;
 	unsigned int BMaxDSL;
 	unsigned char ModemMode;
-	unsigned char ModemOption[16];
+	unsigned char ModemOption[MODEM_OPTION_LENGTH];
 };
 
 struct speedtch_instance_data {
@@ -228,7 +230,9 @@
 	   rate -- it does require the new firmware too, although it works OK
 	   with older firmware */
 	ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
-			      0x01, 0x40, 0x14, 0x00, instance->params.ModemOption, 0x10, CTRL_TIMEOUT);
+			      0x01, 0x40, 0x14, 0x00,
+			      instance->params.ModemOption,
+			      MODEM_OPTION_LENGTH, CTRL_TIMEOUT);
 	if (ret < 0)
 		usb_warn(usbatm, "%s failed on URBext2: %d\n", __func__, ret);
 
@@ -803,7 +807,7 @@
 	instance->params.altsetting = altsetting;
 	instance->params.BMaxDSL = BMaxDSL;
 	instance->params.ModemMode = ModemMode;
-	memset(instance->params.ModemOption, 0, sizeof(instance->params.ModemOption));
+	memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH);
 	memcpy(instance->params.ModemOption, ModemOption, num_ModemOption);
 	use_isoc = enable_isoc;
 



From duncan at infradead.org  Thu Oct  5 05:01:25 2006
From: duncan at infradead.org (Duncan Sands)
Date: Thu, 05 Oct 2006 10:01:25 +0100
Subject: speedtch cxacru.c,1.44,1.45
Message-ID: <E1GVP6b-0004YB-Ji@phoenix.infradead.org>

Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv17462

Modified Files:
	cxacru.c 
Log Message:
Add the ZTE ZXDSL 852.


Index: cxacru.c
===================================================================
RCS file: /home/cvs/speedtch/cxacru.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- cxacru.c	1 Feb 2006 11:06:01 -0000	1.44
+++ cxacru.c	5 Oct 2006 09:01:22 -0000	1.45
@@ -793,6 +793,9 @@
 	{ /* V = Conexant			P = ADSL modem				*/
 		USB_DEVICE(0x0572, 0xcb06),	.driver_info = (unsigned long) &cxacru_cb00
 	},
+	{ /* V = Conexant			P = ADSL modem (ZTE ZXDSL 852)		*/
+		USB_DEVICE(0x0572, 0xcb07),	.driver_info = (unsigned long) &cxacru_cb00
+	},
 	{ /* V = Olitec				P = ADSL modem version 2		*/
 		USB_DEVICE(0x08e3, 0x0100),	.driver_info = (unsigned long) &cxacru_cafe
 	},



From duncan at infradead.org  Wed Oct 11 03:51:37 2006
From: duncan at infradead.org (Duncan Sands)
Date: Wed, 11 Oct 2006 08:51:37 +0100
Subject: speedtch cxacru.c,1.45,1.46 speedtch.c,1.79,1.80 usbatm.c,1.67,1.68
Message-ID: <E1GXYsK-0005xU-S7@phoenix.infradead.org>

Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv22896

Modified Files:
	cxacru.c speedtch.c usbatm.c 
Log Message:
Remove struct pt_regs argument in completion handlers.  Use current rather
than get_current().


Index: cxacru.c
===================================================================
RCS file: /home/cvs/speedtch/cxacru.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- cxacru.c	5 Oct 2006 09:01:22 -0000	1.45
+++ cxacru.c	11 Oct 2006 07:51:33 -0000	1.46
@@ -171,7 +171,7 @@
 };
 
 /* the following three functions are stolen from drivers/usb/core/message.c */
-static void cxacru_blocking_completion(struct urb *urb, struct pt_regs *regs)
+static void cxacru_blocking_completion(struct urb *urb)
 {
 	complete((struct completion *)urb->context);
 }

Index: speedtch.c
===================================================================
RCS file: /home/cvs/speedtch/speedtch.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- speedtch.c	4 Oct 2006 20:37:58 -0000	1.79
+++ speedtch.c	11 Oct 2006 07:51:34 -0000	1.80
@@ -604,7 +604,7 @@
 	}
 }
 
-static void speedtch_handle_int(struct urb *int_urb, struct pt_regs *regs)
+static void speedtch_handle_int(struct urb *int_urb)
 {
 	struct speedtch_instance_data *instance = int_urb->context;
 	struct usbatm_data *usbatm = instance->usbatm;

Index: usbatm.c
===================================================================
RCS file: /home/cvs/speedtch/usbatm.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- usbatm.c	29 Sep 2006 09:34:34 -0000	1.67
+++ usbatm.c	11 Oct 2006 07:51:34 -0000	1.68
@@ -254,7 +254,7 @@
 	return ret;
 }
 
-static void usbatm_complete(struct urb *urb, struct pt_regs *regs)
+static void usbatm_complete(struct urb *urb)
 {
 	struct usbatm_channel *channel = urb->context;
 	unsigned long flags;
@@ -1001,7 +1001,7 @@
 
 	daemonize(instance->driver->driver_name);
 	allow_signal(SIGTERM);
-	instance->thread_pid = get_current()->pid;
+	instance->thread_pid = current->pid;
 
 	complete(&instance->thread_started);
 



From duncan at infradead.org  Thu Oct 26 08:53:07 2006
From: duncan at infradead.org (Duncan Sands)
Date: Thu, 26 Oct 2006 13:53:07 +0100
Subject: speedtch speedtch.c,1.80,1.81
Message-ID: <E1Gd4jL-0005nk-8f@phoenix.infradead.org>

Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv22290

Modified Files:
	speedtch.c 
Log Message:
Remove trailing space.


Index: speedtch.c
===================================================================
RCS file: /home/cvs/speedtch/speedtch.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- speedtch.c	11 Oct 2006 07:51:34 -0000	1.80
+++ speedtch.c	26 Oct 2006 12:53:03 -0000	1.81
@@ -226,7 +226,7 @@
 		usb_warn(usbatm, "%s failed on URBext1: %d\n", __func__, ret);
 
 	/* URBext2 */
-	/* This seems to be the one which actually triggers the higher sync 
+	/* This seems to be the one which actually triggers the higher sync
 	   rate -- it does require the new firmware too, although it works OK
 	   with older firmware */
 	ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),



From duncan at infradead.org  Thu Oct 26 08:55:34 2006
From: duncan at infradead.org (Duncan Sands)
Date: Thu, 26 Oct 2006 13:55:34 +0100
Subject: speedtch usbatm.c,1.68,1.69
Message-ID: <E1Gd4li-0005oP-D6@phoenix.infradead.org>

Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv22332

Modified Files:
	usbatm.c 
Log Message:
Use BUILD_BUG_ON to fail compilation if the module can't possibly work.


Index: usbatm.c
===================================================================
RCS file: /home/cvs/speedtch/usbatm.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- usbatm.c	11 Oct 2006 07:51:34 -0000	1.68
+++ usbatm.c	26 Oct 2006 12:55:31 -0000	1.69
@@ -1332,10 +1332,7 @@
 {
 	dbg("%s: driver version %s", __func__, DRIVER_VERSION);
 
-	if (sizeof(struct usbatm_control) > sizeof(((struct sk_buff *) 0)->cb)) {
-		printk(KERN_ERR "%s unusable with this kernel!\n", usbatm_driver_name);
-		return -EIO;
-	}
+	BUILD_BUG_ON(sizeof(struct usbatm_control) > sizeof(((struct sk_buff *) 0)->cb));
 
 	if ((num_rcv_urbs > UDSL_MAX_RCV_URBS)
 	    || (num_snd_urbs > UDSL_MAX_SND_URBS)



From duncan at infradead.org  Sun Oct 29 05:26:56 2006
From: duncan at infradead.org (Duncan Sands)
Date: Sun, 29 Oct 2006 10:26:56 +0000
Subject: speedtch cxacru.c,1.46,1.47
Message-ID: <E1Ge7sW-0005DV-Jc@phoenix.infradead.org>

Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv20042

Modified Files:
	cxacru.c 
Log Message:
Fix up some endian problems (or rather: non-problems) pointed out by sparse.


Index: cxacru.c
===================================================================
RCS file: /home/cvs/speedtch/cxacru.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- cxacru.c	11 Oct 2006 07:51:33 -0000	1.46
+++ cxacru.c	29 Oct 2006 10:26:53 -0000	1.47
@@ -297,8 +297,8 @@
 			       u32 *data, int size)
 {
 	int ret, len;
-	u32 *buf;
-	int offb, offd;
+	__le32 *buf;
+	u32 offb, offd;
 	const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
 	int buflen =  ((size - 1) / stride + 1 + size * 2) * 4;
 
@@ -313,7 +313,7 @@
 	/* len > 0 && len % 4 == 0 guaranteed by cxacru_cm() */
 	len = ret / 4;
 	for (offb = 0; offb < len; ) {
-		int l = le32_to_cpu(buf[offb++]);
+		u32 l = le32_to_cpu(buf[offb++]);
 		if (l > stride || l > (len - offb) / 2) {
 			dbg("wrong data length %#x in response", l);
 			ret = -EIO;
@@ -469,7 +469,7 @@
 		buf[offb++] = l;
 		buf[offb++] = code1;
 		buf[offb++] = code2;
-		*((u32 *) (buf + offb)) = cpu_to_le32(addr);
+		*((__le32 *) (buf + offb)) = cpu_to_le32(addr);
 		offb += 4;
 		addr += l;
 		if(l)
@@ -506,8 +506,8 @@
 	int off;
 	struct usbatm_data *usbatm = instance->usbatm;
 	struct usb_device *usb_dev = usbatm->usb_dev;
-	u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };
-	u32 val;
+	__le16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };
+	__le32 val;
 
 	dbg("cxacru_upload_firmware");
 
@@ -587,7 +587,7 @@
 	/* Load config data (le32), doing one packet at a time */
 	if (cf)
 		for (off = 0; off < cf->size / 4; ) {
-			u32 buf[CMD_PACKET_SIZE / 4 - 1];
+			__le32 buf[CMD_PACKET_SIZE / 4 - 1];
 			int i, len = min_t(int, cf->size / 4 - off, CMD_PACKET_SIZE / 4 / 2 - 1);
 			buf[0] = cpu_to_le32(len);
 			for (i = 0; i < len; i++, off++) {



