netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: netdev@vger.kernel.org
Cc: Marek Vasut <marex@denx.de>,
	"David S . Miller" <davem@davemloft.net>,
	Lukas Wunner <lukas@wunner.de>, Petr Stetiar <ynezz@true.cz>,
	YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH V7 07/19] net: ks8851: Remove ks8851_rdreg32()
Date: Fri, 29 May 2020 00:21:34 +0200	[thread overview]
Message-ID: <20200528222146.348805-8-marex@denx.de> (raw)
In-Reply-To: <20200528222146.348805-1-marex@denx.de>

The ks8851_rdreg32() is used only in one place, to read two registers
using a single read. To make it easier to support 16-bit accesses via
parallel bus later on, replace this single read with two 16-bit reads
from each of the registers and drop the ks8851_rdreg32() altogether.

If this has noticeable performance impact on the SPI variant of KS8851,
then we should consider using regmap to abstract the SPI and parallel
bus options and in case of SPI, permit regmap to merge register reads
of neighboring registers into single, longer, read.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Petr Stetiar <ynezz@true.cz>
Cc: YueHaibing <yuehaibing@huawei.com>
---
V2: No change
V3: No change
V4: Drop the NOTE from the comment, the performance is OK
V5: No change
V6: No change
V7: No change
---
 drivers/net/ethernet/micrel/ks8851.c | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index fe2037e166dc..8df130efbde1 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -296,25 +296,6 @@ static unsigned ks8851_rdreg16(struct ks8851_net *ks, unsigned reg)
 	return le16_to_cpu(rx);
 }
 
-/**
- * ks8851_rdreg32 - read 32 bit register from device
- * @ks: The chip information
- * @reg: The register address
- *
- * Read a 32bit register from the chip.
- *
- * Note, this read requires the address be aligned to 4 bytes.
-*/
-static unsigned ks8851_rdreg32(struct ks8851_net *ks, unsigned reg)
-{
-	__le32 rx = 0;
-
-	WARN_ON(reg & 3);
-
-	ks8851_rdreg(ks, MK_OP(0xf, reg), (u8 *)&rx, 4);
-	return le32_to_cpu(rx);
-}
-
 /**
  * ks8851_soft_reset - issue one of the soft reset to the device
  * @ks: The device state.
@@ -508,7 +489,6 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
 	unsigned rxfc;
 	unsigned rxlen;
 	unsigned rxstat;
-	u32 rxh;
 	u8 *rxpkt;
 
 	rxfc = ks8851_rdreg8(ks, KS_RXFC);
@@ -527,9 +507,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
 	 */
 
 	for (; rxfc != 0; rxfc--) {
-		rxh = ks8851_rdreg32(ks, KS_RXFHSR);
-		rxstat = rxh & 0xffff;
-		rxlen = (rxh >> 16) & 0xfff;
+		rxstat = ks8851_rdreg16(ks, KS_RXFHSR);
+		rxlen = ks8851_rdreg16(ks, KS_RXFHBCR) & RXFHBCR_CNT_MASK;
 
 		netif_dbg(ks, rx_status, ks->netdev,
 			  "rx: stat 0x%04x, len 0x%04x\n", rxstat, rxlen);
-- 
2.25.1


  parent reply	other threads:[~2020-05-28 22:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 22:21 [PATCH V7 00/19] net: ks8851: Unify KS8851 SPI and MLL drivers Marek Vasut
2020-05-28 22:21 ` [PATCH V7 01/19] net: ks8851: Factor out spi->dev in probe()/remove() Marek Vasut
2020-05-28 22:21 ` [PATCH V7 02/19] net: ks8851: Rename ndev to netdev in probe Marek Vasut
2020-05-28 22:21 ` [PATCH V7 03/19] net: ks8851: Replace dev_err() with netdev_err() in IRQ handler Marek Vasut
2020-05-28 22:21 ` [PATCH V7 04/19] net: ks8851: Pass device node into ks8851_init_mac() Marek Vasut
2020-05-28 22:26   ` Andrew Lunn
2020-05-28 22:21 ` [PATCH V7 05/19] net: ks8851: Use devm_alloc_etherdev() Marek Vasut
2020-05-28 22:21 ` [PATCH V7 06/19] net: ks8851: Use dev_{get,set}_drvdata() Marek Vasut
2020-05-28 22:21 ` Marek Vasut [this message]
2020-05-28 22:27   ` [PATCH V7 07/19] net: ks8851: Remove ks8851_rdreg32() Andrew Lunn
2020-05-28 22:21 ` [PATCH V7 08/19] net: ks8851: Use 16-bit writes to program MAC address Marek Vasut
2020-05-28 22:21 ` [PATCH V7 09/19] net: ks8851: Use 16-bit read of RXFC register Marek Vasut
2020-05-28 22:29   ` Andrew Lunn
2020-05-28 22:21 ` [PATCH V7 10/19] net: ks8851: Factor out bus lock handling Marek Vasut
2020-05-28 22:21 ` [PATCH V7 11/19] net: ks8851: Factor out SKB receive function Marek Vasut
2020-05-28 22:29   ` Andrew Lunn
2020-05-28 22:21 ` [PATCH V7 12/19] net: ks8851: Split out SPI specific entries in struct ks8851_net Marek Vasut
2020-05-28 22:21 ` [PATCH V7 13/19] net: ks8851: Split out SPI specific code from probe() and remove() Marek Vasut
2020-05-28 22:21 ` [PATCH V7 14/19] net: ks8851: Factor out TX work flush function Marek Vasut
2020-05-28 22:21 ` [PATCH V7 15/19] net: ks8851: Permit overridding interrupt enable register Marek Vasut
2020-05-28 22:21 ` [PATCH V7 16/19] net: ks8851: Implement register, FIFO, lock accessor callbacks Marek Vasut
2020-05-28 22:21 ` [PATCH V7 17/19] net: ks8851: Separate SPI operations into separate file Marek Vasut
2020-05-28 22:21 ` [PATCH V7 18/19] net: ks8851: Implement Parallel bus operations Marek Vasut
2020-05-28 22:35   ` Andrew Lunn
2020-05-28 22:21 ` [PATCH V7 19/19] net: ks8851: Remove ks8851_mll.c Marek Vasut
2020-05-28 22:33   ` Andrew Lunn
2020-05-28 23:30 ` [PATCH V7 00/19] net: ks8851: Unify KS8851 SPI and MLL drivers David Miller

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=20200528222146.348805-8-marex@denx.de \
    --to=marex@denx.de \
    --cc=davem@davemloft.net \
    --cc=lukas@wunner.de \
    --cc=netdev@vger.kernel.org \
    --cc=ynezz@true.cz \
    --cc=yuehaibing@huawei.com \
    /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).