Lines Matching +full:port +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
16 #include "port.h"
23 int port; member
31 struct port_list *port; member
42 struct port_list *port; member
48 int n_fds = 1, fd = -1; in pipe_interrupt()
51 ret = os_rcv_fd_msg(conn->socket[0], &fd, n_fds, &conn->helper_pid, in pipe_interrupt()
52 sizeof(conn->helper_pid)); in pipe_interrupt()
53 if (ret != sizeof(conn->helper_pid)) { in pipe_interrupt()
54 if (ret == -EAGAIN) in pipe_interrupt()
59 os_close_file(conn->fd); in pipe_interrupt()
62 list_del(&conn->list); in pipe_interrupt()
64 conn->fd = fd; in pipe_interrupt()
65 list_add(&conn->list, &conn->port->connections); in pipe_interrupt()
67 complete(&conn->port->done); in pipe_interrupt()
73 "There are currently no UML consoles waiting for port connections.\n" \
78 static int port_accept(struct port_list *port) in port_accept() argument
83 fd = port_connection(port->fd, socket, &pid); in port_accept()
85 if (fd != -EAGAIN) in port_accept()
87 "returned %d\n", -fd); in port_accept()
98 { .list = LIST_HEAD_INIT(conn->list), in port_accept()
100 .socket = { socket[0], socket[1] }, in port_accept()
102 .port = port }); in port_accept()
111 if (atomic_read(&port->wait_count) == 0) { in port_accept()
113 printk(KERN_ERR "No one waiting for port\n"); in port_accept()
115 list_add(&conn->list, &port->pending); in port_accept()
116 return 1; in port_accept()
122 os_kill_process(pid, 1); in port_accept()
132 struct port_list *port; in port_work_proc() local
138 port = list_entry(ele, struct port_list, list); in port_work_proc()
139 if (!port->has_connection) in port_work_proc()
142 while (port_accept(port)) in port_work_proc()
144 port->has_connection = 0; in port_work_proc()
153 struct port_list *port = data; in port_interrupt() local
155 port->has_connection = 1; in port_interrupt()
163 struct port_list *port; in port_data() local
169 port = list_entry(ele, struct port_list, list); in port_data()
170 if (port->port == port_num) in port_data()
173 port = kmalloc(sizeof(struct port_list), GFP_KERNEL); in port_data()
174 if (port == NULL) { in port_data()
175 printk(KERN_ERR "Allocation of port list failed\n"); in port_data()
181 printk(KERN_ERR "binding to port %d failed, errno = %d\n", in port_data()
182 port_num, -fd); in port_data()
187 IRQF_SHARED, "port", port) < 0) { in port_data()
188 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num); in port_data()
192 *port = ((struct port_list) in port_data()
193 { .list = LIST_HEAD_INIT(port->list), in port_data()
196 .port = port_num, in port_data()
198 .pending = LIST_HEAD_INIT(port->pending), in port_data()
199 .connections = LIST_HEAD_INIT(port->connections) }); in port_data()
200 spin_lock_init(&port->lock); in port_data()
201 init_completion(&port->done); in port_data()
202 list_add(&port->list, &ports); in port_data()
207 printk(KERN_ERR "Allocation of port device entry failed\n"); in port_data()
211 *dev = ((struct port_dev) { .port = port, in port_data()
212 .helper_pid = -1, in port_data()
213 .telnetd_pid = -1 }); in port_data()
219 kfree(port); in port_data()
229 struct port_list *port = dev->port; in port_wait() local
232 atomic_inc(&port->wait_count); in port_wait()
233 while (1) { in port_wait()
234 fd = -ERESTARTSYS; in port_wait()
235 if (wait_for_completion_interruptible(&port->done)) in port_wait()
238 spin_lock(&port->lock); in port_wait()
240 conn = list_entry(port->connections.next, struct connection, in port_wait()
242 list_del(&conn->list); in port_wait()
243 spin_unlock(&port->lock); in port_wait()
245 os_shutdown_socket(conn->socket[0], 1, 1); in port_wait()
246 os_close_file(conn->socket[0]); in port_wait()
247 os_shutdown_socket(conn->socket[1], 1, 1); in port_wait()
248 os_close_file(conn->socket[1]); in port_wait()
258 if (conn->fd >= 0) in port_wait()
260 os_close_file(conn->fd); in port_wait()
264 fd = conn->fd; in port_wait()
265 dev->helper_pid = conn->helper_pid; in port_wait()
266 dev->telnetd_pid = conn->telnetd_pid; in port_wait()
269 atomic_dec(&port->wait_count); in port_wait()
277 if (dev->helper_pid != -1) in port_remove_dev()
278 os_kill_process(dev->helper_pid, 0); in port_remove_dev()
279 if (dev->telnetd_pid != -1) in port_remove_dev()
280 os_kill_process(dev->telnetd_pid, 1); in port_remove_dev()
281 dev->helper_pid = -1; in port_remove_dev()
282 dev->telnetd_pid = -1; in port_remove_dev()
296 struct port_list *port; in free_port() local
299 port = list_entry(ele, struct port_list, list); in free_port()
300 free_irq_by_fd(port->fd); in free_port()
301 os_close_file(port->fd); in free_port()