From 9430dfa67d7609b2d6c1ba1ce609c4db192fd78e Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 2 Sep 2014 09:51:16 -0300 Subject: drm/tilcdc: panel: Add missing of_node_put This commit adds the missing calls to of_node_put to release the node that's currently held by the of_get_child_by_name() call in the panel info parsing code. Tested-by: Darren Etheridge Tested-by: Johannes Pointner Signed-off-by: Ezequiel Garcia Signed-off-by: Dave Airlie --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/gpu/drm/tilcdc/tilcdc_panel.c') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index 4c7aa1d8134f..d581c532790a 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -311,6 +311,7 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np) info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) { pr_err("%s: allocation failed\n", __func__); + of_node_put(info_np); return NULL; } @@ -331,8 +332,10 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np) if (ret) { pr_err("%s: error reading panel-info properties\n", __func__); kfree(info); + of_node_put(info_np); return NULL; } + of_node_put(info_np); return info; } -- cgit v1.2.2 From 75ece7b788f37bf7a2c51ff199b2011ee5e631a4 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 2 Sep 2014 09:51:17 -0300 Subject: drm/tilcdc: panel: Remove unused variable Just a trivial cleanup to remove the variable. Tested-by: Darren Etheridge Tested-by: Johannes Pointner Signed-off-by: Ezequiel Garcia Signed-off-by: Dave Airlie --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/gpu/drm/tilcdc/tilcdc_panel.c') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index d581c532790a..8f88bfd14822 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -340,8 +340,6 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np) return info; } -static struct of_device_id panel_of_match[]; - static int panel_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; -- cgit v1.2.2 From e3a9b04621681d0f07bc8e9935684e6400edef7c Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 2 Sep 2014 09:51:18 -0300 Subject: drm/tilcdc: panel: Spurious whitespace removal Just a cosmetic cleanup. Tested-by: Darren Etheridge Tested-by: Johannes Pointner Signed-off-by: Ezequiel Garcia Signed-off-by: Dave Airlie --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/gpu/drm/tilcdc/tilcdc_panel.c') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index 8f88bfd14822..4b36e68158b2 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -348,7 +348,6 @@ static int panel_probe(struct platform_device *pdev) struct pinctrl *pinctrl; int ret = -EINVAL; - /* bail out early if no DT data: */ if (!node) { dev_err(&pdev->dev, "device-tree data is missing\n"); -- cgit v1.2.2 From 971645d1fd734b8098a5113d61ab9ea93ce83921 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 2 Sep 2014 09:51:19 -0300 Subject: drm/tilcdc: panel: Use devm_kzalloc to simplify the error path Using the managed variant to allocate the resource makes the code simpler and less error-prone. Tested-by: Darren Etheridge Tested-by: Johannes Pointner Signed-off-by: Ezequiel Garcia Signed-off-by: Dave Airlie --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/gpu/drm/tilcdc/tilcdc_panel.c') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index 4b36e68158b2..c716c128ded2 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -354,7 +354,7 @@ static int panel_probe(struct platform_device *pdev) return -ENXIO; } - panel_mod = kzalloc(sizeof(*panel_mod), GFP_KERNEL); + panel_mod = devm_kzalloc(&pdev->dev, sizeof(*panel_mod), GFP_KERNEL); if (!panel_mod) return -ENOMEM; @@ -391,7 +391,6 @@ fail_timings: display_timings_release(panel_mod->timings); fail_free: - kfree(panel_mod); tilcdc_module_cleanup(mod); return ret; } @@ -405,7 +404,6 @@ static int panel_remove(struct platform_device *pdev) tilcdc_module_cleanup(mod); kfree(panel_mod->info); - kfree(panel_mod); return 0; } -- cgit v1.2.2 From 18c44db8cafe9bda4fcb51bfc05c1f1d7cefc44c Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 2 Sep 2014 09:51:20 -0300 Subject: drm/tilcdc: panel: Fix backlight devicetree support The current backlight support is broken; the driver expects a backlight-class in the panel devicetree node. Fix this by implementing it properly, getting an optional backlight from a phandle. This shouldn't cause any backward-compatibility DT issue because the current implementation doesn't work and is not even documented. Tested-by: Darren Etheridge Tested-by: Johannes Pointner Signed-off-by: Ezequiel Garcia Signed-off-by: Dave Airlie --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/drm/tilcdc/tilcdc_panel.c') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index c716c128ded2..3dcf08e4dc91 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -342,7 +342,7 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np) static int panel_probe(struct platform_device *pdev) { - struct device_node *node = pdev->dev.of_node; + struct device_node *bl_node, *node = pdev->dev.of_node; struct panel_module *panel_mod; struct tilcdc_module *mod; struct pinctrl *pinctrl; @@ -358,6 +358,17 @@ static int panel_probe(struct platform_device *pdev) if (!panel_mod) return -ENOMEM; + bl_node = of_parse_phandle(node, "backlight", 0); + if (bl_node) { + panel_mod->backlight = of_find_backlight_by_node(bl_node); + of_node_put(bl_node); + + if (!panel_mod->backlight) + return -EPROBE_DEFER; + + dev_info(&pdev->dev, "found backlight\n"); + } + mod = &panel_mod->base; pdev->dev.platform_data = mod; @@ -381,10 +392,6 @@ static int panel_probe(struct platform_device *pdev) mod->preferred_bpp = panel_mod->info->bpp; - panel_mod->backlight = of_find_backlight_by_node(node); - if (panel_mod->backlight) - dev_info(&pdev->dev, "found backlight\n"); - return 0; fail_timings: @@ -392,6 +399,8 @@ fail_timings: fail_free: tilcdc_module_cleanup(mod); + if (panel_mod->backlight) + put_device(&panel_mod->backlight->dev); return ret; } @@ -399,6 +408,10 @@ static int panel_remove(struct platform_device *pdev) { struct tilcdc_module *mod = dev_get_platdata(&pdev->dev); struct panel_module *panel_mod = to_panel_module(mod); + struct backlight_device *backlight = panel_mod->backlight; + + if (backlight) + put_device(&backlight->dev); display_timings_release(panel_mod->timings); -- cgit v1.2.2 From 12778fc14301cf24d79cd89b0129874c319d0a38 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 2 Sep 2014 09:51:21 -0300 Subject: drm/tilcdc: panel: Set return value explicitly Instead of setting an initial value for the return code, set it explicitly on each error path. This is just a cosmetic cleanup, as preparation for the enable GPIO support. Tested-by: Darren Etheridge Tested-by: Johannes Pointner Signed-off-by: Ezequiel Garcia Signed-off-by: Dave Airlie --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/tilcdc/tilcdc_panel.c') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index 3dcf08e4dc91..f2a5b23782fa 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -346,7 +346,7 @@ static int panel_probe(struct platform_device *pdev) struct panel_module *panel_mod; struct tilcdc_module *mod; struct pinctrl *pinctrl; - int ret = -EINVAL; + int ret; /* bail out early if no DT data: */ if (!node) { @@ -381,12 +381,14 @@ static int panel_probe(struct platform_device *pdev) panel_mod->timings = of_get_display_timings(node); if (!panel_mod->timings) { dev_err(&pdev->dev, "could not get panel timings\n"); + ret = -EINVAL; goto fail_free; } panel_mod->info = of_get_panel_info(node); if (!panel_mod->info) { dev_err(&pdev->dev, "could not get panel info\n"); + ret = -EINVAL; goto fail_timings; } -- cgit v1.2.2 From d898ce03675fc061f89a347a22d41271ed75c436 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 2 Sep 2014 09:51:22 -0300 Subject: drm/tilcdc: panel: Add support for enable GPIO In order to support the "enable GPIO" available in many panel devices, this commit adds a proper devicetree binding. By providing an enable GPIO in the devicetree, the driver can now turn off and on the panel device, and/or the backlight device. Both the backlight and the GPIO are optional properties. Tested-by: Darren Etheridge Tested-by: Johannes Pointner Signed-off-by: Ezequiel Garcia Signed-off-by: Dave Airlie --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 37 ++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/drm/tilcdc/tilcdc_panel.c') diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index f2a5b23782fa..7a0315855e90 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -18,6 +18,7 @@ #include #include #include +#include #include