]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/dsp/dsp_ctl_core.c
ARM: OMAP: DSPGW: cleanup
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / dsp / dsp_ctl_core.c
1 /*
2  * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
3  *
4  * Copyright (C) 2004-2006 Nokia Corporation. All rights reserved.
5  *
6  * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23
24 #include <linux/major.h>
25 #include <linux/fs.h>
26 #include <linux/device.h>
27 #include <linux/init.h>
28 #include "dsp.h"
29
30 #define CTL_MINOR       0
31 #define MEM_MINOR       1
32 #define TWCH_MINOR      2
33 #define ERR_MINOR       3
34
35 static struct class *dsp_ctl_class;
36 extern struct file_operations dsp_ctl_fops,
37                               dsp_mem_fops,
38                               dsp_twch_fops,
39                               dsp_err_fops;
40
41 static int dsp_ctl_core_open(struct inode *inode, struct file *file)
42 {
43         switch (iminor(inode)) {
44         case CTL_MINOR:
45                 file->f_op = &dsp_ctl_fops;
46                 break;
47         case MEM_MINOR:
48                 file->f_op = &dsp_mem_fops;
49                 break;
50         case TWCH_MINOR:
51                 file->f_op = &dsp_twch_fops;
52                 break;
53         case ERR_MINOR:
54                 file->f_op = &dsp_err_fops;
55                 break;
56         default:
57                 return -ENXIO;
58         }
59         if (file->f_op && file->f_op->open)
60                 return file->f_op->open(inode, file);
61         return 0;
62 }
63
64 static struct file_operations dsp_ctl_core_fops = {
65         .owner = THIS_MODULE,
66         .open  = dsp_ctl_core_open,
67 };
68
69 static const struct dev_list {
70         unsigned int    minor;
71         char            *devname;
72         umode_t         mode;
73 } dev_list[] = {
74         {CTL_MINOR,  "dspctl",  S_IRUSR | S_IWUSR},
75         {MEM_MINOR,  "dspmem",  S_IRUSR | S_IWUSR | S_IRGRP},
76         {TWCH_MINOR, "dsptwch", S_IRUSR | S_IWUSR | S_IRGRP},
77         {ERR_MINOR,  "dsperr",  S_IRUSR | S_IRGRP},
78 };
79
80 int __init dsp_ctl_core_init(void)
81 {
82         int retval;
83         int i;
84
85         retval = register_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl",
86                                  &dsp_ctl_core_fops);
87         if (retval < 0) {
88                 printk(KERN_ERR
89                        "omapdsp: failed to register dspctl device: %d\n",
90                        retval);
91                 return retval;
92         }
93
94         dsp_ctl_class = class_create(THIS_MODULE, "dspctl");
95         for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
96                 class_device_create(dsp_ctl_class, NULL,
97                                     MKDEV(OMAP_DSP_CTL_MAJOR,
98                                           dev_list[i].minor),
99                                     NULL, dev_list[i].devname);
100         }
101
102         return 0;
103 }
104
105 void dsp_ctl_core_exit(void)
106 {
107         int i;
108
109         for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
110                 class_device_destroy(dsp_ctl_class,
111                                      MKDEV(OMAP_DSP_CTL_MAJOR,
112                                            dev_list[i].minor));
113         }
114         class_destroy(dsp_ctl_class);
115
116         unregister_chrdev(OMAP_DSP_CTL_MAJOR, "dspctl");
117 }