linux-stable/include/linux/firmware/imx/dsp.h
Pierre-Louis Bossart e302f8d9f7
ASoC: SOF: imx: remove error checks on NULL ipc
imx_dsp_get_data() can return NULL, but the value is not checked
before being usd, leading to static analysis warnings.

sound/soc/sof/imx/imx8.c:85:32: error: dereference of NULL ‘0’
[CWE-476] [-Werror=analyzer-null-dereference]

   85 |         spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
      |                            ~~~~^~~~~~

It appears this is not really a possible problem, so remove those checks.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Yaochun Hung <yc.hung@mediatek.com>
Link: https://lore.kernel.org/r/20230731213748.440285-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-31 23:22:15 +01:00

71 lines
1.5 KiB
C

/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2019 NXP
*
* Header file for the DSP IPC implementation
*/
#ifndef _IMX_DSP_IPC_H
#define _IMX_DSP_IPC_H
#include <linux/device.h>
#include <linux/types.h>
#include <linux/mailbox_client.h>
#define DSP_MU_CHAN_NUM 4
struct imx_dsp_chan {
struct imx_dsp_ipc *ipc;
struct mbox_client cl;
struct mbox_chan *ch;
char *name;
int idx;
};
struct imx_dsp_ops {
void (*handle_reply)(struct imx_dsp_ipc *ipc);
void (*handle_request)(struct imx_dsp_ipc *ipc);
};
struct imx_dsp_ipc {
/* Host <-> DSP communication uses 2 txdb and 2 rxdb channels */
struct imx_dsp_chan chans[DSP_MU_CHAN_NUM];
struct device *dev;
struct imx_dsp_ops *ops;
void *private_data;
};
static inline void imx_dsp_set_data(struct imx_dsp_ipc *ipc, void *data)
{
ipc->private_data = data;
}
static inline void *imx_dsp_get_data(struct imx_dsp_ipc *ipc)
{
return ipc->private_data;
}
#if IS_ENABLED(CONFIG_IMX_DSP)
int imx_dsp_ring_doorbell(struct imx_dsp_ipc *dsp, unsigned int chan_idx);
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx);
void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx);
#else
static inline int imx_dsp_ring_doorbell(struct imx_dsp_ipc *ipc,
unsigned int chan_idx)
{
return -ENOTSUPP;
}
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx)
{
return ERR_PTR(-EOPNOTSUPP);
}
void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx) { }
#endif
#endif /* _IMX_DSP_IPC_H */