Re: [PATCH 7/7] usb: host: ohci-exynos: Convert to devm_of_phy_optional_get()

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

 



On Wed, Jan 18, 2023 at 11:15:20AM +0100, Geert Uytterhoeven wrote:
> Use the new devm_of_phy_optional_get() helper instead of open-coding the
> same operation.
> 
> This lets us drop several checks for IS_ERR(), as phy_power_{on,off}()
> handle NULL parameters fine.

The patch ignores a possible -ENOSYS error return.  Is it known that 
this will never happen?

Alan Stern

> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> ---
>  drivers/usb/host/ohci-exynos.c | 24 +++++++-----------------
>  1 file changed, 7 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
> index 8d7977fd5d3bd502..8dd9c3b2411c383f 100644
> --- a/drivers/usb/host/ohci-exynos.c
> +++ b/drivers/usb/host/ohci-exynos.c
> @@ -69,19 +69,12 @@ static int exynos_ohci_get_phy(struct device *dev,
>  			return -EINVAL;
>  		}
>  
> -		phy = devm_of_phy_get(dev, child, NULL);
> +		phy = devm_of_phy_optional_get(dev, child, NULL);
>  		exynos_ohci->phy[phy_number] = phy;
>  		if (IS_ERR(phy)) {
> -			ret = PTR_ERR(phy);
> -			if (ret == -EPROBE_DEFER) {
> -				of_node_put(child);
> -				return ret;
> -			} else if (ret != -ENOSYS && ret != -ENODEV) {
> -				dev_err(dev,
> -					"Error retrieving usb2 phy: %d\n", ret);
> -				of_node_put(child);
> -				return ret;
> -			}
> +			of_node_put(child);
> +			return dev_err_probe(dev, PTR_ERR(phy),
> +					     "Error retrieving usb2 phy\n");
>  		}
>  	}
>  
> @@ -97,12 +90,10 @@ static int exynos_ohci_phy_enable(struct device *dev)
>  	int ret = 0;
>  
>  	for (i = 0; ret == 0 && i < PHY_NUMBER; i++)
> -		if (!IS_ERR(exynos_ohci->phy[i]))
> -			ret = phy_power_on(exynos_ohci->phy[i]);
> +		ret = phy_power_on(exynos_ohci->phy[i]);
>  	if (ret)
>  		for (i--; i >= 0; i--)
> -			if (!IS_ERR(exynos_ohci->phy[i]))
> -				phy_power_off(exynos_ohci->phy[i]);
> +			phy_power_off(exynos_ohci->phy[i]);
>  
>  	return ret;
>  }
> @@ -114,8 +105,7 @@ static void exynos_ohci_phy_disable(struct device *dev)
>  	int i;
>  
>  	for (i = 0; i < PHY_NUMBER; i++)
> -		if (!IS_ERR(exynos_ohci->phy[i]))
> -			phy_power_off(exynos_ohci->phy[i]);
> +		phy_power_off(exynos_ohci->phy[i]);
>  }
>  
>  static int exynos_ohci_probe(struct platform_device *pdev)
> -- 
> 2.34.1
> 



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux