Re: [net-next: PATCH 01/12] net: phy: fixed_phy: switch to fwnode_ API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux