Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47453
b: refs/heads/master
c: 67608e0
h: refs/heads/master
i:
  47451: fd681f3
v: v3
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed Feb 11, 2007
1 parent 264591d commit e9df36f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 55 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d832fc60d533d52da7170cf5f95271c331259bca
refs/heads/master: 67608e0c809ceca1b44755ee818199af7478ca77
46 changes: 23 additions & 23 deletions trunk/arch/um/drivers/port_kern.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
Expand Down Expand Up @@ -55,9 +55,9 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
if(fd < 0){
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);
os_close_file(conn->fd);
}
Expand All @@ -68,7 +68,7 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
list_add(&conn->list, &conn->port->connections);

complete(&conn->port->done);
return(IRQ_HANDLED);
return IRQ_HANDLED;
}

#define NO_WAITER_MSG \
Expand Down Expand Up @@ -97,14 +97,14 @@ static int port_accept(struct port_list *port)
"connection\n");
goto out_close;
}
*conn = ((struct connection)
*conn = ((struct connection)
{ .list = LIST_HEAD_INIT(conn->list),
.fd = fd,
.socket = { socket[0], socket[1] },
.telnetd_pid = pid,
.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,
"telnetd", conn)){
printk(KERN_ERR "port_accept : failed to get IRQ for "
Expand All @@ -117,17 +117,17 @@ static int port_accept(struct port_list *port)
printk("No one waiting for port\n");
}
list_add(&conn->list, &port->pending);
return(1);
return 1;

out_free:
kfree(conn);
out_close:
os_close_file(fd);
if(pid != -1)
if(pid != -1)
os_kill_process(pid, 1);
out:
return(ret);
}
return ret;
}

static DECLARE_MUTEX(ports_sem);
static struct list_head ports = LIST_HEAD_INIT(ports);
Expand Down Expand Up @@ -158,8 +158,8 @@ static irqreturn_t port_interrupt(int irq, void *data)

port->has_connection = 1;
schedule_work(&port_work);
return(IRQ_HANDLED);
}
return IRQ_HANDLED;
}

void *port_data(int port_num)
{
Expand All @@ -185,14 +185,14 @@ void *port_data(int port_num)
port_num, -fd);
goto out_free;
}
if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, "port",
port)){
if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
"port", port)){
printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
goto out_close;
}

*port = ((struct port_list)
*port = ((struct port_list)
{ .list = LIST_HEAD_INIT(port->list),
.wait_count = ATOMIC_INIT(0),
.has_connection = 0,
Expand Down Expand Up @@ -222,7 +222,7 @@ void *port_data(int port_num)
os_close_file(fd);
out:
up(&ports_sem);
return(dev);
return dev;
}

int port_wait(void *data)
Expand All @@ -232,28 +232,28 @@ int port_wait(void *data)
struct port_list *port = dev->port;
int fd;

atomic_inc(&port->wait_count);
atomic_inc(&port->wait_count);
while(1){
fd = -ERESTARTSYS;
if(wait_for_completion_interruptible(&port->done))
goto out;
if(wait_for_completion_interruptible(&port->done))
goto out;

spin_lock(&port->lock);

conn = list_entry(port->connections.next, struct connection,
conn = list_entry(port->connections.next, struct connection,
list);
list_del(&conn->list);
spin_unlock(&port->lock);

os_shutdown_socket(conn->socket[0], 1, 1);
os_close_file(conn->socket[0]);
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
* within the IRQ handler. So, pipe_interrupt always ups
* 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.
*/
free_irq(TELNETD_IRQ, conn);
Expand Down
51 changes: 20 additions & 31 deletions trunk/arch/um/drivers/port_user.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
Expand Down Expand Up @@ -38,18 +38,18 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
if(*str != ':'){
printk("port_init : channel type 'port' must specify a "
"port number\n");
return(NULL);
return NULL;
}
str++;
port = strtoul(str, &end, 0);
if((*end != '\0') || (end == str)){
printk("port_init : couldn't parse port '%s'\n", str);
return(NULL);
return NULL;
}

kern_data = port_data(port);
if(kern_data == NULL)
return(NULL);
return NULL;

data = um_kmalloc(sizeof(*data));
if(data == NULL)
Expand All @@ -59,10 +59,10 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
.kernel_data = kern_data });
sprintf(data->dev, "%d", port);

return(data);
return data;
err:
port_kern_free(kern_data);
return(NULL);
return NULL;
}

static void port_free(void *d)
Expand All @@ -83,14 +83,14 @@ static int port_open(int input, int output, int primary, void *d,
if((fd >= 0) && data->raw){
CATCH_EINTR(err = tcgetattr(fd, &data->tt));
if(err)
return(err);
return err;

err = raw(fd);
if(err)
return(err);
return err;
}
*dev_out = data->dev;
return(fd);
return fd;
}

static void port_close(int fd, void *d)
Expand Down Expand Up @@ -120,8 +120,8 @@ int port_listen_fd(int port)
int fd, err, arg;

fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1)
return(-errno);
if(fd == -1)
return -errno;

arg = 1;
if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
Expand All @@ -136,7 +136,7 @@ int port_listen_fd(int port)
err = -errno;
goto out;
}

if(listen(fd, 1) < 0){
err = -errno;
goto out;
Expand All @@ -146,10 +146,10 @@ int port_listen_fd(int port)
if(err < 0)
goto out;

return(fd);
return fd;
out:
os_close_file(fd);
return(err);
return err;
}

struct port_pre_exec_data {
Expand All @@ -173,13 +173,13 @@ void port_pre_exec(void *arg)
int port_connection(int fd, int *socket, int *pid_out)
{
int new, err;
char *argv[] = { "/usr/sbin/in.telnetd", "-L",
char *argv[] = { "/usr/sbin/in.telnetd", "-L",
"/usr/lib/uml/port-helper", NULL };
struct port_pre_exec_data data;

new = os_accept_connection(fd);
if(new < 0)
return(new);
return new;

err = os_pipe(socket, 0, 0);
if(err < 0)
Expand All @@ -190,29 +190,18 @@ int port_connection(int fd, int *socket, int *pid_out)
.pipe_fd = socket[1] });

err = run_helper(port_pre_exec, &data, argv, NULL);
if(err < 0)
if(err < 0)
goto out_shutdown;

*pid_out = err;
return(new);
return new;

out_shutdown:
os_shutdown_socket(socket[0], 1, 1);
os_close_file(socket[0]);
os_shutdown_socket(socket[1], 1, 1);
os_shutdown_socket(socket[1], 1, 1);
os_close_file(socket[1]);
out_close:
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:
*/

0 comments on commit e9df36f

Please sign in to comment.