summaryrefslogtreecommitdiff
path: root/packages/linux/linux-ezx-2.6.21/patches/mux-fix.patch
blob: b820762f41e522be10a52bb762636f121ba7312c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
Index: linux-2.6.20.7/drivers/char/ts0710_mux_usb.c
===================================================================
--- linux-2.6.20.7.orig/drivers/char/ts0710_mux_usb.c	2007-04-21 18:07:45.000000000 +0200
+++ linux-2.6.20.7/drivers/char/ts0710_mux_usb.c	2007-04-21 20:55:13.000000000 +0200
@@ -626,7 +626,6 @@
 	}

 	interface = &intf->cur_altsetting->desc;
-	endpoint = &intf->cur_altsetting->endpoint[0].desc;
 	/* Start checking for two bulk endpoints or ... FIXME: This is a future
 	 * enhancement...*/
 	bvd_dbg("usb_ipc_probe: Number of Endpoints:%d",
@@ -638,30 +637,26 @@

 	ep_cnt = have_bulk_in_mux = have_bulk_out_mux = 0;

-	bvd_dbg("usb_ipc_probe: endpoint[0] is:%x",
-		(&endpoint[0])->bEndpointAddress);
-	bvd_dbg("usb_ipc_probe: endpoint[1] is:%x ",
-		(&endpoint[1])->bEndpointAddress);
-
 	while (ep_cnt < interface->bNumEndpoints) {
-
-		if (!have_bulk_in_mux && IS_EP_BULK_IN(endpoint[ep_cnt])) {
-			bvd_dbg("usb_ipc_probe: bEndpointAddress(IN) is:%x ",
-				(&endpoint[ep_cnt])->bEndpointAddress);
-			have_bulk_in_mux =
-					(&endpoint[ep_cnt])->bEndpointAddress;
-			readsize = (&endpoint[ep_cnt])->wMaxPacketSize;
+		endpoint = &intf->cur_altsetting->endpoint[ep_cnt].desc;
+		bvd_dbg("usb_ipc_probe: endpoint[%i] is: %x", ep_cnt,
+			endpoint->bEndpointAddress);
+
+		if (!have_bulk_in_mux && IS_EP_BULK_IN(*endpoint)) {
+			bvd_dbg("usb_ipc_probe: bEndpointAddress(IN) is: %x ",
+				endpoint->bEndpointAddress);
+			have_bulk_in_mux =  endpoint->bEndpointAddress;
+			readsize = endpoint->wMaxPacketSize;
 			bvd_dbg("usb_ipc_probe: readsize=%d", readsize);
 			ep_cnt++;
 			continue;
 		}

-		if (!have_bulk_out_mux && IS_EP_BULK_OUT(endpoint[ep_cnt])) {
-			bvd_dbg("usb_ipc_probe: bEndpointAddress(OUT) is:%x ",
-				(&endpoint[ep_cnt])->bEndpointAddress);
-			have_bulk_out_mux =
-				(&endpoint[ep_cnt])->bEndpointAddress;
-			writesize = (&endpoint[ep_cnt])->wMaxPacketSize;
+		if (!have_bulk_out_mux && IS_EP_BULK_OUT(*endpoint)) {
+			bvd_dbg("usb_ipc_probe: bEndpointAddress(OUT) is: %x ",
+				endpoint->bEndpointAddress);
+			have_bulk_out_mux = endpoint->bEndpointAddress;
+			writesize = endpoint->wMaxPacketSize;
 			bvd_dbg("usb_ipc_probe: writesize=%d", writesize);
 			ep_cnt++;
 			continue;
@@ -718,21 +713,27 @@
 	bvd_ipc->bh_bp.func = usbipc_bh_bp_func;
 	bvd_ipc->bh_bp.data = (unsigned long) bvd_ipc;

+	bvd_dbg("after assignements");
 	/*Build a write urb*/
+	usb_init_urb(&bvd_ipc->writeurb_mux);
 	usb_fill_bulk_urb(&bvd_ipc->writeurb_mux, usbdev,
 			  usb_sndbulkpipe(bvd_ipc->ipc_dev,
 			  		  bvd_ipc->bulk_out_ep_mux),
 			  bvd_ipc->obuf, writesize, usb_ipc_write_bulk,
 			  bvd_ipc);
 	//bvd_ipc->writeurb_mux.transfer_flags |= USB_ASYNC_UNLINK;
+	bvd_dbg("after write urb");

 	/*Build a read urb and send a IN token first time*/
+	usb_init_urb(&bvd_ipc->readurb_mux);
 	usb_fill_bulk_urb(&bvd_ipc->readurb_mux, usbdev,
 			  usb_rcvbulkpipe(usbdev, bvd_ipc->bulk_in_ep_mux),
 			  bvd_ipc->ibuf, readsize, usb_ipc_read_bulk, bvd_ipc);
 	//bvd_ipc->readurb_mux.transfer_flags |= USB_ASYNC_UNLINK;
+	bvd_dbg("after read urb");

-	usb_driver_claim_interface(&usb_ipc_driver, intf, bvd_ipc);
+	//usb_driver_claim_interface(&usb_ipc_driver, intf, bvd_ipc);
+	bvd_dbg("after claim interface");
 	//usb_driver_claim_interface(&usb_ipc_driver, &ipccfg->interface[1], bvd_ipc);

         // a2590c: dsplog is not supported by this driver
@@ -740,6 +741,8 @@
 	//				   &ipccfg->interface[2], bvd_ipc);
 	/*send a IN token first time*/
 	bvd_ipc->readurb_mux.dev = bvd_ipc->ipc_dev;
+	bvd_dbg("after assignement");
+
 	if (usb_submit_urb(&bvd_ipc->readurb_mux, GFP_ATOMIC))
 		printk("usb_ipc_prob: usb_submit_urb(read mux bulk) failed!\n");

@@ -750,7 +753,7 @@
 		tasklet_schedule(&bvd_ipc->bh);
 	}

-	printk("usb_ipc_probe: completed probe!");
+	printk("usb_ipc_probe: completed probe!\n");
 	usb_set_intfdata(intf, &bvd_ipc);
 	return 0;
 }
@@ -760,21 +763,23 @@
 	//struct usb_device *usbdev = interface_to_usbdev(intf);
 	struct ipc_usb_data *bvd_ipc_disconnect = usb_get_intfdata(intf);

-	printk("usb_ipc_disconnect:*** \n");

+	printk("usb_ipc_disconnect. bvd_ipc_disconnect address: %p\n", bvd_ipc_disconnect);
+
+	//FIXME: Memory leak?
 	if ((UHCRHPS3 & 0x4) == 0)
-		usb_unlink_urb(&bvd_ipc_disconnect->readurb_mux);
+	//	usb_unlink_urb(&bvd_ipc_disconnect->readurb_mux);

-	usb_unlink_urb(&bvd_ipc_disconnect->writeurb_mux);
+	//usb_unlink_urb(&bvd_ipc_disconnect->writeurb_mux);

 	bvd_ipc_disconnect->ipc_flag = IPC_USB_PROBE_NOT_READY;
 	kfree(bvd_ipc_disconnect->ibuf);
 	kfree(bvd_ipc_disconnect->obuf);

-	usb_driver_release_interface(&usb_ipc_driver,
-			bvd_ipc_disconnect->ipc_dev->actconfig->interface[0]);
-        usb_driver_release_interface(&usb_ipc_driver,
-			bvd_ipc_disconnect->ipc_dev->actconfig->interface[1]);
+	//usb_driver_release_interface(&usb_ipc_driver,
+	//		bvd_ipc_disconnect->ipc_dev->actconfig->interface[0]);
+        //usb_driver_release_interface(&usb_ipc_driver,
+	//		bvd_ipc_disconnect->ipc_dev->actconfig->interface[1]);

 	//a2590c: dsplog interface is not supported by this driver
 	//usb_driver_release_interface(&usb_ipc_driver, &bvd_ipc_disconnect->ipc_dev->actconfig->interface[2]);
@@ -803,13 +808,6 @@
 	int result;

 	bvd_dbg("init usb_ipc");
-	/* register driver at the USB subsystem */
-	result = usb_register(&usb_ipc_driver);
-	if (result < 0) {
-		err ("usb ipc driver could not be registered");
-		return result;
-	}
-
 	/*init the related mux interface*/
 	if (!(bvd_ipc = kzalloc(sizeof(struct ipc_usb_data), GFP_KERNEL))) {
 		err("usb_ipc_init: Out of memory.");
@@ -836,6 +834,14 @@
 	usb_for_mux_driver = &ipcusb_tty_driver;
 	usb_for_mux_tty = &ipcusb_tty;

+	/* register driver at the USB subsystem */
+	// this was called before bvd_ipc was allocated
+	result = usb_register(&usb_ipc_driver);
+	if (result < 0) {
+		err ("usb ipc driver could not be registered");
+		return result;
+	}
+
 	/* init timers for ipcusb read process and usb suspend */
 	init_timer(&ipcusb_timer);
 	ipcusb_timer.function = ipcusb_timeout;