Messages in this thread | | | Date | Mon, 20 Jun 2022 20:25:33 +0300 | From | Andy Shevchenko <> | Subject | Re: [net-next: PATCH 01/12] net: phy: fixed_phy: switch to fwnode_ API |
| |
On Mon, Jun 20, 2022 at 05:02:14PM +0200, Marcin Wojtas wrote: > This patch allows to use fixed_phy driver and its helper > functions without Device Tree dependency, by swtiching from > of_ to fwnode_ API.
...
> -#ifdef CONFIG_OF_GPIO
Nice to see this gone, because it's my goal as well.
...
> -static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np) > +static struct gpio_desc *fixed_phy_get_gpiod(struct fwnode_handle *fwnode) > { > - struct device_node *fixed_link_node; > + struct fwnode_handle *fixed_link_node; > struct gpio_desc *gpiod;
> - if (!np) > + if (!fwnode) > return NULL;
Can be dropped altogether. The following call will fail and return the same.
> - fixed_link_node = of_get_child_by_name(np, "fixed-link"); > + fixed_link_node = fwnode_get_named_child_node(fwnode, "fixed-link"); > if (!fixed_link_node) > return NULL; > > @@ -204,7 +203,7 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np) > * Linux device associated with it, we simply have obtain > * the GPIO descriptor from the device tree like this. > */ > - gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
> + gpiod = fwnode_gpiod_get_index(fixed_link_node, > "link", 0, GPIOD_IN, "mdio");
Can fit one line now.
> if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) { > if (PTR_ERR(gpiod) != -ENOENT) > @@ -212,20 +211,14 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np) > fixed_link_node); > gpiod = NULL; > } > - of_node_put(fixed_link_node); > + fwnode_handle_put(fixed_link_node); > > return gpiod; > }
...
> - of_node_get(np); > - phy->mdio.dev.of_node = np; > + fwnode_handle_get(fwnode); > + phy->mdio.dev.fwnode = fwnode;
Please, use device_set_node().
...
> + fwnode_handle_put(phy->mdio.dev.fwnode);
dev_fwnode()
-- With Best Regards, Andy Shevchenko
| |