Commit 97ac0e47 authored by Russell King's avatar Russell King Committed by Sean Paul

drm: convert DT component matching to component_match_add_release()

Convert DT component matching to use component_match_add_release().
Acked-by: default avatarJyri Sarha <jsarha@ti.com>
Reviewed-by: default avatarJyri Sarha <jsarha@ti.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/E1bwo6l-0005Io-Q1@rmk-PC.armlinux.org.uk
parent f54d1867
...@@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev) ...@@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
return -EAGAIN; return -EAGAIN;
} }
component_match_add(&pdev->dev, &match, compare_dev, port); drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
of_node_put(port);
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops, return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
match); match);
......
...@@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev) ...@@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
return -EAGAIN; return -EAGAIN;
} }
component_match_add(&pdev->dev, &match, malidp_compare_dev, port); drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
port);
of_node_put(port);
return component_master_add_with_match(&pdev->dev, &malidp_master_ops, return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
match); match);
} }
......
...@@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev, ...@@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
continue; continue;
} }
component_match_add(dev, match, compare_of, remote); drm_of_component_match_add(dev, match, compare_of, remote);
of_node_put(remote); of_node_put(remote);
} }
} }
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
#include <drm/drm_crtc.h> #include <drm/drm_crtc.h>
#include <drm/drm_of.h> #include <drm/drm_of.h>
static void drm_release_of(struct device *dev, void *data)
{
of_node_put(data);
}
/** /**
* drm_crtc_port_mask - find the mask of a registered CRTC by port OF node * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
* @dev: DRM device * @dev: DRM device
...@@ -63,6 +68,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, ...@@ -63,6 +68,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
} }
EXPORT_SYMBOL(drm_of_find_possible_crtcs); EXPORT_SYMBOL(drm_of_find_possible_crtcs);
/**
* drm_of_component_match_add - Add a component helper OF node match rule
* @master: master device
* @matchptr: component match pointer
* @compare: compare function used for matching component
* @node: of_node
*/
void drm_of_component_match_add(struct device *master,
struct component_match **matchptr,
int (*compare)(struct device *, void *),
struct device_node *node)
{
of_node_get(node);
component_match_add_release(master, matchptr, drm_release_of,
compare, node);
}
EXPORT_SYMBOL_GPL(drm_of_component_match_add);
/** /**
* drm_of_component_probe - Generic probe function for a component based master * drm_of_component_probe - Generic probe function for a component based master
* @dev: master device containing the OF node * @dev: master device containing the OF node
...@@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev, ...@@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
continue; continue;
} }
component_match_add(dev, &match, compare_of, port); drm_of_component_match_add(dev, &match, compare_of, port);
of_node_put(port); of_node_put(port);
} }
...@@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev, ...@@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
continue; continue;
} }
component_match_add(dev, &match, compare_of, remote); drm_of_component_match_add(dev, &match, compare_of,
remote);
of_node_put(remote); of_node_put(remote);
} }
of_node_put(port); of_node_put(port);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/component.h> #include <linux/component.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <drm/drm_of.h>
#include "etnaviv_drv.h" #include "etnaviv_drv.h"
#include "etnaviv_gpu.h" #include "etnaviv_gpu.h"
...@@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev) ...@@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
if (!core_node) if (!core_node)
break; break;
component_match_add(&pdev->dev, &match, compare_of, drm_of_component_match_add(&pdev->dev, &match,
core_node); compare_of, core_node);
of_node_put(core_node); of_node_put(core_node);
} }
} else if (dev->platform_data) { } else if (dev->platform_data) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_of.h>
#include "kirin_drm_drv.h" #include "kirin_drm_drv.h"
...@@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np) ...@@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
DRM_ERROR("no valid endpoint node\n"); DRM_ERROR("no valid endpoint node\n");
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
of_node_put(endpoint);
remote = of_graph_get_remote_port_parent(endpoint); remote = of_graph_get_remote_port_parent(endpoint);
of_node_put(endpoint);
if (!remote) { if (!remote) {
DRM_ERROR("no valid remote node\n"); DRM_ERROR("no valid remote node\n");
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
of_node_put(remote);
if (!of_device_is_available(remote)) { if (!of_device_is_available(remote)) {
DRM_ERROR("not available for remote node\n"); DRM_ERROR("not available for remote node\n");
...@@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) ...@@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
if (IS_ERR(remote)) if (IS_ERR(remote))
return PTR_ERR(remote); return PTR_ERR(remote);
component_match_add(dev, &match, compare_of, remote); drm_of_component_match_add(dev, &match, compare_of, remote);
of_node_put(remote);
return component_master_add_with_match(dev, &kirin_drm_ops, match); return component_master_add_with_match(dev, &kirin_drm_ops, match);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_of.h>
#include <linux/component.h> #include <linux/component.h>
#include <linux/iommu.h> #include <linux/iommu.h>
#include <linux/of_address.h> #include <linux/of_address.h>
...@@ -416,7 +417,8 @@ static int mtk_drm_probe(struct platform_device *pdev) ...@@ -416,7 +417,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
comp_type == MTK_DPI) { comp_type == MTK_DPI) {
dev_info(dev, "Adding component match for %s\n", dev_info(dev, "Adding component match for %s\n",
node->full_name); node->full_name);
component_match_add(dev, &match, compare_of, node); drm_of_component_match_add(dev, &match, compare_of,
node);
} else { } else {
struct mtk_ddp_comp *comp; struct mtk_ddp_comp *comp;
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <drm/drm_of.h>
#include "msm_drv.h" #include "msm_drv.h"
#include "msm_debugfs.h" #include "msm_debugfs.h"
#include "msm_fence.h" #include "msm_fence.h"
...@@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev, ...@@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
continue; continue;
} }
component_match_add(master_dev, matchptr, compare_of, intf); drm_of_component_match_add(master_dev, matchptr, compare_of,
intf);
of_node_put(intf); of_node_put(intf);
of_node_put(ep_node); of_node_put(ep_node);
} }
...@@ -962,7 +964,7 @@ static int add_display_components(struct device *dev, ...@@ -962,7 +964,7 @@ static int add_display_components(struct device *dev,
put_device(mdp_dev); put_device(mdp_dev);
/* add the MDP component itself */ /* add the MDP component itself */
component_match_add(dev, matchptr, compare_of, drm_of_component_match_add(dev, matchptr, compare_of,
mdp_dev->of_node); mdp_dev->of_node);
} else { } else {
/* MDP4 */ /* MDP4 */
...@@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev, ...@@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
if (!np) if (!np)
return 0; return 0;
component_match_add(dev, matchptr, compare_of, np); drm_of_component_match_add(dev, matchptr, compare_of, np);
of_node_put(np); of_node_put(np);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_of.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev, ...@@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
continue; continue;
} }
component_match_add(dev, match, compare_of, remote); drm_of_component_match_add(dev, match, compare_of, remote);
of_node_put(remote); of_node_put(remote);
} }
} }
...@@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) ...@@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
} }
of_node_put(iommu); of_node_put(iommu);
component_match_add(dev, &match, compare_of, port->parent); drm_of_component_match_add(dev, &match, compare_of,
port->parent);
of_node_put(port); of_node_put(port);
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
#include <drm/drm_of.h>
#include "sti_crtc.h" #include "sti_crtc.h"
#include "sti_drv.h" #include "sti_drv.h"
...@@ -424,8 +425,8 @@ static int sti_platform_probe(struct platform_device *pdev) ...@@ -424,8 +425,8 @@ static int sti_platform_probe(struct platform_device *pdev)
child_np = of_get_next_available_child(node, NULL); child_np = of_get_next_available_child(node, NULL);
while (child_np) { while (child_np) {
component_match_add(dev, &match, compare_of, child_np); drm_of_component_match_add(dev, &match, compare_of,
of_node_put(child_np); child_np);
child_np = of_get_next_available_child(node, child_np); child_np = of_get_next_available_child(node, child_np);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_of.h>
#include "sun4i_crtc.h" #include "sun4i_crtc.h"
#include "sun4i_drv.h" #include "sun4i_drv.h"
...@@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev, ...@@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
/* Add current component */ /* Add current component */
DRM_DEBUG_DRIVER("Adding component %s\n", DRM_DEBUG_DRIVER("Adding component %s\n",
of_node_full_name(node)); of_node_full_name(node));
component_match_add(dev, match, compare_of, node); drm_of_component_match_add(dev, match, compare_of, node);
count++; count++;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/component.h> #include <linux/component.h>
#include <linux/of_graph.h> #include <linux/of_graph.h>
#include <drm/drm_of.h>
#include "tilcdc_drv.h" #include "tilcdc_drv.h"
#include "tilcdc_external.h" #include "tilcdc_external.h"
...@@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev, ...@@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
dev_dbg(dev, "Subdevice node '%s' found\n", node->name); dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
if (match) if (match)
component_match_add(dev, match, dev_match_of, node); drm_of_component_match_add(dev, match, dev_match_of,
node);
of_node_put(node); of_node_put(node);
count++; count++;
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/of_graph.h> #include <linux/of_graph.h>
struct component_master_ops; struct component_master_ops;
struct component_match;
struct device; struct device;
struct drm_device; struct drm_device;
struct drm_encoder; struct drm_encoder;
...@@ -12,6 +13,10 @@ struct device_node; ...@@ -12,6 +13,10 @@ struct device_node;
#ifdef CONFIG_OF #ifdef CONFIG_OF
extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
struct device_node *port); struct device_node *port);
extern void drm_of_component_match_add(struct device *master,
struct component_match **matchptr,
int (*compare)(struct device *, void *),
struct device_node *node);
extern int drm_of_component_probe(struct device *dev, extern int drm_of_component_probe(struct device *dev,
int (*compare_of)(struct device *, void *), int (*compare_of)(struct device *, void *),
const struct component_master_ops *m_ops); const struct component_master_ops *m_ops);
...@@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, ...@@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
return 0; return 0;
} }
static void drm_of_component_match_add(struct device *master,
struct component_match **matchptr,
int (*compare)(struct device *, void *),
struct device_node *node)
{
}
static inline int static inline int
drm_of_component_probe(struct device *dev, drm_of_component_probe(struct device *dev,
int (*compare_of)(struct device *, void *), int (*compare_of)(struct device *, void *),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment