diff options
author | Jiri Slaby <xslaby@fi.muni.cz> | 2006-01-09 23:54:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-10 11:02:00 -0500 |
commit | d8d16e47442a84d7fefc7ff839952ddfc919e495 (patch) | |
tree | 7ca3154f0dfce5f90cf85c32c1b4ed0e3d51849b /drivers/char | |
parent | d9e39538ce7c52e45e653e777d73ed373189c20d (diff) |
[PATCH] char/isicom: Whitespace cleanup
Trailing spaces and tabs and space used for indentation deleted. Indented
content of structures. Switch/case indent.
Signed-off-by: Jiri Slaby <xslaby@fi.muni.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/isicom.c | 1365 |
1 files changed, 682 insertions, 683 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index 86033bed5d6c..761c5622b7af 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c | |||
@@ -20,7 +20,7 @@ | |||
20 | * 3/9/99 sameer Added support for ISI4616 cards. | 20 | * 3/9/99 sameer Added support for ISI4616 cards. |
21 | * | 21 | * |
22 | * 16/9/99 sameer We do not force RTS low anymore. | 22 | * 16/9/99 sameer We do not force RTS low anymore. |
23 | * This is to prevent the firmware | 23 | * This is to prevent the firmware |
24 | * from getting confused. | 24 | * from getting confused. |
25 | * | 25 | * |
26 | * 26/10/99 sameer Cosmetic changes:The driver now | 26 | * 26/10/99 sameer Cosmetic changes:The driver now |
@@ -31,28 +31,28 @@ | |||
31 | * | 31 | * |
32 | * 10/5/00 sameer Fixed isicom_shutdown_board() | 32 | * 10/5/00 sameer Fixed isicom_shutdown_board() |
33 | * to not lower DTR on all the ports | 33 | * to not lower DTR on all the ports |
34 | * when the last port on the card is | 34 | * when the last port on the card is |
35 | * closed. | 35 | * closed. |
36 | * | 36 | * |
37 | * 10/5/00 sameer Signal mask setup command added | 37 | * 10/5/00 sameer Signal mask setup command added |
38 | * to isicom_setup_port and | 38 | * to isicom_setup_port and |
39 | * isicom_shutdown_port. | 39 | * isicom_shutdown_port. |
40 | * | 40 | * |
41 | * 24/5/00 sameer The driver is now SMP aware. | 41 | * 24/5/00 sameer The driver is now SMP aware. |
42 | * | 42 | * |
43 | * | 43 | * |
44 | * 27/11/00 Vinayak P Risbud Fixed the Driver Crash Problem | 44 | * 27/11/00 Vinayak P Risbud Fixed the Driver Crash Problem |
45 | * | 45 | * |
46 | * | 46 | * |
47 | * 03/01/01 anil .s Added support for resetting the | 47 | * 03/01/01 anil .s Added support for resetting the |
48 | * internal modems on ISI cards. | 48 | * internal modems on ISI cards. |
49 | * | 49 | * |
50 | * 08/02/01 anil .s Upgraded the driver for kernel | 50 | * 08/02/01 anil .s Upgraded the driver for kernel |
51 | * 2.4.x | 51 | * 2.4.x |
52 | * | 52 | * |
53 | * 11/04/01 Kevin Fixed firmware load problem with | 53 | * 11/04/01 Kevin Fixed firmware load problem with |
54 | * ISIHP-4X card | 54 | * ISIHP-4X card |
55 | * | 55 | * |
56 | * 30/04/01 anil .s Fixed the remote login through | 56 | * 30/04/01 anil .s Fixed the remote login through |
57 | * ISI port problem. Now the link | 57 | * ISI port problem. Now the link |
58 | * does not go down before password | 58 | * does not go down before password |
@@ -62,9 +62,9 @@ | |||
62 | * among ISI-PCI cards. | 62 | * among ISI-PCI cards. |
63 | * | 63 | * |
64 | * 03/05/01 anil .s Added support to display the version | 64 | * 03/05/01 anil .s Added support to display the version |
65 | * info during insmod as well as module | 65 | * info during insmod as well as module |
66 | * listing by lsmod. | 66 | * listing by lsmod. |
67 | * | 67 | * |
68 | * 10/05/01 anil .s Done the modifications to the source | 68 | * 10/05/01 anil .s Done the modifications to the source |
69 | * file and Install script so that the | 69 | * file and Install script so that the |
70 | * same installation can be used for | 70 | * same installation can be used for |
@@ -73,19 +73,19 @@ | |||
73 | * 06/06/01 anil .s Now we drop both dtr and rts during | 73 | * 06/06/01 anil .s Now we drop both dtr and rts during |
74 | * shutdown_port as well as raise them | 74 | * shutdown_port as well as raise them |
75 | * during isicom_config_port. | 75 | * during isicom_config_port. |
76 | * | 76 | * |
77 | * 09/06/01 acme@conectiva.com.br use capable, not suser, do | 77 | * 09/06/01 acme@conectiva.com.br use capable, not suser, do |
78 | * restore_flags on failure in | 78 | * restore_flags on failure in |
79 | * isicom_send_break, verify put_user | 79 | * isicom_send_break, verify put_user |
80 | * result | 80 | * result |
81 | * | 81 | * |
82 | * 11/02/03 ranjeeth Added support for 230 Kbps and 460 Kbps | 82 | * 11/02/03 ranjeeth Added support for 230 Kbps and 460 Kbps |
83 | * Baud index extended to 21 | 83 | * Baud index extended to 21 |
84 | * | 84 | * |
85 | * 20/03/03 ranjeeth Made to work for Linux Advanced server. | 85 | * 20/03/03 ranjeeth Made to work for Linux Advanced server. |
86 | * Taken care of license warning. | 86 | * Taken care of license warning. |
87 | * | 87 | * |
88 | * 10/12/03 Ravindra Made to work for Fedora Core 1 of | 88 | * 10/12/03 Ravindra Made to work for Fedora Core 1 of |
89 | * Red Hat Distribution | 89 | * Red Hat Distribution |
90 | * | 90 | * |
91 | * 06/01/05 Alan Cox Merged the ISI and base kernel strands | 91 | * 06/01/05 Alan Cox Merged the ISI and base kernel strands |
@@ -93,10 +93,10 @@ | |||
93 | * | 93 | * |
94 | * *********************************************************** | 94 | * *********************************************************** |
95 | * | 95 | * |
96 | * To use this driver you also need the support package. You | 96 | * To use this driver you also need the support package. You |
97 | * can find this in RPM format on | 97 | * can find this in RPM format on |
98 | * ftp://ftp.linux.org.uk/pub/linux/alan | 98 | * ftp://ftp.linux.org.uk/pub/linux/alan |
99 | * | 99 | * |
100 | * You can find the original tools for this direct from Multitech | 100 | * You can find the original tools for this direct from Multitech |
101 | * ftp://ftp.multitech.com/ISI-Cards/ | 101 | * ftp://ftp.multitech.com/ISI-Cards/ |
102 | * | 102 | * |
@@ -161,16 +161,15 @@ static unsigned long tx_count = 0; | |||
161 | static int ISILoad_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); | 161 | static int ISILoad_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); |
162 | 162 | ||
163 | static void isicom_tx(unsigned long _data); | 163 | static void isicom_tx(unsigned long _data); |
164 | static void isicom_start(struct tty_struct * tty); | 164 | static void isicom_start(struct tty_struct *tty); |
165 | 165 | ||
166 | static unsigned char * tmp_buf; | 166 | static unsigned char *tmp_buf; |
167 | static DECLARE_MUTEX(tmp_buf_sem); | 167 | static DECLARE_MUTEX(tmp_buf_sem); |
168 | 168 | ||
169 | /* baud index mappings from linux defns to isi */ | 169 | /* baud index mappings from linux defns to isi */ |
170 | 170 | ||
171 | static signed char linuxb_to_isib[] = { | 171 | static signed char linuxb_to_isib[] = { |
172 | -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, | 172 | -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19 |
173 | 18, 19 | ||
174 | }; | 173 | }; |
175 | 174 | ||
176 | struct isi_board { | 175 | struct isi_board { |
@@ -216,7 +215,7 @@ static struct isi_port isi_ports[PORT_COUNT]; | |||
216 | * the kernel lock for the card and have the card in a position that | 215 | * the kernel lock for the card and have the card in a position that |
217 | * it wants to talk. | 216 | * it wants to talk. |
218 | */ | 217 | */ |
219 | 218 | ||
220 | static int lock_card(struct isi_board *card) | 219 | static int lock_card(struct isi_board *card) |
221 | { | 220 | { |
222 | char retries; | 221 | char retries; |
@@ -225,7 +224,7 @@ static int lock_card(struct isi_board *card) | |||
225 | for (retries = 0; retries < 100; retries++) { | 224 | for (retries = 0; retries < 100; retries++) { |
226 | spin_lock_irqsave(&card->card_lock, card->flags); | 225 | spin_lock_irqsave(&card->card_lock, card->flags); |
227 | if (inw(base + 0xe) & 0x1) { | 226 | if (inw(base + 0xe) & 0x1) { |
228 | return 1; | 227 | return 1; |
229 | } else { | 228 | } else { |
230 | spin_unlock_irqrestore(&card->card_lock, card->flags); | 229 | spin_unlock_irqrestore(&card->card_lock, card->flags); |
231 | udelay(1000); /* 1ms */ | 230 | udelay(1000); /* 1ms */ |
@@ -244,7 +243,7 @@ static int lock_card_at_interrupt(struct isi_board *card) | |||
244 | spin_lock_irqsave(&card->card_lock, card->flags); | 243 | spin_lock_irqsave(&card->card_lock, card->flags); |
245 | 244 | ||
246 | if (inw(base + 0xe) & 0x1) | 245 | if (inw(base + 0xe) & 0x1) |
247 | return 1; | 246 | return 1; |
248 | else | 247 | else |
249 | spin_unlock_irqrestore(&card->card_lock, card->flags); | 248 | spin_unlock_irqrestore(&card->card_lock, card->flags); |
250 | } | 249 | } |
@@ -260,119 +259,119 @@ static void unlock_card(struct isi_board *card) | |||
260 | /* | 259 | /* |
261 | * ISI Card specific ops ... | 260 | * ISI Card specific ops ... |
262 | */ | 261 | */ |
263 | 262 | ||
264 | static void raise_dtr(struct isi_port * port) | 263 | static void raise_dtr(struct isi_port *port) |
265 | { | 264 | { |
266 | struct isi_board * card = port->card; | 265 | struct isi_board *card = port->card; |
267 | unsigned short base = card->base; | 266 | unsigned short base = card->base; |
268 | unsigned char channel = port->channel; | 267 | unsigned char channel = port->channel; |
269 | 268 | ||
270 | if (!lock_card(card)) | 269 | if (!lock_card(card)) |
271 | return; | 270 | return; |
272 | 271 | ||
273 | outw(0x8000 | (channel << card->shift_count) | 0x02 , base); | 272 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
274 | outw(0x0504, base); | 273 | outw(0x0504, base); |
275 | InterruptTheCard(base); | 274 | InterruptTheCard(base); |
276 | port->status |= ISI_DTR; | 275 | port->status |= ISI_DTR; |
277 | unlock_card(card); | 276 | unlock_card(card); |
278 | } | 277 | } |
279 | 278 | ||
280 | static inline void drop_dtr(struct isi_port * port) | 279 | static inline void drop_dtr(struct isi_port *port) |
281 | { | 280 | { |
282 | struct isi_board * card = port->card; | 281 | struct isi_board *card = port->card; |
283 | unsigned short base = card->base; | 282 | unsigned short base = card->base; |
284 | unsigned char channel = port->channel; | 283 | unsigned char channel = port->channel; |
285 | 284 | ||
286 | if (!lock_card(card)) | 285 | if (!lock_card(card)) |
287 | return; | 286 | return; |
288 | 287 | ||
289 | outw(0x8000 | (channel << card->shift_count) | 0x02 , base); | 288 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
290 | outw(0x0404, base); | 289 | outw(0x0404, base); |
291 | InterruptTheCard(base); | 290 | InterruptTheCard(base); |
292 | port->status &= ~ISI_DTR; | 291 | port->status &= ~ISI_DTR; |
293 | unlock_card(card); | 292 | unlock_card(card); |
294 | } | 293 | } |
295 | 294 | ||
296 | static inline void raise_rts(struct isi_port * port) | 295 | static inline void raise_rts(struct isi_port *port) |
297 | { | 296 | { |
298 | struct isi_board * card = port->card; | 297 | struct isi_board *card = port->card; |
299 | unsigned short base = card->base; | 298 | unsigned short base = card->base; |
300 | unsigned char channel = port->channel; | 299 | unsigned char channel = port->channel; |
301 | 300 | ||
302 | if (!lock_card(card)) | 301 | if (!lock_card(card)) |
303 | return; | 302 | return; |
304 | 303 | ||
305 | outw(0x8000 | (channel << card->shift_count) | 0x02 , base); | 304 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
306 | outw(0x0a04, base); | 305 | outw(0x0a04, base); |
307 | InterruptTheCard(base); | 306 | InterruptTheCard(base); |
308 | port->status |= ISI_RTS; | 307 | port->status |= ISI_RTS; |
309 | unlock_card(card); | 308 | unlock_card(card); |
310 | } | 309 | } |
311 | static inline void drop_rts(struct isi_port * port) | 310 | static inline void drop_rts(struct isi_port *port) |
312 | { | 311 | { |
313 | struct isi_board * card = port->card; | 312 | struct isi_board *card = port->card; |
314 | unsigned short base = card->base; | 313 | unsigned short base = card->base; |
315 | unsigned char channel = port->channel; | 314 | unsigned char channel = port->channel; |
316 | 315 | ||
317 | if (!lock_card(card)) | 316 | if (!lock_card(card)) |
318 | return; | 317 | return; |
319 | 318 | ||
320 | outw(0x8000 | (channel << card->shift_count) | 0x02 , base); | 319 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
321 | outw(0x0804, base); | 320 | outw(0x0804, base); |
322 | InterruptTheCard(base); | 321 | InterruptTheCard(base); |
323 | port->status &= ~ISI_RTS; | 322 | port->status &= ~ISI_RTS; |
324 | unlock_card(card); | 323 | unlock_card(card); |
325 | } | 324 | } |
326 | 325 | ||
327 | static inline void raise_dtr_rts(struct isi_port * port) | 326 | static inline void raise_dtr_rts(struct isi_port *port) |
328 | { | 327 | { |
329 | struct isi_board * card = port->card; | 328 | struct isi_board *card = port->card; |
330 | unsigned short base = card->base; | 329 | unsigned short base = card->base; |
331 | unsigned char channel = port->channel; | 330 | unsigned char channel = port->channel; |
332 | 331 | ||
333 | if (!lock_card(card)) | 332 | if (!lock_card(card)) |
334 | return; | 333 | return; |
335 | 334 | ||
336 | outw(0x8000 | (channel << card->shift_count) | 0x02 , base); | 335 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
337 | outw(0x0f04, base); | 336 | outw(0x0f04, base); |
338 | InterruptTheCard(base); | 337 | InterruptTheCard(base); |
339 | port->status |= (ISI_DTR | ISI_RTS); | 338 | port->status |= (ISI_DTR | ISI_RTS); |
340 | unlock_card(card); | 339 | unlock_card(card); |
341 | } | 340 | } |
342 | 341 | ||
343 | static void drop_dtr_rts(struct isi_port * port) | 342 | static void drop_dtr_rts(struct isi_port *port) |
344 | { | 343 | { |
345 | struct isi_board * card = port->card; | 344 | struct isi_board *card = port->card; |
346 | unsigned short base = card->base; | 345 | unsigned short base = card->base; |
347 | unsigned char channel = port->channel; | 346 | unsigned char channel = port->channel; |
348 | 347 | ||
349 | if (!lock_card(card)) | 348 | if (!lock_card(card)) |
350 | return; | 349 | return; |
351 | 350 | ||
352 | outw(0x8000 | (channel << card->shift_count) | 0x02 , base); | 351 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
353 | outw(0x0c04, base); | 352 | outw(0x0c04, base); |
354 | InterruptTheCard(base); | 353 | InterruptTheCard(base); |
355 | port->status &= ~(ISI_RTS | ISI_DTR); | 354 | port->status &= ~(ISI_RTS | ISI_DTR); |
356 | unlock_card(card); | 355 | unlock_card(card); |
357 | } | 356 | } |
358 | 357 | ||
359 | static inline void kill_queue(struct isi_port * port, short queue) | 358 | static inline void kill_queue(struct isi_port *port, short queue) |
360 | { | 359 | { |
361 | struct isi_board * card = port->card; | 360 | struct isi_board *card = port->card; |
362 | unsigned short base = card->base; | 361 | unsigned short base = card->base; |
363 | unsigned char channel = port->channel; | 362 | unsigned char channel = port->channel; |
364 | 363 | ||
365 | if (!lock_card(card)) | 364 | if (!lock_card(card)) |
366 | return; | 365 | return; |
367 | 366 | ||
368 | outw(0x8000 | (channel << card->shift_count) | 0x02 , base); | 367 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
369 | outw((queue << 8) | 0x06, base); | 368 | outw((queue << 8) | 0x06, base); |
370 | InterruptTheCard(base); | 369 | InterruptTheCard(base); |
371 | unlock_card(card); | 370 | unlock_card(card); |
372 | } | 371 | } |
373 | 372 | ||
374 | 373 | ||
375 | /* | 374 | /* |
376 | * Firmware loader driver specific routines. This needs to mostly die | 375 | * Firmware loader driver specific routines. This needs to mostly die |
377 | * and be replaced with request_firmware. | 376 | * and be replaced with request_firmware. |
378 | */ | 377 | */ |
@@ -386,19 +385,19 @@ static struct miscdevice isiloader_device = { | |||
386 | ISILOAD_MISC_MINOR, "isictl", &ISILoad_fops | 385 | ISILOAD_MISC_MINOR, "isictl", &ISILoad_fops |
387 | }; | 386 | }; |
388 | 387 | ||
389 | 388 | ||
390 | static inline int WaitTillCardIsFree(unsigned short base) | 389 | static inline int WaitTillCardIsFree(unsigned short base) |
391 | { | 390 | { |
392 | unsigned long count=0; | 391 | unsigned long count=0; |
393 | while( (!(inw(base+0xe) & 0x1)) && (count++ < 6000000)); | 392 | while( (!(inw(base+0xe) & 0x1)) && (count++ < 6000000)); |
394 | if (inw(base+0xe)&0x1) | 393 | if (inw(base+0xe)&0x1) |
395 | return 0; | 394 | return 0; |
396 | else | 395 | else |
397 | return 1; | 396 | return 1; |
398 | } | 397 | } |
399 | 398 | ||
400 | static int ISILoad_ioctl(struct inode *inode, struct file *filp, | 399 | static int ISILoad_ioctl(struct inode *inode, struct file *filp, |
401 | unsigned int cmd, unsigned long arg) | 400 | unsigned int cmd, unsigned long arg) |
402 | { | 401 | { |
403 | unsigned int card, i, j, signature, status, portcount = 0; | 402 | unsigned int card, i, j, signature, status, portcount = 0; |
404 | unsigned long t; | 403 | unsigned long t; |
@@ -406,213 +405,211 @@ static int ISILoad_ioctl(struct inode *inode, struct file *filp, | |||
406 | bin_frame frame; | 405 | bin_frame frame; |
407 | void __user *argp = (void __user *)arg; | 406 | void __user *argp = (void __user *)arg; |
408 | /* exec_record exec_rec; */ | 407 | /* exec_record exec_rec; */ |
409 | 408 | ||
410 | if(get_user(card, (int __user *)argp)) | 409 | if (get_user(card, (int __user *)argp)) |
411 | return -EFAULT; | 410 | return -EFAULT; |
412 | 411 | ||
413 | if(card < 0 || card >= BOARD_COUNT) | 412 | if (card < 0 || card >= BOARD_COUNT) |
414 | return -ENXIO; | 413 | return -ENXIO; |
415 | 414 | ||
416 | base=isi_card[card].base; | 415 | base=isi_card[card].base; |
417 | 416 | ||
418 | if(base==0) | 417 | if (base==0) |
419 | return -ENXIO; /* disabled or not used */ | 418 | return -ENXIO; /* disabled or not used */ |
420 | 419 | ||
421 | switch(cmd) { | 420 | switch(cmd) { |
422 | case MIOCTL_RESET_CARD: | 421 | case MIOCTL_RESET_CARD: |
423 | if (!capable(CAP_SYS_ADMIN)) | 422 | if (!capable(CAP_SYS_ADMIN)) |
424 | return -EPERM; | 423 | return -EPERM; |
425 | printk(KERN_DEBUG "ISILoad:Resetting Card%d at 0x%x ",card+1,base); | 424 | printk(KERN_DEBUG "ISILoad:Resetting Card%d at 0x%x ",card+1,base); |
426 | 425 | ||
427 | inw(base+0x8); | 426 | inw(base+0x8); |
428 | 427 | ||
429 | for(t=jiffies+HZ/100;time_before(jiffies, t);); | 428 | for (t=jiffies+HZ/100;time_before(jiffies, t);); |
430 | 429 | ||
431 | outw(0,base+0x8); /* Reset */ | 430 | outw(0,base+0x8); /* Reset */ |
432 | 431 | ||
433 | for(j=1;j<=3;j++) { | 432 | for (j=1;j<=3;j++) { |
434 | for(t=jiffies+HZ;time_before(jiffies, t);); | 433 | for (t=jiffies+HZ;time_before(jiffies, t);); |
435 | printk("."); | 434 | printk("."); |
436 | } | 435 | } |
437 | signature=(inw(base+0x4)) & 0xff; | 436 | signature=(inw(base+0x4)) & 0xff; |
438 | if (isi_card[card].isa) { | 437 | if (isi_card[card].isa) { |
439 | 438 | ||
440 | if (!(inw(base+0xe) & 0x1) || (inw(base+0x2))) { | 439 | if (!(inw(base+0xe) & 0x1) || (inw(base+0x2))) { |
441 | #ifdef ISICOM_DEBUG | ||
442 | printk("\nbase+0x2=0x%x , base+0xe=0x%x",inw(base+0x2),inw(base+0xe)); | ||
443 | #endif | ||
444 | printk("\nISILoad:ISA Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); | ||
445 | return -EIO; | ||
446 | } | ||
447 | } | ||
448 | else { | ||
449 | portcount = inw(base+0x2); | ||
450 | if (!(inw(base+0xe) & 0x1) || ((portcount!=0) && (portcount!=4) && (portcount!=8))) { | ||
451 | #ifdef ISICOM_DEBUG | 440 | #ifdef ISICOM_DEBUG |
452 | printk("\nbase+0x2=0x%x , base+0xe=0x%x",inw(base+0x2),inw(base+0xe)); | 441 | printk("\nbase+0x2=0x%x , base+0xe=0x%x",inw(base+0x2),inw(base+0xe)); |
453 | #endif | 442 | #endif |
454 | printk("\nISILoad:PCI Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); | 443 | printk("\nISILoad:ISA Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); |
455 | return -EIO; | 444 | return -EIO; |
456 | } | 445 | } |
457 | } | 446 | } |
458 | switch(signature) { | 447 | else { |
459 | case 0xa5: | 448 | portcount = inw(base+0x2); |
460 | case 0xbb: | 449 | if (!(inw(base+0xe) & 0x1) || ((portcount!=0) && (portcount!=4) && (portcount!=8))) { |
461 | case 0xdd: | 450 | #ifdef ISICOM_DEBUG |
462 | if (isi_card[card].isa) | 451 | printk("\nbase+0x2=0x%x , base+0xe=0x%x",inw(base+0x2),inw(base+0xe)); |
463 | isi_card[card].port_count = 8; | 452 | #endif |
464 | else { | 453 | printk("\nISILoad:PCI Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); |
465 | if (portcount == 4) | 454 | return -EIO; |
466 | isi_card[card].port_count = 4; | ||
467 | else | ||
468 | isi_card[card].port_count = 8; | ||
469 | } | ||
470 | isi_card[card].shift_count = 12; | ||
471 | break; | ||
472 | |||
473 | case 0xcc: isi_card[card].port_count = 16; | ||
474 | isi_card[card].shift_count = 11; | ||
475 | break; | ||
476 | |||
477 | default: printk("ISILoad:Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); | ||
478 | #ifdef ISICOM_DEBUG | ||
479 | printk("Sig=0x%x\n",signature); | ||
480 | #endif | ||
481 | return -EIO; | ||
482 | } | 455 | } |
483 | printk("-Done\n"); | 456 | } |
484 | return put_user(signature,(unsigned __user *)argp); | 457 | switch(signature) { |
485 | 458 | case 0xa5: | |
459 | case 0xbb: | ||
460 | case 0xdd: | ||
461 | if (isi_card[card].isa) | ||
462 | isi_card[card].port_count = 8; | ||
463 | else { | ||
464 | if (portcount == 4) | ||
465 | isi_card[card].port_count = 4; | ||
466 | else | ||
467 | isi_card[card].port_count = 8; | ||
468 | } | ||
469 | isi_card[card].shift_count = 12; | ||
470 | break; | ||
471 | |||
472 | case 0xcc: isi_card[card].port_count = 16; | ||
473 | isi_card[card].shift_count = 11; | ||
474 | break; | ||
475 | |||
476 | default: printk("ISILoad:Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); | ||
477 | #ifdef ISICOM_DEBUG | ||
478 | printk("Sig=0x%x\n",signature); | ||
479 | #endif | ||
480 | return -EIO; | ||
481 | } | ||
482 | printk("-Done\n"); | ||
483 | return put_user(signature,(unsigned __user *)argp); | ||
484 | |||
486 | case MIOCTL_LOAD_FIRMWARE: | 485 | case MIOCTL_LOAD_FIRMWARE: |
487 | if (!capable(CAP_SYS_ADMIN)) | 486 | if (!capable(CAP_SYS_ADMIN)) |
488 | return -EPERM; | 487 | return -EPERM; |
489 | 488 | ||
490 | if(copy_from_user(&frame, argp, sizeof(bin_frame))) | 489 | if (copy_from_user(&frame, argp, sizeof(bin_frame))) |
491 | return -EFAULT; | 490 | return -EFAULT; |
492 | 491 | ||
493 | if (WaitTillCardIsFree(base)) | 492 | if (WaitTillCardIsFree(base)) |
494 | return -EIO; | 493 | return -EIO; |
495 | 494 | ||
496 | outw(0xf0,base); /* start upload sequence */ | 495 | outw(0xf0,base); /* start upload sequence */ |
497 | outw(0x00,base); | 496 | outw(0x00,base); |
498 | outw((frame.addr), base);/* lsb of adderess */ | 497 | outw((frame.addr), base); /* lsb of adderess */ |
499 | 498 | ||
500 | word_count=(frame.count >> 1) + frame.count % 2; | 499 | word_count=(frame.count >> 1) + frame.count % 2; |
501 | outw(word_count, base); | 500 | outw(word_count, base); |
502 | InterruptTheCard(base); | 501 | InterruptTheCard(base); |
503 | 502 | ||
504 | for(i=0;i<=0x2f;i++); /* a wee bit of delay */ | 503 | for (i=0;i<=0x2f;i++); /* a wee bit of delay */ |
505 | 504 | ||
506 | if (WaitTillCardIsFree(base)) | 505 | if (WaitTillCardIsFree(base)) |
507 | return -EIO; | 506 | return -EIO; |
508 | 507 | ||
509 | if ((status=inw(base+0x4))!=0) { | 508 | if ((status=inw(base+0x4))!=0) { |
510 | printk(KERN_WARNING "ISILoad:Card%d rejected load header:\nAddress:0x%x \nCount:0x%x \nStatus:0x%x \n", | 509 | printk(KERN_WARNING "ISILoad:Card%d rejected load header:\nAddress:0x%x \nCount:0x%x \nStatus:0x%x \n", |
511 | card+1, frame.addr, frame.count, status); | 510 | card+1, frame.addr, frame.count, status); |
512 | return -EIO; | 511 | return -EIO; |
513 | } | 512 | } |
514 | outsw(base, (void *) frame.bin_data, word_count); | 513 | outsw(base, (void *) frame.bin_data, word_count); |
515 | 514 | ||
516 | InterruptTheCard(base); | 515 | InterruptTheCard(base); |
517 | 516 | ||
518 | for(i=0;i<=0x0f;i++); /* another wee bit of delay */ | 517 | for (i=0;i<=0x0f;i++); /* another wee bit of delay */ |
519 | 518 | ||
520 | if (WaitTillCardIsFree(base)) | 519 | if (WaitTillCardIsFree(base)) |
521 | return -EIO; | 520 | return -EIO; |
522 | 521 | ||
523 | if ((status=inw(base+0x4))!=0) { | 522 | if ((status=inw(base+0x4))!=0) { |
524 | printk(KERN_ERR "ISILoad:Card%d got out of sync.Card Status:0x%x\n",card+1, status); | 523 | printk(KERN_ERR "ISILoad:Card%d got out of sync.Card Status:0x%x\n",card+1, status); |
525 | return -EIO; | 524 | return -EIO; |
526 | } | 525 | } |
527 | return 0; | 526 | return 0; |
528 | 527 | ||
529 | case MIOCTL_READ_FIRMWARE: | 528 | case MIOCTL_READ_FIRMWARE: |
530 | if (!capable(CAP_SYS_ADMIN)) | 529 | if (!capable(CAP_SYS_ADMIN)) |
531 | return -EPERM; | 530 | return -EPERM; |
532 | 531 | ||
533 | if(copy_from_user(&frame, argp, sizeof(bin_header))) | 532 | if (copy_from_user(&frame, argp, sizeof(bin_header))) |
534 | return -EFAULT; | 533 | return -EFAULT; |
535 | 534 | ||
536 | if (WaitTillCardIsFree(base)) | 535 | if (WaitTillCardIsFree(base)) |
537 | return -EIO; | 536 | return -EIO; |
538 | 537 | ||
539 | outw(0xf1,base); /* start download sequence */ | 538 | outw(0xf1,base); /* start download sequence */ |
540 | outw(0x00,base); | 539 | outw(0x00,base); |
541 | outw((frame.addr), base);/* lsb of adderess */ | 540 | outw((frame.addr), base); /* lsb of adderess */ |
542 | 541 | ||
543 | word_count=(frame.count >> 1) + frame.count % 2; | 542 | word_count=(frame.count >> 1) + frame.count % 2; |
544 | outw(word_count+1, base); | 543 | outw(word_count+1, base); |
545 | InterruptTheCard(base); | 544 | InterruptTheCard(base); |
546 | 545 | ||
547 | for(i=0;i<=0xf;i++); /* a wee bit of delay */ | 546 | for (i=0;i<=0xf;i++); /* a wee bit of delay */ |
548 | 547 | ||
549 | if (WaitTillCardIsFree(base)) | 548 | if (WaitTillCardIsFree(base)) |
550 | return -EIO; | 549 | return -EIO; |
551 | 550 | ||
552 | if ((status=inw(base+0x4))!=0) { | 551 | if ((status=inw(base+0x4))!=0) { |
553 | printk(KERN_WARNING "ISILoad:Card%d rejected verify header:\nAddress:0x%x \nCount:0x%x \nStatus:0x%x \n", | 552 | printk(KERN_WARNING "ISILoad:Card%d rejected verify header:\nAddress:0x%x \nCount:0x%x \nStatus:0x%x \n", |
554 | card+1, frame.addr, frame.count, status); | 553 | card+1, frame.addr, frame.count, status); |
555 | return -EIO; | 554 | return -EIO; |
556 | } | 555 | } |
557 | 556 | ||
558 | inw(base); | 557 | inw(base); |
559 | insw(base, frame.bin_data, word_count); | 558 | insw(base, frame.bin_data, word_count); |
560 | InterruptTheCard(base); | 559 | InterruptTheCard(base); |
561 | 560 | ||
562 | for(i=0;i<=0x0f;i++); /* another wee bit of delay */ | 561 | for (i=0;i<=0x0f;i++); /* another wee bit of delay */ |
563 | 562 | ||
564 | if (WaitTillCardIsFree(base)) | 563 | if (WaitTillCardIsFree(base)) |
565 | return -EIO; | 564 | return -EIO; |
566 | 565 | ||
567 | if ((status=inw(base+0x4))!=0) { | 566 | if ((status=inw(base+0x4))!=0) { |
568 | printk(KERN_ERR "ISILoad:Card%d verify got out of sync.Card Status:0x%x\n",card+1, status); | 567 | printk(KERN_ERR "ISILoad:Card%d verify got out of sync.Card Status:0x%x\n",card+1, status); |
569 | return -EIO; | 568 | return -EIO; |
570 | } | 569 | } |
571 | 570 | ||
572 | if(copy_to_user(argp, &frame, sizeof(bin_frame))) | 571 | if (copy_to_user(argp, &frame, sizeof(bin_frame))) |
573 | return -EFAULT; | 572 | return -EFAULT; |
574 | return 0; | 573 | return 0; |
575 | 574 | ||
576 | case MIOCTL_XFER_CTRL: | 575 | case MIOCTL_XFER_CTRL: |
577 | if (!capable(CAP_SYS_ADMIN)) | 576 | if (!capable(CAP_SYS_ADMIN)) |
578 | return -EPERM; | 577 | return -EPERM; |
579 | if (WaitTillCardIsFree(base)) | 578 | if (WaitTillCardIsFree(base)) |
580 | return -EIO; | 579 | return -EIO; |
581 | 580 | ||
582 | outw(0xf2, base); | 581 | outw(0xf2, base); |
583 | outw(0x800, base); | 582 | outw(0x800, base); |
584 | outw(0x0, base); | 583 | outw(0x0, base); |
585 | outw(0x0, base); | 584 | outw(0x0, base); |
586 | InterruptTheCard(base); | 585 | InterruptTheCard(base); |
587 | outw(0x0, base+0x4); /* for ISI4608 cards */ | 586 | outw(0x0, base+0x4); /* for ISI4608 cards */ |
588 | 587 | ||
589 | isi_card[card].status |= FIRMWARE_LOADED; | 588 | isi_card[card].status |= FIRMWARE_LOADED; |
590 | return 0; | 589 | return 0; |
591 | 590 | ||
592 | default: | 591 | default: |
593 | #ifdef ISICOM_DEBUG | 592 | #ifdef ISICOM_DEBUG |
594 | printk(KERN_DEBUG "ISILoad: Received Ioctl cmd 0x%x.\n", cmd); | 593 | printk(KERN_DEBUG "ISILoad: Received Ioctl cmd 0x%x.\n", cmd); |
595 | #endif | 594 | #endif |
596 | return -ENOIOCTLCMD; | 595 | return -ENOIOCTLCMD; |
597 | |||
598 | } | 596 | } |
599 | |||
600 | } | 597 | } |
601 | 598 | ||
602 | 599 | ||
603 | /* | 600 | /* |
604 | * ISICOM Driver specific routines ... | 601 | * ISICOM Driver specific routines ... |
605 | * | 602 | * |
606 | */ | 603 | */ |
607 | 604 | ||
608 | static inline int isicom_paranoia_check(struct isi_port const * port, char *name, | 605 | static inline int isicom_paranoia_check(struct isi_port const *port, char *name, |
609 | const char * routine) | 606 | const char *routine) |
610 | { | 607 | { |
611 | #ifdef ISICOM_DEBUG | 608 | #ifdef ISICOM_DEBUG |
612 | static const char * badmagic = | 609 | static const char *badmagic = |
613 | KERN_WARNING "ISICOM: Warning: bad isicom magic for dev %s in %s.\n"; | 610 | KERN_WARNING "ISICOM: Warning: bad isicom magic for dev %s in %s.\n"; |
614 | static const char * badport = | 611 | static const char *badport = |
615 | KERN_WARNING "ISICOM: Warning: NULL isicom port for dev %s in %s.\n"; | 612 | KERN_WARNING "ISICOM: Warning: NULL isicom port for dev %s in %s.\n"; |
616 | if (!port) { | 613 | if (!port) { |
617 | printk(badport, name, routine); | 614 | printk(badport, name, routine); |
618 | return 1; | 615 | return 1; |
@@ -620,13 +617,13 @@ static inline int isicom_paranoia_check(struct isi_port const * port, char *name | |||
620 | if (port->magic != ISICOM_MAGIC) { | 617 | if (port->magic != ISICOM_MAGIC) { |
621 | printk(badmagic, name, routine); | 618 | printk(badmagic, name, routine); |
622 | return 1; | 619 | return 1; |
623 | } | 620 | } |
624 | #endif | 621 | #endif |
625 | return 0; | 622 | return 0; |
626 | } | 623 | } |
627 | 624 | ||
628 | /* | 625 | /* |
629 | * Transmitter. | 626 | * Transmitter. |
630 | * | 627 | * |
631 | * We shovel data into the card buffers on a regular basis. The card | 628 | * We shovel data into the card buffers on a regular basis. The card |
632 | * will do the rest of the work for us. | 629 | * will do the rest of the work for us. |
@@ -636,25 +633,25 @@ static void isicom_tx(unsigned long _data) | |||
636 | { | 633 | { |
637 | short count = (BOARD_COUNT-1), card, base; | 634 | short count = (BOARD_COUNT-1), card, base; |
638 | short txcount, wrd, residue, word_count, cnt; | 635 | short txcount, wrd, residue, word_count, cnt; |
639 | struct isi_port * port; | 636 | struct isi_port *port; |
640 | struct tty_struct * tty; | 637 | struct tty_struct *tty; |
641 | 638 | ||
642 | #ifdef ISICOM_DEBUG | 639 | #ifdef ISICOM_DEBUG |
643 | ++tx_count; | 640 | ++tx_count; |
644 | #endif | 641 | #endif |
645 | 642 | ||
646 | /* find next active board */ | 643 | /* find next active board */ |
647 | card = (prev_card + 1) & 0x0003; | 644 | card = (prev_card + 1) & 0x0003; |
648 | while(count-- > 0) { | 645 | while(count-- > 0) { |
649 | if (isi_card[card].status & BOARD_ACTIVE) | 646 | if (isi_card[card].status & BOARD_ACTIVE) |
650 | break; | 647 | break; |
651 | card = (card + 1) & 0x0003; | 648 | card = (card + 1) & 0x0003; |
652 | } | 649 | } |
653 | if (!(isi_card[card].status & BOARD_ACTIVE)) | 650 | if (!(isi_card[card].status & BOARD_ACTIVE)) |
654 | goto sched_again; | 651 | goto sched_again; |
655 | 652 | ||
656 | prev_card = card; | 653 | prev_card = card; |
657 | 654 | ||
658 | count = isi_card[card].port_count; | 655 | count = isi_card[card].port_count; |
659 | port = isi_card[card].ports; | 656 | port = isi_card[card].ports; |
660 | base = isi_card[card].base; | 657 | base = isi_card[card].base; |
@@ -663,18 +660,18 @@ static void isicom_tx(unsigned long _data) | |||
663 | continue; | 660 | continue; |
664 | /* port not active or tx disabled to force flow control */ | 661 | /* port not active or tx disabled to force flow control */ |
665 | if (!(port->flags & ASYNC_INITIALIZED) || | 662 | if (!(port->flags & ASYNC_INITIALIZED) || |
666 | !(port->status & ISI_TXOK)) | 663 | !(port->status & ISI_TXOK)) |
667 | unlock_card(&isi_card[card]); | 664 | unlock_card(&isi_card[card]); |
668 | continue; | 665 | continue; |
669 | 666 | ||
670 | tty = port->tty; | 667 | tty = port->tty; |
671 | 668 | ||
672 | 669 | ||
673 | if(tty == NULL) { | 670 | if (tty == NULL) { |
674 | unlock_card(&isi_card[card]); | 671 | unlock_card(&isi_card[card]); |
675 | continue; | 672 | continue; |
676 | } | 673 | } |
677 | 674 | ||
678 | txcount = min_t(short, TX_SIZE, port->xmit_cnt); | 675 | txcount = min_t(short, TX_SIZE, port->xmit_cnt); |
679 | if (txcount <= 0 || tty->stopped || tty->hw_stopped) { | 676 | if (txcount <= 0 || tty->stopped || tty->hw_stopped) { |
680 | unlock_card(&isi_card[card]); | 677 | unlock_card(&isi_card[card]); |
@@ -682,16 +679,16 @@ static void isicom_tx(unsigned long _data) | |||
682 | } | 679 | } |
683 | if (!(inw(base + 0x02) & (1 << port->channel))) { | 680 | if (!(inw(base + 0x02) & (1 << port->channel))) { |
684 | unlock_card(&isi_card[card]); | 681 | unlock_card(&isi_card[card]); |
685 | continue; | 682 | continue; |
686 | } | 683 | } |
687 | #ifdef ISICOM_DEBUG | 684 | #ifdef ISICOM_DEBUG |
688 | printk(KERN_DEBUG "ISICOM: txing %d bytes, port%d.\n", | 685 | printk(KERN_DEBUG "ISICOM: txing %d bytes, port%d.\n", |
689 | txcount, port->channel+1); | 686 | txcount, port->channel+1); |
690 | #endif | 687 | #endif |
691 | outw((port->channel << isi_card[card].shift_count) | txcount | 688 | outw((port->channel << isi_card[card].shift_count) | txcount |
692 | , base); | 689 | , base); |
693 | residue = NO; | 690 | residue = NO; |
694 | wrd = 0; | 691 | wrd = 0; |
695 | while (1) { | 692 | while (1) { |
696 | cnt = min_t(int, txcount, (SERIAL_XMIT_SIZE - port->xmit_tail)); | 693 | cnt = min_t(int, txcount, (SERIAL_XMIT_SIZE - port->xmit_tail)); |
697 | if (residue == YES) { | 694 | if (residue == YES) { |
@@ -702,13 +699,13 @@ static void isicom_tx(unsigned long _data) | |||
702 | port->xmit_cnt--; | 699 | port->xmit_cnt--; |
703 | txcount--; | 700 | txcount--; |
704 | cnt--; | 701 | cnt--; |
705 | outw(wrd, base); | 702 | outw(wrd, base); |
706 | } | 703 | } |
707 | else { | 704 | else { |
708 | outw(wrd, base); | 705 | outw(wrd, base); |
709 | break; | 706 | break; |
710 | } | 707 | } |
711 | } | 708 | } |
712 | if (cnt <= 0) break; | 709 | if (cnt <= 0) break; |
713 | word_count = cnt >> 1; | 710 | word_count = cnt >> 1; |
714 | outsw(base, port->xmit_buf+port->xmit_tail, word_count); | 711 | outsw(base, port->xmit_buf+port->xmit_tail, word_count); |
@@ -731,68 +728,68 @@ static void isicom_tx(unsigned long _data) | |||
731 | if (port->xmit_cnt <= WAKEUP_CHARS) | 728 | if (port->xmit_cnt <= WAKEUP_CHARS) |
732 | schedule_work(&port->bh_tqueue); | 729 | schedule_work(&port->bh_tqueue); |
733 | unlock_card(&isi_card[card]); | 730 | unlock_card(&isi_card[card]); |
734 | } | 731 | } |
735 | 732 | ||
736 | /* schedule another tx for hopefully in about 10ms */ | 733 | /* schedule another tx for hopefully in about 10ms */ |
737 | sched_again: | 734 | sched_again: |
738 | if (!re_schedule) | 735 | if (!re_schedule) |
739 | return; | 736 | return; |
740 | init_timer(&tx); | 737 | init_timer(&tx); |
741 | tx.expires = jiffies + HZ/100; | 738 | tx.expires = jiffies + HZ/100; |
742 | tx.data = 0; | 739 | tx.data = 0; |
743 | tx.function = isicom_tx; | 740 | tx.function = isicom_tx; |
744 | add_timer(&tx); | 741 | add_timer(&tx); |
745 | 742 | ||
746 | return; | 743 | return; |
747 | } | 744 | } |
748 | 745 | ||
749 | /* Interrupt handlers */ | 746 | /* Interrupt handlers */ |
750 | 747 | ||
751 | 748 | ||
752 | static void isicom_bottomhalf(void * data) | 749 | static void isicom_bottomhalf(void *data) |
753 | { | 750 | { |
754 | struct isi_port * port = (struct isi_port *) data; | 751 | struct isi_port *port = (struct isi_port *) data; |
755 | struct tty_struct * tty = port->tty; | 752 | struct tty_struct *tty = port->tty; |
756 | 753 | ||
757 | if (!tty) | 754 | if (!tty) |
758 | return; | 755 | return; |
759 | 756 | ||
760 | tty_wakeup(tty); | 757 | tty_wakeup(tty); |
761 | wake_up_interruptible(&tty->write_wait); | 758 | wake_up_interruptible(&tty->write_wait); |
762 | } | 759 | } |
763 | 760 | ||
764 | /* | 761 | /* |
765 | * Main interrupt handler routine | 762 | * Main interrupt handler routine |
766 | */ | 763 | */ |
767 | 764 | ||
768 | static irqreturn_t isicom_interrupt(int irq, void *dev_id, | 765 | static irqreturn_t isicom_interrupt(int irq, void *dev_id, |
769 | struct pt_regs *regs) | 766 | struct pt_regs *regs) |
770 | { | 767 | { |
771 | struct isi_board * card; | 768 | struct isi_board *card; |
772 | struct isi_port * port; | 769 | struct isi_port *port; |
773 | struct tty_struct * tty; | 770 | struct tty_struct *tty; |
774 | unsigned short base, header, word_count, count; | 771 | unsigned short base, header, word_count, count; |
775 | unsigned char channel; | 772 | unsigned char channel; |
776 | short byte_count; | 773 | short byte_count; |
777 | unsigned char *rp; | 774 | unsigned char *rp; |
778 | 775 | ||
779 | card = (struct isi_board *) dev_id; | 776 | card = (struct isi_board *) dev_id; |
780 | 777 | ||
781 | if (!card || !(card->status & FIRMWARE_LOADED)) | 778 | if (!card || !(card->status & FIRMWARE_LOADED)) |
782 | return IRQ_NONE; | 779 | return IRQ_NONE; |
783 | 780 | ||
784 | base = card->base; | 781 | base = card->base; |
785 | spin_lock(&card->card_lock); | 782 | spin_lock(&card->card_lock); |
786 | 783 | ||
787 | if (card->isa == NO) { | 784 | if (card->isa == NO) { |
788 | /* | 785 | /* |
789 | * disable any interrupts from the PCI card and lower the | 786 | * disable any interrupts from the PCI card and lower the |
790 | * interrupt line | 787 | * interrupt line |
791 | */ | 788 | */ |
792 | outw(0x8000, base+0x04); | 789 | outw(0x8000, base+0x04); |
793 | ClearInterrupt(base); | 790 | ClearInterrupt(base); |
794 | } | 791 | } |
795 | 792 | ||
796 | inw(base); /* get the dummy word out */ | 793 | inw(base); /* get the dummy word out */ |
797 | header = inw(base); | 794 | header = inw(base); |
798 | channel = (header & 0x7800) >> card->shift_count; | 795 | channel = (header & 0x7800) >> card->shift_count; |
@@ -804,9 +801,9 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, | |||
804 | if (card->isa) | 801 | if (card->isa) |
805 | ClearInterrupt(base); | 802 | ClearInterrupt(base); |
806 | else | 803 | else |
807 | outw(0x0000, base+0x04); /* enable interrupts */ | 804 | outw(0x0000, base+0x04); /* enable interrupts */ |
808 | spin_unlock(&card->card_lock); | 805 | spin_unlock(&card->card_lock); |
809 | return IRQ_HANDLED; | 806 | return IRQ_HANDLED; |
810 | } | 807 | } |
811 | port = card->ports + channel; | 808 | port = card->ports + channel; |
812 | if (!(port->flags & ASYNC_INITIALIZED)) { | 809 | if (!(port->flags & ASYNC_INITIALIZED)) { |
@@ -815,8 +812,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, | |||
815 | else | 812 | else |
816 | outw(0x0000, base+0x04); /* enable interrupts */ | 813 | outw(0x0000, base+0x04); /* enable interrupts */ |
817 | return IRQ_HANDLED; | 814 | return IRQ_HANDLED; |
818 | } | 815 | } |
819 | 816 | ||
820 | tty = port->tty; | 817 | tty = port->tty; |
821 | if (tty == NULL) { | 818 | if (tty == NULL) { |
822 | word_count = byte_count >> 1; | 819 | word_count = byte_count >> 1; |
@@ -833,107 +830,107 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, | |||
833 | spin_unlock(&card->card_lock); | 830 | spin_unlock(&card->card_lock); |
834 | return IRQ_HANDLED; | 831 | return IRQ_HANDLED; |
835 | } | 832 | } |
836 | 833 | ||
837 | if (header & 0x8000) { /* Status Packet */ | 834 | if (header & 0x8000) { /* Status Packet */ |
838 | header = inw(base); | 835 | header = inw(base); |
839 | switch(header & 0xff) { | 836 | switch(header & 0xff) { |
840 | case 0: /* Change in EIA signals */ | 837 | case 0: /* Change in EIA signals */ |
841 | 838 | ||
842 | if (port->flags & ASYNC_CHECK_CD) { | 839 | if (port->flags & ASYNC_CHECK_CD) { |
843 | if (port->status & ISI_DCD) { | 840 | if (port->status & ISI_DCD) { |
844 | if (!(header & ISI_DCD)) { | 841 | if (!(header & ISI_DCD)) { |
845 | /* Carrier has been lost */ | 842 | /* Carrier has been lost */ |
846 | #ifdef ISICOM_DEBUG | ||
847 | printk(KERN_DEBUG "ISICOM: interrupt: DCD->low.\n"); | ||
848 | #endif | ||
849 | port->status &= ~ISI_DCD; | ||
850 | schedule_work(&port->hangup_tq); | ||
851 | } | ||
852 | } | ||
853 | else { | ||
854 | if (header & ISI_DCD) { | ||
855 | /* Carrier has been detected */ | ||
856 | #ifdef ISICOM_DEBUG | 843 | #ifdef ISICOM_DEBUG |
857 | printk(KERN_DEBUG "ISICOM: interrupt: DCD->high.\n"); | 844 | printk(KERN_DEBUG "ISICOM: interrupt: DCD->low.\n"); |
858 | #endif | 845 | #endif |
859 | port->status |= ISI_DCD; | 846 | port->status &= ~ISI_DCD; |
860 | wake_up_interruptible(&port->open_wait); | 847 | schedule_work(&port->hangup_tq); |
861 | } | ||
862 | } | 848 | } |
863 | } | 849 | } |
864 | else { | 850 | else { |
865 | if (header & ISI_DCD) | 851 | if (header & ISI_DCD) { |
852 | /* Carrier has been detected */ | ||
853 | #ifdef ISICOM_DEBUG | ||
854 | printk(KERN_DEBUG "ISICOM: interrupt: DCD->high.\n"); | ||
855 | #endif | ||
866 | port->status |= ISI_DCD; | 856 | port->status |= ISI_DCD; |
867 | else | 857 | wake_up_interruptible(&port->open_wait); |
868 | port->status &= ~ISI_DCD; | ||
869 | } | ||
870 | |||
871 | if (port->flags & ASYNC_CTS_FLOW) { | ||
872 | if (port->tty->hw_stopped) { | ||
873 | if (header & ISI_CTS) { | ||
874 | port->tty->hw_stopped = 0; | ||
875 | /* start tx ing */ | ||
876 | port->status |= (ISI_TXOK | ISI_CTS); | ||
877 | schedule_work(&port->bh_tqueue); | ||
878 | } | ||
879 | } | 858 | } |
880 | else { | 859 | } |
881 | if (!(header & ISI_CTS)) { | 860 | } |
882 | port->tty->hw_stopped = 1; | 861 | else { |
883 | /* stop tx ing */ | 862 | if (header & ISI_DCD) |
884 | port->status &= ~(ISI_TXOK | ISI_CTS); | 863 | port->status |= ISI_DCD; |
885 | } | 864 | else |
865 | port->status &= ~ISI_DCD; | ||
866 | } | ||
867 | |||
868 | if (port->flags & ASYNC_CTS_FLOW) { | ||
869 | if (port->tty->hw_stopped) { | ||
870 | if (header & ISI_CTS) { | ||
871 | port->tty->hw_stopped = 0; | ||
872 | /* start tx ing */ | ||
873 | port->status |= (ISI_TXOK | ISI_CTS); | ||
874 | schedule_work(&port->bh_tqueue); | ||
886 | } | 875 | } |
887 | } | 876 | } |
888 | else { | 877 | else { |
889 | if (header & ISI_CTS) | 878 | if (!(header & ISI_CTS)) { |
890 | port->status |= ISI_CTS; | 879 | port->tty->hw_stopped = 1; |
891 | else | 880 | /* stop tx ing */ |
892 | port->status &= ~ISI_CTS; | 881 | port->status &= ~(ISI_TXOK | ISI_CTS); |
882 | } | ||
893 | } | 883 | } |
894 | 884 | } | |
895 | if (header & ISI_DSR) | 885 | else { |
896 | port->status |= ISI_DSR; | 886 | if (header & ISI_CTS) |
897 | else | 887 | port->status |= ISI_CTS; |
898 | port->status &= ~ISI_DSR; | ||
899 | |||
900 | if (header & ISI_RI) | ||
901 | port->status |= ISI_RI; | ||
902 | else | 888 | else |
903 | port->status &= ~ISI_RI; | 889 | port->status &= ~ISI_CTS; |
904 | 890 | } | |
905 | break; | 891 | |
906 | 892 | if (header & ISI_DSR) | |
907 | case 1: /* Received Break !!! */ | 893 | port->status |= ISI_DSR; |
908 | tty_insert_flip_char(tty, 0, TTY_BREAK); | 894 | else |
909 | if (port->flags & ASYNC_SAK) | 895 | port->status &= ~ISI_DSR; |
910 | do_SAK(tty); | 896 | |
911 | tty_flip_buffer_push(tty); | 897 | if (header & ISI_RI) |
912 | break; | 898 | port->status |= ISI_RI; |
913 | 899 | else | |
914 | case 2: /* Statistics */ | 900 | port->status &= ~ISI_RI; |
915 | printk(KERN_DEBUG "ISICOM: isicom_interrupt: stats!!!.\n"); | 901 | |
916 | break; | 902 | break; |
917 | 903 | ||
918 | default: | 904 | case 1: /* Received Break !!! */ |
919 | printk(KERN_WARNING "ISICOM: Intr: Unknown code in status packet.\n"); | 905 | tty_insert_flip_char(tty, 0, TTY_BREAK); |
920 | break; | 906 | if (port->flags & ASYNC_SAK) |
921 | } | 907 | do_SAK(tty); |
908 | tty_flip_buffer_push(tty); | ||
909 | break; | ||
910 | |||
911 | case 2: /* Statistics */ | ||
912 | printk(KERN_DEBUG "ISICOM: isicom_interrupt: stats!!!.\n"); | ||
913 | break; | ||
914 | |||
915 | default: | ||
916 | printk(KERN_WARNING "ISICOM: Intr: Unknown code in status packet.\n"); | ||
917 | break; | ||
918 | } | ||
922 | } | 919 | } |
923 | else { /* Data Packet */ | 920 | else { /* Data Packet */ |
924 | 921 | ||
925 | count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); | 922 | count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); |
926 | #ifdef ISICOM_DEBUG | 923 | #ifdef ISICOM_DEBUG |
927 | printk(KERN_DEBUG "ISICOM: Intr: Can rx %d of %d bytes.\n", | 924 | printk(KERN_DEBUG "ISICOM: Intr: Can rx %d of %d bytes.\n", |
928 | count, byte_count); | 925 | count, byte_count); |
929 | #endif | 926 | #endif |
930 | word_count = count >> 1; | 927 | word_count = count >> 1; |
931 | insw(base, rp, word_count); | 928 | insw(base, rp, word_count); |
932 | byte_count -= (word_count << 1); | 929 | byte_count -= (word_count << 1); |
933 | if (count & 0x0001) { | 930 | if (count & 0x0001) { |
934 | tty_insert_flip_char(tty, inw(base) & 0xff, TTY_NORMAL); | 931 | tty_insert_flip_char(tty, inw(base) & 0xff, TTY_NORMAL); |
935 | byte_count -= 2; | 932 | byte_count -= 2; |
936 | } | 933 | } |
937 | if (byte_count > 0) { | 934 | if (byte_count > 0) { |
938 | printk(KERN_DEBUG "ISICOM: Intr(0x%x:%d): Flip buffer overflow! dropping bytes...\n", | 935 | printk(KERN_DEBUG "ISICOM: Intr(0x%x:%d): Flip buffer overflow! dropping bytes...\n", |
939 | base, channel+1); | 936 | base, channel+1); |
@@ -947,102 +944,102 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, | |||
947 | if (card->isa == YES) | 944 | if (card->isa == YES) |
948 | ClearInterrupt(base); | 945 | ClearInterrupt(base); |
949 | else | 946 | else |
950 | outw(0x0000, base+0x04); /* enable interrupts */ | 947 | outw(0x0000, base+0x04); /* enable interrupts */ |
951 | return IRQ_HANDLED; | 948 | return IRQ_HANDLED; |
952 | } | 949 | } |
953 | 950 | ||
954 | static void isicom_config_port(struct isi_port * port) | 951 | static void isicom_config_port(struct isi_port *port) |
955 | { | 952 | { |
956 | struct isi_board * card = port->card; | 953 | struct isi_board *card = port->card; |
957 | struct tty_struct * tty; | 954 | struct tty_struct *tty; |
958 | unsigned long baud; | 955 | unsigned long baud; |
959 | unsigned short channel_setup, base = card->base; | 956 | unsigned short channel_setup, base = card->base; |
960 | unsigned short channel = port->channel, shift_count = card->shift_count; | 957 | unsigned short channel = port->channel, shift_count = card->shift_count; |
961 | unsigned char flow_ctrl; | 958 | unsigned char flow_ctrl; |
962 | 959 | ||
963 | if (!(tty = port->tty) || !tty->termios) | 960 | if (!(tty = port->tty) || !tty->termios) |
964 | return; | 961 | return; |
965 | baud = C_BAUD(tty); | 962 | baud = C_BAUD(tty); |
966 | if (baud & CBAUDEX) { | 963 | if (baud & CBAUDEX) { |
967 | baud &= ~CBAUDEX; | 964 | baud &= ~CBAUDEX; |
968 | 965 | ||
969 | /* if CBAUDEX bit is on and the baud is set to either 50 or 75 | 966 | /* if CBAUDEX bit is on and the baud is set to either 50 or 75 |
970 | * then the card is programmed for 57.6Kbps or 115Kbps | 967 | * then the card is programmed for 57.6Kbps or 115Kbps |
971 | * respectively. | 968 | * respectively. |
972 | */ | 969 | */ |
973 | 970 | ||
974 | if (baud < 1 || baud > 2) | 971 | if (baud < 1 || baud > 2) |
975 | port->tty->termios->c_cflag &= ~CBAUDEX; | 972 | port->tty->termios->c_cflag &= ~CBAUDEX; |
976 | else | 973 | else |
977 | baud += 15; | 974 | baud += 15; |
978 | } | 975 | } |
979 | if (baud == 15) { | 976 | if (baud == 15) { |
980 | 977 | ||
981 | /* the ASYNC_SPD_HI and ASYNC_SPD_VHI options are set | 978 | /* the ASYNC_SPD_HI and ASYNC_SPD_VHI options are set |
982 | * by the set_serial_info ioctl ... this is done by | 979 | * by the set_serial_info ioctl ... this is done by |
983 | * the 'setserial' utility. | 980 | * the 'setserial' utility. |
984 | */ | 981 | */ |
985 | 982 | ||
986 | if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) | 983 | if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) |
987 | baud++; /* 57.6 Kbps */ | 984 | baud++; /* 57.6 Kbps */ |
988 | if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) | 985 | if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) |
989 | baud +=2; /* 115 Kbps */ | 986 | baud +=2; /* 115 Kbps */ |
990 | } | 987 | } |
991 | if (linuxb_to_isib[baud] == -1) { | 988 | if (linuxb_to_isib[baud] == -1) { |
992 | /* hang up */ | 989 | /* hang up */ |
993 | drop_dtr(port); | 990 | drop_dtr(port); |
994 | return; | 991 | return; |
995 | } | 992 | } |
996 | else | 993 | else |
997 | raise_dtr(port); | 994 | raise_dtr(port); |
998 | 995 | ||
999 | if (lock_card(card)) { | 996 | if (lock_card(card)) { |
1000 | outw(0x8000 | (channel << shift_count) |0x03, base); | 997 | outw(0x8000 | (channel << shift_count) |0x03, base); |
1001 | outw(linuxb_to_isib[baud] << 8 | 0x03, base); | 998 | outw(linuxb_to_isib[baud] << 8 | 0x03, base); |
1002 | channel_setup = 0; | 999 | channel_setup = 0; |
1003 | switch(C_CSIZE(tty)) { | 1000 | switch(C_CSIZE(tty)) { |
1004 | case CS5: | 1001 | case CS5: |
1005 | channel_setup |= ISICOM_CS5; | 1002 | channel_setup |= ISICOM_CS5; |
1006 | break; | 1003 | break; |
1007 | case CS6: | 1004 | case CS6: |
1008 | channel_setup |= ISICOM_CS6; | 1005 | channel_setup |= ISICOM_CS6; |
1009 | break; | 1006 | break; |
1010 | case CS7: | 1007 | case CS7: |
1011 | channel_setup |= ISICOM_CS7; | 1008 | channel_setup |= ISICOM_CS7; |
1012 | break; | 1009 | break; |
1013 | case CS8: | 1010 | case CS8: |
1014 | channel_setup |= ISICOM_CS8; | 1011 | channel_setup |= ISICOM_CS8; |
1015 | break; | 1012 | break; |
1016 | } | 1013 | } |
1017 | 1014 | ||
1018 | if (C_CSTOPB(tty)) | 1015 | if (C_CSTOPB(tty)) |
1019 | channel_setup |= ISICOM_2SB; | 1016 | channel_setup |= ISICOM_2SB; |
1020 | if (C_PARENB(tty)) { | 1017 | if (C_PARENB(tty)) { |
1021 | channel_setup |= ISICOM_EVPAR; | 1018 | channel_setup |= ISICOM_EVPAR; |
1022 | if (C_PARODD(tty)) | 1019 | if (C_PARODD(tty)) |
1023 | channel_setup |= ISICOM_ODPAR; | 1020 | channel_setup |= ISICOM_ODPAR; |
1024 | } | 1021 | } |
1025 | outw(channel_setup, base); | 1022 | outw(channel_setup, base); |
1026 | InterruptTheCard(base); | 1023 | InterruptTheCard(base); |
1027 | unlock_card(card); | 1024 | unlock_card(card); |
1028 | } | 1025 | } |
1029 | if (C_CLOCAL(tty)) | 1026 | if (C_CLOCAL(tty)) |
1030 | port->flags &= ~ASYNC_CHECK_CD; | 1027 | port->flags &= ~ASYNC_CHECK_CD; |
1031 | else | 1028 | else |
1032 | port->flags |= ASYNC_CHECK_CD; | 1029 | port->flags |= ASYNC_CHECK_CD; |
1033 | 1030 | ||
1034 | /* flow control settings ...*/ | 1031 | /* flow control settings ...*/ |
1035 | flow_ctrl = 0; | 1032 | flow_ctrl = 0; |
1036 | port->flags &= ~ASYNC_CTS_FLOW; | 1033 | port->flags &= ~ASYNC_CTS_FLOW; |
1037 | if (C_CRTSCTS(tty)) { | 1034 | if (C_CRTSCTS(tty)) { |
1038 | port->flags |= ASYNC_CTS_FLOW; | 1035 | port->flags |= ASYNC_CTS_FLOW; |
1039 | flow_ctrl |= ISICOM_CTSRTS; | 1036 | flow_ctrl |= ISICOM_CTSRTS; |
1040 | } | 1037 | } |
1041 | if (I_IXON(tty)) | 1038 | if (I_IXON(tty)) |
1042 | flow_ctrl |= ISICOM_RESPOND_XONXOFF; | 1039 | flow_ctrl |= ISICOM_RESPOND_XONXOFF; |
1043 | if (I_IXOFF(tty)) | 1040 | if (I_IXOFF(tty)) |
1044 | flow_ctrl |= ISICOM_INITIATE_XONXOFF; | 1041 | flow_ctrl |= ISICOM_INITIATE_XONXOFF; |
1045 | 1042 | ||
1046 | if (lock_card(card)) { | 1043 | if (lock_card(card)) { |
1047 | outw(0x8000 | (channel << shift_count) |0x04, base); | 1044 | outw(0x8000 | (channel << shift_count) |0x04, base); |
1048 | outw(flow_ctrl << 8 | 0x05, base); | 1045 | outw(flow_ctrl << 8 | 0x05, base); |
@@ -1050,22 +1047,22 @@ static void isicom_config_port(struct isi_port * port) | |||
1050 | InterruptTheCard(base); | 1047 | InterruptTheCard(base); |
1051 | unlock_card(card); | 1048 | unlock_card(card); |
1052 | } | 1049 | } |
1053 | 1050 | ||
1054 | /* rx enabled -> enable port for rx on the card */ | 1051 | /* rx enabled -> enable port for rx on the card */ |
1055 | if (C_CREAD(tty)) { | 1052 | if (C_CREAD(tty)) { |
1056 | card->port_status |= (1 << channel); | 1053 | card->port_status |= (1 << channel); |
1057 | outw(card->port_status, base + 0x02); | 1054 | outw(card->port_status, base + 0x02); |
1058 | } | 1055 | } |
1059 | } | 1056 | } |
1060 | |||
1061 | /* open et all */ | ||
1062 | 1057 | ||
1063 | static inline void isicom_setup_board(struct isi_board * bp) | 1058 | /* open et all */ |
1059 | |||
1060 | static inline void isicom_setup_board(struct isi_board *bp) | ||
1064 | { | 1061 | { |
1065 | int channel; | 1062 | int channel; |
1066 | struct isi_port * port; | 1063 | struct isi_port *port; |
1067 | unsigned long flags; | 1064 | unsigned long flags; |
1068 | 1065 | ||
1069 | spin_lock_irqsave(&bp->card_lock, flags); | 1066 | spin_lock_irqsave(&bp->card_lock, flags); |
1070 | if (bp->status & BOARD_ACTIVE) { | 1067 | if (bp->status & BOARD_ACTIVE) { |
1071 | spin_unlock_irqrestore(&bp->card_lock, flags); | 1068 | spin_unlock_irqrestore(&bp->card_lock, flags); |
@@ -1074,53 +1071,53 @@ static inline void isicom_setup_board(struct isi_board * bp) | |||
1074 | port = bp->ports; | 1071 | port = bp->ports; |
1075 | bp->status |= BOARD_ACTIVE; | 1072 | bp->status |= BOARD_ACTIVE; |
1076 | spin_unlock_irqrestore(&bp->card_lock, flags); | 1073 | spin_unlock_irqrestore(&bp->card_lock, flags); |
1077 | for(channel = 0; channel < bp->port_count; channel++, port++) | 1074 | for (channel = 0; channel < bp->port_count; channel++, port++) |
1078 | drop_dtr_rts(port); | 1075 | drop_dtr_rts(port); |
1079 | return; | 1076 | return; |
1080 | } | 1077 | } |
1081 | 1078 | ||
1082 | static int isicom_setup_port(struct isi_port * port) | 1079 | static int isicom_setup_port(struct isi_port *port) |
1083 | { | 1080 | { |
1084 | struct isi_board * card = port->card; | 1081 | struct isi_board *card = port->card; |
1085 | unsigned long flags; | 1082 | unsigned long flags; |
1086 | 1083 | ||
1087 | if (port->flags & ASYNC_INITIALIZED) { | 1084 | if (port->flags & ASYNC_INITIALIZED) { |
1088 | return 0; | 1085 | return 0; |
1089 | } | 1086 | } |
1090 | if (!port->xmit_buf) { | 1087 | if (!port->xmit_buf) { |
1091 | unsigned long page; | 1088 | unsigned long page; |
1092 | 1089 | ||
1093 | if (!(page = get_zeroed_page(GFP_KERNEL))) | 1090 | if (!(page = get_zeroed_page(GFP_KERNEL))) |
1094 | return -ENOMEM; | 1091 | return -ENOMEM; |
1095 | 1092 | ||
1096 | if (port->xmit_buf) { | 1093 | if (port->xmit_buf) { |
1097 | free_page(page); | 1094 | free_page(page); |
1098 | return -ERESTARTSYS; | 1095 | return -ERESTARTSYS; |
1099 | } | 1096 | } |
1100 | port->xmit_buf = (unsigned char *) page; | 1097 | port->xmit_buf = (unsigned char *) page; |
1101 | } | 1098 | } |
1102 | 1099 | ||
1103 | spin_lock_irqsave(&card->card_lock, flags); | 1100 | spin_lock_irqsave(&card->card_lock, flags); |
1104 | if (port->tty) | 1101 | if (port->tty) |
1105 | clear_bit(TTY_IO_ERROR, &port->tty->flags); | 1102 | clear_bit(TTY_IO_ERROR, &port->tty->flags); |
1106 | if (port->count == 1) | 1103 | if (port->count == 1) |
1107 | card->count++; | 1104 | card->count++; |
1108 | 1105 | ||
1109 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; | 1106 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; |
1110 | 1107 | ||
1111 | /* discard any residual data */ | 1108 | /* discard any residual data */ |
1112 | kill_queue(port, ISICOM_KILLTX | ISICOM_KILLRX); | 1109 | kill_queue(port, ISICOM_KILLTX | ISICOM_KILLRX); |
1113 | 1110 | ||
1114 | isicom_config_port(port); | 1111 | isicom_config_port(port); |
1115 | port->flags |= ASYNC_INITIALIZED; | 1112 | port->flags |= ASYNC_INITIALIZED; |
1116 | spin_unlock_irqrestore(&card->card_lock, flags); | 1113 | spin_unlock_irqrestore(&card->card_lock, flags); |
1117 | 1114 | ||
1118 | return 0; | 1115 | return 0; |
1119 | } | 1116 | } |
1120 | 1117 | ||
1121 | static int block_til_ready(struct tty_struct * tty, struct file * filp, struct isi_port * port) | 1118 | static int block_til_ready(struct tty_struct *tty, struct file *filp, struct isi_port *port) |
1122 | { | 1119 | { |
1123 | struct isi_board * card = port->card; | 1120 | struct isi_board *card = port->card; |
1124 | int do_clocal = 0, retval; | 1121 | int do_clocal = 0, retval; |
1125 | unsigned long flags; | 1122 | unsigned long flags; |
1126 | DECLARE_WAITQUEUE(wait, current); | 1123 | DECLARE_WAITQUEUE(wait, current); |
@@ -1128,30 +1125,30 @@ static int block_til_ready(struct tty_struct * tty, struct file * filp, struct i | |||
1128 | /* block if port is in the process of being closed */ | 1125 | /* block if port is in the process of being closed */ |
1129 | 1126 | ||
1130 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { | 1127 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { |
1131 | #ifdef ISICOM_DEBUG | 1128 | #ifdef ISICOM_DEBUG |
1132 | printk(KERN_DEBUG "ISICOM: block_til_ready: close in progress.\n"); | 1129 | printk(KERN_DEBUG "ISICOM: block_til_ready: close in progress.\n"); |
1133 | #endif | 1130 | #endif |
1134 | interruptible_sleep_on(&port->close_wait); | 1131 | interruptible_sleep_on(&port->close_wait); |
1135 | if (port->flags & ASYNC_HUP_NOTIFY) | 1132 | if (port->flags & ASYNC_HUP_NOTIFY) |
1136 | return -EAGAIN; | 1133 | return -EAGAIN; |
1137 | else | 1134 | else |
1138 | return -ERESTARTSYS; | 1135 | return -ERESTARTSYS; |
1139 | } | 1136 | } |
1140 | 1137 | ||
1141 | /* if non-blocking mode is set ... */ | 1138 | /* if non-blocking mode is set ... */ |
1142 | 1139 | ||
1143 | if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { | 1140 | if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { |
1144 | #ifdef ISICOM_DEBUG | 1141 | #ifdef ISICOM_DEBUG |
1145 | printk(KERN_DEBUG "ISICOM: block_til_ready: non-block mode.\n"); | 1142 | printk(KERN_DEBUG "ISICOM: block_til_ready: non-block mode.\n"); |
1146 | #endif | 1143 | #endif |
1147 | port->flags |= ASYNC_NORMAL_ACTIVE; | 1144 | port->flags |= ASYNC_NORMAL_ACTIVE; |
1148 | return 0; | 1145 | return 0; |
1149 | } | 1146 | } |
1150 | 1147 | ||
1151 | if (C_CLOCAL(tty)) | 1148 | if (C_CLOCAL(tty)) |
1152 | do_clocal = 1; | 1149 | do_clocal = 1; |
1153 | 1150 | ||
1154 | /* block waiting for DCD to be asserted, and while | 1151 | /* block waiting for DCD to be asserted, and while |
1155 | callout dev is busy */ | 1152 | callout dev is busy */ |
1156 | retval = 0; | 1153 | retval = 0; |
1157 | add_wait_queue(&port->open_wait, &wait); | 1154 | add_wait_queue(&port->open_wait, &wait); |
@@ -1161,27 +1158,27 @@ static int block_til_ready(struct tty_struct * tty, struct file * filp, struct i | |||
1161 | port->count--; | 1158 | port->count--; |
1162 | port->blocked_open++; | 1159 | port->blocked_open++; |
1163 | spin_unlock_irqrestore(&card->card_lock, flags); | 1160 | spin_unlock_irqrestore(&card->card_lock, flags); |
1164 | 1161 | ||
1165 | while (1) { | 1162 | while (1) { |
1166 | raise_dtr_rts(port); | 1163 | raise_dtr_rts(port); |
1167 | 1164 | ||
1168 | set_current_state(TASK_INTERRUPTIBLE); | 1165 | set_current_state(TASK_INTERRUPTIBLE); |
1169 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { | 1166 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { |
1170 | if (port->flags & ASYNC_HUP_NOTIFY) | 1167 | if (port->flags & ASYNC_HUP_NOTIFY) |
1171 | retval = -EAGAIN; | 1168 | retval = -EAGAIN; |
1172 | else | 1169 | else |
1173 | retval = -ERESTARTSYS; | 1170 | retval = -ERESTARTSYS; |
1174 | break; | 1171 | break; |
1175 | } | 1172 | } |
1176 | if (!(port->flags & ASYNC_CLOSING) && | 1173 | if (!(port->flags & ASYNC_CLOSING) && |
1177 | (do_clocal || (port->status & ISI_DCD))) { | 1174 | (do_clocal || (port->status & ISI_DCD))) { |
1178 | break; | 1175 | break; |
1179 | } | 1176 | } |
1180 | if (signal_pending(current)) { | 1177 | if (signal_pending(current)) { |
1181 | retval = -ERESTARTSYS; | 1178 | retval = -ERESTARTSYS; |
1182 | break; | 1179 | break; |
1183 | } | 1180 | } |
1184 | schedule(); | 1181 | schedule(); |
1185 | } | 1182 | } |
1186 | set_current_state(TASK_RUNNING); | 1183 | set_current_state(TASK_RUNNING); |
1187 | remove_wait_queue(&port->open_wait, &wait); | 1184 | remove_wait_queue(&port->open_wait, &wait); |
@@ -1195,11 +1192,11 @@ static int block_til_ready(struct tty_struct * tty, struct file * filp, struct i | |||
1195 | port->flags |= ASYNC_NORMAL_ACTIVE; | 1192 | port->flags |= ASYNC_NORMAL_ACTIVE; |
1196 | return 0; | 1193 | return 0; |
1197 | } | 1194 | } |
1198 | 1195 | ||
1199 | static int isicom_open(struct tty_struct * tty, struct file * filp) | 1196 | static int isicom_open(struct tty_struct *tty, struct file *filp) |
1200 | { | 1197 | { |
1201 | struct isi_port * port; | 1198 | struct isi_port *port; |
1202 | struct isi_board * card; | 1199 | struct isi_board *card; |
1203 | unsigned int line, board; | 1200 | unsigned int line, board; |
1204 | int error; | 1201 | int error; |
1205 | 1202 | ||
@@ -1208,20 +1205,20 @@ static int isicom_open(struct tty_struct * tty, struct file * filp) | |||
1208 | return -ENODEV; | 1205 | return -ENODEV; |
1209 | board = BOARD(line); | 1206 | board = BOARD(line); |
1210 | card = &isi_card[board]; | 1207 | card = &isi_card[board]; |
1211 | 1208 | ||
1212 | if (!(card->status & FIRMWARE_LOADED)) | 1209 | if (!(card->status & FIRMWARE_LOADED)) |
1213 | return -ENODEV; | 1210 | return -ENODEV; |
1214 | 1211 | ||
1215 | /* open on a port greater than the port count for the card !!! */ | 1212 | /* open on a port greater than the port count for the card !!! */ |
1216 | if (line > ((board * 16) + card->port_count - 1)) | 1213 | if (line > ((board * 16) + card->port_count - 1)) |
1217 | return -ENODEV; | 1214 | return -ENODEV; |
1218 | 1215 | ||
1219 | port = &isi_ports[line]; | 1216 | port = &isi_ports[line]; |
1220 | if (isicom_paranoia_check(port, tty->name, "isicom_open")) | 1217 | if (isicom_paranoia_check(port, tty->name, "isicom_open")) |
1221 | return -ENODEV; | 1218 | return -ENODEV; |
1222 | 1219 | ||
1223 | isicom_setup_board(card); | 1220 | isicom_setup_board(card); |
1224 | 1221 | ||
1225 | port->count++; | 1222 | port->count++; |
1226 | tty->driver_data = port; | 1223 | tty->driver_data = port; |
1227 | port->tty = tty; | 1224 | port->tty = tty; |
@@ -1230,12 +1227,12 @@ static int isicom_open(struct tty_struct * tty, struct file * filp) | |||
1230 | if ((error = block_til_ready(tty, filp, port))!=0) | 1227 | if ((error = block_til_ready(tty, filp, port))!=0) |
1231 | return error; | 1228 | return error; |
1232 | 1229 | ||
1233 | return 0; | 1230 | return 0; |
1234 | } | 1231 | } |
1235 | 1232 | ||
1236 | /* close et all */ | 1233 | /* close et all */ |
1237 | 1234 | ||
1238 | static inline void isicom_shutdown_board(struct isi_board * bp) | 1235 | static inline void isicom_shutdown_board(struct isi_board *bp) |
1239 | { | 1236 | { |
1240 | unsigned long flags; | 1237 | unsigned long flags; |
1241 | 1238 | ||
@@ -1246,15 +1243,15 @@ static inline void isicom_shutdown_board(struct isi_board * bp) | |||
1246 | spin_unlock_irqrestore(&bp->card_lock, flags); | 1243 | spin_unlock_irqrestore(&bp->card_lock, flags); |
1247 | } | 1244 | } |
1248 | 1245 | ||
1249 | static void isicom_shutdown_port(struct isi_port * port) | 1246 | static void isicom_shutdown_port(struct isi_port *port) |
1250 | { | 1247 | { |
1251 | struct isi_board * card = port->card; | 1248 | struct isi_board *card = port->card; |
1252 | struct tty_struct * tty; | 1249 | struct tty_struct *tty; |
1253 | unsigned long flags; | 1250 | unsigned long flags; |
1254 | 1251 | ||
1255 | tty = port->tty; | 1252 | tty = port->tty; |
1256 | 1253 | ||
1257 | spin_lock_irqsave(&card->card_lock, flags); | 1254 | spin_lock_irqsave(&card->card_lock, flags); |
1258 | if (!(port->flags & ASYNC_INITIALIZED)) { | 1255 | if (!(port->flags & ASYNC_INITIALIZED)) { |
1259 | spin_unlock_irqrestore(&card->card_lock, flags); | 1256 | spin_unlock_irqrestore(&card->card_lock, flags); |
1260 | return; | 1257 | return; |
@@ -1262,60 +1259,60 @@ static void isicom_shutdown_port(struct isi_port * port) | |||
1262 | if (port->xmit_buf) { | 1259 | if (port->xmit_buf) { |
1263 | free_page((unsigned long) port->xmit_buf); | 1260 | free_page((unsigned long) port->xmit_buf); |
1264 | port->xmit_buf = NULL; | 1261 | port->xmit_buf = NULL; |
1265 | } | 1262 | } |
1266 | port->flags &= ~ASYNC_INITIALIZED; | 1263 | port->flags &= ~ASYNC_INITIALIZED; |
1267 | /* 3rd October 2000 : Vinayak P Risbud */ | 1264 | /* 3rd October 2000 : Vinayak P Risbud */ |
1268 | port->tty = NULL; | 1265 | port->tty = NULL; |
1269 | spin_unlock_irqrestore(&card->card_lock, flags); | 1266 | spin_unlock_irqrestore(&card->card_lock, flags); |
1270 | 1267 | ||
1271 | /*Fix done by Anil .S on 30-04-2001 | 1268 | /*Fix done by Anil .S on 30-04-2001 |
1272 | remote login through isi port has dtr toggle problem | 1269 | remote login through isi port has dtr toggle problem |
1273 | due to which the carrier drops before the password prompt | 1270 | due to which the carrier drops before the password prompt |
1274 | appears on the remote end. Now we drop the dtr only if the | 1271 | appears on the remote end. Now we drop the dtr only if the |
1275 | HUPCL(Hangup on close) flag is set for the tty*/ | 1272 | HUPCL(Hangup on close) flag is set for the tty*/ |
1276 | 1273 | ||
1277 | if (C_HUPCL(tty)) | 1274 | if (C_HUPCL(tty)) |
1278 | /* drop dtr on this port */ | 1275 | /* drop dtr on this port */ |
1279 | drop_dtr(port); | 1276 | drop_dtr(port); |
1280 | 1277 | ||
1281 | /* any other port uninits */ | 1278 | /* any other port uninits */ |
1282 | if (tty) | 1279 | if (tty) |
1283 | set_bit(TTY_IO_ERROR, &tty->flags); | 1280 | set_bit(TTY_IO_ERROR, &tty->flags); |
1284 | 1281 | ||
1285 | if (--card->count < 0) { | 1282 | if (--card->count < 0) { |
1286 | printk(KERN_DEBUG "ISICOM: isicom_shutdown_port: bad board(0x%x) count %d.\n", | 1283 | printk(KERN_DEBUG "ISICOM: isicom_shutdown_port: bad board(0x%x) count %d.\n", |
1287 | card->base, card->count); | 1284 | card->base, card->count); |
1288 | card->count = 0; | 1285 | card->count = 0; |
1289 | } | 1286 | } |
1290 | 1287 | ||
1291 | /* last port was closed , shutdown that boad too */ | 1288 | /* last port was closed , shutdown that boad too */ |
1292 | if(C_HUPCL(tty)) { | 1289 | if (C_HUPCL(tty)) { |
1293 | if (!card->count) | 1290 | if (!card->count) |
1294 | isicom_shutdown_board(card); | 1291 | isicom_shutdown_board(card); |
1295 | } | 1292 | } |
1296 | } | 1293 | } |
1297 | 1294 | ||
1298 | static void isicom_close(struct tty_struct * tty, struct file * filp) | 1295 | static void isicom_close(struct tty_struct *tty, struct file *filp) |
1299 | { | 1296 | { |
1300 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1297 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1301 | struct isi_board * card = port->card; | 1298 | struct isi_board *card = port->card; |
1302 | unsigned long flags; | 1299 | unsigned long flags; |
1303 | 1300 | ||
1304 | if (!port) | 1301 | if (!port) |
1305 | return; | 1302 | return; |
1306 | if (isicom_paranoia_check(port, tty->name, "isicom_close")) | 1303 | if (isicom_paranoia_check(port, tty->name, "isicom_close")) |
1307 | return; | 1304 | return; |
1308 | 1305 | ||
1309 | #ifdef ISICOM_DEBUG | 1306 | #ifdef ISICOM_DEBUG |
1310 | printk(KERN_DEBUG "ISICOM: Close start!!!.\n"); | 1307 | printk(KERN_DEBUG "ISICOM: Close start!!!.\n"); |
1311 | #endif | 1308 | #endif |
1312 | 1309 | ||
1313 | spin_lock_irqsave(&card->card_lock, flags); | 1310 | spin_lock_irqsave(&card->card_lock, flags); |
1314 | if (tty_hung_up_p(filp)) { | 1311 | if (tty_hung_up_p(filp)) { |
1315 | spin_unlock_irqrestore(&card->card_lock, flags); | 1312 | spin_unlock_irqrestore(&card->card_lock, flags); |
1316 | return; | 1313 | return; |
1317 | } | 1314 | } |
1318 | 1315 | ||
1319 | if (tty->count == 1 && port->count != 1) { | 1316 | if (tty->count == 1 && port->count != 1) { |
1320 | printk(KERN_WARNING "ISICOM:(0x%x) isicom_close: bad port count" | 1317 | printk(KERN_WARNING "ISICOM:(0x%x) isicom_close: bad port count" |
1321 | "tty->count = 1 port count = %d.\n", | 1318 | "tty->count = 1 port count = %d.\n", |
@@ -1324,31 +1321,31 @@ static void isicom_close(struct tty_struct * tty, struct file * filp) | |||
1324 | } | 1321 | } |
1325 | if (--port->count < 0) { | 1322 | if (--port->count < 0) { |
1326 | printk(KERN_WARNING "ISICOM:(0x%x) isicom_close: bad port count for" | 1323 | printk(KERN_WARNING "ISICOM:(0x%x) isicom_close: bad port count for" |
1327 | "channel%d = %d", card->base, port->channel, | 1324 | "channel%d = %d", card->base, port->channel, |
1328 | port->count); | 1325 | port->count); |
1329 | port->count = 0; | 1326 | port->count = 0; |
1330 | } | 1327 | } |
1331 | 1328 | ||
1332 | if (port->count) { | 1329 | if (port->count) { |
1333 | spin_unlock_irqrestore(&card->card_lock, flags); | 1330 | spin_unlock_irqrestore(&card->card_lock, flags); |
1334 | return; | 1331 | return; |
1335 | } | 1332 | } |
1336 | port->flags |= ASYNC_CLOSING; | 1333 | port->flags |= ASYNC_CLOSING; |
1337 | tty->closing = 1; | 1334 | tty->closing = 1; |
1338 | spin_unlock_irqrestore(&card->card_lock, flags); | 1335 | spin_unlock_irqrestore(&card->card_lock, flags); |
1339 | 1336 | ||
1340 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 1337 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
1341 | tty_wait_until_sent(tty, port->closing_wait); | 1338 | tty_wait_until_sent(tty, port->closing_wait); |
1342 | /* indicate to the card that no more data can be received | 1339 | /* indicate to the card that no more data can be received |
1343 | on this port */ | 1340 | on this port */ |
1344 | spin_lock_irqsave(&card->card_lock, flags); | 1341 | spin_lock_irqsave(&card->card_lock, flags); |
1345 | if (port->flags & ASYNC_INITIALIZED) { | 1342 | if (port->flags & ASYNC_INITIALIZED) { |
1346 | card->port_status &= ~(1 << port->channel); | 1343 | card->port_status &= ~(1 << port->channel); |
1347 | outw(card->port_status, card->base + 0x02); | 1344 | outw(card->port_status, card->base + 0x02); |
1348 | } | 1345 | } |
1349 | isicom_shutdown_port(port); | 1346 | isicom_shutdown_port(port); |
1350 | spin_unlock_irqrestore(&card->card_lock, flags); | 1347 | spin_unlock_irqrestore(&card->card_lock, flags); |
1351 | 1348 | ||
1352 | if (tty->driver->flush_buffer) | 1349 | if (tty->driver->flush_buffer) |
1353 | tty->driver->flush_buffer(tty); | 1350 | tty->driver->flush_buffer(tty); |
1354 | tty_ldisc_flush(tty); | 1351 | tty_ldisc_flush(tty); |
@@ -1359,65 +1356,65 @@ static void isicom_close(struct tty_struct * tty, struct file * filp) | |||
1359 | if (port->blocked_open) { | 1356 | if (port->blocked_open) { |
1360 | spin_unlock_irqrestore(&card->card_lock, flags); | 1357 | spin_unlock_irqrestore(&card->card_lock, flags); |
1361 | if (port->close_delay) { | 1358 | if (port->close_delay) { |
1362 | #ifdef ISICOM_DEBUG | 1359 | #ifdef ISICOM_DEBUG |
1363 | printk(KERN_DEBUG "ISICOM: scheduling until time out.\n"); | 1360 | printk(KERN_DEBUG "ISICOM: scheduling until time out.\n"); |
1364 | #endif | 1361 | #endif |
1365 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); | 1362 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); |
1366 | } | 1363 | } |
1367 | spin_lock_irqsave(&card->card_lock, flags); | 1364 | spin_lock_irqsave(&card->card_lock, flags); |
1368 | wake_up_interruptible(&port->open_wait); | 1365 | wake_up_interruptible(&port->open_wait); |
1369 | } | 1366 | } |
1370 | port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); | 1367 | port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); |
1371 | wake_up_interruptible(&port->close_wait); | 1368 | wake_up_interruptible(&port->close_wait); |
1372 | spin_unlock_irqrestore(&card->card_lock, flags); | 1369 | spin_unlock_irqrestore(&card->card_lock, flags); |
1373 | } | 1370 | } |
1374 | 1371 | ||
1375 | /* write et all */ | 1372 | /* write et all */ |
1376 | static int isicom_write(struct tty_struct * tty, | 1373 | static int isicom_write(struct tty_struct *tty, const unsigned char *buf, |
1377 | const unsigned char * buf, int count) | 1374 | int count) |
1378 | { | 1375 | { |
1379 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1376 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1380 | struct isi_board * card = port->card; | 1377 | struct isi_board *card = port->card; |
1381 | unsigned long flags; | 1378 | unsigned long flags; |
1382 | int cnt, total = 0; | 1379 | int cnt, total = 0; |
1383 | 1380 | ||
1384 | if (isicom_paranoia_check(port, tty->name, "isicom_write")) | 1381 | if (isicom_paranoia_check(port, tty->name, "isicom_write")) |
1385 | return 0; | 1382 | return 0; |
1386 | 1383 | ||
1387 | if (!tty || !port->xmit_buf || !tmp_buf) | 1384 | if (!tty || !port->xmit_buf || !tmp_buf) |
1388 | return 0; | 1385 | return 0; |
1389 | 1386 | ||
1390 | spin_lock_irqsave(&card->card_lock, flags); | 1387 | spin_lock_irqsave(&card->card_lock, flags); |
1391 | 1388 | ||
1392 | while(1) { | 1389 | while(1) { |
1393 | cnt = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, | 1390 | cnt = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, |
1394 | SERIAL_XMIT_SIZE - port->xmit_head)); | 1391 | SERIAL_XMIT_SIZE - port->xmit_head)); |
1395 | if (cnt <= 0) | 1392 | if (cnt <= 0) |
1396 | break; | 1393 | break; |
1397 | 1394 | ||
1398 | memcpy(port->xmit_buf + port->xmit_head, buf, cnt); | 1395 | memcpy(port->xmit_buf + port->xmit_head, buf, cnt); |
1399 | port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE - 1); | 1396 | port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE - 1); |
1400 | port->xmit_cnt += cnt; | 1397 | port->xmit_cnt += cnt; |
1401 | buf += cnt; | 1398 | buf += cnt; |
1402 | count -= cnt; | 1399 | count -= cnt; |
1403 | total += cnt; | 1400 | total += cnt; |
1404 | } | 1401 | } |
1405 | if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped) | 1402 | if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped) |
1406 | port->status |= ISI_TXOK; | 1403 | port->status |= ISI_TXOK; |
1407 | spin_unlock_irqrestore(&card->card_lock, flags); | 1404 | spin_unlock_irqrestore(&card->card_lock, flags); |
1408 | return total; | 1405 | return total; |
1409 | } | 1406 | } |
1410 | 1407 | ||
1411 | /* put_char et all */ | 1408 | /* put_char et all */ |
1412 | static void isicom_put_char(struct tty_struct * tty, unsigned char ch) | 1409 | static void isicom_put_char(struct tty_struct *tty, unsigned char ch) |
1413 | { | 1410 | { |
1414 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1411 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1415 | struct isi_board * card = port->card; | 1412 | struct isi_board *card = port->card; |
1416 | unsigned long flags; | 1413 | unsigned long flags; |
1417 | 1414 | ||
1418 | if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) | 1415 | if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) |
1419 | return; | 1416 | return; |
1420 | 1417 | ||
1421 | if (!tty || !port->xmit_buf) | 1418 | if (!tty || !port->xmit_buf) |
1422 | return; | 1419 | return; |
1423 | 1420 | ||
@@ -1426,7 +1423,7 @@ static void isicom_put_char(struct tty_struct * tty, unsigned char ch) | |||
1426 | spin_unlock_irqrestore(&card->card_lock, flags); | 1423 | spin_unlock_irqrestore(&card->card_lock, flags); |
1427 | return; | 1424 | return; |
1428 | } | 1425 | } |
1429 | 1426 | ||
1430 | port->xmit_buf[port->xmit_head++] = ch; | 1427 | port->xmit_buf[port->xmit_head++] = ch; |
1431 | port->xmit_head &= (SERIAL_XMIT_SIZE - 1); | 1428 | port->xmit_head &= (SERIAL_XMIT_SIZE - 1); |
1432 | port->xmit_cnt++; | 1429 | port->xmit_cnt++; |
@@ -1434,30 +1431,30 @@ static void isicom_put_char(struct tty_struct * tty, unsigned char ch) | |||
1434 | } | 1431 | } |
1435 | 1432 | ||
1436 | /* flush_chars et all */ | 1433 | /* flush_chars et all */ |
1437 | static void isicom_flush_chars(struct tty_struct * tty) | 1434 | static void isicom_flush_chars(struct tty_struct *tty) |
1438 | { | 1435 | { |
1439 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1436 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1440 | 1437 | ||
1441 | if (isicom_paranoia_check(port, tty->name, "isicom_flush_chars")) | 1438 | if (isicom_paranoia_check(port, tty->name, "isicom_flush_chars")) |
1442 | return; | 1439 | return; |
1443 | 1440 | ||
1444 | if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || !port->xmit_buf) | 1441 | if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || !port->xmit_buf) |
1445 | return; | 1442 | return; |
1446 | 1443 | ||
1447 | /* this tells the transmitter to consider this port for | 1444 | /* this tells the transmitter to consider this port for |
1448 | data output to the card ... that's the best we can do. */ | 1445 | data output to the card ... that's the best we can do. */ |
1449 | port->status |= ISI_TXOK; | 1446 | port->status |= ISI_TXOK; |
1450 | } | 1447 | } |
1451 | 1448 | ||
1452 | /* write_room et all */ | 1449 | /* write_room et all */ |
1453 | static int isicom_write_room(struct tty_struct * tty) | 1450 | static int isicom_write_room(struct tty_struct *tty) |
1454 | { | 1451 | { |
1455 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1452 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1456 | int free; | 1453 | int free; |
1457 | 1454 | ||
1458 | if (isicom_paranoia_check(port, tty->name, "isicom_write_room")) | 1455 | if (isicom_paranoia_check(port, tty->name, "isicom_write_room")) |
1459 | return 0; | 1456 | return 0; |
1460 | 1457 | ||
1461 | free = SERIAL_XMIT_SIZE - port->xmit_cnt - 1; | 1458 | free = SERIAL_XMIT_SIZE - port->xmit_cnt - 1; |
1462 | if (free < 0) | 1459 | if (free < 0) |
1463 | free = 0; | 1460 | free = 0; |
@@ -1465,23 +1462,23 @@ static int isicom_write_room(struct tty_struct * tty) | |||
1465 | } | 1462 | } |
1466 | 1463 | ||
1467 | /* chars_in_buffer et all */ | 1464 | /* chars_in_buffer et all */ |
1468 | static int isicom_chars_in_buffer(struct tty_struct * tty) | 1465 | static int isicom_chars_in_buffer(struct tty_struct *tty) |
1469 | { | 1466 | { |
1470 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1467 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1471 | if (isicom_paranoia_check(port, tty->name, "isicom_chars_in_buffer")) | 1468 | if (isicom_paranoia_check(port, tty->name, "isicom_chars_in_buffer")) |
1472 | return 0; | 1469 | return 0; |
1473 | return port->xmit_cnt; | 1470 | return port->xmit_cnt; |
1474 | } | 1471 | } |
1475 | 1472 | ||
1476 | /* ioctl et all */ | 1473 | /* ioctl et all */ |
1477 | static inline void isicom_send_break(struct isi_port * port, unsigned long length) | 1474 | static inline void isicom_send_break(struct isi_port *port, unsigned long length) |
1478 | { | 1475 | { |
1479 | struct isi_board * card = port->card; | 1476 | struct isi_board *card = port->card; |
1480 | unsigned short base = card->base; | 1477 | unsigned short base = card->base; |
1481 | 1478 | ||
1482 | if(!lock_card(card)) | 1479 | if (!lock_card(card)) |
1483 | return; | 1480 | return; |
1484 | 1481 | ||
1485 | outw(0x8000 | ((port->channel) << (card->shift_count)) | 0x3, base); | 1482 | outw(0x8000 | ((port->channel) << (card->shift_count)) | 0x3, base); |
1486 | outw((length & 0xff) << 8 | 0x00, base); | 1483 | outw((length & 0xff) << 8 | 0x00, base); |
1487 | outw((length & 0xff00), base); | 1484 | outw((length & 0xff00), base); |
@@ -1492,13 +1489,13 @@ static inline void isicom_send_break(struct isi_port * port, unsigned long lengt | |||
1492 | 1489 | ||
1493 | static int isicom_tiocmget(struct tty_struct *tty, struct file *file) | 1490 | static int isicom_tiocmget(struct tty_struct *tty, struct file *file) |
1494 | { | 1491 | { |
1495 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1492 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1496 | /* just send the port status */ | 1493 | /* just send the port status */ |
1497 | unsigned short status = port->status; | 1494 | unsigned short status = port->status; |
1498 | 1495 | ||
1499 | if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) | 1496 | if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) |
1500 | return -ENODEV; | 1497 | return -ENODEV; |
1501 | 1498 | ||
1502 | return ((status & ISI_RTS) ? TIOCM_RTS : 0) | | 1499 | return ((status & ISI_RTS) ? TIOCM_RTS : 0) | |
1503 | ((status & ISI_DTR) ? TIOCM_DTR : 0) | | 1500 | ((status & ISI_DTR) ? TIOCM_DTR : 0) | |
1504 | ((status & ISI_DCD) ? TIOCM_CAR : 0) | | 1501 | ((status & ISI_DCD) ? TIOCM_CAR : 0) | |
@@ -1508,13 +1505,13 @@ static int isicom_tiocmget(struct tty_struct *tty, struct file *file) | |||
1508 | } | 1505 | } |
1509 | 1506 | ||
1510 | static int isicom_tiocmset(struct tty_struct *tty, struct file *file, | 1507 | static int isicom_tiocmset(struct tty_struct *tty, struct file *file, |
1511 | unsigned int set, unsigned int clear) | 1508 | unsigned int set, unsigned int clear) |
1512 | { | 1509 | { |
1513 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1510 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1514 | 1511 | ||
1515 | if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) | 1512 | if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) |
1516 | return -ENODEV; | 1513 | return -ENODEV; |
1517 | 1514 | ||
1518 | if (set & TIOCM_RTS) | 1515 | if (set & TIOCM_RTS) |
1519 | raise_rts(port); | 1516 | raise_rts(port); |
1520 | if (set & TIOCM_DTR) | 1517 | if (set & TIOCM_DTR) |
@@ -1526,46 +1523,46 @@ static int isicom_tiocmset(struct tty_struct *tty, struct file *file, | |||
1526 | drop_dtr(port); | 1523 | drop_dtr(port); |
1527 | 1524 | ||
1528 | return 0; | 1525 | return 0; |
1529 | } | 1526 | } |
1530 | 1527 | ||
1531 | static int isicom_set_serial_info(struct isi_port * port, | 1528 | static int isicom_set_serial_info(struct isi_port *port, |
1532 | struct serial_struct __user *info) | 1529 | struct serial_struct __user *info) |
1533 | { | 1530 | { |
1534 | struct serial_struct newinfo; | 1531 | struct serial_struct newinfo; |
1535 | int reconfig_port; | 1532 | int reconfig_port; |
1536 | 1533 | ||
1537 | if(copy_from_user(&newinfo, info, sizeof(newinfo))) | 1534 | if (copy_from_user(&newinfo, info, sizeof(newinfo))) |
1538 | return -EFAULT; | 1535 | return -EFAULT; |
1539 | 1536 | ||
1540 | reconfig_port = ((port->flags & ASYNC_SPD_MASK) != | 1537 | reconfig_port = ((port->flags & ASYNC_SPD_MASK) != |
1541 | (newinfo.flags & ASYNC_SPD_MASK)); | 1538 | (newinfo.flags & ASYNC_SPD_MASK)); |
1542 | 1539 | ||
1543 | if (!capable(CAP_SYS_ADMIN)) { | 1540 | if (!capable(CAP_SYS_ADMIN)) { |
1544 | if ((newinfo.close_delay != port->close_delay) || | 1541 | if ((newinfo.close_delay != port->close_delay) || |
1545 | (newinfo.closing_wait != port->closing_wait) || | 1542 | (newinfo.closing_wait != port->closing_wait) || |
1546 | ((newinfo.flags & ~ASYNC_USR_MASK) != | 1543 | ((newinfo.flags & ~ASYNC_USR_MASK) != |
1547 | (port->flags & ~ASYNC_USR_MASK))) | 1544 | (port->flags & ~ASYNC_USR_MASK))) |
1548 | return -EPERM; | 1545 | return -EPERM; |
1549 | port->flags = ((port->flags & ~ ASYNC_USR_MASK) | | 1546 | port->flags = ((port->flags & ~ ASYNC_USR_MASK) | |
1550 | (newinfo.flags & ASYNC_USR_MASK)); | 1547 | (newinfo.flags & ASYNC_USR_MASK)); |
1551 | } | 1548 | } |
1552 | else { | 1549 | else { |
1553 | port->close_delay = newinfo.close_delay; | 1550 | port->close_delay = newinfo.close_delay; |
1554 | port->closing_wait = newinfo.closing_wait; | 1551 | port->closing_wait = newinfo.closing_wait; |
1555 | port->flags = ((port->flags & ~ASYNC_FLAGS) | | 1552 | port->flags = ((port->flags & ~ASYNC_FLAGS) | |
1556 | (newinfo.flags & ASYNC_FLAGS)); | 1553 | (newinfo.flags & ASYNC_FLAGS)); |
1557 | } | 1554 | } |
1558 | if (reconfig_port) { | 1555 | if (reconfig_port) { |
1559 | isicom_config_port(port); | 1556 | isicom_config_port(port); |
1560 | } | 1557 | } |
1561 | return 0; | 1558 | return 0; |
1562 | } | 1559 | } |
1563 | 1560 | ||
1564 | static int isicom_get_serial_info(struct isi_port * port, | 1561 | static int isicom_get_serial_info(struct isi_port *port, |
1565 | struct serial_struct __user *info) | 1562 | struct serial_struct __user *info) |
1566 | { | 1563 | { |
1567 | struct serial_struct out_info; | 1564 | struct serial_struct out_info; |
1568 | 1565 | ||
1569 | memset(&out_info, 0, sizeof(out_info)); | 1566 | memset(&out_info, 0, sizeof(out_info)); |
1570 | /* out_info.type = ? */ | 1567 | /* out_info.type = ? */ |
1571 | out_info.line = port - isi_ports; | 1568 | out_info.line = port - isi_ports; |
@@ -1575,15 +1572,15 @@ static int isicom_get_serial_info(struct isi_port * port, | |||
1575 | /* out_info.baud_base = ? */ | 1572 | /* out_info.baud_base = ? */ |
1576 | out_info.close_delay = port->close_delay; | 1573 | out_info.close_delay = port->close_delay; |
1577 | out_info.closing_wait = port->closing_wait; | 1574 | out_info.closing_wait = port->closing_wait; |
1578 | if(copy_to_user(info, &out_info, sizeof(out_info))) | 1575 | if (copy_to_user(info, &out_info, sizeof(out_info))) |
1579 | return -EFAULT; | 1576 | return -EFAULT; |
1580 | return 0; | 1577 | return 0; |
1581 | } | 1578 | } |
1582 | 1579 | ||
1583 | static int isicom_ioctl(struct tty_struct * tty, struct file * filp, | 1580 | static int isicom_ioctl(struct tty_struct *tty, struct file *filp, |
1584 | unsigned int cmd, unsigned long arg) | 1581 | unsigned int cmd, unsigned long arg) |
1585 | { | 1582 | { |
1586 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1583 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1587 | void __user *argp = (void __user *)arg; | 1584 | void __user *argp = (void __user *)arg; |
1588 | int retval; | 1585 | int retval; |
1589 | 1586 | ||
@@ -1591,139 +1588,140 @@ static int isicom_ioctl(struct tty_struct * tty, struct file * filp, | |||
1591 | return -ENODEV; | 1588 | return -ENODEV; |
1592 | 1589 | ||
1593 | switch(cmd) { | 1590 | switch(cmd) { |
1594 | case TCSBRK: | 1591 | case TCSBRK: |
1595 | retval = tty_check_change(tty); | 1592 | retval = tty_check_change(tty); |
1596 | if (retval) | 1593 | if (retval) |
1597 | return retval; | 1594 | return retval; |
1598 | tty_wait_until_sent(tty, 0); | 1595 | tty_wait_until_sent(tty, 0); |
1599 | if (!arg) | 1596 | if (!arg) |
1600 | isicom_send_break(port, HZ/4); | 1597 | isicom_send_break(port, HZ/4); |
1601 | return 0; | 1598 | return 0; |
1602 | 1599 | ||
1603 | case TCSBRKP: | 1600 | case TCSBRKP: |
1604 | retval = tty_check_change(tty); | 1601 | retval = tty_check_change(tty); |
1605 | if (retval) | 1602 | if (retval) |
1606 | return retval; | 1603 | return retval; |
1607 | tty_wait_until_sent(tty, 0); | 1604 | tty_wait_until_sent(tty, 0); |
1608 | isicom_send_break(port, arg ? arg * (HZ/10) : HZ/4); | 1605 | isicom_send_break(port, arg ? arg * (HZ/10) : HZ/4); |
1609 | return 0; | 1606 | return 0; |
1610 | 1607 | ||
1611 | case TIOCGSOFTCAR: | 1608 | case TIOCGSOFTCAR: |
1612 | return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp); | 1609 | return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp); |
1613 | 1610 | ||
1614 | case TIOCSSOFTCAR: | 1611 | case TIOCSSOFTCAR: |
1615 | if(get_user(arg, (unsigned long __user *) argp)) | 1612 | if (get_user(arg, (unsigned long __user *) argp)) |
1616 | return -EFAULT; | 1613 | return -EFAULT; |
1617 | tty->termios->c_cflag = | 1614 | tty->termios->c_cflag = |
1618 | ((tty->termios->c_cflag & ~CLOCAL) | | 1615 | ((tty->termios->c_cflag & ~CLOCAL) | |
1619 | (arg ? CLOCAL : 0)); | 1616 | (arg ? CLOCAL : 0)); |
1620 | return 0; | 1617 | return 0; |
1621 | 1618 | ||
1622 | case TIOCGSERIAL: | 1619 | case TIOCGSERIAL: |
1623 | return isicom_get_serial_info(port, argp); | 1620 | return isicom_get_serial_info(port, argp); |
1624 | 1621 | ||
1625 | case TIOCSSERIAL: | 1622 | case TIOCSSERIAL: |
1626 | return isicom_set_serial_info(port, argp); | 1623 | return isicom_set_serial_info(port, argp); |
1627 | 1624 | ||
1628 | default: | 1625 | default: |
1629 | return -ENOIOCTLCMD; | 1626 | return -ENOIOCTLCMD; |
1630 | } | 1627 | } |
1631 | return 0; | 1628 | return 0; |
1632 | } | 1629 | } |
1633 | 1630 | ||
1634 | /* set_termios et all */ | 1631 | /* set_termios et all */ |
1635 | static void isicom_set_termios(struct tty_struct * tty, struct termios * old_termios) | 1632 | static void isicom_set_termios(struct tty_struct *tty, |
1633 | struct termios *old_termios) | ||
1636 | { | 1634 | { |
1637 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1635 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1638 | 1636 | ||
1639 | if (isicom_paranoia_check(port, tty->name, "isicom_set_termios")) | 1637 | if (isicom_paranoia_check(port, tty->name, "isicom_set_termios")) |
1640 | return; | 1638 | return; |
1641 | 1639 | ||
1642 | if (tty->termios->c_cflag == old_termios->c_cflag && | 1640 | if (tty->termios->c_cflag == old_termios->c_cflag && |
1643 | tty->termios->c_iflag == old_termios->c_iflag) | 1641 | tty->termios->c_iflag == old_termios->c_iflag) |
1644 | return; | 1642 | return; |
1645 | 1643 | ||
1646 | isicom_config_port(port); | 1644 | isicom_config_port(port); |
1647 | 1645 | ||
1648 | if ((old_termios->c_cflag & CRTSCTS) && | 1646 | if ((old_termios->c_cflag & CRTSCTS) && |
1649 | !(tty->termios->c_cflag & CRTSCTS)) { | 1647 | !(tty->termios->c_cflag & CRTSCTS)) { |
1650 | tty->hw_stopped = 0; | 1648 | tty->hw_stopped = 0; |
1651 | isicom_start(tty); | 1649 | isicom_start(tty); |
1652 | } | 1650 | } |
1653 | } | 1651 | } |
1654 | 1652 | ||
1655 | /* throttle et all */ | 1653 | /* throttle et all */ |
1656 | static void isicom_throttle(struct tty_struct * tty) | 1654 | static void isicom_throttle(struct tty_struct *tty) |
1657 | { | 1655 | { |
1658 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1656 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1659 | struct isi_board * card = port->card; | 1657 | struct isi_board *card = port->card; |
1660 | 1658 | ||
1661 | if (isicom_paranoia_check(port, tty->name, "isicom_throttle")) | 1659 | if (isicom_paranoia_check(port, tty->name, "isicom_throttle")) |
1662 | return; | 1660 | return; |
1663 | 1661 | ||
1664 | /* tell the card that this port cannot handle any more data for now */ | 1662 | /* tell the card that this port cannot handle any more data for now */ |
1665 | card->port_status &= ~(1 << port->channel); | 1663 | card->port_status &= ~(1 << port->channel); |
1666 | outw(card->port_status, card->base + 0x02); | 1664 | outw(card->port_status, card->base + 0x02); |
1667 | } | 1665 | } |
1668 | 1666 | ||
1669 | /* unthrottle et all */ | 1667 | /* unthrottle et all */ |
1670 | static void isicom_unthrottle(struct tty_struct * tty) | 1668 | static void isicom_unthrottle(struct tty_struct *tty) |
1671 | { | 1669 | { |
1672 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1670 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1673 | struct isi_board * card = port->card; | 1671 | struct isi_board *card = port->card; |
1674 | 1672 | ||
1675 | if (isicom_paranoia_check(port, tty->name, "isicom_unthrottle")) | 1673 | if (isicom_paranoia_check(port, tty->name, "isicom_unthrottle")) |
1676 | return; | 1674 | return; |
1677 | 1675 | ||
1678 | /* tell the card that this port is ready to accept more data */ | 1676 | /* tell the card that this port is ready to accept more data */ |
1679 | card->port_status |= (1 << port->channel); | 1677 | card->port_status |= (1 << port->channel); |
1680 | outw(card->port_status, card->base + 0x02); | 1678 | outw(card->port_status, card->base + 0x02); |
1681 | } | 1679 | } |
1682 | 1680 | ||
1683 | /* stop et all */ | 1681 | /* stop et all */ |
1684 | static void isicom_stop(struct tty_struct * tty) | 1682 | static void isicom_stop(struct tty_struct *tty) |
1685 | { | 1683 | { |
1686 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1684 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1687 | 1685 | ||
1688 | if (isicom_paranoia_check(port, tty->name, "isicom_stop")) | 1686 | if (isicom_paranoia_check(port, tty->name, "isicom_stop")) |
1689 | return; | 1687 | return; |
1690 | 1688 | ||
1691 | /* this tells the transmitter not to consider this port for | 1689 | /* this tells the transmitter not to consider this port for |
1692 | data output to the card. */ | 1690 | data output to the card. */ |
1693 | port->status &= ~ISI_TXOK; | 1691 | port->status &= ~ISI_TXOK; |
1694 | } | 1692 | } |
1695 | 1693 | ||
1696 | /* start et all */ | 1694 | /* start et all */ |
1697 | static void isicom_start(struct tty_struct * tty) | 1695 | static void isicom_start(struct tty_struct *tty) |
1698 | { | 1696 | { |
1699 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1697 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1700 | 1698 | ||
1701 | if (isicom_paranoia_check(port, tty->name, "isicom_start")) | 1699 | if (isicom_paranoia_check(port, tty->name, "isicom_start")) |
1702 | return; | 1700 | return; |
1703 | 1701 | ||
1704 | /* this tells the transmitter to consider this port for | 1702 | /* this tells the transmitter to consider this port for |
1705 | data output to the card. */ | 1703 | data output to the card. */ |
1706 | port->status |= ISI_TXOK; | 1704 | port->status |= ISI_TXOK; |
1707 | } | 1705 | } |
1708 | 1706 | ||
1709 | /* hangup et all */ | 1707 | /* hangup et all */ |
1710 | static void do_isicom_hangup(void * data) | 1708 | static void do_isicom_hangup(void *data) |
1711 | { | 1709 | { |
1712 | struct isi_port * port = (struct isi_port *) data; | 1710 | struct isi_port *port = (struct isi_port *) data; |
1713 | struct tty_struct * tty; | 1711 | struct tty_struct *tty; |
1714 | 1712 | ||
1715 | tty = port->tty; | 1713 | tty = port->tty; |
1716 | if (tty) | 1714 | if (tty) |
1717 | tty_hangup(tty); | 1715 | tty_hangup(tty); |
1718 | } | 1716 | } |
1719 | 1717 | ||
1720 | static void isicom_hangup(struct tty_struct * tty) | 1718 | static void isicom_hangup(struct tty_struct *tty) |
1721 | { | 1719 | { |
1722 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1720 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1723 | 1721 | ||
1724 | if (isicom_paranoia_check(port, tty->name, "isicom_hangup")) | 1722 | if (isicom_paranoia_check(port, tty->name, "isicom_hangup")) |
1725 | return; | 1723 | return; |
1726 | 1724 | ||
1727 | isicom_shutdown_port(port); | 1725 | isicom_shutdown_port(port); |
1728 | port->count = 0; | 1726 | port->count = 0; |
1729 | port->flags &= ~ASYNC_NORMAL_ACTIVE; | 1727 | port->flags &= ~ASYNC_NORMAL_ACTIVE; |
@@ -1732,19 +1730,19 @@ static void isicom_hangup(struct tty_struct * tty) | |||
1732 | } | 1730 | } |
1733 | 1731 | ||
1734 | /* flush_buffer et all */ | 1732 | /* flush_buffer et all */ |
1735 | static void isicom_flush_buffer(struct tty_struct * tty) | 1733 | static void isicom_flush_buffer(struct tty_struct *tty) |
1736 | { | 1734 | { |
1737 | struct isi_port * port = (struct isi_port *) tty->driver_data; | 1735 | struct isi_port *port = (struct isi_port *) tty->driver_data; |
1738 | struct isi_board * card = port->card; | 1736 | struct isi_board *card = port->card; |
1739 | unsigned long flags; | 1737 | unsigned long flags; |
1740 | 1738 | ||
1741 | if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer")) | 1739 | if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer")) |
1742 | return; | 1740 | return; |
1743 | 1741 | ||
1744 | spin_lock_irqsave(&card->card_lock, flags); | 1742 | spin_lock_irqsave(&card->card_lock, flags); |
1745 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; | 1743 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; |
1746 | spin_unlock_irqrestore(&card->card_lock, flags); | 1744 | spin_unlock_irqrestore(&card->card_lock, flags); |
1747 | 1745 | ||
1748 | wake_up_interruptible(&tty->write_wait); | 1746 | wake_up_interruptible(&tty->write_wait); |
1749 | tty_wakeup(tty); | 1747 | tty_wakeup(tty); |
1750 | } | 1748 | } |
@@ -1768,33 +1766,33 @@ static int __devinit register_ioregion(void) | |||
1768 | static void unregister_ioregion(void) | 1766 | static void unregister_ioregion(void) |
1769 | { | 1767 | { |
1770 | int count; | 1768 | int count; |
1771 | for (count=0; count < BOARD_COUNT; count++ ) | 1769 | for (count=0; count < BOARD_COUNT; count++ ) |
1772 | if (isi_card[count].base) { | 1770 | if (isi_card[count].base) { |
1773 | release_region(isi_card[count].base,16); | 1771 | release_region(isi_card[count].base,16); |
1774 | #ifdef ISICOM_DEBUG | 1772 | #ifdef ISICOM_DEBUG |
1775 | printk(KERN_DEBUG "ISICOM: I/O Region 0x%x-0x%x released for Card%d.\n",isi_card[count].base,isi_card[count].base+15,count+1); | 1773 | printk(KERN_DEBUG "ISICOM: I/O Region 0x%x-0x%x released for Card%d.\n",isi_card[count].base,isi_card[count].base+15,count+1); |
1776 | #endif | 1774 | #endif |
1777 | } | 1775 | } |
1778 | } | 1776 | } |
1779 | 1777 | ||
1780 | static struct tty_operations isicom_ops = { | 1778 | static struct tty_operations isicom_ops = { |
1781 | .open = isicom_open, | 1779 | .open = isicom_open, |
1782 | .close = isicom_close, | 1780 | .close = isicom_close, |
1783 | .write = isicom_write, | 1781 | .write = isicom_write, |
1784 | .put_char = isicom_put_char, | 1782 | .put_char = isicom_put_char, |
1785 | .flush_chars = isicom_flush_chars, | 1783 | .flush_chars = isicom_flush_chars, |
1786 | .write_room = isicom_write_room, | 1784 | .write_room = isicom_write_room, |
1787 | .chars_in_buffer = isicom_chars_in_buffer, | 1785 | .chars_in_buffer = isicom_chars_in_buffer, |
1788 | .ioctl = isicom_ioctl, | 1786 | .ioctl = isicom_ioctl, |
1789 | .set_termios = isicom_set_termios, | 1787 | .set_termios = isicom_set_termios, |
1790 | .throttle = isicom_throttle, | 1788 | .throttle = isicom_throttle, |
1791 | .unthrottle = isicom_unthrottle, | 1789 | .unthrottle = isicom_unthrottle, |
1792 | .stop = isicom_stop, | 1790 | .stop = isicom_stop, |
1793 | .start = isicom_start, | 1791 | .start = isicom_start, |
1794 | .hangup = isicom_hangup, | 1792 | .hangup = isicom_hangup, |
1795 | .flush_buffer = isicom_flush_buffer, | 1793 | .flush_buffer = isicom_flush_buffer, |
1796 | .tiocmget = isicom_tiocmget, | 1794 | .tiocmget = isicom_tiocmget, |
1797 | .tiocmset = isicom_tiocmset, | 1795 | .tiocmset = isicom_tiocmset, |
1798 | }; | 1796 | }; |
1799 | 1797 | ||
1800 | static int __devinit register_drivers(void) | 1798 | static int __devinit register_drivers(void) |
@@ -1814,11 +1812,11 @@ static int __devinit register_drivers(void) | |||
1814 | isicom_normal->type = TTY_DRIVER_TYPE_SERIAL; | 1812 | isicom_normal->type = TTY_DRIVER_TYPE_SERIAL; |
1815 | isicom_normal->subtype = SERIAL_TYPE_NORMAL; | 1813 | isicom_normal->subtype = SERIAL_TYPE_NORMAL; |
1816 | isicom_normal->init_termios = tty_std_termios; | 1814 | isicom_normal->init_termios = tty_std_termios; |
1817 | isicom_normal->init_termios.c_cflag = | 1815 | isicom_normal->init_termios.c_cflag = |
1818 | B9600 | CS8 | CREAD | HUPCL |CLOCAL; | 1816 | B9600 | CS8 | CREAD | HUPCL |CLOCAL; |
1819 | isicom_normal->flags = TTY_DRIVER_REAL_RAW; | 1817 | isicom_normal->flags = TTY_DRIVER_REAL_RAW; |
1820 | tty_set_operations(isicom_normal, &isicom_ops); | 1818 | tty_set_operations(isicom_normal, &isicom_ops); |
1821 | 1819 | ||
1822 | if ((error=tty_register_driver(isicom_normal))!=0) { | 1820 | if ((error=tty_register_driver(isicom_normal))!=0) { |
1823 | printk(KERN_DEBUG "ISICOM: Couldn't register the dialin driver, error=%d\n", | 1821 | printk(KERN_DEBUG "ISICOM: Couldn't register the dialin driver, error=%d\n", |
1824 | error); | 1822 | error); |
@@ -1843,13 +1841,13 @@ static int __devinit register_isr(void) | |||
1843 | 1841 | ||
1844 | for (count=0; count < BOARD_COUNT; count++ ) { | 1842 | for (count=0; count < BOARD_COUNT; count++ ) { |
1845 | if (isi_card[count].base) { | 1843 | if (isi_card[count].base) { |
1846 | irqflags = (isi_card[count].isa == YES) ? | 1844 | irqflags = (isi_card[count].isa == YES) ? |
1847 | SA_INTERRUPT : | 1845 | SA_INTERRUPT : |
1848 | (SA_INTERRUPT | SA_SHIRQ); | 1846 | (SA_INTERRUPT | SA_SHIRQ); |
1849 | 1847 | ||
1850 | if (request_irq(isi_card[count].irq, | 1848 | if (request_irq(isi_card[count].irq, |
1851 | isicom_interrupt, | 1849 | isicom_interrupt, |
1852 | irqflags, | 1850 | irqflags, |
1853 | ISICOM_NAME, &isi_card[count])) { | 1851 | ISICOM_NAME, &isi_card[count])) { |
1854 | 1852 | ||
1855 | printk(KERN_WARNING "ISICOM: Could not" | 1853 | printk(KERN_WARNING "ISICOM: Could not" |
@@ -1862,7 +1860,7 @@ static int __devinit register_isr(void) | |||
1862 | } | 1860 | } |
1863 | else | 1861 | else |
1864 | done++; | 1862 | done++; |
1865 | } | 1863 | } |
1866 | } | 1864 | } |
1867 | return done; | 1865 | return done; |
1868 | } | 1866 | } |
@@ -1880,42 +1878,42 @@ static void __exit unregister_isr(void) | |||
1880 | static int __devinit isicom_init(void) | 1878 | static int __devinit isicom_init(void) |
1881 | { | 1879 | { |
1882 | int card, channel, base; | 1880 | int card, channel, base; |
1883 | struct isi_port * port; | 1881 | struct isi_port *port; |
1884 | unsigned long page; | 1882 | unsigned long page; |
1885 | 1883 | ||
1886 | if (!tmp_buf) { | 1884 | if (!tmp_buf) { |
1887 | page = get_zeroed_page(GFP_KERNEL); | 1885 | page = get_zeroed_page(GFP_KERNEL); |
1888 | if (!page) { | 1886 | if (!page) { |
1889 | #ifdef ISICOM_DEBUG | 1887 | #ifdef ISICOM_DEBUG |
1890 | printk(KERN_DEBUG "ISICOM: Couldn't allocate page for tmp_buf.\n"); | 1888 | printk(KERN_DEBUG "ISICOM: Couldn't allocate page for tmp_buf.\n"); |
1891 | #else | 1889 | #else |
1892 | printk(KERN_ERR "ISICOM: Not enough memory...\n"); | 1890 | printk(KERN_ERR "ISICOM: Not enough memory...\n"); |
1893 | #endif | 1891 | #endif |
1894 | return 0; | 1892 | return 0; |
1895 | } | 1893 | } |
1896 | tmp_buf = (unsigned char *) page; | 1894 | tmp_buf = (unsigned char *) page; |
1897 | } | 1895 | } |
1898 | 1896 | ||
1899 | if (!register_ioregion()) | 1897 | if (!register_ioregion()) |
1900 | { | 1898 | { |
1901 | printk(KERN_ERR "ISICOM: All required I/O space found busy.\n"); | 1899 | printk(KERN_ERR "ISICOM: All required I/O space found busy.\n"); |
1902 | free_page((unsigned long)tmp_buf); | 1900 | free_page((unsigned long)tmp_buf); |
1903 | return 0; | 1901 | return 0; |
1904 | } | 1902 | } |
1905 | if (register_drivers()) | 1903 | if (register_drivers()) |
1906 | { | 1904 | { |
1907 | unregister_ioregion(); | 1905 | unregister_ioregion(); |
1908 | free_page((unsigned long)tmp_buf); | 1906 | free_page((unsigned long)tmp_buf); |
1909 | return 0; | 1907 | return 0; |
1910 | } | 1908 | } |
1911 | if (!register_isr()) | 1909 | if (!register_isr()) |
1912 | { | 1910 | { |
1913 | unregister_drivers(); | 1911 | unregister_drivers(); |
1914 | /* ioports already uregistered in register_isr */ | 1912 | /* ioports already uregistered in register_isr */ |
1915 | free_page((unsigned long)tmp_buf); | 1913 | free_page((unsigned long)tmp_buf); |
1916 | return 0; | 1914 | return 0; |
1917 | } | 1915 | } |
1918 | 1916 | ||
1919 | memset(isi_ports, 0, sizeof(isi_ports)); | 1917 | memset(isi_ports, 0, sizeof(isi_ports)); |
1920 | for (card = 0; card < BOARD_COUNT; card++) { | 1918 | for (card = 0; card < BOARD_COUNT; card++) { |
1921 | port = &isi_ports[card * 16]; | 1919 | port = &isi_ports[card * 16]; |
@@ -1926,24 +1924,24 @@ static int __devinit isicom_init(void) | |||
1926 | port->magic = ISICOM_MAGIC; | 1924 | port->magic = ISICOM_MAGIC; |
1927 | port->card = &isi_card[card]; | 1925 | port->card = &isi_card[card]; |
1928 | port->channel = channel; | 1926 | port->channel = channel; |
1929 | port->close_delay = 50 * HZ/100; | 1927 | port->close_delay = 50 * HZ/100; |
1930 | port->closing_wait = 3000 * HZ/100; | 1928 | port->closing_wait = 3000 * HZ/100; |
1931 | INIT_WORK(&port->hangup_tq, do_isicom_hangup, port); | 1929 | INIT_WORK(&port->hangup_tq, do_isicom_hangup, port); |
1932 | INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port); | 1930 | INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port); |
1933 | port->status = 0; | 1931 | port->status = 0; |
1934 | init_waitqueue_head(&port->open_wait); | 1932 | init_waitqueue_head(&port->open_wait); |
1935 | init_waitqueue_head(&port->close_wait); | 1933 | init_waitqueue_head(&port->close_wait); |
1936 | /* . . . */ | 1934 | /* . . . */ |
1937 | } | 1935 | } |
1938 | } | 1936 | } |
1939 | 1937 | ||
1940 | return 1; | 1938 | return 1; |
1941 | } | 1939 | } |
1942 | 1940 | ||
1943 | /* | 1941 | /* |
1944 | * Insmod can set static symbols so keep these static | 1942 | * Insmod can set static symbols so keep these static |
1945 | */ | 1943 | */ |
1946 | 1944 | ||
1947 | static int io[4]; | 1945 | static int io[4]; |
1948 | static int irq[4]; | 1946 | static int irq[4]; |
1949 | 1947 | ||
@@ -1961,9 +1959,9 @@ static int __devinit isicom_setup(void) | |||
1961 | int retval, card, idx, count; | 1959 | int retval, card, idx, count; |
1962 | unsigned char pciirq; | 1960 | unsigned char pciirq; |
1963 | unsigned int ioaddr; | 1961 | unsigned int ioaddr; |
1964 | 1962 | ||
1965 | card = 0; | 1963 | card = 0; |
1966 | for(idx=0; idx < BOARD_COUNT; idx++) { | 1964 | for (idx=0; idx < BOARD_COUNT; idx++) { |
1967 | if (io[idx]) { | 1965 | if (io[idx]) { |
1968 | isi_card[idx].base=io[idx]; | 1966 | isi_card[idx].base=io[idx]; |
1969 | isi_card[idx].irq=irq[idx]; | 1967 | isi_card[idx].irq=irq[idx]; |
@@ -1975,23 +1973,23 @@ static int __devinit isicom_setup(void) | |||
1975 | isi_card[idx].irq = 0; | 1973 | isi_card[idx].irq = 0; |
1976 | } | 1974 | } |
1977 | } | 1975 | } |
1978 | 1976 | ||
1979 | for (idx=0 ;idx < card; idx++) { | 1977 | for (idx=0 ;idx < card; idx++) { |
1980 | if (!((isi_card[idx].irq==2)||(isi_card[idx].irq==3)|| | 1978 | if (!((isi_card[idx].irq==2)||(isi_card[idx].irq==3)|| |
1981 | (isi_card[idx].irq==4)||(isi_card[idx].irq==5)|| | 1979 | (isi_card[idx].irq==4)||(isi_card[idx].irq==5)|| |
1982 | (isi_card[idx].irq==7)||(isi_card[idx].irq==10)|| | 1980 | (isi_card[idx].irq==7)||(isi_card[idx].irq==10)|| |
1983 | (isi_card[idx].irq==11)||(isi_card[idx].irq==12)|| | 1981 | (isi_card[idx].irq==11)||(isi_card[idx].irq==12)|| |
1984 | (isi_card[idx].irq==15))) { | 1982 | (isi_card[idx].irq==15))) { |
1985 | 1983 | ||
1986 | if (isi_card[idx].base) { | 1984 | if (isi_card[idx].base) { |
1987 | printk(KERN_ERR "ISICOM: Irq %d unsupported. Disabling Card%d...\n", | 1985 | printk(KERN_ERR "ISICOM: Irq %d unsupported. Disabling Card%d...\n", |
1988 | isi_card[idx].irq, idx+1); | 1986 | isi_card[idx].irq, idx+1); |
1989 | isi_card[idx].base=0; | 1987 | isi_card[idx].base=0; |
1990 | card--; | 1988 | card--; |
1991 | } | 1989 | } |
1992 | } | 1990 | } |
1993 | } | 1991 | } |
1994 | 1992 | ||
1995 | if (card < BOARD_COUNT) { | 1993 | if (card < BOARD_COUNT) { |
1996 | for (idx=0; idx < DEVID_COUNT; idx++) { | 1994 | for (idx=0; idx < DEVID_COUNT; idx++) { |
1997 | dev = NULL; | 1995 | dev = NULL; |
@@ -2000,21 +1998,22 @@ static int __devinit isicom_setup(void) | |||
2000 | break; | 1998 | break; |
2001 | if (card >= BOARD_COUNT) | 1999 | if (card >= BOARD_COUNT) |
2002 | break; | 2000 | break; |
2003 | 2001 | ||
2004 | if (pci_enable_device(dev)) | 2002 | if (pci_enable_device(dev)) |
2005 | break; | 2003 | break; |
2006 | 2004 | ||
2007 | /* found a PCI ISI card! */ | 2005 | /* found a PCI ISI card! */ |
2008 | ioaddr = pci_resource_start (dev, 3); /* i.e at offset 0x1c in the | 2006 | ioaddr = pci_resource_start (dev, 3); |
2009 | * PCI configuration register | 2007 | /* i.e at offset 0x1c in the |
2010 | * space. | 2008 | * PCI configuration register |
2011 | */ | 2009 | * space. |
2010 | */ | ||
2012 | pciirq = dev->irq; | 2011 | pciirq = dev->irq; |
2013 | printk(KERN_INFO "ISI PCI Card(Device ID 0x%x)\n", isicom_pci_tbl[idx].device); | 2012 | printk(KERN_INFO "ISI PCI Card(Device ID 0x%x)\n", isicom_pci_tbl[idx].device); |
2014 | /* | 2013 | /* |
2015 | * allot the first empty slot in the array | 2014 | * allot the first empty slot in the array |
2016 | */ | 2015 | */ |
2017 | for (count=0; count < BOARD_COUNT; count++) { | 2016 | for (count=0; count < BOARD_COUNT; count++) { |
2018 | if (isi_card[count].base == 0) { | 2017 | if (isi_card[count].base == 0) { |
2019 | isi_card[count].base = ioaddr; | 2018 | isi_card[count].base = ioaddr; |
2020 | isi_card[count].irq = pciirq; | 2019 | isi_card[count].irq = pciirq; |
@@ -2023,35 +2022,35 @@ static int __devinit isicom_setup(void) | |||
2023 | break; | 2022 | break; |
2024 | } | 2023 | } |
2025 | } | 2024 | } |
2026 | } | 2025 | } |
2027 | if (card >= BOARD_COUNT) break; | 2026 | if (card >= BOARD_COUNT) break; |
2028 | } | 2027 | } |
2029 | } | 2028 | } |
2030 | 2029 | ||
2031 | if (!(isi_card[0].base || isi_card[1].base || isi_card[2].base || isi_card[3].base)) { | 2030 | if (!(isi_card[0].base || isi_card[1].base || isi_card[2].base || isi_card[3].base)) { |
2032 | printk(KERN_ERR "ISICOM: No valid card configuration. Driver cannot be initialized...\n"); | 2031 | printk(KERN_ERR "ISICOM: No valid card configuration. Driver cannot be initialized...\n"); |
2033 | return -EIO; | 2032 | return -EIO; |
2034 | } | 2033 | } |
2035 | 2034 | ||
2036 | retval = misc_register(&isiloader_device); | 2035 | retval = misc_register(&isiloader_device); |
2037 | if (retval < 0) { | 2036 | if (retval < 0) { |
2038 | printk(KERN_ERR "ISICOM: Unable to register firmware loader driver.\n"); | 2037 | printk(KERN_ERR "ISICOM: Unable to register firmware loader driver.\n"); |
2039 | return retval; | 2038 | return retval; |
2040 | } | 2039 | } |
2041 | 2040 | ||
2042 | if (!isicom_init()) { | 2041 | if (!isicom_init()) { |
2043 | if (misc_deregister(&isiloader_device)) | 2042 | if (misc_deregister(&isiloader_device)) |
2044 | printk(KERN_ERR "ISICOM: Unable to unregister Firmware Loader driver\n"); | 2043 | printk(KERN_ERR "ISICOM: Unable to unregister Firmware Loader driver\n"); |
2045 | return -EIO; | 2044 | return -EIO; |
2046 | } | 2045 | } |
2047 | 2046 | ||
2048 | init_timer(&tx); | 2047 | init_timer(&tx); |
2049 | tx.expires = jiffies + 1; | 2048 | tx.expires = jiffies + 1; |
2050 | tx.data = 0; | 2049 | tx.data = 0; |
2051 | tx.function = isicom_tx; | 2050 | tx.function = isicom_tx; |
2052 | re_schedule = 1; | 2051 | re_schedule = 1; |
2053 | add_timer(&tx); | 2052 | add_timer(&tx); |
2054 | 2053 | ||
2055 | return 0; | 2054 | return 0; |
2056 | } | 2055 | } |
2057 | 2056 | ||
@@ -2062,8 +2061,8 @@ static void __exit isicom_exit(void) | |||
2062 | msleep(1000); | 2061 | msleep(1000); |
2063 | unregister_isr(); | 2062 | unregister_isr(); |
2064 | unregister_drivers(); | 2063 | unregister_drivers(); |
2065 | unregister_ioregion(); | 2064 | unregister_ioregion(); |
2066 | if(tmp_buf) | 2065 | if (tmp_buf) |
2067 | free_page((unsigned long)tmp_buf); | 2066 | free_page((unsigned long)tmp_buf); |
2068 | if (misc_deregister(&isiloader_device)) | 2067 | if (misc_deregister(&isiloader_device)) |
2069 | printk(KERN_ERR "ISICOM: Unable to unregister Firmware Loader driver\n"); | 2068 | printk(KERN_ERR "ISICOM: Unable to unregister Firmware Loader driver\n"); |