asoc: codecs: Add proper null checks and initialize variables
Add proper null checks and initialize variables in rx-macro, tx-macro, va-macro and wcd937x drivers. Change-Id: I90899c84d3391305b9a24d4b043adc08b7c0332a Signed-off-by: Tanya Dixit <tdixit@codeaurora.org>
This commit is contained in:
parent
54179d2aca
commit
8530fb9b5d
@ -770,6 +770,11 @@ static int rx_macro_mclk_enable(struct rx_macro_priv *rx_priv,
|
||||
struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
|
||||
int ret = 0, mclk_mux = MCLK_MUX0;
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(rx_priv->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
|
||||
__func__, mclk_enable, dapm, rx_priv->rx_mclk_users);
|
||||
|
||||
@ -1570,6 +1575,11 @@ static void rx_macro_restore_iir_coeff(struct rx_macro_priv *rx_priv, int iir_id
|
||||
u16 reg_add = 0, coeff_idx = 0, idx = 0;
|
||||
struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
regmap_write(regmap,
|
||||
(BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx),
|
||||
(band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
|
||||
@ -2383,6 +2393,11 @@ static int rx_swrm_clock(void *handle, bool enable)
|
||||
struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
|
||||
int ret = 0;
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&rx_priv->swr_clk_lock);
|
||||
|
||||
dev_dbg(rx_priv->dev, "%s: swrm clock %s\n",
|
||||
|
@ -183,6 +183,11 @@ static int tx_macro_mclk_enable(struct tx_macro_priv *tx_priv,
|
||||
struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
|
||||
int ret = 0;
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(tx_priv->dev, "%s: mclk_enable = %u,clk_users= %d\n",
|
||||
__func__, mclk_enable, tx_priv->tx_mclk_users);
|
||||
|
||||
@ -1319,6 +1324,11 @@ static int tx_macro_swrm_clock(void *handle, bool enable)
|
||||
struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
|
||||
int ret = 0;
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&tx_priv->swr_clk_lock);
|
||||
|
||||
dev_dbg(tx_priv->dev, "%s: swrm clock %s\n",
|
||||
|
@ -143,6 +143,11 @@ static int va_macro_mclk_enable(struct va_macro_priv *va_priv,
|
||||
struct regmap *regmap = dev_get_regmap(va_priv->dev->parent, NULL);
|
||||
int ret = 0;
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(va_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(va_priv->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
|
||||
__func__, mclk_enable, dapm, va_priv->va_mclk_users);
|
||||
|
||||
|
@ -142,8 +142,8 @@ static int wcd937x_set_port_params(struct snd_soc_codec *codec, u8 slv_prt_type,
|
||||
u8 *port_type, u8 path)
|
||||
{
|
||||
int i, j;
|
||||
u8 num_ports;
|
||||
struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT];
|
||||
u8 num_ports = 0;
|
||||
struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT] = NULL;
|
||||
struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
|
||||
|
||||
switch (path) {
|
||||
@ -186,8 +186,8 @@ static int wcd937x_parse_port_mapping(struct device *dev,
|
||||
u32 slave_port_type, master_port_type;
|
||||
u32 i, ch_iter = 0;
|
||||
int ret = 0;
|
||||
u8 *num_ports;
|
||||
struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT];
|
||||
u8 *num_ports = NULL;
|
||||
struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT] = NULL;
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(dev);
|
||||
|
||||
switch (path) {
|
||||
|
Loading…
Reference in New Issue
Block a user