diff mbox series

[RFC,12/19] staging: qlge: rewrite do while loops as for loops in qlge_start_rx_ring

Message ID 20210621134902.83587-13-coiby.xu@gmail.com (mailing list archive)
State RFC
Headers show
Series Improve the qlge driver based on drivers/staging/qlge/TODO | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Coiby Xu June 21, 2021, 1:48 p.m. UTC
Since MAX_DB_PAGES_PER_BQ > 0, the for loop is equivalent to do while
loop.

Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
---
 drivers/staging/qlge/qlge_main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Benjamin Poirier June 22, 2021, 7:45 a.m. UTC | #1
On 2021-06-21 21:48 +0800, Coiby Xu wrote:
> Since MAX_DB_PAGES_PER_BQ > 0, the for loop is equivalent to do while
> loop.
> 
> Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
> ---
>  drivers/staging/qlge/qlge_main.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
> index 7aee9e904097..c5e161595b1f 100644
> --- a/drivers/staging/qlge/qlge_main.c
> +++ b/drivers/staging/qlge/qlge_main.c
> @@ -3029,12 +3029,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
>  		tmp = (u64)rx_ring->lbq.base_dma;
>  		base_indirect_ptr = rx_ring->lbq.base_indirect;
>  		page_entries = 0;

This initialization can be removed now. Same thing below.

> -		do {
> +		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
>  			*base_indirect_ptr = cpu_to_le64(tmp);
>  			tmp += DB_PAGE_SIZE;
>  			base_indirect_ptr++;
> -			page_entries++;
> -		} while (page_entries < MAX_DB_PAGES_PER_BQ);
> +		}
>  		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
>  		cqicb->lbq_buf_size =
>  			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
> @@ -3046,12 +3045,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
>  		tmp = (u64)rx_ring->sbq.base_dma;
>  		base_indirect_ptr = rx_ring->sbq.base_indirect;
>  		page_entries = 0;
> -		do {
> +		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
>  			*base_indirect_ptr = cpu_to_le64(tmp);
>  			tmp += DB_PAGE_SIZE;
>  			base_indirect_ptr++;
> -			page_entries++;
> -		} while (page_entries < MAX_DB_PAGES_PER_BQ);
> +		}
>  		cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma);
>  		cqicb->sbq_buf_size = cpu_to_le16(QLGE_SMALL_BUFFER_SIZE);
>  		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN));
> -- 
> 2.32.0
>
Coiby Xu June 24, 2021, 11:56 a.m. UTC | #2
On Tue, Jun 22, 2021 at 04:45:22PM +0900, Benjamin Poirier wrote:
>On 2021-06-21 21:48 +0800, Coiby Xu wrote:
>> Since MAX_DB_PAGES_PER_BQ > 0, the for loop is equivalent to do while
>> loop.
>>
>> Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
>> ---
>>  drivers/staging/qlge/qlge_main.c | 10 ++++------
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
>> index 7aee9e904097..c5e161595b1f 100644
>> --- a/drivers/staging/qlge/qlge_main.c
>> +++ b/drivers/staging/qlge/qlge_main.c
>> @@ -3029,12 +3029,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
>>  		tmp = (u64)rx_ring->lbq.base_dma;
>>  		base_indirect_ptr = rx_ring->lbq.base_indirect;
>>  		page_entries = 0;
>
>This initialization can be removed now. Same thing below.

Yes, thanks for the suggestion!

>
>> -		do {
>> +		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
>>  			*base_indirect_ptr = cpu_to_le64(tmp);
>>  			tmp += DB_PAGE_SIZE;
>>  			base_indirect_ptr++;
>> -			page_entries++;
>> -		} while (page_entries < MAX_DB_PAGES_PER_BQ);
>> +		}
>>  		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
>>  		cqicb->lbq_buf_size =
>>  			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
>> @@ -3046,12 +3045,11 @@ static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
>>  		tmp = (u64)rx_ring->sbq.base_dma;
>>  		base_indirect_ptr = rx_ring->sbq.base_indirect;
>>  		page_entries = 0;
>> -		do {
>> +		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
>>  			*base_indirect_ptr = cpu_to_le64(tmp);
>>  			tmp += DB_PAGE_SIZE;
>>  			base_indirect_ptr++;
>> -			page_entries++;
>> -		} while (page_entries < MAX_DB_PAGES_PER_BQ);
>> +		}
>>  		cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma);
>>  		cqicb->sbq_buf_size = cpu_to_le16(QLGE_SMALL_BUFFER_SIZE);
>>  		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN));
>> --
>> 2.32.0
>>
diff mbox series

Patch

diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 7aee9e904097..c5e161595b1f 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -3029,12 +3029,11 @@  static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->lbq.base_dma;
 		base_indirect_ptr = rx_ring->lbq.base_indirect;
 		page_entries = 0;
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
 		cqicb->lbq_buf_size =
 			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
@@ -3046,12 +3045,11 @@  static int qlge_start_cq(struct qlge_adapter *qdev, struct qlge_cq *cq)
 		tmp = (u64)rx_ring->sbq.base_dma;
 		base_indirect_ptr = rx_ring->sbq.base_indirect;
 		page_entries = 0;
-		do {
+		for (page_entries = 0; page_entries < MAX_DB_PAGES_PER_BQ; page_entries++) {
 			*base_indirect_ptr = cpu_to_le64(tmp);
 			tmp += DB_PAGE_SIZE;
 			base_indirect_ptr++;
-			page_entries++;
-		} while (page_entries < MAX_DB_PAGES_PER_BQ);
+		}
 		cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(QLGE_SMALL_BUFFER_SIZE);
 		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN));