[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a3ec2bbd-9f0a-4378-a3fa-8e0a82c8b808@rowland.harvard.edu>
Date: Wed, 21 Aug 2024 10:37:52 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Jinjie Ruan <ruanjinjie@...wei.com>
Cc: gregkh@...uxfoundation.org, krzk@...nel.org, alim.akhtar@...sung.com,
linux-usb@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-samsung-soc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH -next v2] usb: ehci-exynos: Simplify with scoped for each
OF child loop
On Wed, Aug 21, 2024 at 03:18:56PM +0800, Jinjie Ruan wrote:
> Use scoped for_each_available_child_of_node_scoped() when iterating over
> device nodes to make code a bit simpler.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
> ---
Acked-by: Alan Stern <stern@...land.harvard.edu>
> v2:
> - Update the commit subject.
> - Spilit into 2 patches.
> - Add Reviewed-by.
> ---
> drivers/usb/host/ehci-exynos.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index f40bc2a7a124..e3a961d3f5fc 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -48,7 +48,6 @@ struct exynos_ehci_hcd {
> static int exynos_ehci_get_phy(struct device *dev,
> struct exynos_ehci_hcd *exynos_ehci)
> {
> - struct device_node *child;
> struct phy *phy;
> int phy_number, num_phys;
> int ret;
> @@ -66,26 +65,22 @@ static int exynos_ehci_get_phy(struct device *dev,
> return 0;
>
> /* Get PHYs using legacy bindings */
> - for_each_available_child_of_node(dev->of_node, child) {
> + for_each_available_child_of_node_scoped(dev->of_node, child) {
> ret = of_property_read_u32(child, "reg", &phy_number);
> if (ret) {
> dev_err(dev, "Failed to parse device tree\n");
> - of_node_put(child);
> return ret;
> }
>
> if (phy_number >= PHY_NUMBER) {
> dev_err(dev, "Invalid number of PHYs\n");
> - of_node_put(child);
> return -EINVAL;
> }
>
> phy = devm_of_phy_optional_get(dev, child, NULL);
> exynos_ehci->phy[phy_number] = phy;
> - if (IS_ERR(phy)) {
> - of_node_put(child);
> + if (IS_ERR(phy))
> return PTR_ERR(phy);
> - }
> }
>
> exynos_ehci->legacy_phy = true;
> --
> 2.34.1
>
Powered by blists - more mailing lists