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
50 fd = os_rcv_fd(conn->socket[0], &conn->helper_pid); in pipe_interrupt()
52 if (fd == -EAGAIN) in pipe_interrupt()
56 -fd); in pipe_interrupt()
57 os_close_file(conn->fd); in pipe_interrupt()
60 list_del(&conn->list); in pipe_interrupt()
62 conn->fd = fd; in pipe_interrupt()
63 list_add(&conn->list, &conn->port->connections); in pipe_interrupt()
65 complete(&conn->port->done); in pipe_interrupt()
71 "There are currently no UML consoles waiting for port connections.\n" \
76 static int port_accept(struct port_list *port) in port_accept() argument
81 fd = port_connection(port->fd, socket, &pid); in port_accept()
83 if (fd != -EAGAIN) in port_accept()
85 "returned %d\n", -fd); in port_accept()
96 { .list = LIST_HEAD_INIT(conn->list), in port_accept()
98 .socket = { socket[0], socket[1] }, in port_accept()
100 .port = port }); in port_accept()
109 if (atomic_read(&port->wait_count) == 0) { in port_accept()
111 printk(KERN_ERR "No one waiting for port\n"); in port_accept()
113 list_add(&conn->list, &port->pending); in port_accept()
114 return 1; in port_accept()
120 os_kill_process(pid, 1); in port_accept()
130 struct port_list *port; in port_work_proc() local
136 port = list_entry(ele, struct port_list, list); in port_work_proc()
137 if (!port->has_connection) in port_work_proc()
140 while (port_accept(port)) in port_work_proc()
142 port->has_connection = 0; in port_work_proc()
151 struct port_list *port = data; in port_interrupt() local
153 port->has_connection = 1; in port_interrupt()
161 struct port_list *port; in port_data() local
167 port = list_entry(ele, struct port_list, list); in port_data()
168 if (port->port == port_num) in port_data()
171 port = kmalloc(sizeof(struct port_list), GFP_KERNEL); in port_data()
172 if (port == NULL) { in port_data()
173 printk(KERN_ERR "Allocation of port list failed\n"); in port_data()
179 printk(KERN_ERR "binding to port %d failed, errno = %d\n", in port_data()
180 port_num, -fd); in port_data()
185 IRQF_SHARED, "port", port)) { in port_data()
186 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num); in port_data()
190 *port = ((struct port_list) in port_data()
191 { .list = LIST_HEAD_INIT(port->list), in port_data()
194 .port = port_num, in port_data()
196 .pending = LIST_HEAD_INIT(port->pending), in port_data()
197 .connections = LIST_HEAD_INIT(port->connections) }); in port_data()
198 spin_lock_init(&port->lock); in port_data()
199 init_completion(&port->done); in port_data()
200 list_add(&port->list, &ports); in port_data()
205 printk(KERN_ERR "Allocation of port device entry failed\n"); in port_data()
209 *dev = ((struct port_dev) { .port = port, in port_data()
210 .helper_pid = -1, in port_data()
211 .telnetd_pid = -1 }); in port_data()
217 kfree(port); in port_data()
227 struct port_list *port = dev->port; in port_wait() local
230 atomic_inc(&port->wait_count); in port_wait()
231 while (1) { in port_wait()
232 fd = -ERESTARTSYS; in port_wait()
233 if (wait_for_completion_interruptible(&port->done)) in port_wait()
236 spin_lock(&port->lock); in port_wait()
238 conn = list_entry(port->connections.next, struct connection, in port_wait()
240 list_del(&conn->list); in port_wait()
241 spin_unlock(&port->lock); in port_wait()
243 os_shutdown_socket(conn->socket[0], 1, 1); in port_wait()
244 os_close_file(conn->socket[0]); in port_wait()
245 os_shutdown_socket(conn->socket[1], 1, 1); in port_wait()
246 os_close_file(conn->socket[1]); in port_wait()
256 if (conn->fd >= 0) in port_wait()
258 os_close_file(conn->fd); in port_wait()
262 fd = conn->fd; in port_wait()
263 dev->helper_pid = conn->helper_pid; in port_wait()
264 dev->telnetd_pid = conn->telnetd_pid; in port_wait()
267 atomic_dec(&port->wait_count); in port_wait()
275 if (dev->helper_pid != -1) in port_remove_dev()
276 os_kill_process(dev->helper_pid, 0); in port_remove_dev()
277 if (dev->telnetd_pid != -1) in port_remove_dev()
278 os_kill_process(dev->telnetd_pid, 1); in port_remove_dev()
279 dev->helper_pid = -1; in port_remove_dev()
280 dev->telnetd_pid = -1; in port_remove_dev()
294 struct port_list *port; in free_port() local
297 port = list_entry(ele, struct port_list, list); in free_port()
298 free_irq_by_fd(port->fd); in free_port()
299 os_close_file(port->fd); in free_port()