Commit 8ea6e51e authored by Stefan Wahren's avatar Stefan Wahren Committed by Jakub Kicinski
Browse files

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: default avatarStefan Wahren <wahrenst@gmx.net>
Link: https://patch.msgid.link/20250509120435.43646-7-wahrenst@gmx.net


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4ecf56f4
Loading
Loading
Loading
Loading
+12 −22
Original line number Diff line number Diff line
@@ -319,19 +319,12 @@ static irqreturn_t mse102x_rx_pkt_spi(struct mse102x_net *mse)
	__be16 rx = 0;
	u16 cmd_resp;
	u8 *rxpkt;
	int ret;

	mse102x_tx_cmd_spi(mse, CMD_CTR);
	ret = mse102x_rx_cmd_spi(mse, (u8 *)&rx);
	cmd_resp = be16_to_cpu(rx);

	if (ret || ((cmd_resp & CMD_MASK) != CMD_RTS)) {
	if (mse102x_rx_cmd_spi(mse, (u8 *)&rx)) {
		usleep_range(50, 100);

		mse102x_tx_cmd_spi(mse, CMD_CTR);
		ret = mse102x_rx_cmd_spi(mse, (u8 *)&rx);
		if (ret)
		return IRQ_NONE;
	}

	cmd_resp = be16_to_cpu(rx);
	if ((cmd_resp & CMD_MASK) != CMD_RTS) {
@@ -342,10 +335,6 @@ static irqreturn_t mse102x_rx_pkt_spi(struct mse102x_net *mse)
		goto drop;
	}

		net_dbg_ratelimited("%s: Unexpected response to first CMD\n",
				    __func__);
	}

	rxlen = cmd_resp & LEN_MASK;
	if (rxlen < ETH_ZLEN || rxlen > VLAN_ETH_FRAME_LEN) {
		net_dbg_ratelimited("%s: Invalid frame length: %d\n", __func__,
@@ -565,6 +554,7 @@ static int mse102x_net_open(struct net_device *ndev)
	 * So poll for possible packet(s) to re-arm the interrupt.
	 */
	mutex_lock(&mses->lock);
	if (mse102x_rx_pkt_spi(mse) == IRQ_NONE)
		mse102x_rx_pkt_spi(mse);
	mutex_unlock(&mses->lock);