Lines Matching +full:data +full:- +full:lines
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
19 static irqreturn_t line_interrupt(int irq, void *data) in line_interrupt() argument
21 struct chan *chan = data; in line_interrupt()
22 struct line *line = chan->line; in line_interrupt()
33 * Should be called while holding line->lock (this does not modify data).
39 if (line->buffer == NULL) in write_room()
40 return LINE_BUFSIZE - 1; in write_room()
43 n = line->head - line->tail; in write_room()
47 return n - 1; in write_room()
52 struct line *line = tty->driver_data; in line_write_room()
56 spin_lock_irqsave(&line->lock, flags); in line_write_room()
58 spin_unlock_irqrestore(&line->lock, flags); in line_write_room()
65 struct line *line = tty->driver_data; in line_chars_in_buffer()
69 spin_lock_irqsave(&line->lock, flags); in line_chars_in_buffer()
71 ret = LINE_BUFSIZE - (write_room(line) + 1); in line_chars_in_buffer()
72 spin_unlock_irqrestore(&line->lock, flags); in line_chars_in_buffer()
84 * Must be called while holding line->lock!
90 if (line->buffer == NULL) { in buffer_data()
91 line->buffer = kmalloc(LINE_BUFSIZE, GFP_ATOMIC); in buffer_data()
92 if (line->buffer == NULL) { in buffer_data()
93 printk(KERN_ERR "buffer_data - atomic allocation " in buffer_data()
97 line->head = line->buffer; in buffer_data()
98 line->tail = line->buffer; in buffer_data()
104 end = line->buffer + LINE_BUFSIZE - line->tail; in buffer_data()
107 memcpy(line->tail, buf, len); in buffer_data()
108 line->tail += len; in buffer_data()
112 memcpy(line->tail, buf, end); in buffer_data()
114 memcpy(line->buffer, buf, len - end); in buffer_data()
115 line->tail = line->buffer + len - end; in buffer_data()
123 * called, passing it line->head as buffer, and an appropriate count.
127 * and -errno when an error occurred.
129 * Must be called while holding line->lock!*/
134 if ((line->buffer == NULL) || (line->head == line->tail)) in flush_buffer()
137 if (line->tail < line->head) { in flush_buffer()
138 /* line->buffer + LINE_BUFSIZE is the end of the buffer! */ in flush_buffer()
139 count = line->buffer + LINE_BUFSIZE - line->head; in flush_buffer()
141 n = write_chan(line->chan_out, line->head, count, in flush_buffer()
142 line->write_irq); in flush_buffer()
147 * We have flushed from ->head to buffer end, now we in flush_buffer()
148 * must flush only from the beginning to ->tail. in flush_buffer()
150 line->head = line->buffer; in flush_buffer()
152 line->head += n; in flush_buffer()
157 count = line->tail - line->head; in flush_buffer()
158 n = write_chan(line->chan_out, line->head, count, in flush_buffer()
159 line->write_irq); in flush_buffer()
164 line->head += n; in flush_buffer()
165 return line->head == line->tail; in flush_buffer()
170 struct line *line = tty->driver_data; in line_flush_buffer()
173 spin_lock_irqsave(&line->lock, flags); in line_flush_buffer()
175 spin_unlock_irqrestore(&line->lock, flags); in line_flush_buffer()
179 * We map both ->flush_chars and ->put_char (which go in pair) onto
180 * ->flush_buffer and ->write. Hope it's not that bad.
189 struct line *line = tty->driver_data; in line_write()
193 spin_lock_irqsave(&line->lock, flags); in line_write()
194 if (line->head != line->tail) in line_write()
197 n = write_chan(line->chan_out, buf, len, in line_write()
198 line->write_irq); in line_write()
204 len -= n; in line_write()
210 spin_unlock_irqrestore(&line->lock, flags); in line_write()
216 struct line *line = tty->driver_data; in line_throttle()
218 deactivate_chan(line->chan_in, line->read_irq); in line_throttle()
219 line->throttled = 1; in line_throttle()
224 struct line *line = tty->driver_data; in line_unthrottle()
226 line->throttled = 0; in line_unthrottle()
227 chan_interrupt(line, line->read_irq); in line_unthrottle()
230 static irqreturn_t line_write_interrupt(int irq, void *data) in line_write_interrupt() argument
232 struct chan *chan = data; in line_write_interrupt()
233 struct line *line = chan->line; in line_write_interrupt()
241 spin_lock(&line->lock); in line_write_interrupt()
244 spin_unlock(&line->lock); in line_write_interrupt()
246 } else if ((err < 0) && (err != -EAGAIN)) { in line_write_interrupt()
247 line->head = line->buffer; in line_write_interrupt()
248 line->tail = line->buffer; in line_write_interrupt()
250 spin_unlock(&line->lock); in line_write_interrupt()
252 tty_port_tty_wakeup(&line->port); in line_write_interrupt()
257 int line_setup_irq(int fd, int input, int output, struct line *line, void *data) in line_setup_irq() argument
259 const struct line_driver *driver = line->driver; in line_setup_irq()
265 driver->read_irq_name, data); in line_setup_irq()
269 line->read_irq = err; in line_setup_irq()
275 driver->write_irq_name, data); in line_setup_irq()
279 line->write_irq = err; in line_setup_irq()
288 struct line *line = tty->driver_data; in line_activate()
294 if (!line->sigio) { in line_activate()
295 chan_enable_winch(line->chan_out, port); in line_activate()
296 line->sigio = 1; in line_activate()
299 chan_window_size(line, &tty->winsize.ws_row, in line_activate()
300 &tty->winsize.ws_col); in line_activate()
310 struct line *line = tty->driver_data; in line_destruct()
312 if (line->sigio) { in line_destruct()
314 line->sigio = 0; in line_destruct()
325 struct line *line = tty->driver_data; in line_open()
327 return tty_port_open(&line->port, tty, filp); in line_open()
339 tty->driver_data = line; in line_install()
346 struct line *line = tty->driver_data; in line_close()
348 tty_port_close(&line->port, tty, filp); in line_close()
353 struct line *line = tty->driver_data; in line_hangup()
355 tty_port_hangup(&line->port); in line_hangup()
358 void close_lines(struct line *lines, int nlines) in close_lines() argument
363 close_chan(&lines[i]); in close_lines()
366 int setup_one_line(struct line *lines, int n, char *init, in setup_one_line() argument
369 struct line *line = &lines[n]; in setup_one_line()
370 struct tty_driver *driver = line->driver->driver; in setup_one_line()
371 int err = -EINVAL; in setup_one_line()
373 if (line->port.count) { in setup_one_line()
379 if (line->valid) { in setup_one_line()
380 line->valid = 0; in setup_one_line()
381 kfree(line->init_str); in setup_one_line()
391 return -ENOMEM; in setup_one_line()
393 if (line->valid) { in setup_one_line()
395 kfree(line->init_str); in setup_one_line()
397 line->init_str = new; in setup_one_line()
398 line->valid = 1; in setup_one_line()
401 struct device *d = tty_port_register_device(&line->port, in setup_one_line()
411 line->init_str = NULL; in setup_one_line()
412 line->valid = 0; in setup_one_line()
422 * @lines contains the array (of size @num) to modify;
457 return -EINVAL; in line_setup()
460 int line_config(struct line *lines, unsigned int num, char *str, in line_config() argument
468 return -EINVAL; in line_config()
474 return -EINVAL; in line_config()
478 return -EINVAL; in line_config()
481 return setup_one_line(lines, n, end, opts, error_out); in line_config()
484 int line_get_config(char *name, struct line *lines, unsigned int num, char *str, in line_get_config() argument
502 line = &lines[dev]; in line_get_config()
504 if (!line->valid) in line_get_config()
507 struct tty_struct *tty = tty_port_tty_get(&line->port); in line_get_config()
509 CONFIG_CHUNK(str, size, n, line->init_str, 1); in line_get_config()
526 return -1; in line_id()
534 int line_remove(struct line *lines, unsigned int num, int n, char **error_out) in line_remove() argument
538 return -EINVAL; in line_remove()
540 return setup_one_line(lines, n, "none", NULL, error_out); in line_remove()
545 struct line *lines, int nlines) in register_lines() argument
556 driver->driver_name = line_driver->name; in register_lines()
557 driver->name = line_driver->device_name; in register_lines()
558 driver->major = line_driver->major; in register_lines()
559 driver->minor_start = line_driver->minor_start; in register_lines()
560 driver->type = line_driver->type; in register_lines()
561 driver->subtype = line_driver->subtype; in register_lines()
562 driver->init_termios = tty_std_termios; in register_lines()
565 tty_port_init(&lines[i].port); in register_lines()
566 lines[i].port.ops = &line_port_ops; in register_lines()
567 spin_lock_init(&lines[i].lock); in register_lines()
568 lines[i].driver = line_driver; in register_lines()
569 INIT_LIST_HEAD(&lines[i].chan_list); in register_lines()
576 line_driver->name); in register_lines()
579 tty_port_destroy(&lines[i].port); in register_lines()
583 line_driver->driver = driver; in register_lines()
584 mconsole_register_dev(&line_driver->mc); in register_lines()
606 if (winch->pid != -1) in __free_winch()
607 os_kill_process(winch->pid, 1); in __free_winch()
608 if (winch->stack != 0) in __free_winch()
609 free_stack(winch->stack, 0); in __free_winch()
615 int fd = winch->fd; in free_winch()
616 winch->fd = -1; in free_winch()
617 if (fd != -1) in free_winch()
619 __free_winch(&winch->work); in free_winch()
622 static irqreturn_t winch_interrupt(int irq, void *data) in winch_interrupt() argument
624 struct winch *winch = data; in winch_interrupt()
627 int fd = winch->fd; in winch_interrupt()
632 if (fd != -1) { in winch_interrupt()
636 if (err != -EAGAIN) { in winch_interrupt()
637 winch->fd = -1; in winch_interrupt()
638 list_del(&winch->list); in winch_interrupt()
642 -err); in winch_interrupt()
644 winch->tty_fd); in winch_interrupt()
646 INIT_WORK(&winch->work, __free_winch); in winch_interrupt()
647 schedule_work(&winch->work); in winch_interrupt()
653 tty = tty_port_tty_get(winch->port); in winch_interrupt()
655 line = tty->driver_data; in winch_interrupt()
657 chan_window_size(line, &tty->winsize.ws_row, in winch_interrupt()
658 &tty->winsize.ws_col); in winch_interrupt()
677 printk(KERN_ERR "register_winch_irq - kmalloc failed\n"); in register_winch_irq()
688 list_add(&winch->list, &winch_handlers); in register_winch_irq()
693 printk(KERN_ERR "register_winch_irq - failed to register " in register_winch_irq()
696 list_del(&winch->list); in register_winch_irq()
722 wtty = tty_port_tty_get(winch->port); in unregister_winch()
724 list_del(&winch->list); in unregister_winch()
741 list_del(&winch->list); in winch_cleanup()