Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1414760
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 10/22] usb: phy: am335x-control: Use of_device_match() |
| Date | 2016-06-06 10:40 +0200 |
| Message-ID | <rGYeK-2qH-39@gated-at.bofh.it> (permalink) |
| References | <rGYeJ-2qH-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Thierry Reding <treding@nvidia.com>
This driver uses bus_find_device() to go through every platform device
and match using the driver and device tree node. It's more efficient to
use driver_find_device() to iterate over all devices associated with a
particular driver, in which case the matching is reduced to the device
tree node and can be done using the common implementation.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/usb/phy/phy-am335x-control.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
index 42a1afe36a90..1ac16f649154 100644
--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -2,6 +2,7 @@
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/usb/otg.h>
@@ -117,12 +118,6 @@ static const struct of_device_id omap_control_usb_id_table[] = {
MODULE_DEVICE_TABLE(of, omap_control_usb_id_table);
static struct platform_driver am335x_control_driver;
-static int match(struct device *dev, void *data)
-{
- struct device_node *node = (struct device_node *)data;
- return dev->of_node == node &&
- dev->driver == &am335x_control_driver.driver;
-}
struct phy_control *am335x_get_phy_control(struct device *dev)
{
@@ -133,7 +128,8 @@ struct phy_control *am335x_get_phy_control(struct device *dev)
if (!node)
return NULL;
- dev = bus_find_device(&platform_bus_type, NULL, node, match);
+ dev = driver_find_device(&am335x_control_driver.driver, NULL, node,
+ of_device_match);
if (!dev)
return NULL;
--
2.8.3
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 10/22] usb: phy: am335x-control: Use of_device_match() Thierry Reding <thierry.reding@gmail.com> - 2016-06-06 10:40 +0200
csiph-web