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 = virt_to_dma32(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()
221 ccw->cda = virt_to_dma32(raw->buffer + ix); in raw3215_mk_write_req()
246 static void raw3215_start_io(struct raw3215_info *raw) in raw3215_start_io() argument
251 req = raw->queued_read; in raw3215_start_io()
253 !(raw->flags & (RAW3215_WORKING | RAW3215_THROTTLED))) { in raw3215_start_io()
255 raw->queued_read = NULL; in raw3215_start_io()
256 res = ccw_device_start(raw->cdev, req->ccws, in raw3215_start_io()
260 raw->queued_read = req; in raw3215_start_io()
262 raw->flags |= RAW3215_WORKING; in raw3215_start_io()
265 req = raw->queued_write; in raw3215_start_io()
267 !(raw->flags & (RAW3215_WORKING | RAW3215_STOPPED))) { in raw3215_start_io()
269 raw->queued_write = NULL; in raw3215_start_io()
270 res = ccw_device_start(raw->cdev, req->ccws, in raw3215_start_io()
274 raw->queued_write = req; in raw3215_start_io()
276 raw->flags |= RAW3215_WORKING; in raw3215_start_io()
286 struct raw3215_info *raw = from_timer(raw, t, timer); in raw3215_timeout() local
289 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_timeout()
290 raw->flags &= ~RAW3215_TIMER_RUNS; in raw3215_timeout()
291 raw3215_mk_write_req(raw); in raw3215_timeout()
292 raw3215_start_io(raw); in raw3215_timeout()
293 if ((raw->queued_read || raw->queued_write) && in raw3215_timeout()
294 !(raw->flags & RAW3215_WORKING) && in raw3215_timeout()
295 !(raw->flags & RAW3215_TIMER_RUNS)) { in raw3215_timeout()
296 raw->timer.expires = RAW3215_TIMEOUT + jiffies; in raw3215_timeout()
297 add_timer(&raw->timer); in raw3215_timeout()
298 raw->flags |= RAW3215_TIMER_RUNS; in raw3215_timeout()
300 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_timeout()
309 static inline void raw3215_try_io(struct raw3215_info *raw) in raw3215_try_io() argument
311 if (!tty_port_initialized(&raw->port)) in raw3215_try_io()
313 if (raw->queued_read != NULL) in raw3215_try_io()
314 raw3215_start_io(raw); in raw3215_try_io()
315 else if (raw->queued_write != NULL) { in raw3215_try_io()
316 if ((raw->queued_write->delayable == 0) || in raw3215_try_io()
317 (raw->flags & RAW3215_FLUSHING)) { in raw3215_try_io()
319 raw3215_start_io(raw); in raw3215_try_io()
322 if ((raw->queued_read || raw->queued_write) && in raw3215_try_io()
323 !(raw->flags & RAW3215_WORKING) && in raw3215_try_io()
324 !(raw->flags & RAW3215_TIMER_RUNS)) { in raw3215_try_io()
325 raw->timer.expires = RAW3215_TIMEOUT + jiffies; in raw3215_try_io()
326 add_timer(&raw->timer); in raw3215_try_io()
327 raw->flags |= RAW3215_TIMER_RUNS; in raw3215_try_io()
334 static void raw3215_next_io(struct raw3215_info *raw, struct tty_struct *tty) in raw3215_next_io() argument
336 raw3215_mk_write_req(raw); in raw3215_next_io()
337 raw3215_try_io(raw); in raw3215_next_io()
338 if (tty && RAW3215_BUFFER_SIZE - raw->count >= RAW3215_MIN_SPACE) in raw3215_next_io()
348 struct raw3215_info *raw; in raw3215_irq() local
354 raw = dev_get_drvdata(&cdev->dev); in raw3215_irq()
356 tty = tty_port_tty_get(&raw->port); in raw3215_irq()
360 raw3215_next_io(raw, tty); in raw3215_irq()
369 raw3215_mk_read_req(raw); in raw3215_irq()
370 raw3215_next_io(raw, tty); in raw3215_irq()
375 if ((raw = req->info) == NULL) in raw3215_irq()
386 if ((raw = req->info) == NULL) in raw3215_irq()
392 EBCASC(raw->inbuf, count); in raw3215_irq()
393 cchar = ctrlchar_handle(raw->inbuf, count, tty); in raw3215_irq()
399 tty_insert_flip_char(&raw->port, cchar, in raw3215_irq()
401 tty_flip_buffer_push(&raw->port); in raw3215_irq()
406 (strncmp(raw->inbuf+count-2, "\252n", 2) && in raw3215_irq()
407 strncmp(raw->inbuf+count-2, "^n", 2)) ) { in raw3215_irq()
409 raw->inbuf[count] = '\n'; in raw3215_irq()
413 tty_insert_flip_string(&raw->port, raw->inbuf, in raw3215_irq()
415 tty_flip_buffer_push(&raw->port); in raw3215_irq()
419 raw->count -= req->len; in raw3215_irq()
420 raw->written -= req->len; in raw3215_irq()
422 raw->flags &= ~RAW3215_WORKING; in raw3215_irq()
425 if (waitqueue_active(&raw->empty_wait) && in raw3215_irq()
426 raw->queued_write == NULL && in raw3215_irq()
427 raw->queued_read == NULL) { in raw3215_irq()
428 wake_up_interruptible(&raw->empty_wait); in raw3215_irq()
430 raw3215_next_io(raw, tty); in raw3215_irq()
436 raw->count -= req->len; in raw3215_irq()
437 raw->written -= req->len; in raw3215_irq()
439 raw->flags &= ~RAW3215_WORKING; in raw3215_irq()
442 raw3215_next_io(raw, tty); in raw3215_irq()
456 static unsigned int raw3215_drop(struct raw3215_info *raw) in raw3215_drop() argument
460 req = raw->queued_write; in raw3215_drop()
463 raw->written -= req->len; in raw3215_drop()
465 raw->queued_write = NULL; in raw3215_drop()
467 raw->head = (raw->head - raw->count + raw->written) & in raw3215_drop()
469 raw->count = raw->written; in raw3215_drop()
471 return RAW3215_BUFFER_SIZE - raw->count; in raw3215_drop()
481 static unsigned int raw3215_make_room(struct raw3215_info *raw, in raw3215_make_room() argument
484 while (RAW3215_BUFFER_SIZE - raw->count < length) { in raw3215_make_room()
486 return raw3215_drop(raw); in raw3215_make_room()
489 raw->flags |= RAW3215_FLUSHING; in raw3215_make_room()
490 raw3215_mk_write_req(raw); in raw3215_make_room()
491 raw3215_try_io(raw); in raw3215_make_room()
492 raw->flags &= ~RAW3215_FLUSHING; in raw3215_make_room()
494 ccw_device_wait_idle(raw->cdev); in raw3215_make_room()
497 if (RAW3215_BUFFER_SIZE - raw->count >= length) in raw3215_make_room()
500 spin_unlock(get_ccwdev_lock(raw->cdev)); in raw3215_make_room()
502 spin_lock(get_ccwdev_lock(raw->cdev)); in raw3215_make_room()
526 struct raw3215_info *raw, int opmode, in raw3215_addtext() argument
530 unsigned int column = raw->line_pos; in raw3215_addtext()
563 raw->buffer[raw->head] = _ascebc[ch]; in raw3215_addtext()
564 raw->head = (raw->head + 1) & (RAW3215_BUFFER_SIZE - 1); in raw3215_addtext()
565 raw->count++; in raw3215_addtext()
567 raw->line_pos = column; in raw3215_addtext()
575 static void raw3215_write(struct raw3215_info *raw, const u8 *str, in raw3215_write() argument
581 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_write()
583 count = raw3215_addtext(str, length, raw, RAW3215_COUNT, 0); in raw3215_write()
585 avail = raw3215_make_room(raw, count, con3215_drop); in raw3215_write()
587 raw3215_addtext(str, length, raw, RAW3215_STORE, in raw3215_write()
590 if (!(raw->flags & RAW3215_WORKING)) { in raw3215_write()
591 raw3215_mk_write_req(raw); in raw3215_write()
593 raw3215_try_io(raw); in raw3215_write()
595 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_write()
601 static void raw3215_putchar(struct raw3215_info *raw, u8 ch) in raw3215_putchar() argument
603 raw3215_write(raw, &ch, 1); in raw3215_putchar()
610 static void raw3215_flush_buffer(struct raw3215_info *raw) in raw3215_flush_buffer() argument
614 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_flush_buffer()
615 if (raw->count > 0) { in raw3215_flush_buffer()
616 raw->flags |= RAW3215_FLUSHING; in raw3215_flush_buffer()
617 raw3215_try_io(raw); in raw3215_flush_buffer()
618 raw->flags &= ~RAW3215_FLUSHING; in raw3215_flush_buffer()
620 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_flush_buffer()
626 static int raw3215_startup(struct raw3215_info *raw) in raw3215_startup() argument
630 if (tty_port_initialized(&raw->port)) in raw3215_startup()
632 raw->line_pos = 0; in raw3215_startup()
633 tty_port_set_initialized(&raw->port, true); in raw3215_startup()
634 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_startup()
635 raw3215_try_io(raw); in raw3215_startup()
636 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_startup()
644 static void raw3215_shutdown(struct raw3215_info *raw) in raw3215_shutdown() argument
649 if (!tty_port_initialized(&raw->port) || (raw->flags & RAW3215_FIXED)) in raw3215_shutdown()
652 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
653 if ((raw->flags & RAW3215_WORKING) || in raw3215_shutdown()
654 raw->queued_write != NULL || in raw3215_shutdown()
655 raw->queued_read != NULL) { in raw3215_shutdown()
656 add_wait_queue(&raw->empty_wait, &wait); in raw3215_shutdown()
658 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
660 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
661 remove_wait_queue(&raw->empty_wait, &wait); in raw3215_shutdown()
663 tty_port_set_initialized(&raw->port, true); in raw3215_shutdown()
665 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in raw3215_shutdown()
692 static void raw3215_free_info(struct raw3215_info *raw) in raw3215_free_info() argument
694 kfree(raw->inbuf); in raw3215_free_info()
695 kfree(raw->buffer); in raw3215_free_info()
696 tty_port_destroy(&raw->port); in raw3215_free_info()
697 kfree(raw); in raw3215_free_info()
702 struct raw3215_info *raw; in raw3215_probe() local
709 raw = raw3215_alloc_info(); in raw3215_probe()
710 if (raw == NULL) in raw3215_probe()
713 raw->cdev = cdev; in raw3215_probe()
714 dev_set_drvdata(&cdev->dev, raw); in raw3215_probe()
720 raw3215[line] = raw; in raw3215_probe()
726 raw3215_free_info(raw); in raw3215_probe()
735 struct raw3215_info *raw; in raw3215_remove() local
739 raw = dev_get_drvdata(&cdev->dev); in raw3215_remove()
740 if (raw) { in raw3215_remove()
743 if (raw3215[line] == raw) in raw3215_remove()
748 raw3215_free_info(raw); in raw3215_remove()
754 struct raw3215_info *raw; in raw3215_set_online() local
756 raw = dev_get_drvdata(&cdev->dev); in raw3215_set_online()
757 if (!raw) in raw3215_set_online()
760 return raw3215_startup(raw); in raw3215_set_online()
765 struct raw3215_info *raw; in raw3215_set_offline() local
767 raw = dev_get_drvdata(&cdev->dev); in raw3215_set_offline()
768 if (!raw) in raw3215_set_offline()
771 raw3215_shutdown(raw); in raw3215_set_offline()
828 static void handle_write(struct raw3215_info *raw, const u8 *str, size_t count) in handle_write() argument
832 raw3215_write(raw, str, i); in handle_write()
864 struct raw3215_info *raw; in con3215_notify() local
867 raw = raw3215[0]; /* console 3215 is the first one */ in con3215_notify()
868 if (!spin_trylock_irqsave(get_ccwdev_lock(raw->cdev), flags)) in con3215_notify()
870 raw3215_make_room(raw, RAW3215_BUFFER_SIZE, false); in con3215_notify()
871 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in con3215_notify()
902 struct raw3215_info *raw; in con3215_init() local
930 raw3215[0] = raw = raw3215_alloc_info(); in con3215_init()
931 raw->cdev = cdev; in con3215_init()
932 dev_set_drvdata(&cdev->dev, raw); in con3215_init()
935 raw->flags |= RAW3215_FIXED; in con3215_init()
938 raw3215_free_info(raw); in con3215_init()
944 if (raw3215_startup(raw) != 0) { in con3215_init()
945 raw3215_free_info(raw); in con3215_init()
959 struct raw3215_info *raw; in tty3215_install() local
961 raw = raw3215[tty->index]; in tty3215_install()
962 if (raw == NULL) in tty3215_install()
965 tty->driver_data = raw; in tty3215_install()
967 return tty_port_install(&raw->port, driver, tty); in tty3215_install()
977 struct raw3215_info *raw = tty->driver_data; in tty3215_open() local
979 tty_port_tty_set(&raw->port, tty); in tty3215_open()
984 return raw3215_startup(raw); in tty3215_open()
995 struct raw3215_info *raw = tty->driver_data; in tty3215_close() local
997 if (raw == NULL || tty->count > 1) in tty3215_close()
1001 raw3215_shutdown(raw); in tty3215_close()
1003 tty_port_tty_set(&raw->port, NULL); in tty3215_close()
1011 struct raw3215_info *raw = tty->driver_data; in tty3215_write_room() local
1014 if ((RAW3215_BUFFER_SIZE - raw->count - TAB_STOP_SIZE) >= 0) in tty3215_write_room()
1015 return RAW3215_BUFFER_SIZE - raw->count - TAB_STOP_SIZE; in tty3215_write_room()
1035 struct raw3215_info *raw = tty->driver_data; in tty3215_put_char() local
1037 raw3215_putchar(raw, ch); in tty3215_put_char()
1051 struct raw3215_info *raw = tty->driver_data; in tty3215_chars_in_buffer() local
1053 return raw->count; in tty3215_chars_in_buffer()
1058 struct raw3215_info *raw = tty->driver_data; in tty3215_flush_buffer() local
1060 raw3215_flush_buffer(raw); in tty3215_flush_buffer()
1069 struct raw3215_info *raw = tty->driver_data; in tty3215_throttle() local
1071 raw->flags |= RAW3215_THROTTLED; in tty3215_throttle()
1079 struct raw3215_info *raw = tty->driver_data; in tty3215_unthrottle() local
1082 if (raw->flags & RAW3215_THROTTLED) { in tty3215_unthrottle()
1083 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in tty3215_unthrottle()
1084 raw->flags &= ~RAW3215_THROTTLED; in tty3215_unthrottle()
1085 raw3215_try_io(raw); in tty3215_unthrottle()
1086 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in tty3215_unthrottle()
1095 struct raw3215_info *raw = tty->driver_data; in tty3215_stop() local
1097 raw->flags |= RAW3215_STOPPED; in tty3215_stop()
1105 struct raw3215_info *raw = tty->driver_data; in tty3215_start() local
1108 if (raw->flags & RAW3215_STOPPED) { in tty3215_start()
1109 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); in tty3215_start()
1110 raw->flags &= ~RAW3215_STOPPED; in tty3215_start()
1111 raw3215_try_io(raw); in tty3215_start()
1112 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); in tty3215_start()