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

Rob Herring
2023-01-18T17:31:10Z

On Wed, Jan 18, 2023 at 4:15 AM Geert Uytterhoeven
<geert+renesas@glider.be> 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.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> 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");

Optional is really the only reason for the caller to decide whether to
print an error message or not. If we have both flavors of 'get', then
really the 'get' functions should print an error message.

Rob