8 #include <linux/sched.h>
9 #include <linux/slab.h>
16 #define LINE_BUFSIZE 4096
35 static int write_room(
struct line *
line)
57 room = write_room(line);
58 spin_unlock_irqrestore(&line->
lock, flags);
72 spin_unlock_irqrestore(&line->
lock, flags);
86 static int buffer_data(
struct line *line,
const char *
buf,
int len)
101 room = write_room(line);
102 len = (len > room) ? room : len;
130 static int flush_buffer(
struct line *line)
175 spin_unlock_irqrestore(&line->
lock, flags);
200 ret = buffer_data(line, buf, len);
212 ret += buffer_data(line, buf + n, len);
215 spin_unlock_irqrestore(&line->
lock, flags);
251 struct line *line = chan->
line;
260 spin_lock(&line->
lock);
261 err = flush_buffer(line);
263 spin_unlock(&line->
lock);
265 }
else if (err < 0) {
269 spin_unlock(&line->
lock);
320 .activate = line_activate,
344 static void unregister_winch(
struct tty_struct *tty);
351 unregister_winch(tty);
374 for(i = 0; i < nlines; i++)
381 struct line *line = &lines[
n];
385 if (line->
port.count) {
386 *error_out =
"Device is already open";
390 if (!
strcmp(init,
"none")) {
401 *error_out =
"Failed to allocate memory";
415 *error_out =
"Failed to register device";
453 error =
"Couldn't parse device number";
457 error =
"Device number out of range";
466 "configuration string \"%s\" : %s\n", name, init, error);
477 *error_out =
"Can't configure all devices from mconsole";
483 *error_out =
"Couldn't parse device number";
487 *error_out =
"Device number out of range";
495 int size,
char **error_out)
502 if ((*end !=
'\0') || (end == name)) {
503 *error_out =
"line_get_config failed to parse device number";
507 if ((dev < 0) || (dev >= num)) {
508 *error_out =
"device number out of range";
535 if ((*end !=
'\0') || (end == *str))
544 int line_remove(
struct line *lines,
unsigned int num,
int n,
char **error_out)
547 *error_out =
"Device number out of range";
555 struct line *lines,
int nlines)
573 for (i = 0; i < nlines; i++) {
575 lines[
i].
port.ops = &line_port_ops;
578 INIT_LIST_HEAD(&lines[i].chan_list);
613 if (winch->
pid != -1)
615 if (winch->
stack != 0)
620 static void free_winch(
struct winch *winch)
627 __free_winch(&winch->
work);
630 static irqreturn_t winch_interrupt(
int irq,
void *data)
632 struct winch *winch =
data;
647 "read failed, errno = %d\n", -err);
649 "support\n", winch->
tty_fd);
697 spin_lock(&winch_handler_lock);
698 list_add(&winch->
list, &winch_handlers);
699 spin_unlock(&winch_handler_lock);
712 static void unregister_winch(
struct tty_struct *tty)
717 spin_lock(&winch_handler_lock);
721 if (winch->
tty == tty) {
726 spin_unlock(&winch_handler_lock);
729 static void winch_cleanup(
void)
734 spin_lock(&winch_handler_lock);
741 spin_unlock(&winch_handler_lock);
761 snprintf(title, len,
"%s (%s)", base, umid);