tools, slub: Fix off-by-one buffer corruption after readlink() call
[linux-2.6/linux-mips.git] / arch / arm / plat-mxc / devices / platform-ipu-core.c
blob79d340ae0af134eb00431fab41b2a3f55770355a
1 /*
2 * Copyright (C) 2011 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9 #include <linux/dma-mapping.h>
10 #include <mach/hardware.h>
11 #include <mach/devices-common.h>
13 #define imx_ipu_core_entry_single(soc) \
14 { \
15 .iobase = soc ## _IPU_CTRL_BASE_ADDR, \
16 .synirq = soc ## _INT_IPU_SYN, \
17 .errirq = soc ## _INT_IPU_ERR, \
20 #ifdef CONFIG_SOC_IMX31
21 const struct imx_ipu_core_data imx31_ipu_core_data __initconst =
22 imx_ipu_core_entry_single(MX31);
23 #endif
25 #ifdef CONFIG_SOC_IMX35
26 const struct imx_ipu_core_data imx35_ipu_core_data __initconst =
27 imx_ipu_core_entry_single(MX35);
28 #endif
30 static struct platform_device *imx_ipu_coredev __initdata;
32 struct platform_device *__init imx_add_ipu_core(
33 const struct imx_ipu_core_data *data,
34 const struct ipu_platform_data *pdata)
36 /* The resource order is important! */
37 struct resource res[] = {
39 .start = data->iobase,
40 .end = data->iobase + 0x5f,
41 .flags = IORESOURCE_MEM,
42 }, {
43 .start = data->iobase + 0x88,
44 .end = data->iobase + 0xb3,
45 .flags = IORESOURCE_MEM,
46 }, {
47 .start = data->synirq,
48 .end = data->synirq,
49 .flags = IORESOURCE_IRQ,
50 }, {
51 .start = data->errirq,
52 .end = data->errirq,
53 .flags = IORESOURCE_IRQ,
57 return imx_ipu_coredev = imx_add_platform_device("ipu-core", -1,
58 res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
61 struct platform_device *__init imx_alloc_mx3_camera(
62 const struct imx_ipu_core_data *data,
63 const struct mx3_camera_pdata *pdata)
65 struct resource res[] = {
67 .start = data->iobase + 0x60,
68 .end = data->iobase + 0x87,
69 .flags = IORESOURCE_MEM,
72 int ret = -ENOMEM;
73 struct platform_device *pdev;
75 if (IS_ERR_OR_NULL(imx_ipu_coredev))
76 return ERR_PTR(-ENODEV);
78 pdev = platform_device_alloc("mx3-camera", 0);
79 if (!pdev)
80 goto err;
82 pdev->dev.dma_mask = kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
83 if (!pdev->dev.dma_mask)
84 goto err;
86 *pdev->dev.dma_mask = DMA_BIT_MASK(32);
87 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
89 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
90 if (ret)
91 goto err;
93 if (pdata) {
94 struct mx3_camera_pdata *copied_pdata;
96 ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
97 if (ret) {
98 err:
99 kfree(pdev->dev.dma_mask);
100 platform_device_put(pdev);
101 return ERR_PTR(-ENODEV);
103 copied_pdata = dev_get_platdata(&pdev->dev);
104 copied_pdata->dma_dev = &imx_ipu_coredev->dev;
107 return pdev;
110 struct platform_device *__init imx_add_mx3_sdc_fb(
111 const struct imx_ipu_core_data *data,
112 struct mx3fb_platform_data *pdata)
114 struct resource res[] = {
116 .start = data->iobase + 0xb4,
117 .end = data->iobase + 0x1bf,
118 .flags = IORESOURCE_MEM,
122 if (IS_ERR_OR_NULL(imx_ipu_coredev))
123 return ERR_PTR(-ENODEV);
125 pdata->dma_dev = &imx_ipu_coredev->dev;
127 return imx_add_platform_device_dmamask("mx3_sdc_fb", -1,
128 res, ARRAY_SIZE(res), pdata, sizeof(*pdata),
129 DMA_BIT_MASK(32));