Re: [PATCH v1 1/1] spi: fsl-dspi: Unify error messaging in dspi_request_dma()

From: Vladimir Oltean
Date: Sun Feb 04 2024 - 13:31:46 EST


On Sun, Feb 04, 2024 at 08:24:17PM +0200, Vladimir Oltean wrote:
> > @@ -541,16 +538,14 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
> > cfg.direction = DMA_DEV_TO_MEM;
> > ret = dmaengine_slave_config(dma->chan_rx, &cfg);
> > if (ret) {
> > - dev_err(dev, "can't configure rx dma channel\n");
> > - ret = -EINVAL;
> > + ret = dev_err_probe(dev, -EINVAL, "can't configure rx dma channel\n");
>
> Passing -EINVAL to dev_err_probe() here doesn't work. It overwrites the "ret"
> from dmaengine_slave_config().
>
> int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
> {
> struct va_format vaf;
> va_list args;
>
> va_start(args, fmt);
> vaf.fmt = fmt;
> vaf.va = &args;
>
> if (err != -EPROBE_DEFER) { // <-------- always true
> dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
> } else {
> device_set_deferred_probe_reason(dev, &vaf);
> dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
> }
>
> va_end(args);
>
> return err;
> }

Ah, the original code also ignores the dmaengine_slave_config() return
code and replaces it with -EINVAL? I wonder why that is... It doesn't
appear to be a widespread pattern. Pretty arbitrary. Could you please
make 2 patches, one which preserves the original return code and another
which uses dev_err_probe()?