aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-08-06 02:53:39 -0400
committerThierry Reding <treding@nvidia.com>2014-11-13 07:56:14 -0500
commit3ef0592426da2e21bd3a265e9376cddffff931c1 (patch)
tree9ae8b9f708422585dfbf76db110f08beffa29e9a
parent3b46d4a0def157e77000e252bf5caae7d3defe1b (diff)
drm/dsi: Resolve MIPI DSI device from phandle
Add a function, of_find_mipi_dsi_device_by_node(), that can be used to resolve a phandle to a MIPI DSI device. Acked-by: Andrzej Hajda <a.hajda@samsung.com> Reviewed-by: Sean Paul <seanpaul@chromium.org> Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/drm_mipi_dsi.c23
-rw-r--r--include/drm/drm_mipi_dsi.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 2f39372e58b6..3850b3529601 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -67,6 +67,29 @@ static struct bus_type mipi_dsi_bus_type = {
67 .pm = &mipi_dsi_device_pm_ops, 67 .pm = &mipi_dsi_device_pm_ops,
68}; 68};
69 69
70static int of_device_match(struct device *dev, void *data)
71{
72 return dev->of_node == data;
73}
74
75/**
76 * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
77 * device tree node
78 * @np: device tree node
79 *
80 * Return: A pointer to the MIPI DSI device corresponding to @np or NULL if no
81 * such device exists (or has not been registered yet).
82 */
83struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np)
84{
85 struct device *dev;
86
87 dev = bus_find_device(&mipi_dsi_bus_type, NULL, np, of_device_match);
88
89 return dev ? to_mipi_dsi_device(dev) : NULL;
90}
91EXPORT_SYMBOL(of_find_mipi_dsi_device_by_node);
92
70static void mipi_dsi_dev_release(struct device *dev) 93static void mipi_dsi_dev_release(struct device *dev)
71{ 94{
72 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); 95 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 061a792daf7d..ea0d982058c3 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -163,6 +163,7 @@ static inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev)
163 return container_of(dev, struct mipi_dsi_device, dev); 163 return container_of(dev, struct mipi_dsi_device, dev);
164} 164}
165 165
166struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np);
166int mipi_dsi_attach(struct mipi_dsi_device *dsi); 167int mipi_dsi_attach(struct mipi_dsi_device *dsi);
167int mipi_dsi_detach(struct mipi_dsi_device *dsi); 168int mipi_dsi_detach(struct mipi_dsi_device *dsi);
168int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, 169int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,