Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] uml: const more data

Make lots of structures const in order to make it obvious that they need no
locking.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jeff Dike and committed by
Linus Torvalds
5e7672ec 48af05ed

+65 -65
+8 -8
arch/um/drivers/chan_kern.c
··· 110 110 "UML\n"); 111 111 } 112 112 113 - static struct chan_ops not_configged_ops = { 113 + static const struct chan_ops not_configged_ops = { 114 114 .init = not_configged_init, 115 115 .open = not_configged_open, 116 116 .close = not_configged_close, ··· 373 373 } 374 374 375 375 int console_open_chan(struct line *line, struct console *co, 376 - struct chan_opts *opts) 376 + const struct chan_opts *opts) 377 377 { 378 378 int err; 379 379 ··· 494 494 495 495 struct chan_type { 496 496 char *key; 497 - struct chan_ops *ops; 497 + const struct chan_ops *ops; 498 498 }; 499 499 500 - static struct chan_type chan_table[] = { 500 + static const struct chan_type chan_table[] = { 501 501 { "fd", &fd_ops }, 502 502 503 503 #ifdef CONFIG_NULL_CHAN ··· 534 534 }; 535 535 536 536 static struct chan *parse_chan(struct line *line, char *str, int device, 537 - struct chan_opts *opts) 537 + const struct chan_opts *opts) 538 538 { 539 - struct chan_type *entry; 540 - struct chan_ops *ops; 539 + const struct chan_type *entry; 540 + const struct chan_ops *ops; 541 541 struct chan *chan; 542 542 void *data; 543 543 int i; ··· 582 582 } 583 583 584 584 int parse_chan_pair(char *str, struct line *line, int device, 585 - struct chan_opts *opts) 585 + const struct chan_opts *opts) 586 586 { 587 587 struct list_head *chans = &line->chan_list; 588 588 struct chan *new, *chan;
+1 -1
arch/um/drivers/daemon.h
··· 18 18 void *dev; 19 19 }; 20 20 21 - extern struct net_user_info daemon_user_info; 21 + extern const struct net_user_info daemon_user_info; 22 22 23 23 extern int daemon_user_write(int fd, void *buf, int len, 24 24 struct daemon_data *pri);
+1 -1
arch/um/drivers/daemon_kern.c
··· 57 57 (struct daemon_data *) &lp->user)); 58 58 } 59 59 60 - static struct net_kern_info daemon_kern_info = { 60 + static const struct net_kern_info daemon_kern_info = { 61 61 .init = daemon_init, 62 62 .protocol = eth_protocol, 63 63 .read = daemon_read,
+1 -1
arch/um/drivers/daemon_user.c
··· 182 182 return(mtu); 183 183 } 184 184 185 - struct net_user_info daemon_user_info = { 185 + const struct net_user_info daemon_user_info = { 186 186 .init = daemon_user_init, 187 187 .open = daemon_open, 188 188 .close = NULL,
+2 -2
arch/um/drivers/fd.c
··· 20 20 char str[sizeof("1234567890\0")]; 21 21 }; 22 22 23 - static void *fd_init(char *str, int device, struct chan_opts *opts) 23 + static void *fd_init(char *str, int device, const struct chan_opts *opts) 24 24 { 25 25 struct fd_chan *data; 26 26 char *end; ··· 77 77 } 78 78 } 79 79 80 - struct chan_ops fd_ops = { 80 + const struct chan_ops fd_ops = { 81 81 .type = "fd", 82 82 .init = fd_init, 83 83 .open = fd_open,
+2 -2
arch/um/drivers/hostaudio_kern.c
··· 280 280 281 281 /* kernel module operations */ 282 282 283 - static struct file_operations hostaudio_fops = { 283 + static const struct file_operations hostaudio_fops = { 284 284 .owner = THIS_MODULE, 285 285 .llseek = no_llseek, 286 286 .read = hostaudio_read, ··· 292 292 .release = hostaudio_release, 293 293 }; 294 294 295 - static struct file_operations hostmixer_fops = { 295 + static const struct file_operations hostmixer_fops = { 296 296 .owner = THIS_MODULE, 297 297 .llseek = no_llseek, 298 298 .ioctl = hostmixer_ioctl_mixdev,
+3 -3
arch/um/drivers/line.c
··· 251 251 /* nothing */ 252 252 } 253 253 254 - static struct { 254 + static const struct { 255 255 int cmd; 256 256 char *level; 257 257 char *name; ··· 405 405 406 406 int line_setup_irq(int fd, int input, int output, struct line *line, void *data) 407 407 { 408 - struct line_driver *driver = line->driver; 408 + const struct line_driver *driver = line->driver; 409 409 int err = 0, flags = IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM; 410 410 411 411 if (input) ··· 558 558 } 559 559 560 560 int line_config(struct line *lines, unsigned int num, char *str, 561 - struct chan_opts *opts) 561 + const struct chan_opts *opts) 562 562 { 563 563 struct line *line; 564 564 char *new;
+1 -1
arch/um/drivers/mcast.h
··· 13 13 void *dev; 14 14 }; 15 15 16 - extern struct net_user_info mcast_user_info; 16 + extern const struct net_user_info mcast_user_info; 17 17 18 18 extern int mcast_user_write(int fd, void *buf, int len, 19 19 struct mcast_data *pri);
+1 -1
arch/um/drivers/mcast_kern.c
··· 61 61 (struct mcast_data *) &lp->user); 62 62 } 63 63 64 - static struct net_kern_info mcast_kern_info = { 64 + static const struct net_kern_info mcast_kern_info = { 65 65 .init = mcast_init, 66 66 .protocol = eth_protocol, 67 67 .read = mcast_read,
+1 -1
arch/um/drivers/mcast_user.c
··· 152 152 return(mtu); 153 153 } 154 154 155 - struct net_user_info mcast_user_info = { 155 + const struct net_user_info mcast_user_info = { 156 156 .init = mcast_user_init, 157 157 .open = mcast_open, 158 158 .close = mcast_close,
+2 -2
arch/um/drivers/mmapper_kern.c
··· 85 85 return 0; 86 86 } 87 87 88 - static struct file_operations mmapper_fops = { 88 + static const struct file_operations mmapper_fops = { 89 89 .owner = THIS_MODULE, 90 90 .read = mmapper_read, 91 91 .write = mmapper_write, ··· 95 95 .release = mmapper_release, 96 96 }; 97 97 98 - static struct miscdevice mmapper_dev = { 98 + static const struct miscdevice mmapper_dev = { 99 99 .minor = MISC_DYNAMIC_MINOR, 100 100 .name = "mmapper", 101 101 .fops = &mmapper_fops
+2 -2
arch/um/drivers/null.c
··· 10 10 11 11 static int null_chan; 12 12 13 - static void *null_init(char *str, int device, struct chan_opts *opts) 13 + static void *null_init(char *str, int device, const struct chan_opts *opts) 14 14 { 15 15 return(&null_chan); 16 16 } ··· 31 31 { 32 32 } 33 33 34 - struct chan_ops null_ops = { 34 + const struct chan_ops null_ops = { 35 35 .type = "null", 36 36 .init = null_init, 37 37 .open = null_open,
+1 -1
arch/um/drivers/pcap_kern.c
··· 46 46 return(-EPERM); 47 47 } 48 48 49 - static struct net_kern_info pcap_kern_info = { 49 + static const struct net_kern_info pcap_kern_info = { 50 50 .init = pcap_init, 51 51 .protocol = eth_protocol, 52 52 .read = pcap_read,
+1 -1
arch/um/drivers/pcap_user.c
··· 120 120 return(hdata.len); 121 121 } 122 122 123 - struct net_user_info pcap_user_info = { 123 + const struct net_user_info pcap_user_info = { 124 124 .init = pcap_user_init, 125 125 .open = pcap_open, 126 126 .close = NULL,
+2 -2
arch/um/drivers/port_user.c
··· 27 27 char dev[sizeof("32768\0")]; 28 28 }; 29 29 30 - static void *port_init(char *str, int device, struct chan_opts *opts) 30 + static void *port_init(char *str, int device, const struct chan_opts *opts) 31 31 { 32 32 struct port_chan *data; 33 33 void *kern_data; ··· 100 100 os_close_file(fd); 101 101 } 102 102 103 - struct chan_ops port_ops = { 103 + const struct chan_ops port_ops = { 104 104 .type = "port", 105 105 .init = port_init, 106 106 .open = port_open,
+3 -3
arch/um/drivers/pty.c
··· 22 22 char dev_name[sizeof("/dev/pts/0123456\0")]; 23 23 }; 24 24 25 - static void *pty_chan_init(char *str, int device, struct chan_opts *opts) 25 + static void *pty_chan_init(char *str, int device, const struct chan_opts *opts) 26 26 { 27 27 struct pty_chan *data; 28 28 ··· 118 118 return(fd); 119 119 } 120 120 121 - struct chan_ops pty_ops = { 121 + const struct chan_ops pty_ops = { 122 122 .type = "pty", 123 123 .init = pty_chan_init, 124 124 .open = pty_open, ··· 131 131 .winch = 0, 132 132 }; 133 133 134 - struct chan_ops pts_ops = { 134 + const struct chan_ops pts_ops = { 135 135 .type = "pts", 136 136 .init = pty_chan_init, 137 137 .open = pts_open,
+1 -1
arch/um/drivers/random.c
··· 68 68 return ret; 69 69 } 70 70 71 - static struct file_operations rng_chrdev_ops = { 71 + static const struct file_operations rng_chrdev_ops = { 72 72 .owner = THIS_MODULE, 73 73 .open = rng_dev_open, 74 74 .read = rng_dev_read,
+1 -1
arch/um/drivers/slip.h
··· 12 12 struct slip_proto slip; 13 13 }; 14 14 15 - extern struct net_user_info slip_user_info; 15 + extern const struct net_user_info slip_user_info; 16 16 17 17 extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri); 18 18 extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri);
+1 -1
arch/um/drivers/slip_kern.c
··· 61 61 (struct slip_data *) &lp->user)); 62 62 } 63 63 64 - struct net_kern_info slip_kern_info = { 64 + const struct net_kern_info slip_kern_info = { 65 65 .init = slip_init, 66 66 .protocol = slip_protocol, 67 67 .read = slip_read,
+1 -1
arch/um/drivers/slip_user.c
··· 241 241 close_addr(addr, netmask, pri->name); 242 242 } 243 243 244 - struct net_user_info slip_user_info = { 244 + const struct net_user_info slip_user_info = { 245 245 .init = slip_user_init, 246 246 .open = slip_open, 247 247 .close = slip_close,
+1 -1
arch/um/drivers/slirp.h
··· 24 24 struct slip_proto slip; 25 25 }; 26 26 27 - extern struct net_user_info slirp_user_info; 27 + extern const struct net_user_info slirp_user_info; 28 28 29 29 extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri); 30 30 extern int slirp_user_write(int fd, void *buf, int len,
+1 -1
arch/um/drivers/slirp_kern.c
··· 64 64 (struct slirp_data *) &lp->user)); 65 65 } 66 66 67 - struct net_kern_info slirp_kern_info = { 67 + const struct net_kern_info slirp_kern_info = { 68 68 .init = slirp_init, 69 69 .protocol = slirp_protocol, 70 70 .read = slirp_read,
+1 -1
arch/um/drivers/slirp_user.c
··· 126 126 return(mtu); 127 127 } 128 128 129 - struct net_user_info slirp_user_info = { 129 + const struct net_user_info slirp_user_info = { 130 130 .init = slirp_user_init, 131 131 .open = slirp_open, 132 132 .close = slirp_close,
+2 -2
arch/um/drivers/ssl.c
··· 23 23 #include "irq_user.h" 24 24 #include "mconsole_kern.h" 25 25 26 - static int ssl_version = 1; 26 + static const int ssl_version = 1; 27 27 28 28 /* Referenced only by tty_driver below - presumably it's locked correctly 29 29 * by the tty driver. ··· 123 123 } 124 124 #endif 125 125 126 - static struct tty_operations ssl_ops = { 126 + static const struct tty_operations ssl_ops = { 127 127 .open = ssl_open, 128 128 .close = line_close, 129 129 .write = line_write,
+1 -1
arch/um/drivers/stdio_console.c
··· 110 110 111 111 static int con_init_done = 0; 112 112 113 - static struct tty_operations console_ops = { 113 + static const struct tty_operations console_ops = { 114 114 .open = con_open, 115 115 .close = line_close, 116 116 .write = line_write,
+2 -2
arch/um/drivers/tty.c
··· 18 18 struct termios tt; 19 19 }; 20 20 21 - static void *tty_chan_init(char *str, int device, struct chan_opts *opts) 21 + static void *tty_chan_init(char *str, int device, const struct chan_opts *opts) 22 22 { 23 23 struct tty_chan *data; 24 24 ··· 62 62 return fd; 63 63 } 64 64 65 - struct chan_ops tty_ops = { 65 + const struct chan_ops tty_ops = { 66 66 .type = "tty", 67 67 .init = tty_chan_init, 68 68 .open = tty_open,
+2 -2
arch/um/drivers/xterm.c
··· 31 31 }; 32 32 33 33 /* Not static because it's called directly by the tt mode gdb code */ 34 - void *xterm_init(char *str, int device, struct chan_opts *opts) 34 + void *xterm_init(char *str, int device, const struct chan_opts *opts) 35 35 { 36 36 struct xterm_chan *data; 37 37 ··· 194 194 free(d); 195 195 } 196 196 197 - struct chan_ops xterm_ops = { 197 + const struct chan_ops xterm_ops = { 198 198 .type = "xterm", 199 199 .init = xterm_init, 200 200 .open = xterm_open,
+3 -3
arch/um/include/chan_kern.h
··· 23 23 unsigned int opened:1; 24 24 unsigned int enabled:1; 25 25 int fd; 26 - struct chan_ops *ops; 26 + const struct chan_ops *ops; 27 27 void *data; 28 28 }; 29 29 30 30 extern void chan_interrupt(struct list_head *chans, struct work_struct *task, 31 31 struct tty_struct *tty, int irq); 32 32 extern int parse_chan_pair(char *str, struct line *line, int device, 33 - struct chan_opts *opts); 33 + const struct chan_opts *opts); 34 34 extern int open_chan(struct list_head *chans); 35 35 extern int write_chan(struct list_head *chans, const char *buf, int len, 36 36 int write_irq); 37 37 extern int console_write_chan(struct list_head *chans, const char *buf, 38 38 int len); 39 39 extern int console_open_chan(struct line *line, struct console *co, 40 - struct chan_opts *opts); 40 + const struct chan_opts *opts); 41 41 extern void deactivate_chan(struct list_head *chans, int irq); 42 42 extern void reactivate_chan(struct list_head *chans, int irq); 43 43 extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty);
+3 -3
arch/um/include/chan_user.h
··· 20 20 21 21 struct chan_ops { 22 22 char *type; 23 - void *(*init)(char *, int, struct chan_opts *); 23 + void *(*init)(char *, int, const struct chan_opts *); 24 24 int (*open)(int, int, int, void *, char **); 25 25 void (*close)(int, void *); 26 26 int (*read)(int, char *, void *); ··· 31 31 int winch; 32 32 }; 33 33 34 - extern struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, tty_ops, 35 - xterm_ops; 34 + extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, 35 + tty_ops, xterm_ops; 36 36 37 37 extern void generic_close(int fd, void *unused); 38 38 extern int generic_read(int fd, char *c_out, void *unused);
+1 -1
arch/um/include/kern_util.h
··· 21 21 kern_hndl timer_handler; 22 22 }; 23 23 24 - extern struct kern_handlers handlinfo_kern; 24 + extern const struct kern_handlers handlinfo_kern; 25 25 26 26 extern int ncpus; 27 27 extern char *linux_prog;
+2 -2
arch/um/include/line.h
··· 52 52 53 53 int sigio; 54 54 struct work_struct task; 55 - struct line_driver *driver; 55 + const struct line_driver *driver; 56 56 int have_irq; 57 57 }; 58 58 ··· 99 99 extern void close_lines(struct line *lines, int nlines); 100 100 101 101 extern int line_config(struct line *lines, unsigned int sizeof_lines, 102 - char *str, struct chan_opts *opts); 102 + char *str, const struct chan_opts *opts); 103 103 extern int line_id(char **str, int *start_out, int *end_out); 104 104 extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n); 105 105 extern int line_get_config(char *dev, struct line *lines,
+2 -2
arch/um/include/net_kern.h
··· 54 54 struct list_head list; 55 55 char *name; 56 56 int (*setup)(char *, char **, void *); 57 - struct net_user_info *user; 58 - struct net_kern_info *kern; 57 + const struct net_user_info *user; 58 + const struct net_kern_info *kern; 59 59 int private_size; 60 60 int setup_size; 61 61 };
+1 -1
arch/um/kernel/trap.c
··· 140 140 segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs); 141 141 } 142 142 143 - struct kern_handlers handlinfo_kern = { 143 + const struct kern_handlers handlinfo_kern = { 144 144 .relay_signal = relay_signal, 145 145 .winch = winch, 146 146 .bus_handler = relay_signal,
+1 -1
arch/um/kernel/um_arch.c
··· 106 106 { 107 107 } 108 108 109 - struct seq_operations cpuinfo_op = { 109 + const struct seq_operations cpuinfo_op = { 110 110 .start = c_start, 111 111 .next = c_next, 112 112 .stop = c_stop,
+1 -1
arch/um/os-Linux/drivers/etap.h
··· 13 13 void *dev; 14 14 }; 15 15 16 - extern struct net_user_info ethertap_user_info; 16 + extern const struct net_user_info ethertap_user_info; 17 17 18 18 /* 19 19 * Overrides for Emacs so that we follow Linus's tabbing style.
+1 -1
arch/um/os-Linux/drivers/ethertap_kern.c
··· 65 65 return(net_send(fd, (*skb)->data, (*skb)->len)); 66 66 } 67 67 68 - struct net_kern_info ethertap_kern_info = { 68 + const struct net_kern_info ethertap_kern_info = { 69 69 .init = etap_init, 70 70 .protocol = eth_protocol, 71 71 .read = etap_read,
+1 -1
arch/um/os-Linux/drivers/ethertap_user.c
··· 216 216 etap_close_addr(addr, netmask, &pri->control_fd); 217 217 } 218 218 219 - struct net_user_info ethertap_user_info = { 219 + const struct net_user_info ethertap_user_info = { 220 220 .init = etap_user_init, 221 221 .open = etap_open, 222 222 .close = etap_close,
+1 -1
arch/um/os-Linux/drivers/tuntap.h
··· 16 16 void *dev; 17 17 }; 18 18 19 - extern struct net_user_info tuntap_user_info; 19 + extern const struct net_user_info tuntap_user_info; 20 20 21 21 #endif 22 22
+1 -1
arch/um/os-Linux/drivers/tuntap_kern.c
··· 53 53 return(net_write(fd, (*skb)->data, (*skb)->len)); 54 54 } 55 55 56 - struct net_kern_info tuntap_kern_info = { 56 + const struct net_kern_info tuntap_kern_info = { 57 57 .init = tuntap_init, 58 58 .protocol = eth_protocol, 59 59 .read = tuntap_read,
+1 -1
arch/um/os-Linux/drivers/tuntap_user.c
··· 205 205 return(mtu); 206 206 } 207 207 208 - struct net_user_info tuntap_user_info = { 208 + const struct net_user_info tuntap_user_info = { 209 209 .init = tuntap_user_init, 210 210 .open = tuntap_open, 211 211 .close = tuntap_close,