diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/core.c | 2 | ||||
-rw-r--r-- | drivers/char/mem.c | 29 | ||||
-rw-r--r-- | drivers/char/misc.c | 10 | ||||
-rw-r--r-- | drivers/char/raw.c | 4 | ||||
-rw-r--r-- | drivers/char/tty_io.c | 11 |
5 files changed, 39 insertions, 17 deletions
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index fc93e2fc7c71..1573aebd54b5 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c | |||
@@ -153,7 +153,7 @@ static const struct file_operations rng_chrdev_ops = { | |||
153 | static struct miscdevice rng_miscdev = { | 153 | static struct miscdevice rng_miscdev = { |
154 | .minor = RNG_MISCDEV_MINOR, | 154 | .minor = RNG_MISCDEV_MINOR, |
155 | .name = RNG_MODULE_NAME, | 155 | .name = RNG_MODULE_NAME, |
156 | .devnode = "hwrng", | 156 | .nodename = "hwrng", |
157 | .fops = &rng_chrdev_ops, | 157 | .fops = &rng_chrdev_ops, |
158 | }; | 158 | }; |
159 | 159 | ||
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 0491cdf63f2a..0aede1d6a9ea 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -866,24 +866,25 @@ static const struct file_operations kmsg_fops = { | |||
866 | 866 | ||
867 | static const struct memdev { | 867 | static const struct memdev { |
868 | const char *name; | 868 | const char *name; |
869 | mode_t mode; | ||
869 | const struct file_operations *fops; | 870 | const struct file_operations *fops; |
870 | struct backing_dev_info *dev_info; | 871 | struct backing_dev_info *dev_info; |
871 | } devlist[] = { | 872 | } devlist[] = { |
872 | [ 1] = { "mem", &mem_fops, &directly_mappable_cdev_bdi }, | 873 | [1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi }, |
873 | #ifdef CONFIG_DEVKMEM | 874 | #ifdef CONFIG_DEVKMEM |
874 | [ 2] = { "kmem", &kmem_fops, &directly_mappable_cdev_bdi }, | 875 | [2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi }, |
875 | #endif | 876 | #endif |
876 | [ 3] = {"null", &null_fops, NULL }, | 877 | [3] = { "null", 0666, &null_fops, NULL }, |
877 | #ifdef CONFIG_DEVPORT | 878 | #ifdef CONFIG_DEVPORT |
878 | [ 4] = { "port", &port_fops, NULL }, | 879 | [4] = { "port", 0, &port_fops, NULL }, |
879 | #endif | 880 | #endif |
880 | [ 5] = { "zero", &zero_fops, &zero_bdi }, | 881 | [5] = { "zero", 0666, &zero_fops, &zero_bdi }, |
881 | [ 7] = { "full", &full_fops, NULL }, | 882 | [7] = { "full", 0666, &full_fops, NULL }, |
882 | [ 8] = { "random", &random_fops, NULL }, | 883 | [8] = { "random", 0666, &random_fops, NULL }, |
883 | [ 9] = { "urandom", &urandom_fops, NULL }, | 884 | [9] = { "urandom", 0666, &urandom_fops, NULL }, |
884 | [11] = { "kmsg", &kmsg_fops, NULL }, | 885 | [11] = { "kmsg", 0, &kmsg_fops, NULL }, |
885 | #ifdef CONFIG_CRASH_DUMP | 886 | #ifdef CONFIG_CRASH_DUMP |
886 | [12] = { "oldmem", &oldmem_fops, NULL }, | 887 | [12] = { "oldmem", 0, &oldmem_fops, NULL }, |
887 | #endif | 888 | #endif |
888 | }; | 889 | }; |
889 | 890 | ||
@@ -920,6 +921,13 @@ static const struct file_operations memory_fops = { | |||
920 | .open = memory_open, | 921 | .open = memory_open, |
921 | }; | 922 | }; |
922 | 923 | ||
924 | static char *mem_devnode(struct device *dev, mode_t *mode) | ||
925 | { | ||
926 | if (mode && devlist[MINOR(dev->devt)].mode) | ||
927 | *mode = devlist[MINOR(dev->devt)].mode; | ||
928 | return NULL; | ||
929 | } | ||
930 | |||
923 | static struct class *mem_class; | 931 | static struct class *mem_class; |
924 | 932 | ||
925 | static int __init chr_dev_init(void) | 933 | static int __init chr_dev_init(void) |
@@ -935,6 +943,7 @@ static int __init chr_dev_init(void) | |||
935 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); | 943 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); |
936 | 944 | ||
937 | mem_class = class_create(THIS_MODULE, "mem"); | 945 | mem_class = class_create(THIS_MODULE, "mem"); |
946 | mem_class->devnode = mem_devnode; | ||
938 | for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { | 947 | for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { |
939 | if (!devlist[minor].name) | 948 | if (!devlist[minor].name) |
940 | continue; | 949 | continue; |
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 62c99fa59e2b..1ee27cc23426 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
@@ -263,12 +263,14 @@ int misc_deregister(struct miscdevice *misc) | |||
263 | EXPORT_SYMBOL(misc_register); | 263 | EXPORT_SYMBOL(misc_register); |
264 | EXPORT_SYMBOL(misc_deregister); | 264 | EXPORT_SYMBOL(misc_deregister); |
265 | 265 | ||
266 | static char *misc_nodename(struct device *dev) | 266 | static char *misc_devnode(struct device *dev, mode_t *mode) |
267 | { | 267 | { |
268 | struct miscdevice *c = dev_get_drvdata(dev); | 268 | struct miscdevice *c = dev_get_drvdata(dev); |
269 | 269 | ||
270 | if (c->devnode) | 270 | if (mode && c->mode) |
271 | return kstrdup(c->devnode, GFP_KERNEL); | 271 | *mode = c->mode; |
272 | if (c->nodename) | ||
273 | return kstrdup(c->nodename, GFP_KERNEL); | ||
272 | return NULL; | 274 | return NULL; |
273 | } | 275 | } |
274 | 276 | ||
@@ -287,7 +289,7 @@ static int __init misc_init(void) | |||
287 | err = -EIO; | 289 | err = -EIO; |
288 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) | 290 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) |
289 | goto fail_printk; | 291 | goto fail_printk; |
290 | misc_class->nodename = misc_nodename; | 292 | misc_class->devnode = misc_devnode; |
291 | return 0; | 293 | return 0; |
292 | 294 | ||
293 | fail_printk: | 295 | fail_printk: |
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index 40268db02e22..64acd05f71c8 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -261,7 +261,7 @@ static const struct file_operations raw_ctl_fops = { | |||
261 | 261 | ||
262 | static struct cdev raw_cdev; | 262 | static struct cdev raw_cdev; |
263 | 263 | ||
264 | static char *raw_nodename(struct device *dev) | 264 | static char *raw_devnode(struct device *dev, mode_t *mode) |
265 | { | 265 | { |
266 | return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev)); | 266 | return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev)); |
267 | } | 267 | } |
@@ -289,7 +289,7 @@ static int __init raw_init(void) | |||
289 | ret = PTR_ERR(raw_class); | 289 | ret = PTR_ERR(raw_class); |
290 | goto error_region; | 290 | goto error_region; |
291 | } | 291 | } |
292 | raw_class->nodename = raw_nodename; | 292 | raw_class->devnode = raw_devnode; |
293 | device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); | 293 | device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); |
294 | 294 | ||
295 | return 0; | 295 | return 0; |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 05f443c47bbe..ea18a129b0b5 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -3070,11 +3070,22 @@ void __init console_init(void) | |||
3070 | } | 3070 | } |
3071 | } | 3071 | } |
3072 | 3072 | ||
3073 | static char *tty_devnode(struct device *dev, mode_t *mode) | ||
3074 | { | ||
3075 | if (!mode) | ||
3076 | return NULL; | ||
3077 | if (dev->devt == MKDEV(TTYAUX_MAJOR, 0) || | ||
3078 | dev->devt == MKDEV(TTYAUX_MAJOR, 2)) | ||
3079 | *mode = 0666; | ||
3080 | return NULL; | ||
3081 | } | ||
3082 | |||
3073 | static int __init tty_class_init(void) | 3083 | static int __init tty_class_init(void) |
3074 | { | 3084 | { |
3075 | tty_class = class_create(THIS_MODULE, "tty"); | 3085 | tty_class = class_create(THIS_MODULE, "tty"); |
3076 | if (IS_ERR(tty_class)) | 3086 | if (IS_ERR(tty_class)) |
3077 | return PTR_ERR(tty_class); | 3087 | return PTR_ERR(tty_class); |
3088 | tty_class->devnode = tty_devnode; | ||
3078 | return 0; | 3089 | return 0; |
3079 | } | 3090 | } |
3080 | 3091 | ||