Skip to content

Commit 97ac0e4

Browse files
Russell Kingatseanpaul
authored andcommitted
drm: convert DT component matching to component_match_add_release()
Convert DT component matching to use component_match_add_release(). Acked-by: Jyri Sarha <jsarha@ti.com> Reviewed-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/E1bwo6l-0005Io-Q1@rmk-PC.armlinux.org.uk
1 parent f54d186 commit 97ac0e4

13 files changed

Lines changed: 73 additions & 22 deletions

File tree

‎drivers/gpu/drm/arm/hdlcd_drv.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
453453
return -EAGAIN;
454454
}
455455

456-
component_match_add(&pdev->dev, &match, compare_dev, port);
456+
drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
457+
of_node_put(port);
457458

458459
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
459460
match);

‎drivers/gpu/drm/arm/malidp_drv.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
493493
return -EAGAIN;
494494
}
495495

496-
component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
496+
drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
497+
port);
498+
of_node_put(port);
497499
return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
498500
match);
499501
}

‎drivers/gpu/drm/armada/armada_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
254254
continue;
255255
}
256256

257-
component_match_add(dev, match, compare_of, remote);
257+
drm_of_component_match_add(dev, match, compare_of, remote);
258258
of_node_put(remote);
259259
}
260260
}

‎drivers/gpu/drm/drm_of.c‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#include <drm/drm_crtc.h>
77
#include <drm/drm_of.h>
88

