Commit 67608e0c authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: port driver formatting

Whitespace and style fixes.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d832fc60
/* /*
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
...@@ -55,9 +55,9 @@ static irqreturn_t pipe_interrupt(int irq, void *data) ...@@ -55,9 +55,9 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
fd = os_rcv_fd(conn->socket[0], &conn->helper_pid); fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
if(fd < 0){ if(fd < 0){
if(fd == -EAGAIN) if(fd == -EAGAIN)
return(IRQ_NONE); return IRQ_NONE;
printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n", printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n",
-fd); -fd);
os_close_file(conn->fd); os_close_file(conn->fd);
} }
...@@ -68,7 +68,7 @@ static irqreturn_t pipe_interrupt(int irq, void *data) ...@@ -68,7 +68,7 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
list_add(&conn->list, &conn->port->connections); list_add(&conn->list, &conn->port->connections);
complete(&conn->port->done); complete(&conn->port->done);
return(IRQ_HANDLED); return IRQ_HANDLED;
} }
#define NO_WAITER_MSG \ #define NO_WAITER_MSG \
...@@ -97,14 +97,14 @@ static int port_accept(struct port_list *port) ...@@ -97,14 +97,14 @@ static int port_accept(struct port_list *port)
"connection\n"); "connection\n");
goto out_close; goto out_close;
} }
*conn = ((struct connection) *conn = ((struct connection)
{ .list = LIST_HEAD_INIT(conn->list), { .list = LIST_HEAD_INIT(conn->list),
.fd = fd, .fd = fd,
.socket = { socket[0], socket[1] }, .socket = { socket[0], socket[1] },
.telnetd_pid = pid, .telnetd_pid = pid,
.port = port }); .port = port });
if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt, if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
"telnetd", conn)){ "telnetd", conn)){
printk(KERN_ERR "port_accept : failed to get IRQ for " printk(KERN_ERR "port_accept : failed to get IRQ for "
...@@ -117,17 +117,17 @@ static int port_accept(struct port_list *port) ...@@ -117,17 +117,17 @@ static int port_accept(struct port_list *port)
printk("No one waiting for port\n"); printk("No one waiting for port\n");
} }
list_add(&conn->list, &port->pending); list_add(&conn->list, &port->pending);
return(1); return 1;
out_free: out_free:
kfree(conn); kfree(conn);
out_close: out_close:
os_close_file(fd); os_close_file(fd);
if(pid != -1) if(pid != -1)
os_kill_process(pid, 1); os_kill_process(pid, 1);
out: out:
return(ret); return ret;
} }
static DECLARE_MUTEX(ports_sem); static DECLARE_MUTEX(ports_sem);
static struct list_head ports = LIST_HEAD_INIT(ports); static struct list_head ports = LIST_HEAD_INIT(ports);
...@@ -158,8 +158,8 @@ static irqreturn_t port_interrupt(int irq, void *data) ...@@ -158,8 +158,8 @@ static irqreturn_t port_interrupt(int irq, void *data)
port->has_connection = 1; port->has_connection = 1;
schedule_work(&port_work); schedule_work(&port_work);
return(IRQ_HANDLED); return IRQ_HANDLED;
} }
void *port_data(int port_num) void *port_data(int port_num)
{ {
...@@ -185,14 +185,14 @@ void *port_data(int port_num) ...@@ -185,14 +185,14 @@ void *port_data(int port_num)
port_num, -fd); port_num, -fd);
goto out_free; goto out_free;
} }
if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt, if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, "port", IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
port)){ "port", port)){
printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num); printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
goto out_close; goto out_close;
} }
*port = ((struct port_list) *port = ((struct port_list)
{ .list = LIST_HEAD_INIT(port->list), { .list = LIST_HEAD_INIT(port->list),
.wait_count = ATOMIC_INIT(0), .wait_count = ATOMIC_INIT(0),
.has_connection = 0, .has_connection = 0,
...@@ -222,7 +222,7 @@ void *port_data(int port_num) ...@@ -222,7 +222,7 @@ void *port_data(int port_num)
os_close_file(fd); os_close_file(fd);
out: out:
up(&ports_sem); up(&ports_sem);
return(dev); return dev;
} }
int port_wait(void *data) int port_wait(void *data)
...@@ -232,15 +232,15 @@ int port_wait(void *data) ...@@ -232,15 +232,15 @@ int port_wait(void *data)
struct port_list *port = dev->port; struct port_list *port = dev->port;
int fd; int fd;
atomic_inc(&port->wait_count); atomic_inc(&port->wait_count);
while(1){ while(1){
fd = -ERESTARTSYS; fd = -ERESTARTSYS;
if(wait_for_completion_interruptible(&port->done)) if(wait_for_completion_interruptible(&port->done))
goto out; goto out;
spin_lock(&port->lock); spin_lock(&port->lock);
conn = list_entry(port->connections.next, struct connection, conn = list_entry(port->connections.next, struct connection,
list); list);
list_del(&conn->list); list_del(&conn->list);
spin_unlock(&port->lock); spin_unlock(&port->lock);
...@@ -248,12 +248,12 @@ int port_wait(void *data) ...@@ -248,12 +248,12 @@ int port_wait(void *data)
os_shutdown_socket(conn->socket[0], 1, 1); os_shutdown_socket(conn->socket[0], 1, 1);
os_close_file(conn->socket[0]); os_close_file(conn->socket[0]);
os_shutdown_socket(conn->socket[1], 1, 1); os_shutdown_socket(conn->socket[1], 1, 1);
os_close_file(conn->socket[1]); os_close_file(conn->socket[1]);
/* This is done here because freeing an IRQ can't be done /* This is done here because freeing an IRQ can't be done
* within the IRQ handler. So, pipe_interrupt always ups * within the IRQ handler. So, pipe_interrupt always ups
* the semaphore regardless of whether it got a successful * the semaphore regardless of whether it got a successful
* connection. Then we loop here throwing out failed * connection. Then we loop here throwing out failed
* connections until a good one is found. * connections until a good one is found.
*/ */
free_irq(TELNETD_IRQ, conn); free_irq(TELNETD_IRQ, conn);
......
/* /*
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com) * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
...@@ -38,18 +38,18 @@ static void *port_init(char *str, int device, const struct chan_opts *opts) ...@@ -38,18 +38,18 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
if(*str != ':'){ if(*str != ':'){
printk("port_init : channel type 'port' must specify a " printk("port_init : channel type 'port' must specify a "
"port number\n"); "port number\n");
return(NULL); return NULL;
} }
str++; str++;
port = strtoul(str, &end, 0); port = strtoul(str, &end, 0);
if((*end != '\0') || (end == str)){ if((*end != '\0') || (end == str)){
printk("port_init : couldn't parse port '%s'\n", str); printk("port_init : couldn't parse port '%s'\n", str);
return(NULL); return NULL;
} }
kern_data = port_data(port); kern_data = port_data(port);
if(kern_data == NULL) if(kern_data == NULL)
return(NULL); return NULL;
data = um_kmalloc(sizeof(*data)); data = um_kmalloc(sizeof(*data));
if(data == NULL) if(data == NULL)
...@@ -59,10 +59,10 @@ static void *port_init(char *str, int device, const struct chan_opts *opts) ...@@ -59,10 +59,10 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
.kernel_data = kern_data }); .kernel_data = kern_data });
sprintf(data->dev, "%d", port); sprintf(data->dev, "%d", port);
return(data); return data;
err: err:
port_kern_free(kern_data); port_kern_free(kern_data);
return(NULL); return NULL;
} }
static void port_free(void *d) static void port_free(void *d)
...@@ -83,14 +83,14 @@ static int port_open(int input, int output, int primary, void *d, ...@@ -83,14 +83,14 @@ static int port_open(int input, int output, int primary, void *d,
if((fd >= 0) && data->raw){ if((fd >= 0) && data->raw){
CATCH_EINTR(err = tcgetattr(fd, &data->tt)); CATCH_EINTR(err = tcgetattr(fd, &data->tt));
if(err) if(err)
return(err); return err;
err = raw(fd); err = raw(fd);
if(err) if(err)
return(err); return err;
} }
*dev_out = data->dev; *dev_out = data->dev;
return(fd); return fd;
} }
static void port_close(int fd, void *d) static void port_close(int fd, void *d)
...@@ -120,8 +120,8 @@ int port_listen_fd(int port) ...@@ -120,8 +120,8 @@ int port_listen_fd(int port)
int fd, err, arg; int fd, err, arg;
fd = socket(PF_INET, SOCK_STREAM, 0); fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1) if(fd == -1)
return(-errno); return -errno;
arg = 1; arg = 1;
if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){ if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
...@@ -136,7 +136,7 @@ int port_listen_fd(int port) ...@@ -136,7 +136,7 @@ int port_listen_fd(int port)
err = -errno; err = -errno;
goto out; goto out;
} }
if(listen(fd, 1) < 0){ if(listen(fd, 1) < 0){
err = -errno; err = -errno;
goto out; goto out;
...@@ -146,10 +146,10 @@ int port_listen_fd(int port) ...@@ -146,10 +146,10 @@ int port_listen_fd(int port)
if(err < 0) if(err < 0)
goto out; goto out;
return(fd); return fd;
out: out:
os_close_file(fd); os_close_file(fd);
return(err); return err;
} }
struct port_pre_exec_data { struct port_pre_exec_data {
...@@ -173,13 +173,13 @@ void port_pre_exec(void *arg) ...@@ -173,13 +173,13 @@ void port_pre_exec(void *arg)
int port_connection(int fd, int *socket, int *pid_out) int port_connection(int fd, int *socket, int *pid_out)
{ {
int new, err; int new, err;
char *argv[] = { "/usr/sbin/in.telnetd", "-L", char *argv[] = { "/usr/sbin/in.telnetd", "-L",
"/usr/lib/uml/port-helper", NULL }; "/usr/lib/uml/port-helper", NULL };
struct port_pre_exec_data data; struct port_pre_exec_data data;
new = os_accept_connection(fd); new = os_accept_connection(fd);
if(new < 0) if(new < 0)
return(new); return new;
err = os_pipe(socket, 0, 0); err = os_pipe(socket, 0, 0);
if(err < 0) if(err < 0)
...@@ -190,29 +190,18 @@ int port_connection(int fd, int *socket, int *pid_out) ...@@ -190,29 +190,18 @@ int port_connection(int fd, int *socket, int *pid_out)
.pipe_fd = socket[1] }); .pipe_fd = socket[1] });
err = run_helper(port_pre_exec, &data, argv, NULL); err = run_helper(port_pre_exec, &data, argv, NULL);
if(err < 0) if(err < 0)
goto out_shutdown; goto out_shutdown;
*pid_out = err; *pid_out = err;
return(new); return new;
out_shutdown: out_shutdown:
os_shutdown_socket(socket[0], 1, 1); os_shutdown_socket(socket[0], 1, 1);
os_close_file(socket[0]); os_close_file(socket[0]);
os_shutdown_socket(socket[1], 1, 1); os_shutdown_socket(socket[1], 1, 1);
os_close_file(socket[1]); os_close_file(socket[1]);
out_close: out_close:
os_close_file(new); os_close_file(new);
return(err); return err;
} }
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment