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

Benjamin Poirier
2021-06-22T07:45:34Z

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
>