|
29 | 29 | * DRM operations:
|
30 | 30 | */
|
31 | 31 |
|
| 32 | +static struct device_node *etnaviv_of_first_available_node(void) |
| 33 | +{ |
| 34 | + struct device_node *np; |
| 35 | + |
| 36 | + for_each_compatible_node(np, NULL, "vivante,gc") { |
| 37 | + if (of_device_is_available(np)) |
| 38 | + return np; |
| 39 | + } |
| 40 | + |
| 41 | + return NULL; |
| 42 | +} |
32 | 43 |
|
33 | 44 | static void load_gpu(struct drm_device *dev)
|
34 | 45 | {
|
@@ -597,9 +608,6 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
|
597 | 608 | if (!of_device_is_available(core_node))
|
598 | 609 | continue;
|
599 | 610 |
|
600 |
| - if (!first_node) |
601 |
| - first_node = core_node; |
602 |
| - |
603 | 611 | drm_of_component_match_add(&pdev->dev, &match,
|
604 | 612 | component_compare_of, core_node);
|
605 | 613 | }
|
@@ -634,8 +642,11 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
|
634 | 642 | * device as the GPU we found. This assumes that all Vivante
|
635 | 643 | * GPUs in the system share the same DMA constraints.
|
636 | 644 | */
|
637 |
| - if (first_node) |
| 645 | + first_node = etnaviv_of_first_available_node(); |
| 646 | + if (first_node) { |
638 | 647 | of_dma_configure(&pdev->dev, first_node, true);
|
| 648 | + of_node_put(first_node); |
| 649 | + } |
639 | 650 |
|
640 | 651 | return component_master_add_with_match(dev, &etnaviv_master_ops, match);
|
641 | 652 | }
|
@@ -709,16 +720,13 @@ static int __init etnaviv_init(void)
|
709 | 720 | * If the DT contains at least one available GPU device, instantiate
|
710 | 721 | * the DRM platform device.
|
711 | 722 | */
|
712 |
| - for_each_compatible_node(np, NULL, "vivante,gc") { |
713 |
| - if (!of_device_is_available(np)) |
714 |
| - continue; |
| 723 | + np = etnaviv_of_first_available_node(); |
| 724 | + if (np) { |
715 | 725 | of_node_put(np);
|
716 | 726 |
|
717 | 727 | ret = etnaviv_create_platform_device("etnaviv", &etnaviv_drm);
|
718 | 728 | if (ret)
|
719 | 729 | goto unregister_platform_driver;
|
720 |
| - |
721 |
| - break; |
722 | 730 | }
|
723 | 731 |
|
724 | 732 | return 0;
|
|
0 commit comments