Skip to content

Commit 4dba406

Browse files
lategoodbyekuba-moo
authored andcommitted
qca_spi: Fix clock speed for multiple QCA7000
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 <wahrenst@gmx.net> Link: https://patch.msgid.link/20241206184643.123399-2-wahrenst@gmx.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 356983f commit 4dba406

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
@@ -818,7 +818,6 @@ qcaspi_netdev_init(struct net_device *dev)
818818

819819
dev->mtu = QCAFRM_MAX_MTU;
820820
dev->type = ARPHRD_ETHER;
821-
qca->clkspeed = qcaspi_clkspeed;
822821
qca->burst_len = qcaspi_burst_len;
823822
qca->spi_thread = NULL;
824823
qca->buffer_size = (QCAFRM_MAX_MTU + VLAN_ETH_HLEN + QCAFRM_HEADER_LEN +
@@ -909,17 +908,15 @@ qca_spi_probe(struct spi_device *spi)
909908
legacy_mode = of_property_read_bool(spi->dev.of_node,
910909
"qca,legacy-mode");
911910

912-
if (qcaspi_clkspeed == 0) {
913-
if (spi->max_speed_hz)
914-
qcaspi_clkspeed = spi->max_speed_hz;
915-
else
916-
qcaspi_clkspeed = QCASPI_CLK_SPEED;
917-
}
911+
if (qcaspi_clkspeed)
912+
spi->max_speed_hz = qcaspi_clkspeed;
913+
else if (!spi->max_speed_hz)
914+
spi->max_speed_hz = QCASPI_CLK_SPEED;
918915

919-
if ((qcaspi_clkspeed < QCASPI_CLK_SPEED_MIN) ||
920-
(qcaspi_clkspeed > QCASPI_CLK_SPEED_MAX)) {
921-
dev_err(&spi->dev, "Invalid clkspeed: %d\n",
922-
qcaspi_clkspeed);
916+
if (spi->max_speed_hz < QCASPI_CLK_SPEED_MIN ||
917+
spi->max_speed_hz > QCASPI_CLK_SPEED_MAX) {
918+
dev_err(&spi->dev, "Invalid clkspeed: %u\n",
919+
spi->max_speed_hz);
923920
return -EINVAL;
924921
}
925922

@@ -944,14 +941,13 @@ qca_spi_probe(struct spi_device *spi)
944941
return -EINVAL;
945942
}
946943

947-
dev_info(&spi->dev, "ver=%s, clkspeed=%d, burst_len=%d, pluggable=%d\n",
944+
dev_info(&spi->dev, "ver=%s, clkspeed=%u, burst_len=%d, pluggable=%d\n",
948945
QCASPI_DRV_VERSION,
949-
qcaspi_clkspeed,
946+
spi->max_speed_hz,
950947
qcaspi_burst_len,
951948
qcaspi_pluggable);
952949

953950
spi->mode = SPI_MODE_3;
954-
spi->max_speed_hz = qcaspi_clkspeed;
955951
if (spi_setup(spi) < 0) {
956952
dev_err(&spi->dev, "Unable to setup SPI device\n");
957953
return -EFAULT;

drivers/net/ethernet/qualcomm/qca_spi.h

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

9191
/* user configurable options */
92-
u32 clkspeed;
9392
u8 legacy_mode;
9493
u16 burst_len;
9594
};

0 commit comments

Comments
 (0)