linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next RESEND] usb: xhci: Simplify with scoped for each OF child loop
@ 2024-08-20  6:56 Jinjie Ruan
  2024-08-20  8:18 ` Krzysztof Kozlowski
  2024-08-20 13:46 ` Alan Stern
  0 siblings, 2 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-08-20  6:56 UTC (permalink / raw)
  To: stern, gregkh, krzk, alim.akhtar, linux-usb, linux-arm-kernel,
	linux-samsung-soc, linux-kernel
  Cc: ruanjinjie

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@huawei.com>
---
 drivers/usb/host/ehci-exynos.c | 9 ++-------
 drivers/usb/host/ohci-exynos.c | 9 ++-------
 2 files changed, 4 insertions(+), 14 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;
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index bfa2eba4e3a7..1379e03644b2 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -37,7 +37,6 @@ struct exynos_ohci_hcd {
 static int exynos_ohci_get_phy(struct device *dev,
 				struct exynos_ohci_hcd *exynos_ohci)
 {
-	struct device_node *child;
 	struct phy *phy;
 	int phy_number, num_phys;
 	int ret;
@@ -55,26 +54,22 @@ static int exynos_ohci_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_ohci->phy[phy_number] = phy;
-		if (IS_ERR(phy)) {
-			of_node_put(child);
+		if (IS_ERR(phy))
 			return PTR_ERR(phy);
-		}
 	}
 
 	exynos_ohci->legacy_phy = true;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next RESEND] usb: xhci: Simplify with scoped for each OF child loop
  2024-08-20  6:56 [PATCH -next RESEND] usb: xhci: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-08-20  8:18 ` Krzysztof Kozlowski
  2024-08-20 13:46 ` Alan Stern
  1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-20  8:18 UTC (permalink / raw)
  To: Jinjie Ruan, stern, gregkh, alim.akhtar, linux-usb,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

On 20/08/2024 08:56, 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@huawei.com>

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next RESEND] usb: xhci: Simplify with scoped for each OF child loop
  2024-08-20  6:56 [PATCH -next RESEND] usb: xhci: Simplify with scoped for each OF child loop Jinjie Ruan
  2024-08-20  8:18 ` Krzysztof Kozlowski
@ 2024-08-20 13:46 ` Alan Stern
  2024-08-21  3:19   ` Jinjie Ruan
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Stern @ 2024-08-20 13:46 UTC (permalink / raw)
  To: Jinjie Ruan
  Cc: gregkh, krzk, alim.akhtar, linux-usb, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

On Tue, Aug 20, 2024 at 02:56:35PM +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@huawei.com>
> ---
>  drivers/usb/host/ehci-exynos.c | 9 ++-------
>  drivers/usb/host/ohci-exynos.c | 9 ++-------
>  2 files changed, 4 insertions(+), 14 deletions(-)

The patch changes ehci-exynos.c and ohci-exynos.c.  So then why does the 
Subject: line say "xhci"?

The contents of the patch look okay.

Alan Stern

> 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;
> diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
> index bfa2eba4e3a7..1379e03644b2 100644
> --- a/drivers/usb/host/ohci-exynos.c
> +++ b/drivers/usb/host/ohci-exynos.c
> @@ -37,7 +37,6 @@ struct exynos_ohci_hcd {
>  static int exynos_ohci_get_phy(struct device *dev,
>  				struct exynos_ohci_hcd *exynos_ohci)
>  {
> -	struct device_node *child;
>  	struct phy *phy;
>  	int phy_number, num_phys;
>  	int ret;
> @@ -55,26 +54,22 @@ static int exynos_ohci_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_ohci->phy[phy_number] = phy;
> -		if (IS_ERR(phy)) {
> -			of_node_put(child);
> +		if (IS_ERR(phy))
>  			return PTR_ERR(phy);
> -		}
>  	}
>  
>  	exynos_ohci->legacy_phy = true;
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next RESEND] usb: xhci: Simplify with scoped for each OF child loop
  2024-08-20 13:46 ` Alan Stern
@ 2024-08-21  3:19   ` Jinjie Ruan
  0 siblings, 0 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-08-21  3:19 UTC (permalink / raw)
  To: Alan Stern
  Cc: gregkh, krzk, alim.akhtar, linux-usb, linux-arm-kernel,
	linux-samsung-soc, linux-kernel



On 2024/8/20 21:46, Alan Stern wrote:
> On Tue, Aug 20, 2024 at 02:56:35PM +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@huawei.com>
>> ---
>>  drivers/usb/host/ehci-exynos.c | 9 ++-------
>>  drivers/usb/host/ohci-exynos.c | 9 ++-------
>>  2 files changed, 4 insertions(+), 14 deletions(-)
> 
> The patch changes ehci-exynos.c and ohci-exynos.c.  So then why does the 
> Subject: line say "xhci"?

git log --oneline drivers/usb/host/* shows this subject a lot, so adopt it.

> 
> The contents of the patch look okay.
> 
> Alan Stern
> 
>> 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;
>> diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
>> index bfa2eba4e3a7..1379e03644b2 100644
>> --- a/drivers/usb/host/ohci-exynos.c
>> +++ b/drivers/usb/host/ohci-exynos.c
>> @@ -37,7 +37,6 @@ struct exynos_ohci_hcd {
>>  static int exynos_ohci_get_phy(struct device *dev,
>>  				struct exynos_ohci_hcd *exynos_ohci)
>>  {
>> -	struct device_node *child;
>>  	struct phy *phy;
>>  	int phy_number, num_phys;
>>  	int ret;
>> @@ -55,26 +54,22 @@ static int exynos_ohci_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_ohci->phy[phy_number] = phy;
>> -		if (IS_ERR(phy)) {
>> -			of_node_put(child);
>> +		if (IS_ERR(phy))
>>  			return PTR_ERR(phy);
>> -		}
>>  	}
>>  
>>  	exynos_ohci->legacy_phy = true;
>> -- 
>> 2.34.1
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-21  3:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20  6:56 [PATCH -next RESEND] usb: xhci: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-20  8:18 ` Krzysztof Kozlowski
2024-08-20 13:46 ` Alan Stern
2024-08-21  3:19   ` Jinjie Ruan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).