Re: [PATCH v1 07/12] usb: roles: Find the usb role switch by also matching against the device node
From: Andy Shevchenko
Date: Mon Dec 03 2018 - 03:17:35 EST
On Mon, Dec 3, 2018 at 5:45 AM Yu Chen <chenyu56@xxxxxxxxxx> wrote:
>
> This patch adds code for supporting find usb role switch by matching against
> the device node described using of_graph.
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_graph.h>
Keep it ordered.
> +static int __switch_match_by_of_node(struct device *dev, const void *name)
> +{
> + if (!dev->parent || !dev->parent->of_node)
> + return 0;
> +
> + return of_node_name_eq(dev->parent->of_node, (const char *)name);
> +}
I think Heikki has introduced some more generic function for this.
> sw = device_connection_find_match(dev, "usb-role-switch", NULL,
> usb_role_switch_match);
> + sw = of_graph_find_match_by_type(dev, "usb-role-switch");
Why this is here?! device_connection_find_match() should take care for OF case.
--
With Best Regards,
Andy Shevchenko