u-boot-mkimage-gta01-native: re-add till uboot-utils actually works
[openembedded.git] / packages / linux / linux-ezx-2.6.21 / patches / mux-linux-2.6.21-fix.patch
1 Index: linux-2.6.21/drivers/char/ts0710.h
2 ===================================================================
3 --- linux-2.6.21.orig/drivers/char/ts0710.h     2007-04-27 20:35:44.000000000 -0300
4 +++ linux-2.6.21/drivers/char/ts0710.h  2007-04-27 20:36:03.000000000 -0300
5 @@ -45,7 +45,6 @@
6   *  11/18/2002  Modified
7   */
8  
9 -#include <linux/config.h>
10  #include <linux/module.h>
11  
12  #include <linux/errno.h>
13 @@ -58,7 +57,6 @@
14  #include <linux/major.h>
15  #include <linux/mm.h>
16  #include <linux/init.h>
17 -#include <linux/devfs_fs_kernel.h>
18  
19  #include <asm/uaccess.h>
20  #include <asm/system.h>
21 Index: linux-2.6.21/drivers/char/ts0710_mux.c
22 ===================================================================
23 --- linux-2.6.21.orig/drivers/char/ts0710_mux.c 2007-04-27 20:35:44.000000000 -0300
24 +++ linux-2.6.21/drivers/char/ts0710_mux.c      2007-04-27 20:36:03.000000000 -0300
25 @@ -46,7 +46,6 @@
26   *  11/18/2002  Second version
27   *  04/21/2004  Add GPRS PROC
28   */
29 -#include <linux/config.h>
30  #include <linux/module.h>
31  #include <linux/types.h>
32  
33 @@ -70,15 +69,12 @@
34  #include <linux/mm.h>
35  #include <linux/slab.h>
36  #include <linux/init.h>
37 -#include <linux/devfs_fs_kernel.h>
38 -//#include <syslog.h>
39  
40  #include <asm/uaccess.h>
41  #include <asm/system.h>
42  #include <asm/bitops.h>
43  
44  #ifdef USB_FOR_MUX
45 -//#include <linux/usb.h>
46  #include "ts0710_mux_usb.h"
47  #endif
48  
49 @@ -268,8 +264,8 @@
50  static struct work_struct post_recv_tqueue;
51  
52  static struct tty_struct *mux_table[NR_MUXS];
53 -static struct termios *mux_termios[NR_MUXS];
54 -static struct termios *mux_termios_locked[NR_MUXS];
55 +static struct ktermios *mux_termios[NR_MUXS];
56 +static struct ktermios *mux_termios_locked[NR_MUXS];
57  static volatile short int mux_tty[NR_MUXS];
58  
59  #ifdef min
60 @@ -1894,11 +1890,7 @@
61                                 if (test_bit(TTY_THROTTLED, &tty->flags)) {
62                                         queue_data = 1;
63                                 } else {
64 -                                       if (test_bit
65 -                                           (TTY_DONT_FLIP, &tty->flags)) {
66 -                                               queue_data = 1;
67 -                                               post_recv = 1;
68 -                                       } else if (recv_info->total) {
69 +                                       if (recv_info->total) {
70                                                 queue_data = 1;
71                                                 post_recv = 1;
72                                         } else if (recv_room < uih_len) {
73 @@ -3149,10 +3141,10 @@
74  
75  /*For BP UART problem End*/
76  
77 -static void receive_worker(void *private_)
78 +static void receive_worker(struct work_struct *work)
79  {
80         struct tty_struct *tty = COMM_FOR_MUX_TTY;
81 -       int i, count, tbuf_free, tbuf_read;
82 +       int count, tbuf_free, tbuf_read;
83         static unsigned char tbuf[TS0710MUX_MAX_BUF_SIZE];
84         static unsigned char *tbuf_ptr = &tbuf[0];
85         static unsigned char *start_flag = 0;
86 @@ -3168,7 +3160,7 @@
87         __u32 uih_len;
88         /*For BP UART problem End */
89  
90 -       UNUSED_PARAM(private_);
91 +       UNUSED_PARAM(work);
92  
93         if (!tty)
94                 return;
95 @@ -3440,7 +3432,7 @@
96         clear_bit(RECV_RUNNING, &mux_recv_flags);
97  }
98  
99 -static void post_recv_worker(void *private_)
100 +static void post_recv_worker(struct work_struct *work)
101  {
102         ts0710_con *ts0710 = &ts0710_connection;
103         int tty_idx;
104 @@ -3453,7 +3445,7 @@
105         mux_recv_packet *recv_packet, *recv_packet2;
106         __u8 j;
107  
108 -       UNUSED_PARAM(private_);
109 +       UNUSED_PARAM(work);
110  
111         if (test_and_set_bit(RECV_RUNNING, &mux_recv_flags)) {
112                 schedule_work(&post_recv_tqueue);
113 @@ -3499,10 +3491,6 @@
114                 if (test_bit(TTY_THROTTLED, &tty->flags)) {
115                         add_post_recv_queue(&post_recv_q, recv_info);
116                         continue;
117 -               } else if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
118 -                       post_recv = 1;
119 -                       add_post_recv_queue(&post_recv_q, recv_info);
120 -                       continue;
121                 }
122  
123                 flow_control = 0;
124 @@ -3635,7 +3623,7 @@
125         }
126  }
127  
128 -static void send_worker(void *private_)
129 +static void send_worker(struct work_struct *work)
130  {
131         ts0710_con *ts0710 = &ts0710_connection;
132         __u8 j;
133 @@ -3644,7 +3632,7 @@
134         struct tty_struct *tty;
135         __u8 dlci;
136  
137 -       UNUSED_PARAM(private_);
138 +       UNUSED_PARAM(work);
139  
140         TS0710_DEBUG("Enter into send_worker");
141  
142 @@ -3819,7 +3807,8 @@
143         gprsData[TS0710MUX_GPRS_SESSION_MAX - 1].sentBytes =
144             get_count(TS0710MUX_GPRS2_SEND_COUNT_IDX);
145  
146 -       copy_to_user(buf, gprsData, bufLen);
147 +       if(copy_to_user(buf, gprsData, bufLen))
148 +               return -EFAULT;
149  
150         return bufLen;
151  }
152 @@ -3836,7 +3825,8 @@
153  
154         memset(gprsData, 0, bufLen);
155  
156 -       copy_from_user(gprsData, buf, bufLen);
157 +       if(copy_from_user(gprsData, buf, bufLen))
158 +               return -EFAULT;
159  
160         set_count(TS0710MUX_GPRS1_RECV_COUNT_IDX, gprsData[0].recvBytes);
161         set_count(TS0710MUX_GPRS1_SEND_COUNT_IDX, gprsData[0].sentBytes);
162 @@ -3893,9 +3883,9 @@
163         }
164         post_recv_count_flag = 0;
165  
166 -       INIT_WORK(&send_tqueue, send_worker, NULL);
167 -       INIT_WORK(&receive_tqueue, receive_worker, NULL);
168 -       INIT_WORK(&post_recv_tqueue, post_recv_worker, NULL);
169 +       INIT_WORK(&send_tqueue, send_worker);
170 +       INIT_WORK(&receive_tqueue, receive_worker);
171 +       INIT_WORK(&post_recv_tqueue, post_recv_worker);
172  
173         mux_driver = alloc_tty_driver(NR_MUXS);
174         if (!mux_driver)
175 @@ -3904,12 +3894,11 @@
176         mux_driver->owner = THIS_MODULE;
177         mux_driver->driver_name = "ts0710mux";
178         mux_driver->name = "mux";
179 -       mux_driver->devfs_name = "mux";
180         mux_driver->major = TS0710MUX_MAJOR;
181         mux_driver->minor_start = TS0710MUX_MINOR_START;
182         mux_driver->type = TTY_DRIVER_TYPE_SERIAL;
183         mux_driver->subtype = SERIAL_TYPE_NORMAL;
184 -       mux_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW;
185 +       mux_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
186  
187         mux_driver->init_termios = tty_std_termios;
188         mux_driver->init_termios.c_iflag = 0;
189 @@ -3917,10 +3906,10 @@
190         mux_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
191         mux_driver->init_termios.c_lflag = 0;
192  
193 -//     mux_driver.ttys = mux_table;
194 +       //mux_driver.ttys = mux_table;
195         mux_driver->termios = mux_termios;
196         mux_driver->termios_locked = mux_termios_locked;
197 -//  mux_driver.driver_state = mux_state;
198 +       //mux_driver.driver_state = mux_state;
199         mux_driver->other = NULL;
200  
201         mux_driver->open = mux_open;
202 Index: linux-2.6.21/drivers/char/ts0710_mux_usb.c
203 ===================================================================
204 --- linux-2.6.21.orig/drivers/char/ts0710_mux_usb.c     2007-04-27 20:35:44.000000000 -0300
205 +++ linux-2.6.21/drivers/char/ts0710_mux_usb.c  2007-04-27 22:34:31.000000000 -0300
206 @@ -188,7 +188,8 @@
207         buf_list_t *inbuf;
208         int count = urb->actual_length;
209  
210 -       inbuf = kmalloc(sizeof(buf_list_t), GFP_KERNEL);
211 +       // we are called from interrupt context.
212 +       inbuf = kmalloc(sizeof(buf_list_t), GFP_ATOMIC);
213         if (!inbuf) {
214                 printk("append_to_inbuf_list: (%d) out of memory!\n",
215                         sizeof(buf_list_t));
216 @@ -196,7 +197,7 @@
217         }
218  
219         inbuf->size = count;
220 -       inbuf->body = kmalloc(sizeof(char)*count, GFP_KERNEL);
221 +       inbuf->body = kmalloc(sizeof(char)*count, GFP_ATOMIC);
222         if (!inbuf->body) {
223                 kfree(inbuf);
224                 printk("append_to_inbuf_list: (%d) out of memory!\n",
225 @@ -222,7 +223,7 @@
226                 inbuf = list_entry(ptr, buf_list_t, list);
227                 src_count = inbuf->size;
228                 if (dst_count >= src_count) {
229 -                       memcpy(buf, inbuf->body, src_count);
230 +                       memcpy((unsigned char *)buf, inbuf->body, src_count);
231                         ret = src_count;
232                         list_del(ptr);
233                         kfree(inbuf->body);
234 @@ -282,9 +283,8 @@
235         spin_unlock(&bvd_ipc->in_buf_lock);
236  }
237  
238 -static void usb_ipc_read_bulk(struct urb *urb, struct pt_regs *regs)
239 +static void usb_ipc_read_bulk(struct urb *urb)
240  {
241 -       buf_list_t *inbuf;
242         int count = urb->actual_length;
243         struct tty_struct *tty = &ipcusb_tty;
244  
245 @@ -319,7 +319,7 @@
246         bvd_dbg("usb_ipc_read_bulk: completed!!!");
247  }
248  
249 -static void usb_ipc_write_bulk(struct urb *urb, struct pt_regs *regs)
250 +static void usb_ipc_write_bulk(struct urb *urb)
251  {
252         callback_times++;
253         bvd_ipc->write_finished_flag = 1;
254 @@ -437,7 +437,7 @@
255                         /*send IN token*/
256                         bvd_ipc->readurb_mux.actual_length = 0;
257                         bvd_ipc->readurb_mux.dev = bvd_ipc->ipc_dev;
258 -                       if (ret = usb_submit_urb(&bvd_ipc->readurb_mux, GFP_ATOMIC))
259 +                       if ((ret = usb_submit_urb(&bvd_ipc->readurb_mux, GFP_ATOMIC)))
260                                 printk("ipcusb_xmit_data: usb_submit_urb(read mux bulk)"
261                                         "failed! status=%d\n", ret);
262                         bvd_dbg("ipcusb_xmit_data: Send a IN token successfully!");
263 @@ -447,7 +447,7 @@
264                 bvd_ipc->write_finished_flag = 0;
265                 //printk("%s: clear write_finished_flag:%d\n", __FUNCTION__, bvd_ipc->write_finished_flag);
266                 bvd_ipc->writeurb_mux.dev = bvd_ipc->ipc_dev;
267 -               if (result = usb_submit_urb(&bvd_ipc->writeurb_mux, GFP_ATOMIC))
268 +               if ((result = usb_submit_urb(&bvd_ipc->writeurb_mux, GFP_ATOMIC)))
269                         warn("ipcusb_xmit_data: funky result! result=%d\n", result);
270  
271                 bvd_dbg("ipcusb_xmit_data: usb_submit_urb finished! result:%d", result);
272 @@ -498,7 +498,7 @@
273                 return 0;
274  
275         if (*ipcusb_ap_to_bp != NULL)
276 -               (*ipcusb_ap_to_bp)(buf, count);
277 +               (*ipcusb_ap_to_bp)((unsigned char *)buf, count);
278  
279         bvd_ipc->suspend_flag = 1;
280  
281 @@ -602,6 +602,7 @@
282         }
283  
284         ep_cnt = have_bulk_in_mux = have_bulk_out_mux = 0;
285 +       readsize = writesize = 0;
286  
287         while (ep_cnt < interface->bNumEndpoints) {
288                 endpoint = &intf->cur_altsetting->endpoint[ep_cnt].desc;
289 @@ -792,6 +793,8 @@
290         bvd_ipc->ipc_dev = NULL;
291         bvd_ipc->xmit.head = bvd_ipc->xmit.tail = 0;
292         bvd_ipc->write_flag = IPC_USB_WRITE_INIT;
293 +       spin_lock_init(&bvd_ipc->lock);
294 +       spin_lock_init(&bvd_ipc->in_buf_lock);
295  
296         ipcusb_tty_driver.write = usb_ipc_write;
297         ipcusb_tty_driver.chars_in_buffer = usb_ipc_chars_in_buffer;