summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorGary King <GKing@nvidia.com>2010-02-04 10:23:09 -0800
committerGary King <gking@nvidia.com>2010-02-10 20:05:56 -0800
commit140c5a12fb023152eded54a9e9aebb850463e0db (patch)
tree6ee4eaf751f293bb93676e8c02c68e58f4d454e0 /drivers
parent2d0001233c340d58f208e6a3440370297d43e26b (diff)
nvmap: change from platform device to mem device
in order to implement user vs super-user protections for the nvmap functionality, multiple device nodes need to be created with separate file operations, similar to the mem vs kmem separation. since nvmap is conceptually similar to the other "mem" class devices, the multiple device nodes are added as new minor numbers in the mem class, and the existing platform driver registration is removed. Change-Id: Ie260e4c56679682133d90a69c0985eaaa5a4d071
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/mem.c17
-rw-r--r--drivers/char/nvmap.c80
2 files changed, 26 insertions, 71 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index f91999c7b735..9785f1091721 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -903,6 +903,11 @@ static const struct file_operations kmsg_fops = {
.write = kmsg_write,
};
+#ifdef CONFIG_DEVNVMAP
+extern const struct file_operations nvmap_fops;
+extern const struct file_operations knvmap_fops;
+#endif
+
static int memory_open(struct inode * inode, struct file * filp)
{
int ret = 0;
@@ -952,6 +957,14 @@ static int memory_open(struct inode * inode, struct file * filp)
filp->f_op = &oldmem_fops;
break;
#endif
+#ifdef CONFIG_DEVNVMAP
+ case 13:
+ filp->f_op = &nvmap_fops;
+ break;
+ case 14:
+ filp->f_op = &knvmap_fops;
+ break;
+#endif
default:
unlock_kernel();
return -ENXIO;
@@ -990,6 +1003,10 @@ static const struct {
#ifdef CONFIG_CRASH_DUMP
{12,"oldmem", S_IRUSR | S_IWUSR | S_IRGRP, &oldmem_fops},
#endif
+#ifdef CONFIG_DEVNVMAP
+ {13, "nvmap", S_IRUGO | S_IWUGO, &nvmap_fops},
+ {14, "knvmap", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, &knvmap_fops },
+#endif
};
static struct class *mem_class;
diff --git a/drivers/char/nvmap.c b/drivers/char/nvmap.c
index e62247f9fb4a..f1a3f1ff11b9 100644
--- a/drivers/char/nvmap.c
+++ b/drivers/char/nvmap.c
@@ -90,7 +90,15 @@ static struct vm_operations_struct nvmap_vma_ops = {
.fault = nvmap_vma_fault,
};
-static struct file_operations nvmap_file_ops = {
+const struct file_operations nvmap_fops = {
+ .owner = THIS_MODULE,
+ .open = nvmap_open,
+ .release = nvmap_release,
+ .unlocked_ioctl = nvmap_ioctl,
+ .mmap = nvmap_mmap
+};
+
+const struct file_operations knvmap_fops = {
.owner = THIS_MODULE,
.open = nvmap_open,
.release = nvmap_release,
@@ -104,25 +112,6 @@ struct nvmap_vma_priv {
atomic_t ref;
};
-enum {
- NVMAP_DEV_DRAM = 0,
- NVMAP_DEV_IRAM,
- NVMAP_DEV_COUNT,
-};
-
-static struct {
- struct miscdevice dev;
- umode_t mode;
-} nvmap_device = {
-
- .dev = {
- .name = "nvmap",
- .fops = &nvmap_file_ops,
- .minor = MISC_DYNAMIC_MINOR,
- },
- .mode = S_IRUGO | S_IWUGO,
-};
-
static int _nvmap_map_pte(unsigned long pfn, pgprot_t prot, void **vaddr)
{
static unsigned int last_bit = 0;
@@ -626,40 +615,6 @@ static int nvmap_rw_handle(struct file *filp, int is_read,
return err;
}
-static int nvmap_probe(struct platform_device *pdev)
-{
- int e = 0;
- static int id_count = 0;
-
- /* only one nvmap device can be probed today */
- if (id_count)
- return -EINVAL;
-
- e = misc_register(&nvmap_device.dev);
-
- if (e<0)
- nvmap_device.dev.minor = MISC_DYNAMIC_MINOR;
- else
- id_count++;
-
- return e;
-}
-
-static int nvmap_remove(struct platform_device *pdev)
-{
- if (nvmap_device.dev.minor != MISC_DYNAMIC_MINOR)
- misc_deregister(&nvmap_device.dev);
- nvmap_device.dev.minor = MISC_DYNAMIC_MINOR;
-
- return 0;
-}
-
-static struct platform_driver nvmap_driver = {
- .probe = nvmap_probe,
- .remove = nvmap_remove,
- .driver = { .name = "nvmap_drv" }
-};
-
static int __init nvmap_pte_init(void)
{
u32 base = NVMAP_BASE;
@@ -687,20 +642,3 @@ static int __init nvmap_pte_init(void)
}
core_initcall(nvmap_pte_init);
-static int __init nvmap_init(void)
-{
- int err = bdi_init(&nvmap_bdi);
-
- if (err) return err;
-
- bitmap_zero(nvmap_ptebits, NVMAP_PAGES);
-
- return platform_driver_register(&nvmap_driver);
-}
-
-static void __exit nvmap_deinit(void) {
- platform_driver_unregister(&nvmap_driver);
-}
-
-module_init(nvmap_init);
-module_exit(nvmap_deinit);