9+
static void drm_release_of(struct device *dev, void *data)
10+
{
11+
of_node_put(data);
12+
}
13+
914
/**
1015
* drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
1116
* @dev: DRM device
@@ -63,6 +68,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
6368
}
6469
EXPORT_SYMBOL(drm_of_find_possible_crtcs);
6570

71+
/**
72+
* drm_of_component_match_add - Add a component helper OF node match rule
73+
* @master: master device
74+
* @matchptr: component match pointer
75+
* @compare: compare function used for matching component
76+
* @node: of_node
77+
*/
78+
void drm_of_component_match_add(struct device *master,
79+
struct component_match **matchptr,
80+
int (*compare)(struct device *, void *),
81+
struct device_node *node)
82+
{
83+
of_node_get(node);
84+
component_match_add_release(master, matchptr, drm_release_of,
85+
compare, node);
86+
}
87+
EXPORT_SYMBOL_GPL(drm_of_component_match_add);
88+
6689
/**
6790
* drm_of_component_probe - Generic probe function for a component based master
6891
* @dev: master device containing the OF node
@@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
101124
continue;
102125
}
103126

104-
component_match_add(dev, &match, compare_of, port);
127+
drm_of_component_match_add(dev, &match, compare_of, port);
105128
of_node_put(port);
106129
}
107130

@@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
140163
continue;
141164
}
142165

143-
component_match_add(dev, &match, compare_of, remote);
166+
drm_of_component_match_add(dev, &match, compare_of,
167+
remote);
144168
of_node_put(remote);
145169
}
146170
of_node_put(port);

‎drivers/gpu/drm/etnaviv/etnaviv_drv.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <linux/component.h>
1818
#include <linux/of_platform.h>
19+
#include <drm/drm_of.h>
1920

2021
#include "etnaviv_drv.h"
2122
#include "etnaviv_gpu.h"
@@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
629630
if (!core_node)
630631
break;
631632

632-
component_match_add(&pdev->dev, &match, compare_of,
633-
core_node);
633+
drm_of_component_match_add(&pdev->dev, &match,
634+
compare_of, core_node);
634635
of_node_put(core_node);
635636
}
636637
} else if (dev->platform_data) {

‎drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <drm/drm_fb_cma_helper.h>
2525
#include <drm/drm_atomic_helper.h>
2626
#include <drm/drm_crtc_helper.h>
27+
#include <drm/drm_of.h>
2728

2829
#include "kirin_drm_drv.h"
2930

@@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
260261
DRM_ERROR("no valid endpoint node\n");
261262
return ERR_PTR(-ENODEV);
262263
}
263-
of_node_put(endpoint);
264264

265265
remote = of_graph_get_remote_port_parent(endpoint);
266+
of_node_put(endpoint);
266267
if (!remote) {
267268
DRM_ERROR("no valid remote node\n");
268269
return ERR_PTR(-ENODEV);
269270
}
270-
of_node_put(remote);
271271

272272
if (!of_device_is_available(remote)) {
273273
DRM_ERROR("not available for remote node\n");
@@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
294294
if (IS_ERR(remote))
295295
return PTR_ERR(remote);
296296

297-
component_match_add(dev, &match, compare_of, remote);
297+
drm_of_component_match_add(dev, &match, compare_of, remote);
298+
of_node_put(remote);
298299

299300
return component_master_add_with_match(dev, &kirin_drm_ops, match);
300301

‎drivers/gpu/drm/mediatek/mtk_drm_drv.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <drm/drm_crtc_helper.h>
1919
#include <drm/drm_gem.h>
2020
#include <drm/drm_gem_cma_helper.h>
21+
#include <drm/drm_of.h>
2122
#include <linux/component.h>
2223
#include <linux/iommu.h>
2324
#include <linux/of_address.h>
@@ -416,7 +417,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
416417
comp_type == MTK_DPI) {
417418
dev_info(dev, "Adding component match for %s\n",
418419
node->full_name);
419-
component_match_add(dev, &match, compare_of, node);
420+
drm_of_component_match_add(dev, &match, compare_of,
421+
node);
420422
} else {
421423
struct mtk_ddp_comp *comp;
422424

‎drivers/gpu/drm/msm/msm_drv.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18+
#include <drm/drm_of.h>
19+
1820
#include "msm_drv.h"
1921
#include "msm_debugfs.h"
2022
#include "msm_fence.h"
@@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
919921
continue;
920922
}
921923

922-
component_match_add(master_dev, matchptr, compare_of, intf);
923-
924+
drm_of_component_match_add(master_dev, matchptr, compare_of,
925+
intf);
924926
of_node_put(intf);
925927
of_node_put(ep_node);
926928
}
@@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
962964
put_device(mdp_dev);
963965

964966
/* add the MDP component itself */
965-
component_match_add(dev, matchptr, compare_of,
966-
mdp_dev->of_node);
967+
drm_of_component_match_add(dev, matchptr, compare_of,
968+
mdp_dev->of_node);
967969
} else {
968970
/* MDP4 */
969971
mdp_dev = dev;
@@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
996998
if (!np)
997999
return 0;
9981000

999-
component_match_add(dev, matchptr, compare_of, np);
1001+
drm_of_component_match_add(dev, matchptr, compare_of, np);
10001002

10011003
of_node_put(np);
10021004

‎drivers/gpu/drm/rockchip/rockchip_drm_drv.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <drm/drm_crtc_helper.h>
2121
#include <drm/drm_fb_helper.h>
2222
#include <drm/drm_gem_cma_helper.h>
23+
#include <drm/drm_of.h>
2324
#include <linux/dma-mapping.h>
2425
#include <linux/pm_runtime.h>
2526
#include <linux/module.h>
@@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
388389
continue;
389390
}
390391

391-
component_match_add(dev, match, compare_of, remote);
392+
drm_of_component_match_add(dev, match, compare_of, remote);
392393
of_node_put(remote);
393394
}
394395
}
@@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
437438
}
438439

439440
of_node_put(iommu);
440-
component_match_add(dev, &match, compare_of, port->parent);
441+
drm_of_component_match_add(dev, &match, compare_of,
442+
port->parent);
441443
of_node_put(port);
442444
}
443445

‎drivers/gpu/drm/sti/sti_drv.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <drm/drm_crtc_helper.h>
1818
#include <drm/drm_gem_cma_helper.h>
1919
#include <drm/drm_fb_cma_helper.h>
20+
#include <drm/drm_of.h>
2021

2122
#include "sti_crtc.h"
2223
#include "sti_drv.h"
@@ -424,8 +425,8 @@ static int sti_platform_probe(struct platform_device *pdev)
424425
child_np = of_get_next_available_child(node, NULL);
425426

426427
while (child_np) {
427-
component_match_add(dev, &match, compare_of, child_np);
428-
of_node_put(child_np);
428+
drm_of_component_match_add(dev, &match, compare_of,
429+
child_np);
429430
child_np = of_get_next_available_child(node, child_np);
430431
}
431432

0 commit comments

Comments
 (0)