X-Git-Url: http://git.agner.ch/gitweb/?p=linux-drm-fsl-dcu.git;a=blobdiff_plain;f=arch%2Fum%2Fdrivers%2Fport_user.c;h=80508023054f27bfc493827eeb3e53cbc864f7b0;hp=c43e8bb3250264940af52ea528fe6a378fe41f67;hb=f8abea8f8c24ecdad6d6861bffb912f23f2741cd;hpb=e1d7a2de6c4249072dd886c129410e11e637ceff diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c index c43e8bb32502..80508023054f 100644 --- a/arch/um/drivers/port_user.c +++ b/arch/um/drivers/port_user.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) * Licensed under the GPL */ @@ -19,6 +19,7 @@ #include "chan_user.h" #include "port.h" #include "os.h" +#include "um_malloc.h" struct port_chan { int raw; @@ -27,7 +28,7 @@ struct port_chan { char dev[sizeof("32768\0")]; }; -static void *port_init(char *str, int device, struct chan_opts *opts) +static void *port_init(char *str, int device, const struct chan_opts *opts) { struct port_chan *data; void *kern_data; @@ -37,18 +38,18 @@ static void *port_init(char *str, int device, 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) @@ -58,10 +59,10 @@ static void *port_init(char *str, int device, 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) @@ -82,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) @@ -100,7 +101,7 @@ static void port_close(int fd, void *d) os_close_file(fd); } -struct chan_ops port_ops = { +const struct chan_ops port_ops = { .type = "port", .init = port_init, .open = port_open, @@ -119,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){ @@ -135,7 +136,7 @@ int port_listen_fd(int port) err = -errno; goto out; } - + if(listen(fd, 1) < 0){ err = -errno; goto out; @@ -145,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 { @@ -172,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) @@ -189,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: - */