From: Russell King Date: Sun, 3 Nov 2013 15:31:22 +0000 (+0000) Subject: imx-drm: imx-drm-core: move allocation of imxdrm device to driver load function X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b85f2b5d879597708808ece7e5ebbfd6823e3f69;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git imx-drm: imx-drm-core: move allocation of imxdrm device to driver load function It is now no longer necessary to keep this structure around; we can allocate it upon DRM driver load and destroy it thereafter without affecting the other components now. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index d5b82cb0cfae..35c8f7cf6900 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -38,7 +38,6 @@ struct imx_drm_crtc; struct imx_drm_device { struct drm_device *drm; - struct device *dev; struct imx_drm_crtc *crtc[MAX_CRTC]; int pipes; struct drm_fbdev_cma *fbhelper; @@ -206,13 +205,6 @@ int imx_drm_connector_mode_valid(struct drm_connector *connector, } EXPORT_SYMBOL(imx_drm_connector_mode_valid); -static struct imx_drm_device *imx_drm_device; - -static struct imx_drm_device *__imx_drm_device(void) -{ - return imx_drm_device; -} - void imx_drm_connector_destroy(struct drm_connector *connector) { drm_sysfs_connector_remove(connector); @@ -236,10 +228,14 @@ static struct drm_mode_config_funcs imx_drm_mode_config_funcs = { */ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) { - struct imx_drm_device *imxdrm = __imx_drm_device(); + struct imx_drm_device *imxdrm; struct drm_connector *connector; int ret; + imxdrm = devm_kzalloc(drm->dev, sizeof(*imxdrm), GFP_KERNEL); + if (!imxdrm) + return -ENOMEM; + imxdrm->drm = drm; drm->dev_private = imxdrm; @@ -604,8 +600,6 @@ static int imx_drm_platform_probe(struct platform_device *pdev) if (ret) return ret; - imx_drm_device->dev = &pdev->dev; - return component_master_add(&pdev->dev, &imx_drm_ops); } @@ -630,36 +624,7 @@ static struct platform_driver imx_drm_pdrv = { .of_match_table = imx_drm_dt_ids, }, }; - -static int __init imx_drm_init(void) -{ - int ret; - - imx_drm_device = kzalloc(sizeof(*imx_drm_device), GFP_KERNEL); - if (!imx_drm_device) - return -ENOMEM; - - ret = platform_driver_register(&imx_drm_pdrv); - if (ret) - goto err_pdrv; - - return 0; - -err_pdrv: - kfree(imx_drm_device); - - return ret; -} - -static void __exit imx_drm_exit(void) -{ - platform_driver_unregister(&imx_drm_pdrv); - - kfree(imx_drm_device); -} - -module_init(imx_drm_init); -module_exit(imx_drm_exit); +module_platform_driver(imx_drm_pdrv); MODULE_AUTHOR("Sascha Hauer "); MODULE_DESCRIPTION("i.MX drm driver core");