提交 d7c5762b 编写于 作者: K Kuninori Morimoto 提交者: Mark Brown

ASoC: sh: fsi: free from NULL pointer of struct sh_fsi_platform_info

Current FSI driver assumed master->info is not NULL.
This patch allow NULL in master->info
Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: NPaul Mundt <lethal@linux-sh.org>
Acked-by: NLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 160afa7f
...@@ -113,6 +113,8 @@ ...@@ -113,6 +113,8 @@
#define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE) #define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
typedef int (*set_rate_func)(struct device *dev, int is_porta, int rate, int enable);
/* /*
* FSI driver use below type name for variable * FSI driver use below type name for variable
* *
...@@ -269,11 +271,22 @@ static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream) ...@@ -269,11 +271,22 @@ static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream)
return fsi_get_priv_frm_dai(fsi_get_dai(substream)); return fsi_get_priv_frm_dai(fsi_get_dai(substream));
} }
static set_rate_func fsi_get_info_set_rate(struct fsi_master *master)
{
if (!master->info)
return NULL;
return master->info->set_rate;
}
static u32 fsi_get_info_flags(struct fsi_priv *fsi) static u32 fsi_get_info_flags(struct fsi_priv *fsi)
{ {
int is_porta = fsi_is_port_a(fsi); int is_porta = fsi_is_port_a(fsi);
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
if (!master->info)
return 0;
return is_porta ? master->info->porta_flags : return is_porta ? master->info->porta_flags :
master->info->portb_flags; master->info->portb_flags;
} }
...@@ -830,12 +843,12 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream, ...@@ -830,12 +843,12 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream,
struct fsi_priv *fsi = fsi_get_priv(substream); struct fsi_priv *fsi = fsi_get_priv(substream);
int is_play = fsi_is_play(substream); int is_play = fsi_is_play(substream);
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
int (*set_rate)(struct device *dev, int is_porta, int rate, int enable); set_rate_func set_rate;
fsi_irq_disable(fsi, is_play); fsi_irq_disable(fsi, is_play);
fsi_clk_ctrl(fsi, 0); fsi_clk_ctrl(fsi, 0);
set_rate = master->info->set_rate; set_rate = fsi_get_info_set_rate(master);
if (set_rate && fsi->rate) if (set_rate && fsi->rate)
set_rate(dai->dev, fsi_is_port_a(fsi), fsi->rate, 0); set_rate(dai->dev, fsi_is_port_a(fsi), fsi->rate, 0);
fsi->rate = 0; fsi->rate = 0;
...@@ -902,12 +915,12 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -902,12 +915,12 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream,
{ {
struct fsi_priv *fsi = fsi_get_priv(substream); struct fsi_priv *fsi = fsi_get_priv(substream);
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
int (*set_rate)(struct device *dev, int is_porta, int rate, int enable); set_rate_func set_rate;
int fsi_ver = master->core->ver; int fsi_ver = master->core->ver;
long rate = params_rate(params); long rate = params_rate(params);
int ret; int ret;
set_rate = master->info->set_rate; set_rate = fsi_get_info_set_rate(master);
if (!set_rate) if (!set_rate)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册