speedtch usbatm.h,1.2,1.3 usbatm2.c,1.10,1.11 speedtch2.c,1.7,1.8

Duncan Sands duncan at infradead.org
Tue Jan 25 03:18:12 EST 2005


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

Modified Files:
	usbatm.h usbatm2.c speedtch2.c 
Log Message:
Add a parameter (need_heavy_init) to bind, usefull for skipping the call to
heavy_init if the firmware is already loaded.  Add some forgotten module stuff
to speedtch.


Index: usbatm.h
===================================================================
RCS file: /home/cvs/speedtch/usbatm.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- usbatm.h	24 Jan 2005 10:47:08 -0000	1.2
+++ usbatm.h	25 Jan 2005 08:18:09 -0000	1.3
@@ -65,8 +65,11 @@
 	const char *driver_name;
 	const struct usb_device_id *id_table;
 
-	/* init device ... can sleep, or cause probe() failure */
-        int (*bind) (struct usbatm_data *, struct usb_interface *);
+	/*
+	*  init device ... can sleep, or cause probe() failure.  Drivers with a heavy_init
+	*  method can avoid the call to heavy_init by setting need_heavy_init to zero.
+	*/
+        int (*bind) (struct usbatm_data *, struct usb_interface *, int *need_heavy_init);
 
 	/* additional device initialization that is too slow to be done in probe() */
         int (*heavy_init) (struct usbatm_data *, struct usb_interface *);

Index: usbatm2.c
===================================================================
RCS file: /home/cvs/speedtch/usbatm2.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- usbatm2.c	24 Jan 2005 14:41:31 -0000	1.10
+++ usbatm2.c	25 Jan 2005 08:18:09 -0000	1.11
@@ -1055,6 +1055,7 @@
 	int error = -ENOMEM;
 	int ifnum = intf->altsetting->desc.bInterfaceNumber;
 	int i, length;
+	int need_heavy;
 
 	dev_dbg(&intf->dev, "trying device with vendor=0x%x, product=0x%x, ifnum %d\n", dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum);
 
@@ -1181,12 +1182,13 @@
 	snprintf(buf, length, ")");
 
  bind:
-	if (driver->bind && (error = driver->bind(instance, intf)) < 0)
+	need_heavy = 1;
+	if (driver->bind && (error = driver->bind(instance, intf, &need_heavy)) < 0)
 			goto fail;
 
 	instance->bound = 1;
 
-	if (driver->heavy_init)
+	if (need_heavy && driver->heavy_init)
 		error = usbatm_heavy_init(instance);
 	else
 		error = usbatm_atm_init(instance);

Index: speedtch2.c
===================================================================
RCS file: /home/cvs/speedtch/speedtch2.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- speedtch2.c	24 Jan 2005 09:44:42 -0000	1.7
+++ speedtch2.c	25 Jan 2005 08:18:09 -0000	1.8
@@ -491,7 +491,6 @@
 	int actual_length;
 	int ret;
 	int offset;
-	char buf7[SIZE_7];
 
 	dbg("speedtch_upload_firmware");
 
@@ -513,16 +512,6 @@
 		goto out_free;
 	}
 
-	/* First check whether the modem already seems to be alive */
-	ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
-			      0x12, 0xc0, 0x07, 0x00, buf7, SIZE_7, HZ / 2);
-
-	if (ret == SIZE_7) {
-		dbg("firmware appears to be already loaded");
-		ret = 0;
-		goto out_free;
-	}
-
 	/* URB 7 */
 	if (dl_512_first) {	/* some modems need a read before writing the firmware */
 		ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, SPEEDTCH_ENDPOINT_FIRMWARE),
@@ -686,12 +675,13 @@
 **  USB  **
 **********/
 
-int speedtch_bind(struct usbatm_data *usbatm, struct usb_interface *intf)
+int speedtch_bind(struct usbatm_data *usbatm, struct usb_interface *intf, int *need_heavy_init)
 {
 	struct usb_device *dev = interface_to_usbdev(intf);
 	int ifnum = intf->altsetting->desc.bInterfaceNumber;
 	struct speedtch_instance_data *instance;
 	int ret;
+	char buf7[SIZE_7];
 
 	if (ifnum != 1)
 		return -ENODEV;
@@ -716,6 +706,14 @@
 	instance->usbatm = usbatm;
 	usbatm->driver_data = instance;
 
+	/* First check whether the modem already seems to be alive */
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x12, 0xc0, 0x07, 0x00, buf7, SIZE_7, HZ / 2);
+
+	if (ret == SIZE_7) {
+		dbg("firmware appears to be already loaded");
+		*need_heavy_init = 0;
+	}
+
 	return 0;
 
  fail:
@@ -724,6 +722,11 @@
 	return -ENOMEM;
 }
 
+void speedtch_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
+{
+	kfree(usbatm->driver_data); //QQ need to reference count?
+}
+
 
 /*********
 *  init  *
@@ -742,8 +745,8 @@
 MODULE_DEVICE_TABLE (usb, speedtch_products);
 
 static struct usbatm_driver speedtch_driver = {
-	.driver_name	= speedtch_driver_name,
 	.owner		= THIS_MODULE,
+	.driver_name	= speedtch_driver_name,
 	.id_table	= speedtch_products,
 
 	.bind		= speedtch_bind,
@@ -759,12 +762,21 @@
 
 static int __init speedtch_init(void)
 {
+	dbg("speedtch_init: driver version " DRIVER_VERSION);
+
 	return usbatm_register(&speedtch_driver);
 }
 module_init(speedtch_init);
 
 static void __exit speedtch_exit(void)
 {
+	dbg("speedtch_exit entered");
+
 	usbatm_deregister (&speedtch_driver);
 }
 module_exit(speedtch_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRIVER_VERSION);




More information about the Usbatm-commits mailing list