diff mbox series

[v1,1/7] media: ipu3-cio2: Simplify cleanup code

Message ID 20200814163017.35001-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/7] media: ipu3-cio2: Simplify cleanup code | expand

Commit Message

Andy Shevchenko Aug. 14, 2020, 4:30 p.m. UTC
The code looks more nicer if we use:
	while (i--)
instead:
	for (i = i - 1; i >= 0; i--)

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sakari Ailus Aug. 14, 2020, 8:16 p.m. UTC | #1
Hi Andy,

Thanks for the patchset.

On Fri, Aug 14, 2020 at 07:30:11PM +0300, Andy Shevchenko wrote:
> The code looks more nicer if we use:
> 	while (i--)
> instead:
> 	for (i = i - 1; i >= 0; i--)
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index 92f5eadf2c99..c7c3692a6e72 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -887,7 +887,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb)
>  	b->lop[i][j] = cio2->dummy_page_bus_addr >> PAGE_SHIFT;
>  	return 0;
>  fail:
> -	for (i--; i >= 0; i--)
> +	while (i--)

Nice! This would also allow making i unsigned again.

>  		dma_free_coherent(dev, CIO2_PAGE_SIZE,
>  				  b->lop[i], b->lop_bus_addr[i]);
>  	return -ENOMEM;
Andy Shevchenko Aug. 17, 2020, 2:37 p.m. UTC | #2
On Fri, Aug 14, 2020 at 11:16:17PM +0300, Sakari Ailus wrote:
> On Fri, Aug 14, 2020 at 07:30:11PM +0300, Andy Shevchenko wrote:
> > The code looks more nicer if we use:
> > 	while (i--)
> > instead:
> > 	for (i = i - 1; i >= 0; i--)

...

> > -	for (i--; i >= 0; i--)
> > +	while (i--)
> 
> Nice! This would also allow making i unsigned again.

Yes. I will add this to v2.
diff mbox series

Patch

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 92f5eadf2c99..c7c3692a6e72 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -887,7 +887,7 @@  static int cio2_vb2_buf_init(struct vb2_buffer *vb)
 	b->lop[i][j] = cio2->dummy_page_bus_addr >> PAGE_SHIFT;
 	return 0;
 fail:
-	for (i--; i >= 0; i--)
+	while (i--)
 		dma_free_coherent(dev, CIO2_PAGE_SIZE,
 				  b->lop[i], b->lop_bus_addr[i]);
 	return -ENOMEM;