spi: sg2044-nor: Return transfer errors

The transfer helpers return errors, but both dispatchers discard them.
Return these errors to the SPI memory layer instead of reporting success.

Fixes: de16c322ee ("spi: sophgo: add SG2044 SPI NOR controller driver")
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
Link: https://patch.msgid.link/20261001-fix-sg204xspi-v2-1-014dbaf22b5e@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Han Gao 2026-10-01 02:22:50 +08:00 committed by Mark Brown
parent 853de617c4
commit 53cdc4266b
No known key found for this signature in database
GPG Key ID: 2FEF73B0B3D03889

View File

@ -307,15 +307,15 @@ static ssize_t sg2044_spifmc_tran_cmd(struct sg2044_spifmc *spifmc,
return 0;
}
static void sg2044_spifmc_trans(struct sg2044_spifmc *spifmc,
const struct spi_mem_op *op)
static int sg2044_spifmc_trans(struct sg2044_spifmc *spifmc,
const struct spi_mem_op *op)
{
if (op->data.dir == SPI_MEM_DATA_IN)
sg2044_spifmc_read(spifmc, op);
return sg2044_spifmc_read(spifmc, op);
else if (op->data.dir == SPI_MEM_DATA_OUT)
sg2044_spifmc_write(spifmc, op);
return sg2044_spifmc_write(spifmc, op);
else
sg2044_spifmc_tran_cmd(spifmc, op);
return sg2044_spifmc_tran_cmd(spifmc, op);
}
static ssize_t sg2044_spifmc_trans_reg(struct sg2044_spifmc *spifmc,
@ -389,19 +389,20 @@ static int sg2044_spifmc_exec_op(struct spi_mem *mem,
const struct spi_mem_op *op)
{
struct sg2044_spifmc *spifmc;
int ret;
spifmc = spi_controller_get_devdata(mem->spi->controller);
mutex_lock(&spifmc->lock);
if (op->addr.nbytes == 0)
sg2044_spifmc_trans_reg(spifmc, op);
ret = sg2044_spifmc_trans_reg(spifmc, op);
else
sg2044_spifmc_trans(spifmc, op);
ret = sg2044_spifmc_trans(spifmc, op);
mutex_unlock(&spifmc->lock);
return 0;
return ret;
}
static const struct spi_controller_mem_ops sg2044_spifmc_mem_ops = {