speedtch cxacru.c, 1.37, 1.38 speedtch.c, 1.70, 1.71 testatm.c, 1.7, 1.8 usbatm.c, 1.56, 1.57 usbatm.h, 1.26, 1.27 xusbatm.c, 1.18, 1.19

Duncan Sands duncan at infradead.org
Sun Nov 20 08:30:02 EST 2005


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

Modified Files:
	cxacru.c speedtch.c testatm.c usbatm.c usbatm.h xusbatm.c 
Log Message:
Unify flags and need_heavy_init (suggested by Matthieu Castet).
Put flags in struct usbatm_data.


Index: cxacru.c
===================================================================
RCS file: /home/cvs/speedtch/cxacru.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- cxacru.c	18 Nov 2005 10:35:04 -0000	1.37
+++ cxacru.c	20 Nov 2005 13:29:59 -0000	1.38
@@ -666,8 +666,7 @@
 }
 
 static int cxacru_bind(struct usbatm_data *usbatm_instance,
-		       struct usb_interface *intf, const struct usb_device_id *id,
-		       int *need_heavy_init, int *flags)
+		       struct usb_interface *intf, const struct usb_device_id *id)
 {
 	struct cxacru_data *instance;
 	struct usb_device *usb_dev = interface_to_usbdev(intf);
@@ -724,7 +723,7 @@
 
 	usbatm_instance->driver_data = instance;
 
-	*need_heavy_init = cxacru_card_status(instance);
+	usbatm_instance->flags = cxacru_card_status(instance) ? 0 : USBATM_SKIP_HEAVY_INIT;
 
 	return 0;
 

Index: speedtch.c
===================================================================
RCS file: /home/cvs/speedtch/speedtch.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- speedtch.c	18 Nov 2005 17:56:22 -0000	1.70
+++ speedtch.c	20 Nov 2005 13:29:59 -0000	1.71
@@ -697,8 +697,7 @@
 
 static int speedtch_bind(struct usbatm_data *usbatm,
 			 struct usb_interface *intf,
-			 const struct usb_device_id *id,
-			 int *need_heavy_init, int *flags)
+			 const struct usb_device_id *id)
 {
 	struct usb_device *usb_dev = interface_to_usbdev(intf);
 	struct usb_interface *cur_intf, *data_intf;
@@ -794,7 +793,7 @@
 	if (!instance->altsetting)
 		instance->altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
 
-	*flags = use_isoc ? USBATM_USE_ISOC : 0;
+	usbatm->flags |= use_isoc ? USBATM_USE_ISOC : 0;
 
 	INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance);
 
@@ -822,11 +821,11 @@
 			      0x12, 0xc0, 0x07, 0x00,
 			      instance->scratch_buffer + OFFSET_7, SIZE_7, 500);
 
-	*need_heavy_init = (ret != SIZE_7);
+	usbatm->flags |= ret == SIZE_7 ? USBATM_SKIP_HEAVY_INIT : 0;
 
-	usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already");
+	usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, usbatm->flags & USBATM_SKIP_HEAVY_INIT ? "already" : "not");
 
-	if (*need_heavy_init)
+	if (!(usbatm->flags & USBATM_SKIP_HEAVY_INIT))
 		if ((ret = usb_reset_device(usb_dev)) < 0) {
 			usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret);
 			goto fail_free;

Index: testatm.c
===================================================================
RCS file: /home/cvs/speedtch/testatm.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- testatm.c	9 Sep 2005 12:49:12 -0000	1.7
+++ testatm.c	20 Nov 2005 13:29:59 -0000	1.8
@@ -31,21 +31,21 @@
 uint	idProduct;
 module_param(idProduct, uint, 0444);
 
-static int accept_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id, int *need_heavy_init)
+static int accept_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id)
 {
 	dbg("accept_bind");
 
 	return 0;
 }
 
-static int refuse_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id, int *need_heavy_init)
+static int refuse_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id)
 {
 	dbg("refuse_bind");
 
 	return -1;
 }
 
-static int claim_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id, int *need_heavy_init);
+static int claim_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id);
 
 void testatm_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
 {
@@ -227,7 +227,7 @@
 		}
 }
 
