Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: vertexcom: mse102x: Simplify mse102x_rx_pkt_spi

The function mse102x_rx_pkt_spi is used in two cases:
* initial polling to re-arm RX interrupt
* level based RX interrupt handler

Both of them doesn't need an open-coded retry mechanism.
In the first case the function can be called again, if the return code
is IRQ_NONE. This keeps the error behavior during netdev open.

In the second case the proper retry would be handled implicit by
the SPI interrupt. So drop the retry code and simplify the receive path.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://patch.msgid.link/20250509120435.43646-7-wahrenst@gmx.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Stefan Wahren and committed by
Jakub Kicinski
8ea6e51e 4ecf56f4

+12 -22
+12 -22
drivers/net/ethernet/vertexcom/mse102x.c
··· 319 319 __be16 rx = 0; 320 320 u16 cmd_resp; 321 321 u8 *rxpkt; 322 - int ret; 323 322 324 323 mse102x_tx_cmd_spi(mse, CMD_CTR); 325 - ret = mse102x_rx_cmd_spi(mse, (u8 *)&rx); 326 - cmd_resp = be16_to_cpu(rx); 327 - 328 - if (ret || ((cmd_resp & CMD_MASK) != CMD_RTS)) { 324 + if (mse102x_rx_cmd_spi(mse, (u8 *)&rx)) { 329 325 usleep_range(50, 100); 326 + return IRQ_NONE; 327 + } 330 328 331 - mse102x_tx_cmd_spi(mse, CMD_CTR); 332 - ret = mse102x_rx_cmd_spi(mse, (u8 *)&rx); 333 - if (ret) 334 - return IRQ_NONE; 335 - 336 - cmd_resp = be16_to_cpu(rx); 337 - if ((cmd_resp & CMD_MASK) != CMD_RTS) { 338 - net_dbg_ratelimited("%s: Unexpected response (0x%04x)\n", 339 - __func__, cmd_resp); 340 - mse->stats.invalid_rts++; 341 - drop = true; 342 - goto drop; 343 - } 344 - 345 - net_dbg_ratelimited("%s: Unexpected response to first CMD\n", 346 - __func__); 329 + cmd_resp = be16_to_cpu(rx); 330 + if ((cmd_resp & CMD_MASK) != CMD_RTS) { 331 + net_dbg_ratelimited("%s: Unexpected response (0x%04x)\n", 332 + __func__, cmd_resp); 333 + mse->stats.invalid_rts++; 334 + drop = true; 335 + goto drop; 347 336 } 348 337 349 338 rxlen = cmd_resp & LEN_MASK; ··· 554 565 * So poll for possible packet(s) to re-arm the interrupt. 555 566 */ 556 567 mutex_lock(&mses->lock); 557 - mse102x_rx_pkt_spi(mse); 568 + if (mse102x_rx_pkt_spi(mse) == IRQ_NONE) 569 + mse102x_rx_pkt_spi(mse); 558 570 mutex_unlock(&mses->lock); 559 571 560 572 netif_dbg(mse, ifup, ndev, "network device up\n");