55 |
/* Function prototypes */ |
/* Function prototypes */ |
56 |
static int nokia_startup(struct usb_serial *serial); |
static int nokia_startup(struct usb_serial *serial); |
57 |
static void nokia_shutdown(struct usb_serial *serial); |
static void nokia_shutdown(struct usb_serial *serial); |
58 |
void generic_read_bulk_callback(struct urb *urb); |
static void generic_read_bulk_callback(struct urb *urb); |
59 |
void generic_write_bulk_callback(struct urb *urb); |
static void generic_write_bulk_callback(struct urb *urb); |
60 |
|
|
61 |
static struct usb_device_id id_table [] = { |
static struct usb_device_id id_table [] = { |
62 |
{ USB_DEVICE(NOKIA_VENDOR_ID, NOKIA7600_PRODUCT_ID) }, |
{ USB_DEVICE(NOKIA_VENDOR_ID, NOKIA7600_PRODUCT_ID) }, |
140 |
return 0; |
return 0; |
141 |
} |
} |
142 |
|
|
143 |
|
static void generic_read_bulk_callback (struct urb *urb) |
144 |
|
{ |
145 |
|
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
146 |
|
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); |
147 |
|
struct tty_struct *tty; |
148 |
|
unsigned char *data = urb->transfer_buffer; |
149 |
|
int i; |
150 |
|
int result; |
151 |
|
|
152 |
|
dbg("%s - port %d", __FUNCTION__, port->number); |
153 |
|
|
154 |
|
if (!serial) { |
155 |
|
dbg("%s - bad serial pointer, exiting", __FUNCTION__); |
156 |
|
return; |
157 |
|
} |
158 |
|
|
159 |
|
if (urb->status) { |
160 |
|
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); |
161 |
|
return; |
162 |
|
} |
163 |
|
|
164 |
|
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data); |
165 |
|
|
166 |
|
tty = port->tty; |
167 |
|
if (tty && urb->actual_length) { |
168 |
|
for (i = 0; i < urb->actual_length ; ++i) { |
169 |
|
/* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */ |
170 |
|
if(tty->flip.count >= TTY_FLIPBUF_SIZE) { |
171 |
|
tty_flip_buffer_push(tty); |
172 |
|
} |
173 |
|
/* this doesn't actually push the data through unless tty->low_latency is set */ |
174 |
|
tty_insert_flip_char(tty, data[i], 0); |
175 |
|
} |
176 |
|
tty_flip_buffer_push(tty); |
177 |
|
} |
178 |
|
|
179 |
|
/* Continue trying to always read */ |
180 |
|
usb_fill_bulk_urb (port->read_urb, serial->dev, |
181 |
|
usb_rcvbulkpipe (serial->dev, |
182 |
|
port->bulk_in_endpointAddress), |
183 |
|
port->read_urb->transfer_buffer, |
184 |
|
port->read_urb->transfer_buffer_length, |
185 |
|
((serial->type->read_bulk_callback) ? |
186 |
|
serial->type->read_bulk_callback : |
187 |
|
generic_read_bulk_callback), port); |
188 |
|
result = usb_submit_urb(port->read_urb); |
189 |
|
if (result) |
190 |
|
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); |
191 |
|
} |
192 |
|
|
193 |
|
static void generic_write_bulk_callback (struct urb *urb) |
194 |
|
{ |
195 |
|
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
196 |
|
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); |
197 |
|
|
198 |
|
dbg("%s - port %d", __FUNCTION__, port->number); |
199 |
|
|
200 |
|
port->write_busy = 0; |
201 |
|
wmb(); |
202 |
|
|
203 |
|
if (!serial) { |
204 |
|
err("%s - null serial pointer, exiting", __FUNCTION__); |
205 |
|
return; |
206 |
|
} |
207 |
|
|
208 |
|
if (urb->status) { |
209 |
|
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); |
210 |
|
} |
211 |
|
|
212 |
|
queue_task(&port->tqueue, &tq_immediate); |
213 |
|
mark_bh(IMMEDIATE_BH); |
214 |
|
|
215 |
|
return; |
216 |
|
} |
217 |
|
|
218 |
static void nokia_shutdown(struct usb_serial *serial) |
static void nokia_shutdown(struct usb_serial *serial) |
219 |
{ |
{ |
220 |
int i; |
int i; |