Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk --- drivers/gpu/drm/arm/hdlcd_drv.c | 10 ++++++++-- drivers/gpu/drm/armada/armada_drv.c | 9 +++++++-- drivers/gpu/drm/drm_of.c | 13 +++++++++---- drivers/gpu/drm/msm/msm_drv.c | 8 +++++++- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++--- drivers/gpu/drm/sti/sti_drv.c | 9 +++++++-- drivers/gpu/drm/tilcdc/tilcdc_external.c | 9 +++++++-- 7 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index b987c63ba8d6..bbde48c4f550 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = { .unbind = hdlcd_drm_unbind, };
-static int compare_dev(struct device *dev, void *data) +static int compare_of(struct device *dev, void *data) { return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + static int hdlcd_probe(struct platform_device *pdev) { struct device_node *port, *ep; @@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev) return -EAGAIN; }
- component_match_add(&pdev->dev, &match, compare_dev, port); + component_match_add_release(&pdev->dev, &match, release_of, + compare_of, port);
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops, match); diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 439824a61aa5..6ca2aa36515e 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + static int compare_dev_name(struct device *dev, void *data) { const char *name = data; @@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev, continue; }
- component_match_add(dev, match, compare_of, remote); - of_node_put(remote); + component_match_add_release(dev, match, release_of, + compare_of, remote); } }
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index bc98bb94264d..5d183479d7d6 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -6,6 +6,11 @@ #include <drm/drm_crtc.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 * @dev: DRM device @@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev, continue; }
- component_match_add(dev, &match, compare_of, port); - of_node_put(port); + component_match_add_release(dev, &match, drm_release_of, + compare_of, port); }
if (i == 0) { @@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev, continue; }
- component_match_add(dev, &match, compare_of, remote); - of_node_put(remote); + component_match_add_release(dev, &match, drm_release_of, + compare_of, remote); } of_node_put(port); } diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c654092ef78..1f7de47d817e 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + static int add_components(struct device *dev, struct component_match **matchptr, const char *name) { @@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr, if (!node) break;
- component_match_add(dev, matchptr, compare_of, node); + component_match_add_release(dev, matchptr, release_of, + compare_of, node); }
return 0; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index a409d1f703cb..f5a68fc031ed 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == np; }
+static void release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + static void rockchip_add_endpoints(struct device *dev, struct component_match **match, struct device_node *port) @@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev, continue; }
- component_match_add(dev, match, compare_of, remote); - of_node_put(remote); + component_match_add_release(dev, match, release_of, + compare_of, remote); } }
@@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) is_support_iommu = false; }
- component_match_add(dev, &match, compare_of, port->parent); + of_node_get(port->parent); + component_match_add_release(dev, &match, release_of, + compare_of, port->parent); of_node_put(port); }
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 872495e72294..4ee6fa4f1beb 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + static int sti_bind(struct device *dev) { return drm_platform_init(&sti_driver, to_platform_device(dev)); @@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev) child_np = of_get_next_available_child(node, NULL);
while (child_np) { - component_match_add(dev, &match, compare_of, child_np); - of_node_put(child_np); + component_match_add_release(dev, &match, release_of, + compare_of, child_np); child_np = of_get_next_available_child(node, child_np); }
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c index 03acb4f99982..7e11b5ecdd4a 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c @@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data) return dev->of_node == data; }
+static void dev_release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + int tilcdc_get_external_components(struct device *dev, struct component_match **match) { @@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
dev_dbg(dev, "Subdevice node '%s' found\n", node->name); if (match) - component_match_add(dev, match, dev_match_of, node); - of_node_put(node); + component_match_add_release(dev, match, dev_release_of, + dev_match_of, node); count++; }
On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Hi Russell,
Any reason for not keeping the component_match_add() calls in the drivers? Planning to remove it?
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
Looks good to me!
Reviewed-by: Liviu Dudau Liviu.Dudau@arm.com
For the HDLCD part: Acked-by: Liviu Dudau Liviu.Dudau@arm.com
Thanks, Liviu
drivers/gpu/drm/arm/hdlcd_drv.c | 10 ++++++++-- drivers/gpu/drm/armada/armada_drv.c | 9 +++++++-- drivers/gpu/drm/drm_of.c | 13 +++++++++---- drivers/gpu/drm/msm/msm_drv.c | 8 +++++++- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++--- drivers/gpu/drm/sti/sti_drv.c | 9 +++++++-- drivers/gpu/drm/tilcdc/tilcdc_external.c | 9 +++++++-- 7 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index b987c63ba8d6..bbde48c4f550 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = { .unbind = hdlcd_drm_unbind, };
-static int compare_dev(struct device *dev, void *data) +static int compare_of(struct device *dev, void *data) { return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
static int hdlcd_probe(struct platform_device *pdev) { struct device_node *port, *ep; @@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev) return -EAGAIN; }
- component_match_add(&pdev->dev, &match, compare_dev, port);
component_match_add_release(&pdev->dev, &match, release_of,
compare_of, port);
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops, match);
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 439824a61aa5..6ca2aa36515e 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
static int compare_dev_name(struct device *dev, void *data) { const char *name = data; @@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev, continue; }
component_match_add(dev, match, compare_of, remote);
of_node_put(remote);
component_match_add_release(dev, match, release_of,
}compare_of, remote);
}
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index bc98bb94264d..5d183479d7d6 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -6,6 +6,11 @@ #include <drm/drm_crtc.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
- @dev: DRM device
@@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev, continue; }
component_match_add(dev, &match, compare_of, port);
of_node_put(port);
component_match_add_release(dev, &match, drm_release_of,
compare_of, port);
}
if (i == 0) {
@@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev, continue; }
component_match_add(dev, &match, compare_of, remote);
of_node_put(remote);
component_match_add_release(dev, &match, drm_release_of,
} of_node_put(port); }compare_of, remote);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c654092ef78..1f7de47d817e 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
static int add_components(struct device *dev, struct component_match **matchptr, const char *name) { @@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr, if (!node) break;
component_match_add(dev, matchptr, compare_of, node);
component_match_add_release(dev, matchptr, release_of,
compare_of, node);
}
return 0;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index a409d1f703cb..f5a68fc031ed 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == np; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
static void rockchip_add_endpoints(struct device *dev, struct component_match **match, struct device_node *port) @@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev, continue; }
component_match_add(dev, match, compare_of, remote);
of_node_put(remote);
component_match_add_release(dev, match, release_of,
}compare_of, remote);
}
@@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) is_support_iommu = false; }
component_match_add(dev, &match, compare_of, port->parent);
of_node_get(port->parent);
component_match_add_release(dev, &match, release_of,
of_node_put(port); }compare_of, port->parent);
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 872495e72294..4ee6fa4f1beb 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
static int sti_bind(struct device *dev) { return drm_platform_init(&sti_driver, to_platform_device(dev)); @@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev) child_np = of_get_next_available_child(node, NULL);
while (child_np) {
component_match_add(dev, &match, compare_of, child_np);
of_node_put(child_np);
component_match_add_release(dev, &match, release_of,
child_np = of_get_next_available_child(node, child_np); }compare_of, child_np);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c index 03acb4f99982..7e11b5ecdd4a 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c @@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data) return dev->of_node == data; }
+static void dev_release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
int tilcdc_get_external_components(struct device *dev, struct component_match **match) { @@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
dev_dbg(dev, "Subdevice node '%s' found\n", node->name); if (match)
component_match_add(dev, match, dev_match_of, node);
of_node_put(node);
component_match_add_release(dev, match, dev_release_of,
count++; }dev_match_of, node);
-- 2.1.0
linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Hi Russell,
Any reason for not keeping the component_match_add() calls in the drivers?
Sorry, I don't understand your comment.
If we kept component_match_add() in these drivers, then this patch would not exist, because there wouldn't be any changes to the drivers.
Planning to remove it?
Possibly in the longer term, but at the moment there are drivers where the match data that is passed does not need any release functionality eg, data allocated with devm_k*alloc(), or
component_match_add(dev->parent, match, dss_component_compare, dev);
There are some new cases that need converting which have cropped up during the last merge window, and I expect this to be an on-going educational point for driver authors, so I'm not too bothered about capturing all existing cases in this patch.
On Fri, Jun 03, 2016 at 11:36:33AM +0100, Russell King - ARM Linux wrote:
On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Hi Russell,
Any reason for not keeping the component_match_add() calls in the drivers?
Sorry, I don't understand your comment.
As in: component_match_add() already exists as a macro that calls component_match_add_release(), but with a NULL release function. If it were to be changed to pass a default release_of() function then most of the drivers would not have to change, right? It is just one point of view and I was curious if there was a reason not to choose it, as it would have (probably) generated a smaller delta?
If we kept component_match_add() in these drivers, then this patch would not exist, because there wouldn't be any changes to the drivers.
Planning to remove it?
Possibly in the longer term, but at the moment there are drivers where the match data that is passed does not need any release functionality eg, data allocated with devm_k*alloc(), or
component_match_add(dev->parent, match, dss_component_compare, dev);
There are some new cases that need converting which have cropped up during the last merge window, and I expect this to be an on-going educational point for driver authors, so I'm not too bothered about capturing all existing cases in this patch.
Understood. Using managed allocators is definitely a strong point in favor of having the component_match_add() function with a NULL release() hook.
Best regards, Liviu
-- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
On Fri, Jun 03, 2016 at 12:19:41PM +0100, Liviu Dudau wrote:
On Fri, Jun 03, 2016 at 11:36:33AM +0100, Russell King - ARM Linux wrote:
On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Hi Russell,
Any reason for not keeping the component_match_add() calls in the drivers?
Sorry, I don't understand your comment.
As in: component_match_add() already exists as a macro that calls component_match_add_release(), but with a NULL release function. If it were to be changed to pass a default release_of() function then most of the drivers would not have to change, right? It is just one point of view and I was curious if there was a reason not to choose it, as it would have (probably) generated a smaller delta?
And what should the calls that don't pass a DT node be called? What happens to new users who aren't passing a DT node but use component_match_add() ?
What you're suggesting sound totally insane to me: you're making the change a flag-day: component_match_add() currently takes anything as the data pointer and users can pass anything that their compare function can handle - and changing that to a function which can only take a device_node. That means all non-DT users of that function need to change at the same time.
Flag days are really bad news in kernel development (or any distributed development project), and I won't generate a patch which causes a flag day to occur - especially not one which impacts a large number of users.
Hi Russell,
On 03/06/16 08:58, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/gpu/drm/arm/hdlcd_drv.c | 10 ++++++++-- drivers/gpu/drm/armada/armada_drv.c | 9 +++++++-- drivers/gpu/drm/drm_of.c | 13 +++++++++---- drivers/gpu/drm/msm/msm_drv.c | 8 +++++++- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++--- drivers/gpu/drm/sti/sti_drv.c | 9 +++++++-- drivers/gpu/drm/tilcdc/tilcdc_external.c | 9 +++++++-- 7 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index b987c63ba8d6..bbde48c4f550 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = { .unbind = hdlcd_drm_unbind, };
-static int compare_dev(struct device *dev, void *data) +static int compare_of(struct device *dev, void *data) { return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
Considering that there's 7 identical copies of this function in this patch alone, perhaps there's some mileage in defining it commonly as a static __maybe_unused default_release_of() in component.h or drm_of.h (and maybe default_compare_of() similarly)?
(Apologies if there's already been some strong argument against that which I've not seen, but it seems like a reasonable thing to do.)
Robin.
- static int hdlcd_probe(struct platform_device *pdev) { struct device_node *port, *ep;
@@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev) return -EAGAIN; }
- component_match_add(&pdev->dev, &match, compare_dev, port);
component_match_add_release(&pdev->dev, &match, release_of,
compare_of, port);
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops, match);
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 439824a61aa5..6ca2aa36515e 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
- static int compare_dev_name(struct device *dev, void *data) { const char *name = data;
@@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev, continue; }
component_match_add(dev, match, compare_of, remote);
of_node_put(remote);
component_match_add_release(dev, match, release_of,
} }compare_of, remote);
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index bc98bb94264d..5d183479d7d6 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -6,6 +6,11 @@ #include <drm/drm_crtc.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
- @dev: DRM device
@@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev, continue; }
component_match_add(dev, &match, compare_of, port);
of_node_put(port);
component_match_add_release(dev, &match, drm_release_of,
compare_of, port);
}
if (i == 0) {
@@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev, continue; }
component_match_add(dev, &match, compare_of, remote);
of_node_put(remote);
component_match_add_release(dev, &match, drm_release_of,
} of_node_put(port); }compare_of, remote);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c654092ef78..1f7de47d817e 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
- static int add_components(struct device *dev, struct component_match **matchptr, const char *name) {
@@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr, if (!node) break;
component_match_add(dev, matchptr, compare_of, node);
component_match_add_release(dev, matchptr, release_of,
compare_of, node);
}
return 0;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index a409d1f703cb..f5a68fc031ed 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == np; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
- static void rockchip_add_endpoints(struct device *dev, struct component_match **match, struct device_node *port)
@@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev, continue; }
component_match_add(dev, match, compare_of, remote);
of_node_put(remote);
component_match_add_release(dev, match, release_of,
} }compare_of, remote);
@@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) is_support_iommu = false; }
component_match_add(dev, &match, compare_of, port->parent);
of_node_get(port->parent);
component_match_add_release(dev, &match, release_of,
of_node_put(port); }compare_of, port->parent);
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 872495e72294..4ee6fa4f1beb 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
- static int sti_bind(struct device *dev) { return drm_platform_init(&sti_driver, to_platform_device(dev));
@@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev) child_np = of_get_next_available_child(node, NULL);
while (child_np) {
component_match_add(dev, &match, compare_of, child_np);
of_node_put(child_np);
component_match_add_release(dev, &match, release_of,
child_np = of_get_next_available_child(node, child_np); }compare_of, child_np);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c index 03acb4f99982..7e11b5ecdd4a 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c @@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data) return dev->of_node == data; }
+static void dev_release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
- int tilcdc_get_external_components(struct device *dev, struct component_match **match) {
@@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
dev_dbg(dev, "Subdevice node '%s' found\n", node->name); if (match)
component_match_add(dev, match, dev_match_of, node);
of_node_put(node);
component_match_add_release(dev, match, dev_release_of,
count++; }dev_match_of, node);
On Fri, Jun 03, 2016 at 11:56:40AM +0100, Robin Murphy wrote:
Hi Russell,
On 03/06/16 08:58, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/gpu/drm/arm/hdlcd_drv.c | 10 ++++++++-- drivers/gpu/drm/armada/armada_drv.c | 9 +++++++-- drivers/gpu/drm/drm_of.c | 13 +++++++++---- drivers/gpu/drm/msm/msm_drv.c | 8 +++++++- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++--- drivers/gpu/drm/sti/sti_drv.c | 9 +++++++-- drivers/gpu/drm/tilcdc/tilcdc_external.c | 9 +++++++-- 7 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index b987c63ba8d6..bbde48c4f550 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = { .unbind = hdlcd_drm_unbind, };
-static int compare_dev(struct device *dev, void *data) +static int compare_of(struct device *dev, void *data) { return dev->of_node == data; }
+static void release_of(struct device *dev, void *data) +{
- of_node_put(data);
+}
Considering that there's 7 identical copies of this function in this patch alone, perhaps there's some mileage in defining it commonly as a static __maybe_unused default_release_of() in component.h or drm_of.h (and maybe default_compare_of() similarly)?
(Apologies if there's already been some strong argument against that which I've not seen, but it seems like a reasonable thing to do.)
What we could do is extract out the common bits of OF-component matching into drivers/of/of_component.c and make the whole thing a tad better. I'll send a v2 series threaded to this message.
Add common OF-based component functionality for matching devices by device node, and releasing the device node at the appropraite time.
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk --- drivers/of/Makefile | 2 +- drivers/of/of_component.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/of_component.h | 14 ++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 drivers/of/of_component.c create mode 100644 include/linux/of_component.h
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index d7efd9d458aa..6a4a5e2c0839 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -1,4 +1,4 @@ -obj-y = base.o device.o platform.o +obj-y = base.o of_component.o device.o platform.o obj-$(CONFIG_OF_DYNAMIC) += dynamic.o obj-$(CONFIG_OF_FLATTREE) += fdt.o obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c new file mode 100644 index 000000000000..41e6e817d264 --- /dev/null +++ b/drivers/of/of_component.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 Russell King. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include <linux/component.h> +#include <linux/device.h> +#include <linux/of.h> +#include <linux/of_component.h> +#include <linux/of_graph.h> + +static void component_release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + +void component_match_add_of_compare(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, component_release_of, + compare, node); +} +EXPORT_SYMBOL_GPL(component_match_add_of_compare); + +static void component_compare_of(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +void component_match_add_of(struct device *master, + struct component_match **matchptr, struct device_node *node) +{ + of_node_get(node); + component_match_add_release(master, matchptr, component_release_of, + component_compare_of, node); +} +EXPORT_SYMBOL_GPL(component_match_add_of); diff --git a/include/linux/of_component.h b/include/linux/of_component.h new file mode 100644 index 000000000000..a8170ba3b786 --- /dev/null +++ b/include/linux/of_component.h @@ -0,0 +1,14 @@ +#ifndef __LINUX_COMPONENT_OF_H +#define __LINUX_COMPONENT_OF_H + +struct component_match; +struct device; +struct device_node; + +void component_match_add_of_compare(struct device *master, + struct component_match **matchptr, + int (*compare)(struct device *, void *), struct device_node *node); +void component_match_add_of(struct device *master, + struct component_match **matchptr, struct device_node *node); + +#endif
On Fri, Jun 3, 2016 at 9:21 AM, Russell King rmk+kernel@armlinux.org.uk wrote:
Add common OF-based component functionality for matching devices by device node, and releasing the device node at the appropraite time.
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/of/Makefile | 2 +- drivers/of/of_component.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/of_component.h | 14 ++++++++++++++
I'd prefer this to go into drivers/base/component.c. That's the general direction we've been moving.
I'd expect this would cause some build failures unless the cases you converted all depend on CONFIG_OF.
Rob
On Fri, Jun 03, 2016 at 10:29:40AM -0500, Rob Herring wrote:
On Fri, Jun 3, 2016 at 9:21 AM, Russell King rmk+kernel@armlinux.org.uk wrote:
Add common OF-based component functionality for matching devices by device node, and releasing the device node at the appropraite time.
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/of/Makefile | 2 +- drivers/of/of_component.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/of_component.h | 14 ++++++++++++++
I'd prefer this to go into drivers/base/component.c. That's the general direction we've been moving.
I'd prefer not to, I don't want to turn the component helpers into something OF specific. They aren't OF specific.
I'd expect this would cause some build failures unless the cases you converted all depend on CONFIG_OF.
Okay, I'll stick with v1 then, and the duplication that v1 involves.
On Fri, Jun 3, 2016 at 10:36 AM, Russell King - ARM Linux linux@armlinux.org.uk wrote:
On Fri, Jun 03, 2016 at 10:29:40AM -0500, Rob Herring wrote:
On Fri, Jun 3, 2016 at 9:21 AM, Russell King rmk+kernel@armlinux.org.uk wrote:
Add common OF-based component functionality for matching devices by device node, and releasing the device node at the appropraite time.
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/of/Makefile | 2 +- drivers/of/of_component.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/of_component.h | 14 ++++++++++++++
I'd prefer this to go into drivers/base/component.c. That's the general direction we've been moving.
I'd prefer not to, I don't want to turn the component helpers into something OF specific. They aren't OF specific.
Fine, not enough code to argue about...
I'd expect this would cause some build failures unless the cases you converted all depend on CONFIG_OF.
Okay, I'll stick with v1 then, and the duplication that v1 involves.
Why? You don't want to add empty functions? Seems like good clean-up.
Rob
On Fri, Jun 03, 2016 at 03:21:19PM +0100, Russell King wrote: [...]
diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
[...]
+static void component_compare_of(struct device *dev, void *data) +{
- return dev->of_node == data;
+}
The return statement here doesn't match the return value. Didn't GCC complain about this?
Thierry
On Fri, Jun 03, 2016 at 05:44:30PM +0200, Thierry Reding wrote:
On Fri, Jun 03, 2016 at 03:21:19PM +0100, Russell King wrote: [...]
diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
[...]
+static void component_compare_of(struct device *dev, void *data) +{
- return dev->of_node == data;
+}
The return statement here doesn't match the return value. Didn't GCC complain about this?
I didn't build-test it, because I wanted people's opinions on it first (building means rebuilding my entire tree...)
Anyway, the patch series is dead because I'm not prepared to make the changes which Rob mentioned, so we're back to v1 instead.
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk --- drivers/gpu/drm/arm/hdlcd_drv.c | 9 +++------ drivers/gpu/drm/armada/armada_drv.c | 8 ++------ drivers/gpu/drm/drm_of.c | 6 ++++-- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 11 ++--------- drivers/gpu/drm/msm/msm_drv.c | 8 ++------ drivers/gpu/drm/msm/msm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++--------- drivers/gpu/drm/sti/sti_drv.c | 9 ++------- drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 ++------ 9 files changed, 21 insertions(+), 51 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index b987c63ba8d6..f00845c25795 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -14,6 +14,7 @@ #include <linux/clk.h> #include <linux/component.h> #include <linux/list.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <linux/of_reserved_mem.h> #include <linux/pm_runtime.h> @@ -443,11 +444,6 @@ static const struct component_master_ops hdlcd_master_ops = { .unbind = hdlcd_drm_unbind, };
-static int compare_dev(struct device *dev, void *data) -{ - return dev->of_node == data; -} - static int hdlcd_probe(struct platform_device *pdev) { struct device_node *port, *ep; @@ -474,7 +470,8 @@ static int hdlcd_probe(struct platform_device *pdev) return -EAGAIN; }
- component_match_add(&pdev->dev, &match, compare_dev, port); + component_match_add_of(&pdev->dev, &match, port); + of_node_put(port);
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops, match); diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 439824a61aa5..f2716d20c257 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -9,6 +9,7 @@ #include <linux/component.h> #include <linux/module.h> #include <linux/of_graph.h> +#include <linux/of_component.h> #include <drm/drmP.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_of.h> @@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev) drm_put_dev(dev_get_drvdata(dev)); }
-static int compare_of(struct device *dev, void *data) -{ - return dev->of_node == data; -} - static int compare_dev_name(struct device *dev, void *data) { const char *name = data; @@ -255,7 +251,7 @@ static void armada_add_endpoints(struct device *dev, continue; }
- component_match_add(dev, match, compare_of, remote); + component_match_add_of(dev, match, remote); of_node_put(remote); } } diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index bc98bb94264d..d13fc633aeea 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -1,6 +1,7 @@ #include <linux/component.h> #include <linux/export.h> #include <linux/list.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> @@ -101,7 +102,7 @@ int drm_of_component_probe(struct device *dev, continue; }
- component_match_add(dev, &match, compare_of, port); + component_match_add_of(dev, &match, compare_of, port); of_node_put(port); }
@@ -140,7 +141,8 @@ int drm_of_component_probe(struct device *dev, continue; }
- component_match_add(dev, &match, compare_of, remote); + component_match_add_of_compare(dev, &match, compare_of, + remote); of_node_put(remote); } of_node_put(port); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 3d4f56df8359..a0e0764a6269 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -15,6 +15,7 @@ */
#include <linux/component.h> +#include <linux/of_component.h> #include <linux/of_platform.h>
#include "etnaviv_drv.h" @@ -606,13 +607,6 @@ static const struct component_master_ops etnaviv_master_ops = { .unbind = etnaviv_unbind, };
-static int compare_of(struct device *dev, void *data) -{ - struct device_node *np = data; - - return dev->of_node == np; -} - static int compare_str(struct device *dev, void *data) { return !strcmp(dev_name(dev), data); @@ -635,8 +629,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev) if (!core_node) break;
- component_match_add(&pdev->dev, &match, compare_of, - core_node); + component_match_add_of(&pdev->dev, &match, core_node); of_node_put(core_node); } } else if (dev->platform_data) { diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c654092ef78..5293aa775c5a 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -800,11 +800,6 @@ static const struct dev_pm_ops msm_pm_ops = { * NOTE: duplication of the same code as exynos or imx (or probably any other). * so probably some room for some helpers */ -static int compare_of(struct device *dev, void *data) -{ - return dev->of_node == data; -} - static int add_components(struct device *dev, struct component_match **matchptr, const char *name) { @@ -818,7 +813,8 @@ static int add_components(struct device *dev, struct component_match **matchptr, if (!node) break;
- component_match_add(dev, matchptr, compare_of, node); + component_match_add_of(dev, matchptr, node); + of_node_put(node); }
return 0; diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 5b2963f32291..66dafecaf115 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -30,6 +30,7 @@ #include <linux/list.h> #include <linux/iommu.h> #include <linux/types.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <linux/of_device.h> #include <asm/sizes.h> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index a409d1f703cb..84c50f6770c3 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -22,6 +22,7 @@ #include <linux/dma-mapping.h> #include <linux/pm_runtime.h> #include <linux/module.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <linux/component.h>
@@ -414,13 +415,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = { rockchip_drm_sys_resume) };
-static int compare_of(struct device *dev, void *data) -{ - struct device_node *np = data; - - return dev->of_node == np; -} - static void rockchip_add_endpoints(struct device *dev, struct component_match **match, struct device_node *port) @@ -439,7 +433,7 @@ static void rockchip_add_endpoints(struct device *dev, continue; }
- component_match_add(dev, match, compare_of, remote); + component_match_add_of(dev, match, remote); of_node_put(remote); } } @@ -518,7 +512,7 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) is_support_iommu = false; }
- component_match_add(dev, &match, compare_of, port->parent); + component_match_add_of(dev, &match, port->parent); of_node_put(port); }
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 872495e72294..aeb2787c9bd4 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -10,6 +10,7 @@ #include <linux/debugfs.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of_component.h> #include <linux/of_platform.h>
#include <drm/drm_atomic.h> @@ -341,11 +342,6 @@ static struct drm_driver sti_driver = { .minor = DRIVER_MINOR, };
-static int compare_of(struct device *dev, void *data) -{ - return dev->of_node == data; -} - static int sti_bind(struct device *dev) { return drm_platform_init(&sti_driver, to_platform_device(dev)); @@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev) child_np = of_get_next_available_child(node, NULL);
while (child_np) { - component_match_add(dev, &match, compare_of, child_np); - of_node_put(child_np); + component_match_add_of(dev, &match, child_np); child_np = of_get_next_available_child(node, child_np); }
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c index 03acb4f99982..1b3fd9fa4bef 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c @@ -9,6 +9,7 @@ */
#include <linux/component.h> +#include <linux/of_component.h> #include <linux/of_graph.h>
#include "tilcdc_drv.h" @@ -130,11 +131,6 @@ void tilcdc_remove_external_encoders(struct drm_device *dev) priv->connector_funcs[i]); }
-static int dev_match_of(struct device *dev, void *data) -{ - return dev->of_node == data; -} - int tilcdc_get_external_components(struct device *dev, struct component_match **match) { @@ -152,7 +148,7 @@ int tilcdc_get_external_components(struct device *dev,
dev_dbg(dev, "Subdevice node '%s' found\n", node->name); if (match) - component_match_add(dev, match, dev_match_of, node); + component_match_add_of(dev, match, node); of_node_put(node); count++; }
Am Freitag, den 03.06.2016, 15:21 +0100 schrieb Russell King:
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/gpu/drm/arm/hdlcd_drv.c | 9 +++------ drivers/gpu/drm/armada/armada_drv.c | 8 ++------ drivers/gpu/drm/drm_of.c | 6 ++++-- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 11 ++---------
For the etnaviv part:
Acked-by: Lucas Stach l.stach@pengutronix.de
On Fri, Jun 03, 2016 at 03:21:25PM +0100, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/gpu/drm/arm/hdlcd_drv.c | 9 +++------ drivers/gpu/drm/armada/armada_drv.c | 8 ++------ drivers/gpu/drm/drm_of.c | 6 ++++-- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 11 ++--------- drivers/gpu/drm/msm/msm_drv.c | 8 ++------ drivers/gpu/drm/msm/msm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++--------- drivers/gpu/drm/sti/sti_drv.c | 9 ++------- drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 ++------ 9 files changed, 21 insertions(+), 51 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index b987c63ba8d6..f00845c25795 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -14,6 +14,7 @@ #include <linux/clk.h> #include <linux/component.h> #include <linux/list.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <linux/of_reserved_mem.h> #include <linux/pm_runtime.h> @@ -443,11 +444,6 @@ static const struct component_master_ops hdlcd_master_ops = { .unbind = hdlcd_drm_unbind, };
-static int compare_dev(struct device *dev, void *data) -{
- return dev->of_node == data;
-}
static int hdlcd_probe(struct platform_device *pdev) { struct device_node *port, *ep; @@ -474,7 +470,8 @@ static int hdlcd_probe(struct platform_device *pdev) return -EAGAIN; }
- component_match_add(&pdev->dev, &match, compare_dev, port);
component_match_add_of(&pdev->dev, &match, port);
of_node_put(port);
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops, match);
For the HDLCD part of v2:
Acked-by: Liviu Dudau Liviu.Dudau@arm.com
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 439824a61aa5..f2716d20c257 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -9,6 +9,7 @@ #include <linux/component.h> #include <linux/module.h> #include <linux/of_graph.h> +#include <linux/of_component.h> #include <drm/drmP.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_of.h> @@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev) drm_put_dev(dev_get_drvdata(dev)); }
-static int compare_of(struct device *dev, void *data) -{
- return dev->of_node == data;
-}
static int compare_dev_name(struct device *dev, void *data) { const char *name = data; @@ -255,7 +251,7 @@ static void armada_add_endpoints(struct device *dev, continue; }
component_match_add(dev, match, compare_of, remote);
of_node_put(remote); }component_match_add_of(dev, match, remote);
} diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index bc98bb94264d..d13fc633aeea 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -1,6 +1,7 @@ #include <linux/component.h> #include <linux/export.h> #include <linux/list.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> @@ -101,7 +102,7 @@ int drm_of_component_probe(struct device *dev, continue; }
component_match_add(dev, &match, compare_of, port);
of_node_put(port); }component_match_add_of(dev, &match, compare_of, port);
@@ -140,7 +141,8 @@ int drm_of_component_probe(struct device *dev, continue; }
component_match_add(dev, &match, compare_of, remote);
component_match_add_of_compare(dev, &match, compare_of,
} of_node_put(port);remote); of_node_put(remote);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 3d4f56df8359..a0e0764a6269 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -15,6 +15,7 @@ */
#include <linux/component.h> +#include <linux/of_component.h> #include <linux/of_platform.h>
#include "etnaviv_drv.h" @@ -606,13 +607,6 @@ static const struct component_master_ops etnaviv_master_ops = { .unbind = etnaviv_unbind, };
-static int compare_of(struct device *dev, void *data) -{
- struct device_node *np = data;
- return dev->of_node == np;
-}
static int compare_str(struct device *dev, void *data) { return !strcmp(dev_name(dev), data); @@ -635,8 +629,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev) if (!core_node) break;
component_match_add(&pdev->dev, &match, compare_of,
core_node);
} } else if (dev->platform_data) {component_match_add_of(&pdev->dev, &match, core_node); of_node_put(core_node);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c654092ef78..5293aa775c5a 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -800,11 +800,6 @@ static const struct dev_pm_ops msm_pm_ops = {
- NOTE: duplication of the same code as exynos or imx (or probably any other).
- so probably some room for some helpers
*/ -static int compare_of(struct device *dev, void *data) -{
- return dev->of_node == data;
-}
static int add_components(struct device *dev, struct component_match **matchptr, const char *name) { @@ -818,7 +813,8 @@ static int add_components(struct device *dev, struct component_match **matchptr, if (!node) break;
component_match_add(dev, matchptr, compare_of, node);
component_match_add_of(dev, matchptr, node);
of_node_put(node);
}
return 0;
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 5b2963f32291..66dafecaf115 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -30,6 +30,7 @@ #include <linux/list.h> #include <linux/iommu.h> #include <linux/types.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <linux/of_device.h> #include <asm/sizes.h> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index a409d1f703cb..84c50f6770c3 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -22,6 +22,7 @@ #include <linux/dma-mapping.h> #include <linux/pm_runtime.h> #include <linux/module.h> +#include <linux/of_component.h> #include <linux/of_graph.h> #include <linux/component.h>
@@ -414,13 +415,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = { rockchip_drm_sys_resume) };
-static int compare_of(struct device *dev, void *data) -{
- struct device_node *np = data;
- return dev->of_node == np;
-}
static void rockchip_add_endpoints(struct device *dev, struct component_match **match, struct device_node *port) @@ -439,7 +433,7 @@ static void rockchip_add_endpoints(struct device *dev, continue; }
component_match_add(dev, match, compare_of, remote);
of_node_put(remote); }component_match_add_of(dev, match, remote);
} @@ -518,7 +512,7 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) is_support_iommu = false; }
component_match_add(dev, &match, compare_of, port->parent);
of_node_put(port); }component_match_add_of(dev, &match, port->parent);
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 872495e72294..aeb2787c9bd4 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -10,6 +10,7 @@ #include <linux/debugfs.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of_component.h> #include <linux/of_platform.h>
#include <drm/drm_atomic.h> @@ -341,11 +342,6 @@ static struct drm_driver sti_driver = { .minor = DRIVER_MINOR, };
-static int compare_of(struct device *dev, void *data) -{
- return dev->of_node == data;
-}
static int sti_bind(struct device *dev) { return drm_platform_init(&sti_driver, to_platform_device(dev)); @@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev) child_np = of_get_next_available_child(node, NULL);
while (child_np) {
component_match_add(dev, &match, compare_of, child_np);
of_node_put(child_np);
child_np = of_get_next_available_child(node, child_np); }component_match_add_of(dev, &match, child_np);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c index 03acb4f99982..1b3fd9fa4bef 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c @@ -9,6 +9,7 @@ */
#include <linux/component.h> +#include <linux/of_component.h> #include <linux/of_graph.h>
#include "tilcdc_drv.h" @@ -130,11 +131,6 @@ void tilcdc_remove_external_encoders(struct drm_device *dev) priv->connector_funcs[i]); }
-static int dev_match_of(struct device *dev, void *data) -{
- return dev->of_node == data;
-}
int tilcdc_get_external_components(struct device *dev, struct component_match **match) { @@ -152,7 +148,7 @@ int tilcdc_get_external_components(struct device *dev,
dev_dbg(dev, "Subdevice node '%s' found\n", node->name); if (match)
component_match_add(dev, match, dev_match_of, node);
of_node_put(node); count++; }component_match_add_of(dev, match, node);
-- 2.1.0
On 06/03/2016 04:21 PM, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/gpu/drm/arm/hdlcd_drv.c | 9 +++------ drivers/gpu/drm/armada/armada_drv.c | 8 ++------ drivers/gpu/drm/drm_of.c | 6 ++++-- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 11 ++--------- drivers/gpu/drm/msm/msm_drv.c | 8 ++------ drivers/gpu/drm/msm/msm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++--------- drivers/gpu/drm/sti/sti_drv.c | 9 ++------- drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 ++------ 9 files changed, 21 insertions(+), 51 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 872495e72294..aeb2787c9bd4 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -10,6 +10,7 @@ #include <linux/debugfs.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of_component.h> #include <linux/of_platform.h>
#include <drm/drm_atomic.h> @@ -341,11 +342,6 @@ static struct drm_driver sti_driver = { .minor = DRIVER_MINOR, };
-static int compare_of(struct device *dev, void *data) -{
- return dev->of_node == data;
-}
- static int sti_bind(struct device *dev) { return drm_platform_init(&sti_driver, to_platform_device(dev));
@@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev) child_np = of_get_next_available_child(node, NULL);
while (child_np) {
component_match_add(dev, &match, compare_of, child_np);
of_node_put(child_np);
child_np = of_get_next_available_child(node, child_np); }component_match_add_of(dev, &match, child_np);
Hi Russel,
Ok for the sti driver.
Acked-by: Vincent Abriou vincent.abriou@st.com
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk --- drivers/iommu/mtk_iommu.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index c3043d8754e3..71cf62af4e24 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -24,6 +24,7 @@ #include <linux/iopoll.h> #include <linux/list.h> #include <linux/of_address.h> +#include <linux/of_component.h> #include <linux/of_iommu.h> #include <linux/of_irq.h> #include <linux/of_platform.h> @@ -552,11 +553,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data) return 0; }
-static int compare_of(struct device *dev, void *data) -{ - return dev->of_node == data; -} - static int mtk_iommu_bind(struct device *dev) { struct mtk_iommu_data *data = dev_get_drvdata(dev); @@ -630,17 +626,19 @@ static int mtk_iommu_probe(struct platform_device *pdev) continue;
plarbdev = of_find_device_by_node(larbnode); - of_node_put(larbnode); if (!plarbdev) { plarbdev = of_platform_device_create( larbnode, NULL, platform_bus_type.dev_root); - if (!plarbdev) + if (!plarbdev) { + of_node_put(larbnode); return -EPROBE_DEFER; + } } data->smi_imu.larb_imu[i].dev = &plarbdev->dev;
- component_match_add(dev, &match, compare_of, larbnode); + component_match_add_of(dev, &match, larbnode); + of_node_put(larbnode); }
platform_set_drvdata(pdev, data);
On Fri, Jun 03, 2016 at 03:21:30PM +0100, Russell King wrote:
Convert DT component matching to use component_match_add_release().
Signed-off-by: Russell King rmk+kernel@armlinux.org.uk
drivers/iommu/mtk_iommu.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
Applied, thanks.
dri-devel@lists.freedesktop.org