aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiviu Dudau <Liviu.Dudau@arm.com>2015-10-20 05:23:14 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-10-20 06:01:30 -0400
commit52f5eb60940de889ce98a876f6933b574ead3225 (patch)
tree52cd58b547c0ac6b23f6ffe49cbf86eacdc47eb3
parent9cace32f7e9fb3d506bab2bfda2cafd11e0b5825 (diff)
drm/rockchip: Convert the probe function to the generic drm_of_component_probe()
Use the generic drm_of_component_probe() function to probe for components. Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com> Link: http://patchwork.freedesktop.org/patch/msgid/1445332995-11212-4-git-send-email-Liviu.Dudau@arm.com Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_drv.c81
1 files changed, 6 insertions, 75 deletions
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index f22e1e1ee64a..d26e0cc7dc4b 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -19,6 +19,7 @@
19#include <drm/drmP.h> 19#include <drm/drmP.h>
20#include <drm/drm_crtc_helper.h> 20#include <drm/drm_crtc_helper.h>
21#include <drm/drm_fb_helper.h> 21#include <drm/drm_fb_helper.h>
22#include <drm/drm_of.h>
22#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
23#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
24#include <linux/module.h> 25#include <linux/module.h>
@@ -418,29 +419,6 @@ static int compare_of(struct device *dev, void *data)
418 return dev->of_node == np; 419 return dev->of_node == np;
419} 420}
420 421
421static void rockchip_add_endpoints(struct device *dev,
422 struct component_match **match,
423 struct device_node *port)
424{
425 struct device_node *ep, *remote;
426
427 for_each_child_of_node(port, ep) {
428 remote = of_graph_get_remote_port_parent(ep);
429 if (!remote || !of_device_is_available(remote)) {
430 of_node_put(remote);
431 continue;
432 } else if (!of_device_is_available(remote->parent)) {
433 dev_warn(dev, "parent device of %s is not available\n",
434 remote->full_name);
435 of_node_put(remote);
436 continue;
437 }
438
439 component_match_add(dev, match, compare_of, remote);
440 of_node_put(remote);
441 }
442}
443
444static int rockchip_drm_bind(struct device *dev) 422static int rockchip_drm_bind(struct device *dev)
445{ 423{
446 struct drm_device *drm; 424 struct drm_device *drm;
@@ -483,61 +461,14 @@ static const struct component_master_ops rockchip_drm_ops = {
483 461
484static int rockchip_drm_platform_probe(struct platform_device *pdev) 462static int rockchip_drm_platform_probe(struct platform_device *pdev)
485{ 463{
486 struct device *dev = &pdev->dev; 464 int ret = drm_of_component_probe(&pdev->dev, compare_of,
487 struct component_match *match = NULL; 465 &rockchip_drm_ops);
488 struct device_node *np = dev->of_node;
489 struct device_node *port;
490 int i;
491
492 if (!np)
493 return -ENODEV;
494 /*
495 * Bind the crtc ports first, so that
496 * drm_of_find_possible_crtcs called from encoder .bind callbacks
497 * works as expected.
498 */
499 for (i = 0;; i++) {
500 port = of_parse_phandle(np, "ports", i);
501 if (!port)
502 break;
503
504 if (!of_device_is_available(port->parent)) {
505 of_node_put(port);
506 continue;
507 }
508
509 component_match_add(dev, &match, compare_of, port->parent);
510 of_node_put(port);
511 }
512 466
513 if (i == 0) { 467 /* keep compatibility with old code that was returning -ENODEV */
514 dev_err(dev, "missing 'ports' property\n"); 468 if (ret == -EINVAL)
515 return -ENODEV; 469 return -ENODEV;
516 }
517 470
518 if (!match) { 471 return ret;
519 dev_err(dev, "No available vop found for display-subsystem.\n");
520 return -ENODEV;
521 }
522 /*
523 * For each bound crtc, bind the encoders attached to its
524 * remote endpoint.
525 */
526 for (i = 0;; i++) {
527 port = of_parse_phandle(np, "ports", i);
528 if (!port)
529 break;
530
531 if (!of_device_is_available(port->parent)) {
532 of_node_put(port);
533 continue;
534 }
535
536 rockchip_add_endpoints(dev, &match, port);
537 of_node_put(port);
538 }
539
540 return component_master_add_with_match(dev, &rockchip_drm_ops, match);
541} 472}
542 473
543static int rockchip_drm_platform_remove(struct platform_device *pdev) 474static int rockchip_drm_platform_remove(struct platform_device *pdev)