From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@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>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.5 33/66] net: ks8851-ml: Remove 8-bit bus accessors
Date: Mon, 2 Mar 2020 21:45:42 -0500 [thread overview]
Message-ID: <20200303024615.8889-33-sashal@kernel.org> (raw)
In-Reply-To: <20200303024615.8889-1-sashal@kernel.org>
From: Marek Vasut <marex@denx.de>
[ Upstream commit 69233bba6543a37755158ca3382765387b8078df ]
This driver is mixing 8-bit and 16-bit bus accessors for reasons unknown,
however the speculation is that this was some sort of attempt to support
the 8-bit bus mode.
As per the KS8851-16MLL documentation, all two registers accessed via the
8-bit accessors are internally 16-bit registers, so reading them using
16-bit accessors is fine. The KS_CCR read can be converted to 16-bit read
outright, as it is already a concatenation of two 8-bit reads of that
register. The KS_RXQCR accesses are 8-bit only, however writing the top
8 bits of the register is OK as well, since the driver caches the entire
16-bit register value anyway.
Finally, the driver is not used by any hardware in the kernel right now.
The only hardware available to me is one with 16-bit bus, so I have no
way to test the 8-bit bus mode, however it is unlikely this ever really
worked anyway. If the 8-bit bus mode is ever required, it can be easily
added by adjusting the 16-bit accessors to do 2 consecutive accesses,
which is how this should have been done from the beginning.
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/micrel/ks8851_mll.c | 45 +++---------------------
1 file changed, 5 insertions(+), 40 deletions(-)
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index a41a90c589db2..e2fb20154511e 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -156,24 +156,6 @@ static int msg_enable;
* chip is busy transferring packet data (RX/TX FIFO accesses).
*/
-/**
- * ks_rdreg8 - read 8 bit register from device
- * @ks : The chip information
- * @offset: The register address
- *
- * Read a 8bit register from the chip, returning the result
- */
-static u8 ks_rdreg8(struct ks_net *ks, int offset)
-{
- u16 data;
- u8 shift_bit = offset & 0x03;
- u8 shift_data = (offset & 1) << 3;
- ks->cmd_reg_cache = (u16) offset | (u16)(BE0 << shift_bit);
- iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
- data = ioread16(ks->hw_addr);
- return (u8)(data >> shift_data);
-}
-
/**
* ks_rdreg16 - read 16 bit register from device
* @ks : The chip information
@@ -189,22 +171,6 @@ static u16 ks_rdreg16(struct ks_net *ks, int offset)
return ioread16(ks->hw_addr);
}
-/**
- * ks_wrreg8 - write 8bit register value to chip
- * @ks: The chip information
- * @offset: The register address
- * @value: The value to write
- *
- */
-static void ks_wrreg8(struct ks_net *ks, int offset, u8 value)
-{
- u8 shift_bit = (offset & 0x03);
- u16 value_write = (u16)(value << ((offset & 1) << 3));
- ks->cmd_reg_cache = (u16)offset | (BE0 << shift_bit);
- iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
- iowrite16(value_write, ks->hw_addr);
-}
-
/**
* ks_wrreg16 - write 16bit register value to chip
* @ks: The chip information
@@ -324,8 +290,7 @@ static void ks_read_config(struct ks_net *ks)
u16 reg_data = 0;
/* Regardless of bus width, 8 bit read should always work.*/
- reg_data = ks_rdreg8(ks, KS_CCR) & 0x00FF;
- reg_data |= ks_rdreg8(ks, KS_CCR+1) << 8;
+ reg_data = ks_rdreg16(ks, KS_CCR);
/* addr/data bus are multiplexed */
ks->sharedbus = (reg_data & CCR_SHARED) == CCR_SHARED;
@@ -429,7 +394,7 @@ static inline void ks_read_qmu(struct ks_net *ks, u16 *buf, u32 len)
/* 1. set sudo DMA mode */
ks_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI);
- ks_wrreg8(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_SDA) & 0xff);
+ ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
/* 2. read prepend data */
/**
@@ -446,7 +411,7 @@ static inline void ks_read_qmu(struct ks_net *ks, u16 *buf, u32 len)
ks_inblk(ks, buf, ALIGN(len, 4));
/* 4. reset sudo DMA Mode */
- ks_wrreg8(ks, KS_RXQCR, ks->rc_rxqcr);
+ ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
}
/**
@@ -679,13 +644,13 @@ static void ks_write_qmu(struct ks_net *ks, u8 *pdata, u16 len)
ks->txh.txw[1] = cpu_to_le16(len);
/* 1. set sudo-DMA mode */
- ks_wrreg8(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_SDA) & 0xff);
+ ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
/* 2. write status/lenth info */
ks_outblk(ks, ks->txh.txw, 4);
/* 3. write pkt data */
ks_outblk(ks, (u16 *)pdata, ALIGN(len, 4));
/* 4. reset sudo-DMA mode */
- ks_wrreg8(ks, KS_RXQCR, ks->rc_rxqcr);
+ ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
/* 5. Enqueue Tx(move the pkt from TX buffer into TXQ) */
ks_wrreg16(ks, KS_TXQCR, TXQCR_METFE);
/* 6. wait until TXQCR_METFE is auto-cleared */
--
2.20.1
next prev parent reply other threads:[~2020-03-03 3:01 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 2:45 [PATCH AUTOSEL 5.5 01/66] ALSA: hda: do not override bus codec_mask in link_get() Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 02/66] usb: charger: assign specific number for enum value Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 03/66] serial: ar933x_uart: set UART_CS_{RX,TX}_READY_ORIDE Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 04/66] Kernel selftests: tpm2: check for tpm support Sasha Levin
2020-04-14 16:04 ` shuah
2020-04-16 13:12 ` Jarkko Sakkinen
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 05/66] selftests: fix too long argument Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 06/66] usb: gadget: composite: Support more than 500mA MaxPower Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 07/66] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 08/66] usb: gadget: serial: fix Tx stall after buffer overflow Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 09/66] habanalabs: halt the engines before hard-reset Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 10/66] habanalabs: do not halt CoreSight during hard reset Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 11/66] habanalabs: patched cb equals user cb in device memset Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 12/66] drm/msm/mdp5: rate limit pp done timeout warnings Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 13/66] drm: msm: Fix return type of dsi_mgr_connector_mode_valid for kCFI Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 14/66] drm/modes: Make sure to parse valid rotation value from cmdline Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 15/66] drm/modes: Allow DRM_MODE_ROTATE_0 when applying video mode parameters Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 16/66] scsi: megaraid_sas: silence a warning Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 17/66] drm/msm/dsi: save pll state before dsi host is powered off Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 18/66] drm/msm/dsi/pll: call vco set rate explicitly Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 19/66] selftests: forwarding: use proto icmp for {gretap, ip6gretap}_mac testing Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 20/66] net: macb: ensure interface is not suspended on at91rm9200 Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 21/66] selftests: forwarding: vxlan_bridge_1d: fix tos value Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 22/66] net: atlantic: checksum compat issue Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 23/66] net: atlantic: check rpc result and wait for rpc address Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 24/66] net: atlantic: ptp gpio adjustments Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 25/66] net: atlantic: better loopback mode handling Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 26/66] net: atlantic: fix use after free kasan warn Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 27/66] net: atlantic: fix potential error handling Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 28/66] net: atlantic: possible fault in transition to hibernation Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 29/66] net: atlantic: fix out of range usage of active_vlans array Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 30/66] net: phy: restore mdio regs in the iproc mdio driver Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 31/66] net: dsa: b53: Ensure the default VID is untagged Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 32/66] bonding: add missing netdev_update_lockdep_key() Sasha Levin
2020-03-03 2:45 ` Sasha Levin [this message]
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 34/66] net: ks8851-ml: Fix 16-bit data access Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 35/66] net: ks8851-ml: Fix 16-bit IO operation Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 36/66] net: ethernet: dm9000: Handle -EPROBE_DEFER in dm9000_parse_dt() Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 37/66] watchdog: da9062: do not ping the hw during stop() Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 38/66] s390/cio: cio_ignore_proc_seq_next should increase position index Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 39/66] s390: make 'install' not depend on vmlinux Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 40/66] net: mscc: fix in frame extraction Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 41/66] efi: Only print errors about failing to get certs if EFI vars are found Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 42/66] qede: Fix race between rdma destroy workqueue and link change event Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 43/66] net/mlx5: DR, Fix matching on vport gvmi Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 44/66] iommu/amd: Disable IOMMU on Stoney Ridge systems Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 45/66] nvme/pci: Add sleep quirk for Samsung and Toshiba drives Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 46/66] nvme-pci: Use single IRQ vector for old Apple models Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 47/66] x86/boot/compressed: Don't declare __force_order in kaslr_64.c Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 48/66] s390/qdio: fill SL with absolute addresses Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 49/66] nvme: Fix uninitialized-variable warning Sasha Levin
2020-03-03 2:45 ` [PATCH AUTOSEL 5.5 50/66] nfc: pn544: Fix occasional HW initialization failure Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 51/66] ice: Don't tell the OS that link is going down Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 52/66] x86/xen: Distribute switch variables for initialization Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 53/66] s390/qeth: vnicc Fix EOPNOTSUPP precedence Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 54/66] s390/qeth: fix off-by-one in RX copybreak check Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 55/66] net: macb: Properly handle phylink on at91rm9200 Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 56/66] ionic: fix fw_status read Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 57/66] net: thunderx: workaround BGX TX Underflow issue Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 58/66] bnxt_en: Improve device shutdown method Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 59/66] bnxt_en: Issue PCIe FLR in kdump kernel to cleanup pending DMAs Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 60/66] csky/mm: Fixup export invalid_pte_table symbol Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 61/66] csky: Set regs->usp to kernel sp, when the exception is from kernel Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 62/66] csky/smp: Fixup boot failed when CONFIG_SMP Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 63/66] csky: Fixup ftrace modify panic Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 64/66] csky: Fixup compile warning for three unimplemented syscalls Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 65/66] arch/csky: fix some Kconfig typos Sasha Levin
2020-03-03 2:46 ` [PATCH AUTOSEL 5.5 66/66] selftests: forwarding: vxlan_bridge_1d: use more proper tos value Sasha Levin
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=20200303024615.8889-33-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=marex@denx.de \
--cc=netdev@vger.kernel.org \
--cc=stable@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).