aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1/mailbox.c
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2010-06-11 11:51:45 -0400
committerHiroshi DOYU <Hiroshi.DOYU@nokia.com>2010-08-04 08:50:19 -0400
commit898ee75623d5a151157e3f0dca12b0148051e2d6 (patch)
tree4c71a2b21491b4a97a18d7a6dfd1f85f1bf8281a /arch/arm/mach-omap1/mailbox.c
parent1f2c4dfd30edfe9125a00d76596ebb3adabd8a5a (diff)
omap: mailbox: reorganize registering
It's more extensible this way. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Diffstat (limited to 'arch/arm/mach-omap1/mailbox.c')
-rw-r--r--arch/arm/mach-omap1/mailbox.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 590ac6688866..0318754e8504 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -29,6 +29,8 @@
29 29
30static void __iomem *mbox_base; 30static void __iomem *mbox_base;
31 31
32static struct omap_mbox **list;
33
32struct omap_mbox1_fifo { 34struct omap_mbox1_fifo {
33 unsigned long cmd; 35 unsigned long cmd;
34 unsigned long data; 36 unsigned long data;
@@ -142,44 +144,44 @@ struct omap_mbox mbox_dsp_info = {
142 .priv = &omap1_mbox_dsp_priv, 144 .priv = &omap1_mbox_dsp_priv,
143}; 145};
144 146
147struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
148
145static int __devinit omap1_mbox_probe(struct platform_device *pdev) 149static int __devinit omap1_mbox_probe(struct platform_device *pdev)
146{ 150{
147 struct resource *res; 151 struct resource *mem;
148 int ret; 152 int ret;
153 int i;
149 154
150 /* MBOX base */ 155 list = omap1_mboxes;
151 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 156
152 if (unlikely(!res)) { 157 list[0]->irq = platform_get_irq_byname(pdev, "dsp");
153 dev_err(&pdev->dev, "invalid mem resource\n");
154 return -ENODEV;
155 }
156 158
157 mbox_base = ioremap(res->start, resource_size(res)); 159 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
160 mbox_base = ioremap(mem->start, resource_size(mem));
158 if (!mbox_base) 161 if (!mbox_base)
159 return -ENOMEM; 162 return -ENOMEM;
160 163
161 /* DSP IRQ */ 164 for (i = 0; list[i]; i++) {
162 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 165 ret = omap_mbox_register(&pdev->dev, list[i]);
163 if (unlikely(!res)) { 166 if (ret)
164 dev_err(&pdev->dev, "invalid irq resource\n"); 167 goto err_out;
165 ret = -ENODEV;
166 goto err_out;
167 } 168 }
168 mbox_dsp_info.irq = res->start;
169
170 ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
171 if (ret)
172 goto err_out;
173 return 0; 169 return 0;
174 170
175err_out: 171err_out:
172 while (i--)
173 omap_mbox_unregister(list[i]);
176 iounmap(mbox_base); 174 iounmap(mbox_base);
177 return ret; 175 return ret;
178} 176}
179 177
180static int __devexit omap1_mbox_remove(struct platform_device *pdev) 178static int __devexit omap1_mbox_remove(struct platform_device *pdev)
181{ 179{
182 omap_mbox_unregister(&mbox_dsp_info); 180 int i;
181
182 for (i = 0; list[i]; i++)
183 omap_mbox_unregister(list[i]);
184
183 iounmap(mbox_base); 185 iounmap(mbox_base);
184 return 0; 186 return 0;
185} 187}