Skip to content

Commit ebaf832

Browse files
lategoodbyegregkh
authored andcommitted
qca_spi: Fix clock speed for multiple QCA7000
[ Upstream commit 4dba406 ] Storing the maximum clock speed in module parameter qcaspi_clkspeed has the unintended side effect that the first probed instance defines the value for all other instances. Fix this issue by storing it in max_speed_hz of the relevant SPI device. This fix keeps the priority of the speed parameter (module parameter, device tree property, driver default). Btw this uses the opportunity to get the rid of the unused member clkspeed. Fixes: 291ab06 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") Signed-off-by: Stefan Wahren <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3942f0b commit ebaf832

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

drivers/net/ethernet/qualcomm/qca_spi.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,6 @@ qcaspi_netdev_init(struct net_device *dev)
828828

829829
dev->mtu = QCAFRM_MAX_MTU;
830830
dev->type = ARPHRD_ETHER;
831-
qca->clkspeed = qcaspi_clkspeed;
832831
qca->burst_len = qcaspi_burst_len;
833832
qca->spi_thread = NULL;
834833
qca->buffer_size = (dev->mtu + VLAN_ETH_HLEN + QCAFRM_HEADER_LEN +
@@ -917,17 +916,15 @@ qca_spi_probe(struct spi_device *spi)
917916
legacy_mode = of_property_read_bool(spi->dev.of_node,
918917
"qca,legacy-mode");
919918

920-
if (qcaspi_clkspeed == 0) {
921-
if (spi->max_speed_hz)
922-
qcaspi_clkspeed = spi->max_speed_hz;
923-
else
924-
qcaspi_clkspeed = QCASPI_CLK_SPEED;
925-
}
919+
if (qcaspi_clkspeed)
920+
spi->max_speed_hz = qcaspi_clkspeed;
921+
else if (!spi->max_speed_hz)
922+
spi->max_speed_hz = QCASPI_CLK_SPEED;
926923

927-
if ((qcaspi_clkspeed < QCASPI_CLK_SPEED_MIN) ||
928-
(qcaspi_clkspeed > QCASPI_CLK_SPEED_MAX)) {
929-
dev_err(&spi->dev, "Invalid clkspeed: %d\n",
930-
qcaspi_clkspeed);
924+
if (spi->max_speed_hz < QCASPI_CLK_SPEED_MIN ||
925+
spi->max_speed_hz > QCASPI_CLK_SPEED_MAX) {
926+
dev_err(&spi->dev, "Invalid clkspeed: %u\n",
927+
spi->max_speed_hz);
931928
return -EINVAL;
932929
}
933930

@@ -952,14 +949,13 @@ qca_spi_probe(struct spi_device *spi)
952949
return -EINVAL;
953950
}
954951

955-
dev_info(&spi->dev, "ver=%s, clkspeed=%d, burst_len=%d, pluggable=%d\n",
952+
dev_info(&spi->dev, "ver=%s, clkspeed=%u, burst_len=%d, pluggable=%d\n",
956953
QCASPI_DRV_VERSION,
957-
qcaspi_clkspeed,
954+
spi->max_speed_hz,
958955
qcaspi_burst_len,
959956
qcaspi_pluggable);
960957

961958
spi->mode = SPI_MODE_3;
962-
spi->max_speed_hz = qcaspi_clkspeed;
963959
if (spi_setup(spi) < 0) {
964960
dev_err(&spi->dev, "Unable to setup SPI device\n");
965961
return -EFAULT;

drivers/net/ethernet/qualcomm/qca_spi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ struct qcaspi {
101101
#endif
102102

103103
/* user configurable options */
104-
u32 clkspeed;
105104
u8 legacy_mode;
106105
u16 burst_len;
107106
};

0 commit comments

Comments
 (0)