diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-02-24 00:12:35 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-02-24 00:12:35 +0000 |
commit | 482368b1a8e45430672c58c9a42e7d2004367126 (patch) | |
tree | ce2a1a567d4d62dee7c2e71a46a99cf72cf1d606 /drivers/char/mem.c | |
parent | e4d0251c6f56ab2e191afb70f80f382793e23f74 (diff) |
Merge with 2.3.47. Guys, this is buggy as shit. You've been warned.
Diffstat (limited to 'drivers/char/mem.c')
-rw-r--r-- | drivers/char/mem.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 09c12be26..e70860ea9 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -2,6 +2,9 @@ * linux/drivers/char/mem.c * * Copyright (C) 1991, 1992 Linus Torvalds + * + * Added devfs support. + * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu> */ #include <linux/config.h> @@ -58,9 +61,6 @@ extern void mda_console_init(void); #if defined(CONFIG_ADB) extern void adbdev_init(void); #endif -#ifdef CONFIG_USB -extern void usb_init(void); -#endif #ifdef CONFIG_PHONE extern void telephony_init(void); #endif @@ -248,14 +248,16 @@ static ssize_t read_kmem(struct file *file, char *buf, if (p < PAGE_SIZE && read > 0) { size_t tmp = PAGE_SIZE - p; if (tmp > read) tmp = read; - clear_user(buf, tmp); + if (clear_user(buf, tmp)) + return -EFAULT; buf += tmp; p += tmp; read -= tmp; count -= tmp; } #endif - copy_to_user(buf, (char *)p, read); + if (copy_to_user(buf, (char *)p, read)) + return -EFAULT; p += read; buf += read; count -= read; @@ -574,19 +576,47 @@ static int memory_open(struct inode * inode, struct file * filp) return 0; } +void __init memory_devfs_register (void) +{ + /* These are never unregistered */ + static const struct { + unsigned short minor; + char *name; + umode_t mode; + struct file_operations *fops; + } list[] = { /* list of minor devices */ + {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops}, + {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops}, + {3, "null", S_IRUGO | S_IWUGO, &null_fops}, +#if (!defined(CONFIG_PPC) && !defined(__mc68000__) && !defined(__mips__)) || \ + defined(CONFIG_HAVE_IO_PORTS) + {4, "port", S_IRUSR | S_IWUSR | S_IRGRP, &port_fops}, +#endif + {5, "zero", S_IRUGO | S_IWUGO, &zero_fops}, + {7, "full", S_IRUGO | S_IWUGO, &full_fops}, + {8, "random", S_IRUGO | S_IWUSR, &random_fops}, + {9, "urandom", S_IRUGO | S_IWUSR, &urandom_fops} + }; + int i; + + for (i=0; i<(sizeof(list)/sizeof(*list)); i++) + devfs_register (NULL, list[i].name, 0, DEVFS_FL_NONE, + MEM_MAJOR, list[i].minor, + list[i].mode | S_IFCHR, 0, 0, + list[i].fops, NULL); +} + static struct file_operations memory_fops = { open: memory_open, /* just a selector for the real open */ }; int __init chr_dev_init(void) { - if (register_chrdev(MEM_MAJOR,"mem",&memory_fops)) + if (devfs_register_chrdev(MEM_MAJOR,"mem",&memory_fops)) printk("unable to get major %d for memory devs\n", MEM_MAJOR); + memory_devfs_register(); rand_initialize(); raw_init(); -#ifdef CONFIG_USB - usb_init(); -#endif #ifdef CONFIG_I2C i2c_init_all(); #endif |