Commit 7fc7e86d authored by Liviu Dudau's avatar Liviu Dudau Committed by Daniel Vetter

drm/armada: Convert the probe function to the generic drm_of_component_probe()

The armada DRM driver keeps some old platform data compatibility in the
probe function that makes moving to the generic drm_of_component_probe()
a bit more complicated that it should. Refactor the probe function to do
the platform_data processing after the generic probe (and only if that
fails). This way future cleanup can further remove support for it.
Signed-off-by: default avatarLiviu Dudau <Liviu.Dudau@arm.com>
Acked-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1445332995-11212-5-git-send-email-Liviu.Dudau@arm.comSigned-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 52f5eb60
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/of_graph.h> #include <linux/of_graph.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_of.h>
#include "armada_crtc.h" #include "armada_crtc.h"
#include "armada_drm.h" #include "armada_drm.h"
#include "armada_gem.h" #include "armada_gem.h"
...@@ -262,43 +263,29 @@ static void armada_add_endpoints(struct device *dev, ...@@ -262,43 +263,29 @@ static void armada_add_endpoints(struct device *dev,
} }
} }
static int armada_drm_find_components(struct device *dev, static const struct component_master_ops armada_master_ops = {
struct component_match **match) .bind = armada_drm_bind,
{ .unbind = armada_drm_unbind,
struct device_node *port; };
int i;
if (dev->of_node) {
struct device_node *np = dev->of_node;
for (i = 0; ; i++) {
port = of_parse_phandle(np, "ports", i);
if (!port)
break;
component_match_add(dev, match, compare_of, port);
of_node_put(port);
}
if (i == 0) { static int armada_drm_probe(struct platform_device *pdev)
dev_err(dev, "missing 'ports' property\n"); {
return -ENODEV; struct component_match *match = NULL;
} struct device *dev = &pdev->dev;
int ret;
for (i = 0; ; i++) { ret = drm_of_component_probe(dev, compare_dev_name, &armada_master_ops);
port = of_parse_phandle(np, "ports", i); if (ret != -EINVAL)
if (!port) return ret;
break;
armada_add_endpoints(dev, match, port); if (dev->platform_data) {
of_node_put(port);
}
} else if (dev->platform_data) {
char **devices = dev->platform_data; char **devices = dev->platform_data;
struct device_node *port;
struct device *d; struct device *d;
int i;
for (i = 0; devices[i]; i++) for (i = 0; devices[i]; i++)
component_match_add(dev, match, compare_dev_name, component_match_add(dev, &match, compare_dev_name,
devices[i]); devices[i]);
if (i == 0) { if (i == 0) {
...@@ -311,29 +298,12 @@ static int armada_drm_find_components(struct device *dev, ...@@ -311,29 +298,12 @@ static int armada_drm_find_components(struct device *dev,
devices[i]); devices[i]);
if (d && d->of_node) { if (d && d->of_node) {
for_each_child_of_node(d->of_node, port) for_each_child_of_node(d->of_node, port)
armada_add_endpoints(dev, match, port); armada_add_endpoints(dev, &match, port);
} }
put_device(d); put_device(d);
} }
} }
return 0;
}
static const struct component_master_ops armada_master_ops = {
.bind = armada_drm_bind,
.unbind = armada_drm_unbind,
};
static int armada_drm_probe(struct platform_device *pdev)
{
struct component_match *match = NULL;
int ret;
ret = armada_drm_find_components(&pdev->dev, &match);
if (ret < 0)
return ret;
return component_master_add_with_match(&pdev->dev, &armada_master_ops, return component_master_add_with_match(&pdev->dev, &armada_master_ops,
match); match);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment