40977336a2f982f454d8c627f86a4116219823ee
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 805-display-0038-MLK-16290-drm-Add-drm_of_component_probe_with_match-.patch
1 From 43265ca8cc62395e1750686daa8b7007b617e53b Mon Sep 17 00:00:00 2001
2 From: Liu Ying <victor.liu@nxp.com>
3 Date: Tue, 29 Aug 2017 16:58:58 +0800
4 Subject: [PATCH] MLK-16290 drm: Add drm_of_component_probe_with_match() helper
5
6 A component master may have both OF based and non-OF based components to be
7 bound with. This patch adds a helper drm_of_component_probe_with_match()
8 similar to drm_of_component_probe() so that the new helper may get an
9 additional provided match pointer(contains match entries for non-OF based
10 components) to support this case.
11
12 Tested-by: Meng Mingming <mingming.meng@nxp.com>
13 Signed-off-by: Liu Ying <victor.liu@nxp.com>
14 (cherry picked from commit c3cad7223488638ab56c20b2c29345487857bc5f)
15 ---
16 drivers/gpu/drm/drm_of.c | 31 ++++++++++++++++++++++++++++---
17 include/drm/drm_of.h | 13 +++++++++++++
18 2 files changed, 41 insertions(+), 3 deletions(-)
19
20 --- a/drivers/gpu/drm/drm_of.c
21 +++ b/drivers/gpu/drm/drm_of.c
22 @@ -100,8 +100,10 @@ void drm_of_component_match_add(struct d
23 EXPORT_SYMBOL_GPL(drm_of_component_match_add);
24
25 /**
26 - * drm_of_component_probe - Generic probe function for a component based master
27 + * drm_of_component_probe_with_match - Generic probe function with match
28 + * entries for a component based master
29 * @dev: master device containing the OF node
30 + * @match: component match pointer provided to store matches
31 * @compare_of: compare function used for matching components
32 * @m_ops: component master ops to be used
33 *
34 @@ -112,12 +114,12 @@ EXPORT_SYMBOL_GPL(drm_of_component_match
35 *
36 * Returns zero if successful, or one of the standard error codes if it fails.
37 */
38 -int drm_of_component_probe(struct device *dev,
39 +int drm_of_component_probe_with_match(struct device *dev,
40 + struct component_match *match,
41 int (*compare_of)(struct device *, void *),
42 const struct component_master_ops *m_ops)
43 {
44 struct device_node *ep, *port, *remote;
45 - struct component_match *match = NULL;
46 int i;
47
48 if (!dev->of_node)
49 @@ -183,6 +185,29 @@ int drm_of_component_probe(struct device
50
51 return component_master_add_with_match(dev, m_ops, match);
52 }
53 +EXPORT_SYMBOL(drm_of_component_probe_with_match);
54 +
55 +/**
56 + * drm_of_component_probe - Generic probe function for a component based master
57 + * @dev: master device containing the OF node
58 + * @compare_of: compare function used for matching components
59 + * @master_ops: component master ops to be used
60 + *
61 + * Parse the platform device OF node and bind all the components associated
62 + * with the master. Interface ports are added before the encoders in order to
63 + * satisfy their .bind requirements
64 + * See Documentation/devicetree/bindings/graph.txt for the bindings.
65 + *
66 + * Returns zero if successful, or one of the standard error codes if it fails.
67 + */
68 +int drm_of_component_probe(struct device *dev,
69 + int (*compare_of)(struct device *, void *),
70 + const struct component_master_ops *m_ops)
71 +{
72 + struct component_match *match = NULL;
73 +
74 + return drm_of_component_probe_with_match(dev, match, compare_of, m_ops);
75 +}
76 EXPORT_SYMBOL(drm_of_component_probe);
77
78 /*
79 --- a/include/drm/drm_of.h
80 +++ b/include/drm/drm_of.h
81 @@ -7,6 +7,7 @@
82 #include <drm/drm_bridge.h>
83 #endif
84
85 +struct component_match;
86 struct component_master_ops;
87 struct component_match;
88 struct device;
89 @@ -25,6 +26,10 @@ void drm_of_component_match_add(struct d
90 struct component_match **matchptr,
91 int (*compare)(struct device *, void *),
92 struct device_node *node);
93 +extern int drm_of_component_probe_with_match(struct device *dev,
94 + struct component_match *match,
95 + int (*compare_of)(struct device *, void *),
96 + const struct component_master_ops *m_ops);
97 int drm_of_component_probe(struct device *dev,
98 int (*compare_of)(struct device *, void *),
99 const struct component_master_ops *m_ops);
100 @@ -56,6 +61,14 @@ drm_of_component_match_add(struct device
101 {
102 }
103
104 +static int drm_of_component_probe_with_match(struct device *dev,
105 + struct component_match *match,
106 + int (*compare_of)(struct device *, void *),
107 + const struct component_master_ops *m_ops)
108 +{
109 + return -EINVAL;
110 +}
111 +
112 static inline int
113 drm_of_component_probe(struct device *dev,
114 int (*compare_of)(struct device *, void *),