linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Poirier <bpoirier@suse.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Manish Chopra <manishc@marvell.com>,
	GR-Linux-NIC-Dev@marvell.com, netdev@vger.kernel.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 11/17] staging: qlge: Factor out duplicated expression
Date: Fri, 27 Sep 2019 19:12:05 +0900	[thread overview]
Message-ID: <20190927101210.23856-12-bpoirier@suse.com> (raw)
In-Reply-To: <20190927101210.23856-1-bpoirier@suse.com>

Given that (u16) 65536 == 0, that expression can be replaced by a simple
cast.

Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
---
 drivers/staging/qlge/qlge.h      |  5 +++++
 drivers/staging/qlge/qlge_main.c | 18 ++++++------------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h
index 5a4b2520cd2a..24af938da7a4 100644
--- a/drivers/staging/qlge/qlge.h
+++ b/drivers/staging/qlge/qlge.h
@@ -77,6 +77,11 @@
 #define LSD(x)  ((u32)((u64)(x)))
 #define MSD(x)  ((u32)((((u64)(x)) >> 32)))
 
+/* In some cases, the device interprets a value of 0x0000 as 65536. These
+ * cases are marked using the following macro.
+ */
+#define QLGE_FIT16(value) ((u16)(value))
+
 /* MPI test register definitions. This register
  * is used for determining alternate NIC function's
  * PCI->func number.
diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 0e304a7ac22f..e1099bd29672 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -2974,7 +2974,6 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 	void __iomem *doorbell_area =
 	    qdev->doorbell_area + (DB_PAGE_SIZE * (128 + rx_ring->cq_id));
 	int err = 0;
-	u16 bq_len;
 	u64 tmp;
 	__le64 *base_indirect_ptr;
 	int page_entries;
@@ -3009,8 +3008,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 	memset((void *)cqicb, 0, sizeof(struct cqicb));
 	cqicb->msix_vect = rx_ring->irq;
 
-	bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len;
-	cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT);
+	cqicb->len = cpu_to_le16(QLGE_FIT16(rx_ring->cq_len) | LEN_V |
+				 LEN_CPP_CONT);
 
 	cqicb->addr = cpu_to_le64(rx_ring->cq_base_dma);
 
@@ -3034,12 +3033,9 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 			page_entries++;
 		} while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len));
 		cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma);
-		bq_len = qdev->lbq_buf_size == 65536 ? 0 :
-			(u16)qdev->lbq_buf_size;
-		cqicb->lbq_buf_size = cpu_to_le16(bq_len);
-		bq_len = (rx_ring->lbq.len == 65536) ? 0 :
-			(u16)rx_ring->lbq.len;
-		cqicb->lbq_len = cpu_to_le16(bq_len);
+		cqicb->lbq_buf_size =
+			cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size));
+		cqicb->lbq_len = cpu_to_le16(QLGE_FIT16(rx_ring->lbq.len));
 		rx_ring->lbq.prod_idx = 0;
 		rx_ring->lbq.curr_idx = 0;
 		rx_ring->lbq.clean_idx = 0;
@@ -3059,9 +3055,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 		cqicb->sbq_addr =
 		    cpu_to_le64(rx_ring->sbq.base_indirect_dma);
 		cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUFFER_SIZE);
-		bq_len = (rx_ring->sbq.len == 65536) ? 0 :
-			(u16)rx_ring->sbq.len;
-		cqicb->sbq_len = cpu_to_le16(bq_len);
+		cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(rx_ring->sbq.len));
 		rx_ring->sbq.prod_idx = 0;
 		rx_ring->sbq.curr_idx = 0;
 		rx_ring->sbq.clean_idx = 0;
-- 
2.23.0


  parent reply	other threads:[~2019-09-27 10:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 10:11 [PATCH v2 0/17] staging: qlge: Fix rx stall in case of allocation failures Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 01/17] staging: qlge: Fix irq masking in INTx mode Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 02/17] staging: qlge: Remove irq_cnt Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 03/17] staging: qlge: Remove page_chunk.last_flag Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 04/17] staging: qlge: Deduplicate lbq_buf_size Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 05/17] staging: qlge: Remove bq_desc.maplen Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 06/17] staging: qlge: Remove rx_ring.sbq_buf_size Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 07/17] staging: qlge: Remove useless dma synchronization calls Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 08/17] staging: qlge: Deduplicate rx buffer queue management Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 09/17] staging: qlge: Fix dma_sync_single calls Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 10/17] staging: qlge: Remove rx_ring.type Benjamin Poirier
2019-09-27 10:12 ` Benjamin Poirier [this message]
2019-09-27 10:12 ` [PATCH v2 12/17] staging: qlge: Remove qlge_bq.len & size Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 13/17] staging: qlge: Remove useless memset Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 14/17] staging: qlge: Replace memset with assignment Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 15/17] staging: qlge: Update buffer queue prod index despite oom Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 16/17] staging: qlge: Refill rx buffers up to multiple of 16 Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 17/17] staging: qlge: Refill empty buffer queues from wq Benjamin Poirier
2019-10-04  8:19 ` [PATCH v2 0/17] staging: qlge: Fix rx stall in case of allocation failures Greg Kroah-Hartman
2019-10-04  9:15   ` Benjamin Poirier
2019-10-04 15:19     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190927101210.23856-12-bpoirier@suse.com \
    --to=bpoirier@suse.com \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishc@marvell.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).