[PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop

Andy Shevchenko posted 7 patches 2 months, 4 weeks ago
There is a newer version of this series
[PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop
Posted by Andy Shevchenko 2 months, 4 weeks ago
The while (i--) is a standard pattern for the cleaning up loops.
Apply this pattern where it makes sense in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/ptp/ptp_ocp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 1dbbca4197bc..67a4c60cbbcd 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -4821,8 +4821,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	return 0;
 out_dpll:
-	while (i) {
-		--i;
+	while (i--) {
 		dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp->sma[i]);
 		dpll_pin_put(bp->sma[i].dpll_pin);
 	}
-- 
2.50.1
Re: [PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop
Posted by Vadim Fedorenko 2 months, 3 weeks ago
On 11/11/2025 16:52, Andy Shevchenko wrote:
> The while (i--) is a standard pattern for the cleaning up loops.
> Apply this pattern where it makes sense in the driver.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/ptp/ptp_ocp.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 1dbbca4197bc..67a4c60cbbcd 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -4821,8 +4821,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   
>   	return 0;
>   out_dpll:
> -	while (i) {
> -		--i;
> +	while (i--) {
>   		dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp->sma[i]);
>   		dpll_pin_put(bp->sma[i].dpll_pin);
>   	}

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>