Lines Matching full:raw

143 static void raw3215_mk_read_req(struct raw3215_info *raw)  in raw3215_mk_read_req()  argument
149 req = raw->queued_read; in raw3215_mk_read_req()
154 req->info = raw; in raw3215_mk_read_req()
155 raw->queued_read = req; in raw3215_mk_read_req()
162 ccw->cda = (__u32) __pa(raw->inbuf); in raw3215_mk_read_req()
171 static void raw3215_mk_write_req(struct raw3215_info *raw) in raw3215_mk_write_req() argument
177 if (raw->count <= raw->written) in raw3215_mk_write_req()
180 req = raw->queued_write; in raw3215_mk_write_req()
185 req->info = raw; in raw3215_mk_write_req()
186 raw->queued_write = req; in raw3215_mk_write_req()
188 raw->written -= req->len; in raw3215_mk_write_req()
192 req->start = (raw->head - raw->count + raw->written) & in raw3215_mk_write_req()
201 while (lines < RAW3215_MAX_NEWLINE && ix != raw->head) { in raw3215_mk_write_req()
202 if (raw->buffer[ix] == 0x15) in raw3215_mk_write_req()
210 raw->written += len; in raw3215_mk_write_req()
213 req->delayable = (ix == raw->head) && (len < RAW3215_MIN_WRITE); in raw3215_mk_write_req()
222 (__u32) __pa(raw->buffer + ix); in raw3215_mk_write_req()
247 static void raw3215_start_io(struct raw3215_info *raw) in raw3215_start_io() argument
252 req = raw->queued_read; in raw3215_start_io()
254 !(raw->flags & (RAW3215_WORKING | RAW3215_THROTTLED))) { in raw3215_start_io()
256 raw->queued_read = NULL; in raw3215_start_io()
257 res = ccw_device_start(raw->cdev, req->ccws, in raw3215_start_io()
261 raw->queued_read = req; in raw3215_start_io()
263 raw->flags |= RAW3215_WORKING; in raw3215_start_io()
266 req = raw->queued_write; in raw3215_start_io()
268 !(raw->flags & (RAW3215_WORKING | RAW3215_STOPPED))) { in raw3215_start_io()
270 raw->queued_write = NULL; in raw3215_start_io()
271 res = ccw_device_start(raw->cdev, req->ccws, in raw3215_start_io()
275 raw->queued_write = req; in raw3215_start_io()
277 raw->flags |= RAW3215_WORKING; in raw3215_start_io()
287 struct raw3215_info *raw = from_timer(raw, t, timer); in raw3215_timeout() local
290 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_timeout()
291 raw->flags &= ~RAW3215_TIMER_RUNS; in raw3215_timeout()
292 raw3215_mk_write_req(raw); in raw3215_timeout()
293 raw3215_start_io(raw); in raw3215_timeout()
294 if ((raw->queued_read || raw->queued_write) && in raw3215_timeout()
295 !(raw->flags & RAW3215_WORKING) && in raw3215_timeout()
296 !(raw->flags & RAW3215_TIMER_RUNS)) { in raw3215_timeout()
297 raw->timer.expires = RAW3215_TIMEOUT + jiffies; in raw3215_timeout()
298 add_timer(&raw->timer); in raw3215_timeout()
299 raw->flags |= RAW3215_TIMER_RUNS; in raw3215_timeout()
301 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_timeout()
310 static inline void raw3215_try_io(struct raw3215_info *raw) in raw3215_try_io() argument
312 if (!tty_port_initialized(&raw->port)) in raw3215_try_io()
314 if (raw->queued_read != NULL) in raw3215_try_io()
315 raw3215_start_io(raw); in raw3215_try_io()
316 else if (raw->queued_write != NULL) { in raw3215_try_io()
317 if ((raw->queued_write->delayable == 0) || in raw3215_try_io()
318 (raw->flags & RAW3215_FLUSHING)) { in raw3215_try_io()
320 raw3215_start_io(raw); in raw3215_try_io()
323 if ((raw->queued_read || raw->queued_write) && in raw3215_try_io()
324 !(raw->flags & RAW3215_WORKING) && in raw3215_try_io()
325 !(raw->flags & RAW3215_TIMER_RUNS)) { in raw3215_try_io()
326 raw->timer.expires = RAW3215_TIMEOUT + jiffies; in raw3215_try_io()
327 add_timer(&raw->timer); in raw3215_try_io()
328 raw->flags |= RAW3215_TIMER_RUNS; in raw3215_try_io()
335 static void raw3215_next_io(struct raw3215_info *raw, struct tty_struct *tty) in raw3215_next_io() argument
337 raw3215_mk_write_req(raw); in raw3215_next_io()
338 raw3215_try_io(raw); in raw3215_next_io()
339 if (tty && RAW3215_BUFFER_SIZE - raw->count >= RAW3215_MIN_SPACE) in raw3215_next_io()
349 struct raw3215_info *raw; in raw3215_irq() local
355 raw = dev_get_drvdata(&cdev->dev); in raw3215_irq()
357 tty = tty_port_tty_get(&raw->port); in raw3215_irq()
361 raw3215_next_io(raw, tty); in raw3215_irq()
370 raw3215_mk_read_req(raw); in raw3215_irq()
371 raw3215_next_io(raw, tty); in raw3215_irq()
376 if ((raw = req->info) == NULL) in raw3215_irq()
387 if ((raw = req->info) == NULL) in raw3215_irq()
393 EBCASC(raw->inbuf, count); in raw3215_irq()
394 cchar = ctrlchar_handle(raw->inbuf, count, tty); in raw3215_irq()
400 tty_insert_flip_char(&raw->port, cchar, in raw3215_irq()
402 tty_flip_buffer_push(&raw->port); in raw3215_irq()
407 (strncmp(raw->inbuf+count-2, "\252n", 2) && in raw3215_irq()
408 strncmp(raw->inbuf+count-2, "^n", 2)) ) { in raw3215_irq()
410 raw->inbuf[count] = '\n'; in raw3215_irq()
414 tty_insert_flip_string(&raw->port, raw->inbuf, in raw3215_irq()
416 tty_flip_buffer_push(&raw->port); in raw3215_irq()
420 raw->count -= req->len; in raw3215_irq()
421 raw->written -= req->len; in raw3215_irq()
423 raw->flags &= ~RAW3215_WORKING; in raw3215_irq()
426 if (waitqueue_active(&raw->empty_wait) && in raw3215_irq()
427 raw->queued_write == NULL && in raw3215_irq()
428 raw->queued_read == NULL) { in raw3215_irq()
429 wake_up_interruptible(&raw->empty_wait); in raw3215_irq()
431 raw3215_next_io(raw, tty); in raw3215_irq()
437 raw->count -= req->len; in raw3215_irq()
438 raw->written -= req->len; in raw3215_irq()
440 raw->flags &= ~RAW3215_WORKING; in raw3215_irq()
443 raw3215_next_io(raw, tty); in raw3215_irq()
454 static void raw3215_make_room(struct raw3215_info *raw, unsigned int length) in raw3215_make_room() argument
456 while (RAW3215_BUFFER_SIZE - raw->count < length) { in raw3215_make_room()
458 raw->flags |= RAW3215_FLUSHING; in raw3215_make_room()
459 raw3215_mk_write_req(raw); in raw3215_make_room()
460 raw3215_try_io(raw); in raw3215_make_room()
461 raw->flags &= ~RAW3215_FLUSHING; in raw3215_make_room()
463 ccw_device_wait_idle(raw->cdev); in raw3215_make_room()
466 if (RAW3215_BUFFER_SIZE - raw->count >= length) in raw3215_make_room()
469 spin_unlock(get_ccwdev_lock(raw->cdev)); in raw3215_make_room()
471 spin_lock(get_ccwdev_lock(raw->cdev)); in raw3215_make_room()
478 static void raw3215_write(struct raw3215_info *raw, const char *str, in raw3215_write() argument
485 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_write()
490 raw3215_make_room(raw, count); in raw3215_write()
495 min(RAW3215_BUFFER_SIZE - raw->count, in raw3215_write()
496 RAW3215_BUFFER_SIZE - raw->head)); in raw3215_write()
499 memcpy(raw->buffer + raw->head, str, c); in raw3215_write()
500 ASCEBC(raw->buffer + raw->head, c); in raw3215_write()
501 raw->head = (raw->head + c) & (RAW3215_BUFFER_SIZE - 1); in raw3215_write()
502 raw->count += c; in raw3215_write()
503 raw->line_pos += c; in raw3215_write()
507 if (!(raw->flags & RAW3215_WORKING)) { in raw3215_write()
508 raw3215_mk_write_req(raw); in raw3215_write()
510 raw3215_try_io(raw); in raw3215_write()
512 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_write()
519 static void raw3215_putchar(struct raw3215_info *raw, unsigned char ch) in raw3215_putchar() argument
524 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_putchar()
526 length = TAB_STOP_SIZE - (raw->line_pos%TAB_STOP_SIZE); in raw3215_putchar()
527 raw->line_pos += length; in raw3215_putchar()
531 raw->line_pos = 0; in raw3215_putchar()
534 raw->line_pos++; in raw3215_putchar()
536 raw3215_make_room(raw, length); in raw3215_putchar()
539 raw->buffer[raw->head] = (char) _ascebc[(int) ch]; in raw3215_putchar()
540 raw->head = (raw->head + 1) & (RAW3215_BUFFER_SIZE - 1); in raw3215_putchar()
541 raw->count++; in raw3215_putchar()
543 if (!(raw->flags & RAW3215_WORKING)) { in raw3215_putchar()
544 raw3215_mk_write_req(raw); in raw3215_putchar()
546 raw3215_try_io(raw); in raw3215_putchar()
548 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_putchar()
555 static void raw3215_flush_buffer(struct raw3215_info *raw) in raw3215_flush_buffer() argument
559 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_flush_buffer()
560 if (raw->count > 0) { in raw3215_flush_buffer()
561 raw->flags |= RAW3215_FLUSHING; in raw3215_flush_buffer()
562 raw3215_try_io(raw); in raw3215_flush_buffer()
563 raw->flags &= ~RAW3215_FLUSHING; in raw3215_flush_buffer()
565 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_flush_buffer()
571 static int raw3215_startup(struct raw3215_info *raw) in raw3215_startup() argument
575 if (tty_port_initialized(&raw->port)) in raw3215_startup()
577 raw->line_pos = 0; in raw3215_startup()
578 tty_port_set_initialized(&raw->port, 1); in raw3215_startup()
579 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_startup()
580 raw3215_try_io(raw); in raw3215_startup()
581 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_startup()
589 static void raw3215_shutdown(struct raw3215_info *raw) in raw3215_shutdown() argument
594 if (!tty_port_initialized(&raw->port) || (raw->flags & RAW3215_FIXED)) in raw3215_shutdown()
597 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
598 if ((raw->flags & RAW3215_WORKING) || in raw3215_shutdown()
599 raw->queued_write != NULL || in raw3215_shutdown()
600 raw->queued_read != NULL) { in raw3215_shutdown()
601 add_wait_queue(&raw->empty_wait, &wait); in raw3215_shutdown()
603 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
605 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
606 remove_wait_queue(&raw->empty_wait, &wait); in raw3215_shutdown()
608 tty_port_set_initialized(&raw->port, 1); in raw3215_shutdown()
610 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
637 static void raw3215_free_info(struct raw3215_info *raw) in raw3215_free_info() argument
639 kfree(raw->inbuf); in raw3215_free_info()
640 kfree(raw->buffer); in raw3215_free_info()
641 tty_port_destroy(&raw->port); in raw3215_free_info()
642 kfree(raw); in raw3215_free_info()
647 struct raw3215_info *raw; in raw3215_probe() local
654 raw = raw3215_alloc_info(); in raw3215_probe()
655 if (raw == NULL) in raw3215_probe()
658 raw->cdev = cdev; in raw3215_probe()
659 dev_set_drvdata(&cdev->dev, raw); in raw3215_probe()
665 raw3215[line] = raw; in raw3215_probe()
671 raw3215_free_info(raw); in raw3215_probe()
680 struct raw3215_info *raw; in raw3215_remove() local
684 raw = dev_get_drvdata(&cdev->dev); in raw3215_remove()
685 if (raw) { in raw3215_remove()
688 if (raw3215[line] == raw) in raw3215_remove()
693 raw3215_free_info(raw); in raw3215_remove()
699 struct raw3215_info *raw; in raw3215_set_online() local
701 raw = dev_get_drvdata(&cdev->dev); in raw3215_set_online()
702 if (!raw) in raw3215_set_online()
705 return raw3215_startup(raw); in raw3215_set_online()
710 struct raw3215_info *raw; in raw3215_set_offline() local
712 raw = dev_get_drvdata(&cdev->dev); in raw3215_set_offline()
713 if (!raw) in raw3215_set_offline()
716 raw3215_shutdown(raw); in raw3215_set_offline()
746 struct raw3215_info *raw; in con3215_write() local
751 raw = raw3215[0]; /* console 3215 is the first one */ in con3215_write()
756 raw3215_write(raw, str, i); in con3215_write()
760 raw3215_putchar(raw, *str); in con3215_write()
784 struct raw3215_info *raw; in con3215_notify() local
787 raw = raw3215[0]; /* console 3215 is the first one */ in con3215_notify()
788 if (!spin_trylock_irqsave(get_ccwdev_lock(raw->cdev), flags)) in con3215_notify()
790 raw3215_make_room(raw, RAW3215_BUFFER_SIZE); in con3215_notify()
791 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in con3215_notify()
822 struct raw3215_info *raw; in con3215_init() local
850 raw3215[0] = raw = raw3215_alloc_info(); in con3215_init()
851 raw->cdev = cdev; in con3215_init()
852 dev_set_drvdata(&cdev->dev, raw); in con3215_init()
855 raw->flags |= RAW3215_FIXED; in con3215_init()
858 raw3215_free_info(raw); in con3215_init()
864 if (raw3215_startup(raw) != 0) { in con3215_init()
865 raw3215_free_info(raw); in con3215_init()
879 struct raw3215_info *raw; in tty3215_install() local
881 raw = raw3215[tty->index]; in tty3215_install()
882 if (raw == NULL) in tty3215_install()
885 tty->driver_data = raw; in tty3215_install()
887 return tty_port_install(&raw->port, driver, tty); in tty3215_install()
897 struct raw3215_info *raw = tty->driver_data; in tty3215_open() local
899 tty_port_tty_set(&raw->port, tty); in tty3215_open()
904 return raw3215_startup(raw); in tty3215_open()
915 struct raw3215_info *raw = tty->driver_data; in tty3215_close() local
917 if (raw == NULL || tty->count > 1) in tty3215_close()
921 raw3215_shutdown(raw); in tty3215_close()
923 tty_port_tty_set(&raw->port, NULL); in tty3215_close()
931 struct raw3215_info *raw = tty->driver_data; in tty3215_write_room() local
934 if ((RAW3215_BUFFER_SIZE - raw->count - TAB_STOP_SIZE) >= 0) in tty3215_write_room()
935 return RAW3215_BUFFER_SIZE - raw->count - TAB_STOP_SIZE; in tty3215_write_room()
946 struct raw3215_info *raw = tty->driver_data; in tty3215_write() local
954 raw3215_write(raw, buf, i); in tty3215_write()
958 raw3215_putchar(raw, *buf); in tty3215_write()
971 struct raw3215_info *raw = tty->driver_data; in tty3215_put_char() local
973 raw3215_putchar(raw, ch); in tty3215_put_char()
987 struct raw3215_info *raw = tty->driver_data; in tty3215_chars_in_buffer() local
989 return raw->count; in tty3215_chars_in_buffer()
994 struct raw3215_info *raw = tty->driver_data; in tty3215_flush_buffer() local
996 raw3215_flush_buffer(raw); in tty3215_flush_buffer()
1005 struct raw3215_info *raw = tty->driver_data; in tty3215_throttle() local
1007 raw->flags |= RAW3215_THROTTLED; in tty3215_throttle()
1015 struct raw3215_info *raw = tty->driver_data; in tty3215_unthrottle() local
1018 if (raw->flags & RAW3215_THROTTLED) { in tty3215_unthrottle()
1019 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in tty3215_unthrottle()
1020 raw->flags &= ~RAW3215_THROTTLED; in tty3215_unthrottle()
1021 raw3215_try_io(raw); in tty3215_unthrottle()
1022 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in tty3215_unthrottle()
1031 struct raw3215_info *raw = tty->driver_data; in tty3215_stop() local
1033 raw->flags |= RAW3215_STOPPED; in tty3215_stop()
1041 struct raw3215_info *raw = tty->driver_data; in tty3215_start() local
1044 if (raw->flags & RAW3215_STOPPED) { in tty3215_start()
1045 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in tty3215_start()
1046 raw->flags &= ~RAW3215_STOPPED; in tty3215_start()
1047 raw3215_try_io(raw); in tty3215_start()
1048 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in tty3215_start()