From 5274484b821bb2cf34a697624ef14084c31b16ce Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 10 Sep 2012 13:58:29 +0300 Subject: OMAPDSS: alloc dssdevs dynamically We currently create omap_dss_devices statically in board files, and use those devices directly in the omapdss driver. This model prevents us from having the platform data (which the dssdevs in board files practically are) as read-only, and it's also different than what we will use with device tree. This patch changes the model to be in line with DT model: we allocate the dssdevs dynamically, and initialize them according to the data in the board file's dssdev (basically we memcopy the dssdev fields). The allocation and registration is done in the following steps in the output drivers: - Use dss_alloc_and_init_device to allocate and initialize the device. The function uses kalloc and device_initialize to accomplish this. - Call dss_copy_device_pdata to copy the data from the board file's dssdev - Use dss_add_device to register the device. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/sdi.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'drivers/video/omap2/dss/sdi.c') diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c index 0aaa7f35874c..919ff728c502 100644 --- a/drivers/video/omap2/dss/sdi.c +++ b/drivers/video/omap2/dss/sdi.c @@ -223,25 +223,34 @@ static struct omap_dss_device * __init sdi_find_dssdev(struct platform_device *p return def_dssdev; } -static void __init sdi_probe_pdata(struct platform_device *pdev) +static void __init sdi_probe_pdata(struct platform_device *sdidev) { + struct omap_dss_device *plat_dssdev; struct omap_dss_device *dssdev; int r; - dssdev = sdi_find_dssdev(pdev); + plat_dssdev = sdi_find_dssdev(sdidev); + if (!plat_dssdev) + return; + + dssdev = dss_alloc_and_init_device(&sdidev->dev); if (!dssdev) return; + dss_copy_device_pdata(dssdev, plat_dssdev); + r = sdi_init_display(dssdev); if (r) { DSSERR("device %s init failed: %d\n", dssdev->name, r); + dss_put_device(dssdev); return; } - r = omap_dss_register_device(dssdev, &pdev->dev); + r = dss_add_device(dssdev); if (r) { DSSERR("device %s register failed: %d\n", dssdev->name, r); + dss_put_device(dssdev); return; } } @@ -255,7 +264,7 @@ static int __init omap_sdi_probe(struct platform_device *pdev) static int __exit omap_sdi_remove(struct platform_device *pdev) { - omap_dss_unregister_child_devices(&pdev->dev); + dss_unregister_child_devices(&pdev->dev); return 0; } -- cgit v1.2.3