All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] staging: qlge: code refinement around a for loop
@ 2022-07-13  7:57 Binyi Han
  2022-07-13  7:59 ` [PATCH v4 1/2] staging: qlge: Fix indentation issue under long " Binyi Han
  2022-07-13  8:00 ` [PATCH v4 2/2] staging: qlge: Avoid multiplication while keep the same logic Binyi Han
  0 siblings, 2 replies; 3+ messages in thread
From: Binyi Han @ 2022-07-13  7:57 UTC (permalink / raw)
  To: Manish Chopra, GR-Linux-NIC-Dev, Coiby Xu, Greg Kroah-Hartman,
	Joe Perches
  Cc: netdev, linux-staging, linux-kernel

*	Patch 1: 
		Fix indentation according to checkpatch.
		Format the long for loop thanks to Joe's review.
*	Patch 2: 
		Optimize by avoiding the multiplication thanks to Joe's
		review.
		I agree with Joe and think it's the same logic, and it
		compiles without error.
		But I don't have the real hardware, so can't prove that
		code is still doing the same thing. So I understand if you
		don't apply this patch without the "proof".

v4:
	- Separate the code style change and "optimization" into 2 patches
v3:
	Thanks to Joe's review.
	- Align page_entries in the for loop to open parenthesis.
	- Optimize by avoiding the multiplication.
v2:
	- Change the long for loop into 3 lines

Binyi Han (2):
  staging: qlge: Fix indentation issue under long for loop
  staging: qlge: Avoid multiplication while keep the same logic

 drivers/staging/qlge/qlge_main.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

-- 
2.25.1


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

* [PATCH v4 1/2] staging: qlge: Fix indentation issue under long for loop
  2022-07-13  7:57 [PATCH v4 0/2] staging: qlge: code refinement around a for loop Binyi Han
@ 2022-07-13  7:59 ` Binyi Han
  2022-07-13  8:00 ` [PATCH v4 2/2] staging: qlge: Avoid multiplication while keep the same logic Binyi Han
  1 sibling, 0 replies; 3+ messages in thread
From: Binyi Han @ 2022-07-13  7:59 UTC (permalink / raw)
  To: Manish Chopra, GR-Linux-NIC-Dev, Coiby Xu, Greg Kroah-Hartman,
	Joe Perches
  Cc: netdev, linux-staging, linux-kernel

Fix indentation issue to adhere to Linux kernel coding style, issue
found by checkpatch. And change the long for loop into 3 lines.

Signed-off-by: Binyi Han <dantengknight@gmail.com>
---
 drivers/staging/qlge/qlge_main.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 1a378330d775..5209456edc39 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -3007,10 +3007,11 @@ static int qlge_start_rx_ring(struct qlge_adapter *qdev, struct rx_ring *rx_ring
 		tmp = (u64)rx_ring->lbq.base_dma;
 		base_indirect_ptr = rx_ring->lbq.base_indirect;
 
-		for (page_entries = 0; page_entries <
-			MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN); page_entries++)
-				base_indirect_ptr[page_entries] =
-					cpu_to_le64(tmp + (page_entries * DB_PAGE_SIZE));
+		for (page_entries = 0;
+		     page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN);
+		     page_entries++)
+			base_indirect_ptr[page_entries] =
+				cpu_to_le64(tmp + (page_entries * DB_PAGE_SIZE));
 		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));
@@ -3022,10 +3023,11 @@ static int qlge_start_rx_ring(struct qlge_adapter *qdev, struct rx_ring *rx_ring
 		tmp = (u64)rx_ring->sbq.base_dma;
 		base_indirect_ptr = rx_ring->sbq.base_indirect;
 
-		for (page_entries = 0; page_entries <
-			MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN); page_entries++)
-				base_indirect_ptr[page_entries] =
-					cpu_to_le64(tmp + (page_entries * DB_PAGE_SIZE));
+		for (page_entries = 0;
+		     page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN);
+		     page_entries++)
+			base_indirect_ptr[page_entries] =
+				cpu_to_le64(tmp + (page_entries * DB_PAGE_SIZE));
 		cqicb->sbq_addr =
 			cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUFFER_SIZE);
-- 
2.25.1


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

* [PATCH v4 2/2] staging: qlge: Avoid multiplication while keep the same logic
  2022-07-13  7:57 [PATCH v4 0/2] staging: qlge: code refinement around a for loop Binyi Han
  2022-07-13  7:59 ` [PATCH v4 1/2] staging: qlge: Fix indentation issue under long " Binyi Han
@ 2022-07-13  8:00 ` Binyi Han
  1 sibling, 0 replies; 3+ messages in thread
From: Binyi Han @ 2022-07-13  8:00 UTC (permalink / raw)
  To: Manish Chopra, GR-Linux-NIC-Dev, Coiby Xu, Greg Kroah-Hartman,
	Joe Perches
  Cc: netdev, linux-staging, linux-kernel

Avoid the more expensive multiplication while keep the same logic.

Signed-off-by: Binyi Han <dantengknight@gmail.com>
---
 drivers/staging/qlge/qlge_main.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 5209456edc39..4b166c66cfc5 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -3009,9 +3009,10 @@ static int qlge_start_rx_ring(struct qlge_adapter *qdev, struct rx_ring *rx_ring
 
 		for (page_entries = 0;
 		     page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN);
-		     page_entries++)
-			base_indirect_ptr[page_entries] =
-				cpu_to_le64(tmp + (page_entries * DB_PAGE_SIZE));
+		     page_entries++) {
+			base_indirect_ptr[page_entries] = cpu_to_le64(tmp);
+			tmp += DB_PAGE_SIZE;
+		}
 		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));
@@ -3025,9 +3026,10 @@ static int qlge_start_rx_ring(struct qlge_adapter *qdev, struct rx_ring *rx_ring
 
 		for (page_entries = 0;
 		     page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN);
-		     page_entries++)
-			base_indirect_ptr[page_entries] =
-				cpu_to_le64(tmp + (page_entries * DB_PAGE_SIZE));
+		     page_entries++) {
+			base_indirect_ptr[page_entries] = cpu_to_le64(tmp);
+			tmp += DB_PAGE_SIZE;
+		}
 		cqicb->sbq_addr =
 			cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUFFER_SIZE);
-- 
2.25.1


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

end of thread, other threads:[~2022-07-13  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-13  7:57 [PATCH v4 0/2] staging: qlge: code refinement around a for loop Binyi Han
2022-07-13  7:59 ` [PATCH v4 1/2] staging: qlge: Fix indentation issue under long " Binyi Han
2022-07-13  8:00 ` [PATCH v4 2/2] staging: qlge: Avoid multiplication while keep the same logic Binyi Han

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.