-static int claim_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id, int *need_heavy_init)
+static int claim_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id)
 {
 	struct usb_device *usb_dev = interface_to_usbdev(intf);
 	struct usb_interface *cur_intf;

Index: usbatm.c
===================================================================
RCS file: /home/cvs/speedtch/usbatm.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- usbatm.c	18 Nov 2005 17:59:50 -0000	1.56
+++ usbatm.c	20 Nov 2005 13:29:59 -0000	1.57
@@ -1053,7 +1053,6 @@
 	char *buf;
 	int error = -ENOMEM;
 	int i, length;
-	int need_heavy, flags;
 
 	dev_dbg(dev, "%s: trying driver %s with vendor=%04x, product=%04x, ifnum %2d\n",
 			__func__, driver->driver_name,
@@ -1098,9 +1097,7 @@
 	snprintf(buf, length, ")");
 
  bind:
-	need_heavy = 1;
-	flags = 0;
-	if (driver->bind && (error = driver->bind(instance, intf, id, &need_heavy, &flags)) < 0) {
+	if (driver->bind && (error = driver->bind(instance, intf, id)) < 0) {
 			dev_err(dev, "%s: bind failed: %d!\n", __func__, error);
 			goto fail_free;
 	}
@@ -1127,7 +1124,7 @@
 	instance->tx_channel.buf_size = snd_buf_size;
 	instance->rx_channel.usbatm = instance->tx_channel.usbatm = instance;
 
-	if ((flags & USBATM_USE_ISOC) && driver->isoc_in)
+	if ((instance->flags & USBATM_USE_ISOC) && driver->isoc_in)
 		instance->rx_channel.endpoint = usb_rcvisocpipe(usb_dev, driver->isoc_in);
 	else
 		instance->rx_channel.endpoint = usb_rcvbulkpipe(usb_dev, driver->bulk_in);
@@ -1216,7 +1213,7 @@
 		goto fail_unbind;
 	}
 
-	if (need_heavy && driver->heavy_init) {
+	if (!(instance->flags & USBATM_SKIP_HEAVY_INIT) && driver->heavy_init) {
 		error = usbatm_heavy_init(instance);
 	} else {
 		complete(&instance->thread_exited);	/* pretend that heavy_init was run */

Index: usbatm.h
===================================================================
RCS file: /home/cvs/speedtch/usbatm.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- usbatm.h	18 Nov 2005 10:35:04 -0000	1.26
+++ usbatm.h	20 Nov 2005 13:29:59 -0000	1.27
@@ -90,9 +90,10 @@
 #endif
 
 
-/* bind flags */
+/* flags, set by mini-driver in bind() */
 
-#define USBATM_USE_ISOC		(1<<0)
+#define USBATM_SKIP_HEAVY_INIT	(1<<0)
+#define USBATM_USE_ISOC		(1<<1)
 
 
 /* mini driver */
@@ -110,12 +111,9 @@
 
 	const char *driver_name;
 
-	/*
-	*  init device ... can sleep, or cause probe() failure.  Drivers with a heavy_init
-	*  method can avoid having it called by setting need_heavy_init to zero.
-	*/
+	/* init device ... can sleep, or cause probe() failure */
         int (*bind) (struct usbatm_data *, struct usb_interface *,
-		     const struct usb_device_id *id, int *need_heavy_init, int *flags);
+		     const struct usb_device_id *id);
 
 	/* additional device initialization that is too slow to be done in probe() */
         int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
@@ -165,6 +163,7 @@
 	struct usbatm_driver *driver;
 	void *driver_data;
 	char driver_name[16];
+	unsigned int flags; /* set by mini-driver in bind() */
 
 	/* USB device */
 	struct usb_device *usb_dev;

Index: xusbatm.c
===================================================================
RCS file: /home/cvs/speedtch/xusbatm.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- xusbatm.c	18 Nov 2005 17:46:48 -0000	1.18
+++ xusbatm.c	20 Nov 2005 13:29:59 -0000	1.19
@@ -90,8 +90,7 @@
 }
 
 static int xusbatm_bind(struct usbatm_data *usbatm,
-			struct usb_interface *intf, const struct usb_device_id *id,
-			int *need_heavy_init, int *flags)
+			struct usb_interface *intf, const struct usb_device_id *id)
 {
 	struct usb_device *usb_dev = interface_to_usbdev(intf);
 	int drv_ix = id - xusbatm_usb_ids;




More information about the Usbatm-commits mailing list