From: Marcus Cooper <[email protected]> This patch tidies up the HDMI audio driver in an attempt to removal all warnings and errors when the code is run through checkpatch.
Signed-off-by: Marcus Cooper <[email protected]> --- sound/soc/sunxi/hdmiaudio/sndhdmi.c | 73 +++++++++------ sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c | 59 ++++++------ sound/soc/sunxi/hdmiaudio/sunxi-hdmipcm.c | 139 ++++++++++++++-------------- sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c | 32 ++++--- 4 files changed, 166 insertions(+), 137 deletions(-) diff --git a/sound/soc/sunxi/hdmiaudio/sndhdmi.c b/sound/soc/sunxi/hdmiaudio/sndhdmi.c index 87080bd..90cbe87 100644 --- a/sound/soc/sunxi/hdmiaudio/sndhdmi.c +++ b/sound/soc/sunxi/hdmiaudio/sndhdmi.c @@ -24,6 +24,10 @@ #include <linux/io.h> #include <linux/drv_hdmi.h> +static __audio_hdmi_func g_hdmi_func; +static hdmi_audio_t hdmi_para; + +/* The struct is just for registering the hdmiaudio codec node */ struct sndhdmi_priv { int sysclk; int dai_fmt; @@ -32,15 +36,11 @@ struct sndhdmi_priv { struct snd_pcm_substream *slave_substream; }; -static hdmi_audio_t hdmi_para; -static __audio_hdmi_func g_hdmi_func; - -void audio_set_hdmi_func(__audio_hdmi_func * hdmi_func) +void audio_set_hdmi_func(__audio_hdmi_func *hdmi_func) { g_hdmi_func.hdmi_audio_enable = hdmi_func->hdmi_audio_enable; g_hdmi_func.hdmi_set_audio_para = hdmi_func->hdmi_set_audio_para; } - EXPORT_SYMBOL(audio_set_hdmi_func); #define SNDHDMI_RATES (SNDRV_PCM_RATE_8000_192000|SNDRV_PCM_RATE_KNOT) @@ -53,20 +53,20 @@ static int sndhdmi_mute(struct snd_soc_dai *dai, int mute) } static int sndhdmi_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) + struct snd_soc_dai *dai) { return 0; } static void sndhdmi_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) + struct snd_soc_dai *dai) { } static int sndhdmi_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) { hdmi_para.sample_rate = params_rate(params); hdmi_para.channel_num = params_channels(params); @@ -90,13 +90,14 @@ static int sndhdmi_hw_params(struct snd_pcm_substream *substream, return 0; } -static int sndhdmi_set_dai_sysclk(struct snd_soc_dai *codec_dai, - int clk_id, unsigned int freq, int dir) +static int sndhdmi_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, + unsigned int freq, int dir) { return 0; } -static int sndhdmi_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) +static int sndhdmi_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, + int div) { hdmi_para.fs_between = div; @@ -105,13 +106,12 @@ static int sndhdmi_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int } -static int sndhdmi_set_dai_fmt(struct snd_soc_dai *codec_dai, - unsigned int fmt) +static int sndhdmi_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { return 0; } -//codec dai operation +/* codec dai operation */ struct snd_soc_dai_ops sndhdmi_dai_ops = { .startup = sndhdmi_startup, .shutdown = sndhdmi_shutdown, @@ -122,7 +122,7 @@ struct snd_soc_dai_ops sndhdmi_dai_ops = { .set_fmt = sndhdmi_set_dai_fmt, }; -//codec dai +/* codec dai */ struct snd_soc_dai_driver sndhdmi_dai = { .name = "sndhdmi", /* playback capabilities */ @@ -143,11 +143,17 @@ static int sndhdmi_soc_probe(struct snd_soc_codec *codec) { struct sndhdmi_priv *sndhdmi; + if (!codec) { + printk("error:%s,line:%d\n", __func__, __LINE__); + return -EAGAIN; + } + sndhdmi = kzalloc(sizeof(struct sndhdmi_priv), GFP_KERNEL); - if(sndhdmi == NULL){ - printk("error at:%s,%d\n",__func__,__LINE__); + if (sndhdmi == NULL) { + printk("error at:%s,%d\n", __func__, __LINE__); return -ENOMEM; } + snd_soc_codec_set_drvdata(codec, sndhdmi); return 0; @@ -155,7 +161,13 @@ static int sndhdmi_soc_probe(struct snd_soc_codec *codec) static int sndhdmi_soc_remove(struct snd_soc_codec *codec) { - struct sndhdmi_priv *sndhdmi = snd_soc_codec_get_drvdata(codec); + struct sndhdmi_priv *sndhdmi; + + if (!codec) { + printk("error:%s,line:%d\n", __func__, __LINE__); + return -EAGAIN; + } + sndhdmi = snd_soc_codec_get_drvdata(codec); kfree(sndhdmi); @@ -163,17 +175,26 @@ static int sndhdmi_soc_remove(struct snd_soc_codec *codec) } static struct snd_soc_codec_driver soc_codec_dev_sndhdmi = { - .probe = sndhdmi_soc_probe, - .remove = sndhdmi_soc_remove, + .probe = sndhdmi_soc_probe, + .remove = sndhdmi_soc_remove, }; static int __devinit sndhdmi_codec_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_sndhdmi, &sndhdmi_dai, 1); + if (!pdev) { + printk("error:%s,line:%d\n", __func__, __LINE__); + return -EAGAIN; + } + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_sndhdmi, + &sndhdmi_dai, 1); } -static int __devexit sndhdmi_codec_remove(struct platform_device *pdev) +static int __exit sndhdmi_codec_remove(struct platform_device *pdev) { + if (!pdev) { + printk("error:%s,line:%d\n", __func__, __LINE__); + return -EAGAIN; + } snd_soc_unregister_codec(&pdev->dev); return 0; } @@ -184,14 +205,15 @@ static struct platform_driver sndhdmi_codec_driver = { .owner = THIS_MODULE, }, .probe = sndhdmi_codec_probe, - .remove = __devexit_p(sndhdmi_codec_remove), + .remove = __exit_p(sndhdmi_codec_remove), }; static int __init sndhdmi_codec_init(void) { int err = 0; - if ((err = platform_driver_register(&sndhdmi_codec_driver)) < 0) + err = platform_driver_register(&sndhdmi_codec_driver); + if (err < 0) return err; return 0; @@ -207,4 +229,3 @@ module_exit(sndhdmi_codec_exit); MODULE_DESCRIPTION("SNDHDMI ALSA soc codec driver"); MODULE_AUTHOR("Zoltan Devai, Christian Pellegrin <[email protected]>"); MODULE_LICENSE("GPL"); - diff --git a/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c b/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c index 9951b63..4fc296d 100644 --- a/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c +++ b/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c @@ -39,7 +39,7 @@ static struct sunxi_dma_params sunxi_hdmiaudio_pcm_stereo_out = { #if defined CONFIG_ARCH_SUN4I || defined CONFIG_ARCH_SUN5I .channel = DMACH_HDMIAUDIO, #endif - .dma_addr = 0, + .dma_addr = 0, }; void sunxi_snd_txctrl_hdmiaudio(struct snd_pcm_substream *substream, int on) @@ -53,14 +53,14 @@ static int sunxi_hdmiaudio_set_fmt(struct snd_soc_dai *cpu_dai, } static int sunxi_hdmiaudio_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct sunxi_dma_params *dma_data; /* play or record */ - if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) dma_data = &sunxi_hdmiaudio_pcm_stereo_out; else printk("error:hdmiaudio can't support capture:%s,line:%d\n", @@ -72,7 +72,7 @@ static int sunxi_hdmiaudio_hw_params(struct snd_pcm_substream *substream, } static int sunxi_hdmiaudio_trigger(struct snd_pcm_substream *substream, - int cmd, struct snd_soc_dai *dai) + int cmd, struct snd_soc_dai *dai) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -101,14 +101,15 @@ static int sunxi_hdmiaudio_trigger(struct snd_pcm_substream *substream, return ret; } -//freq: 1: 22.5792MHz 0: 24.576MHz +/* freq: 1: 22.5792MHz 0: 24.576MHz */ static int sunxi_hdmiaudio_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, - unsigned int freq, int dir) + unsigned int freq, int dir) { return 0; } -static int sunxi_hdmiaudio_set_clkdiv(struct snd_soc_dai *cpu_dai, int div_id, int div) +static int sunxi_hdmiaudio_set_clkdiv(struct snd_soc_dai *cpu_dai, int div_id, + int div) { return 0; } @@ -162,25 +163,26 @@ static int sunxi_hdmiaudio_resume(struct snd_soc_dai *cpu_dai) #define SUNXI_HDMI_RATES (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT) static struct snd_soc_dai_ops sunxi_hdmiaudio_dai_ops = { - .trigger = sunxi_hdmiaudio_trigger, - .hw_params = sunxi_hdmiaudio_hw_params, - .set_fmt = sunxi_hdmiaudio_set_fmt, - .set_clkdiv = sunxi_hdmiaudio_set_clkdiv, - .set_sysclk = sunxi_hdmiaudio_set_sysclk, + .trigger = sunxi_hdmiaudio_trigger, + .hw_params = sunxi_hdmiaudio_hw_params, + .set_fmt = sunxi_hdmiaudio_set_fmt, + .set_clkdiv = sunxi_hdmiaudio_set_clkdiv, + .set_sysclk = sunxi_hdmiaudio_set_sysclk, }; static struct snd_soc_dai_driver sunxi_hdmiaudio_dai = { - .probe = sunxi_hdmiaudio_dai_probe, - .suspend = sunxi_hdmiaudio_suspend, - .resume = sunxi_hdmiaudio_resume, - .remove = sunxi_hdmiaudio_dai_remove, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SUNXI_HDMI_RATES, - .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE + + .probe = sunxi_hdmiaudio_dai_probe, + .suspend = sunxi_hdmiaudio_suspend, + .resume = sunxi_hdmiaudio_resume, + .remove = sunxi_hdmiaudio_dai_remove, + .playback = { + .channels_min = 1, + .channels_max = 2, + .rates = SUNXI_HDMI_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, }, - .symmetric_rates = 1, - .ops = &sunxi_hdmiaudio_dai_ops, + .symmetric_rates = 1, + .ops = &sunxi_hdmiaudio_dai_ops, }; static int __devinit sunxi_hdmiaudio_dev_probe(struct platform_device *pdev) @@ -196,9 +198,9 @@ static int __devexit sunxi_hdmiaudio_dev_remove(struct platform_device *pdev) } static struct platform_driver sunxi_hdmiaudio_driver = { - .probe = sunxi_hdmiaudio_dev_probe, - .remove = __devexit_p(sunxi_hdmiaudio_dev_remove), - .driver = { + .probe = sunxi_hdmiaudio_dev_probe, + .remove = __devexit_p(sunxi_hdmiaudio_dev_remove), + .driver = { .name = "sunxi-hdmiaudio", .owner = THIS_MODULE, }, @@ -208,7 +210,8 @@ static int __init sunxi_hdmiaudio_init(void) { int err = 0; - if ((err = platform_driver_register(&sunxi_hdmiaudio_driver)) < 0) + err = platform_driver_register(&sunxi_hdmiaudio_driver); + if (err < 0) return err; return 0; diff --git a/sound/soc/sunxi/hdmiaudio/sunxi-hdmipcm.c b/sound/soc/sunxi/hdmiaudio/sunxi-hdmipcm.c index dc5704a..4916b51 100644 --- a/sound/soc/sunxi/hdmiaudio/sunxi-hdmipcm.c +++ b/sound/soc/sunxi/hdmiaudio/sunxi-hdmipcm.c @@ -29,27 +29,30 @@ #include <mach/hardware.h> #include <plat/dma_compat.h> - -static volatile unsigned int dmasrc = 0; -static volatile unsigned int dmadst = 0; +static volatile unsigned int dmasrc; +static volatile unsigned int dmadst; static const struct snd_pcm_hardware sunxi_pcm_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_RESUME, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S32_LE, - .rates = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT, + SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_8000_192000 | + SNDRV_PCM_RATE_KNOT, .rate_min = 8000, .rate_max = 192000, .channels_min = 1, .channels_max = 2, - .buffer_bytes_max = 128*1024, /* value must be (2^n)Kbyte size */ - .period_bytes_min = 1024*4,//1024*4, - .period_bytes_max = 1024*32,//1024*32, - .periods_min = 4,//4, - .periods_max = 8,//8, - .fifo_size = 128,//32, + .buffer_bytes_max = 128*1024, /* value must be (2^n)Kbyte size */ + .period_bytes_min = 1024*4, + .period_bytes_max = 1024*32, + .periods_min = 4, + .periods_max = 8, + .fifo_size = 128, }; struct sunxi_runtime_data { @@ -72,23 +75,19 @@ static void sunxi_pcm_enqueue(struct snd_pcm_substream *substream) int ret; unsigned long len = prtd->dma_period; - limit = prtd->dma_limit; - while(prtd->dma_loaded < limit) - { - if((pos + len) > prtd->dma_end){ - len = prtd->dma_end - pos; - } + limit = prtd->dma_limit; + while (prtd->dma_loaded < limit) { + if ((pos + len) > prtd->dma_end) + len = prtd->dma_end - pos; ret = sunxi_dma_enqueue(prtd->params, pos, len, 0); if (ret == 0) { prtd->dma_loaded++; pos += prtd->dma_period; - if(pos >= prtd->dma_end) + if (pos >= prtd->dma_end) pos = prtd->dma_start; - }else { + } else break; - } - } prtd->dma_pos = pos; } @@ -99,9 +98,8 @@ static void sunxi_audio_buffdone(struct sunxi_dma_params *dma, void *dev_id) struct snd_pcm_substream *substream = dev_id; prtd = substream->runtime->private_data; - if (substream) { - snd_pcm_period_elapsed(substream); - } + if (substream) + snd_pcm_period_elapsed(substream); spin_lock(&prtd->lock); { @@ -128,13 +126,12 @@ static int sunxi_pcm_hw_params(struct snd_pcm_substream *substream, if (prtd->params == NULL) { prtd->params = dma; ret = sunxi_dma_request(prtd->params, 1); - if (ret < 0) { - return ret; - } + if (ret < 0) + return ret; } if (sunxi_dma_set_callback(prtd->params, sunxi_audio_buffdone, - substream) != 0) { + substream) != 0) { sunxi_dma_release(prtd->params); prtd->params = NULL; return -EINVAL; @@ -181,25 +178,25 @@ static int sunxi_pcm_prepare(struct snd_pcm_substream *substream) if (!prtd->params) return 0; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK){ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { #if defined CONFIG_ARCH_SUN4I || defined CONFIG_ARCH_SUN5I struct dma_hw_conf codec_dma_conf; - codec_dma_conf.drqsrc_type = DRQ_TYPE_SDRAM; - codec_dma_conf.drqdst_type = DRQ_TYPE_HDMIAUDIO; - codec_dma_conf.xfer_type = DMAXFER_D_BWORD_S_BWORD; - codec_dma_conf.address_type = DMAADDRT_D_IO_S_LN; - codec_dma_conf.dir = SW_DMA_WDEV; - codec_dma_conf.reload = 0; - codec_dma_conf.hf_irq = SW_DMA_IRQ_FULL; - codec_dma_conf.from = prtd->dma_start; - codec_dma_conf.to = prtd->params->dma_addr; + codec_dma_conf.drqsrc_type = DRQ_TYPE_SDRAM; + codec_dma_conf.drqdst_type = DRQ_TYPE_HDMIAUDIO; + codec_dma_conf.xfer_type = DMAXFER_D_BWORD_S_BWORD; + codec_dma_conf.address_type = DMAADDRT_D_IO_S_LN; + codec_dma_conf.dir = SW_DMA_WDEV; + codec_dma_conf.reload = 0; + codec_dma_conf.hf_irq = SW_DMA_IRQ_FULL; + codec_dma_conf.from = prtd->dma_start; + codec_dma_conf.to = prtd->params->dma_addr; #else dma_config_t codec_dma_conf; memset(&codec_dma_conf, 0, sizeof(codec_dma_conf)); codec_dma_conf.xfer_type.src_data_width = DATA_WIDTH_32BIT; - codec_dma_conf.xfer_type.src_bst_len = DATA_BRST_4; + codec_dma_conf.xfer_type.src_bst_len = DATA_BRST_4; codec_dma_conf.xfer_type.dst_data_width = DATA_WIDTH_32BIT; - codec_dma_conf.xfer_type.dst_bst_len = DATA_BRST_4; + codec_dma_conf.xfer_type.dst_bst_len = DATA_BRST_4; codec_dma_conf.address_type.src_addr_mode = DDMA_ADDR_LINEAR; codec_dma_conf.address_type.dst_addr_mode = DDMA_ADDR_IO; codec_dma_conf.src_drq_type = D_SRC_SDRAM; @@ -261,21 +258,19 @@ static snd_pcm_uframes_t sunxi_pcm_pointer(struct snd_pcm_substream *substream) snd_pcm_uframes_t offset = 0; spin_lock(&prtd->lock); - - sunxi_dma_getcurposition(prtd->params, (dma_addr_t*)&dmasrc, - (dma_addr_t*)&dmadst); + sunxi_dma_getcurposition(prtd->params, (dma_addr_t *)&dmasrc, + (dma_addr_t *)&dmadst); if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) res = dmadst - prtd->dma_start; else - { - offset = bytes_to_frames(runtime, dmasrc + prtd->dma_period - runtime->dma_addr); - } + offset = bytes_to_frames(runtime, dmasrc + prtd->dma_period - + runtime->dma_addr); spin_unlock(&prtd->lock); - if(offset >= runtime->buffer_size) + if (offset >= runtime->buffer_size) offset = 0; - return offset; + return offset; } static int sunxi_pcm_open(struct snd_pcm_substream *substream) @@ -312,21 +307,21 @@ static int sunxi_pcm_mmap(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; return dma_mmap_writecombine(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); + runtime->dma_area, + runtime->dma_addr, + runtime->dma_bytes); } static struct snd_pcm_ops sunxi_pcm_ops = { - .open = sunxi_pcm_open, + .open = sunxi_pcm_open, .close = sunxi_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = sunxi_pcm_hw_params, + .hw_params = sunxi_pcm_hw_params, .hw_free = sunxi_pcm_hw_free, .prepare = sunxi_pcm_prepare, .trigger = sunxi_pcm_trigger, .pointer = sunxi_pcm_pointer, - .mmap = sunxi_pcm_mmap, + .mmap = sunxi_pcm_mmap, }; static int sunxi_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) @@ -339,7 +334,7 @@ static int sunxi_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) buf->dev.dev = pcm->card->dev; buf->private_data = NULL; buf->area = dma_alloc_writecombine(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); + &buf->addr, GFP_KERNEL); if (!buf->area) return -ENOMEM; buf->bytes = size; @@ -348,9 +343,9 @@ static int sunxi_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) static void sunxi_pcm_free_dma_buffers(struct snd_pcm *pcm) { - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; int stream; + struct snd_dma_buffer *buf; + struct snd_pcm_substream *substream; for (stream = 0; stream < 2; stream++) { substream = pcm->streams[stream].substream; @@ -362,7 +357,7 @@ static void sunxi_pcm_free_dma_buffers(struct snd_pcm *pcm) continue; dma_free_writecombine(pcm->card->dev, buf->bytes, - buf->area, buf->addr); + buf->area, buf->addr); buf->area = NULL; } } @@ -371,9 +366,9 @@ static u64 sunxi_pcm_mask = DMA_BIT_MASK(32); static int sunxi_pcm_new(struct snd_soc_pcm_runtime *rtd) { - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm; int ret = 0; + struct snd_pcm *pcm = rtd->pcm; + struct snd_card *card = rtd->card->snd_card; if (!card->dev->dma_mask) card->dev->dma_mask = &sunxi_pcm_mask; @@ -398,14 +393,15 @@ static int sunxi_pcm_new(struct snd_soc_pcm_runtime *rtd) } static struct snd_soc_platform_driver sunxi_soc_platform_hdmiaudio = { - .ops = &sunxi_pcm_ops, - .pcm_new = sunxi_pcm_new, - .pcm_free = sunxi_pcm_free_dma_buffers, + .ops = &sunxi_pcm_ops, + .pcm_new = sunxi_pcm_new, + .pcm_free = sunxi_pcm_free_dma_buffers, }; static int __devinit sunxi_hdmiaudio_pcm_probe(struct platform_device *pdev) { - return snd_soc_register_platform(&pdev->dev, &sunxi_soc_platform_hdmiaudio); + return snd_soc_register_platform(&pdev->dev, + &sunxi_soc_platform_hdmiaudio); } static int __devexit sunxi_hdmiaudio_pcm_remove(struct platform_device *pdev) @@ -415,9 +411,9 @@ static int __devexit sunxi_hdmiaudio_pcm_remove(struct platform_device *pdev) } static struct platform_driver sunxi_hdmiaudio_pcm_driver = { - .probe = sunxi_hdmiaudio_pcm_probe, - .remove = __devexit_p(sunxi_hdmiaudio_pcm_remove), - .driver = { + .probe = sunxi_hdmiaudio_pcm_probe, + .remove = __devexit_p(sunxi_hdmiaudio_pcm_remove), + .driver = { .name = "sunxi-hdmiaudio-pcm-audio", .owner = THIS_MODULE, }, @@ -427,7 +423,8 @@ static struct platform_driver sunxi_hdmiaudio_pcm_driver = { static int __init sunxi_soc_platform_hdmiaudio_init(void) { int err = 0; - if ((err = platform_driver_register(&sunxi_hdmiaudio_pcm_driver)) < 0) + err = platform_driver_register(&sunxi_hdmiaudio_pcm_driver); + if (err < 0) return err; return 0; } diff --git a/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c b/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c index 953231e..75157fa 100644 --- a/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c +++ b/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c @@ -27,10 +27,18 @@ static int sunxi_sndhdmi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int ret = 0; + struct snd_soc_pcm_runtime *rtd; + struct snd_soc_dai *codec_dai; + struct snd_soc_dai *cpu_dai; + + if (!substream) { + printk("error:%s,line:%d\n", __func__, __LINE__); + return -EAGAIN; + } + rtd = substream->private_data; + codec_dai = rtd->codec_dai; + cpu_dai = rtd->cpu_dai; ret = snd_soc_dai_set_fmt(codec_dai, 0); if (ret < 0) @@ -48,20 +56,20 @@ static struct snd_soc_ops sunxi_sndhdmi_ops = { }; static struct snd_soc_dai_link sunxi_sndhdmi_dai_link = { - .name = "HDMIAUDIO", - .stream_name = "SUNXI-HDMIAUDIO", - .cpu_dai_name = "sunxi-hdmiaudio.0", + .name = "HDMIAUDIO", + .stream_name = "SUNXI-HDMIAUDIO", + .cpu_dai_name = "sunxi-hdmiaudio.0", .codec_dai_name = "sndhdmi", - .platform_name = "sunxi-hdmiaudio-pcm-audio.0", - .codec_name = "sunxi-hdmiaudio-codec.0", - .ops = &sunxi_sndhdmi_ops, + .platform_name = "sunxi-hdmiaudio-pcm-audio.0", + .codec_name = "sunxi-hdmiaudio-codec.0", + .ops = &sunxi_sndhdmi_ops, }; static struct snd_soc_card snd_soc_sunxi_sndhdmi = { - .name = "sunxi-sndhdmi", + .name = "sunxi-sndhdmi", .owner = THIS_MODULE, - .dai_link = &sunxi_sndhdmi_dai_link, - .num_links = 1, + .dai_link = &sunxi_sndhdmi_dai_link, + .num_links = 1, }; static int __devinit sunxi_sndhdmi_probe(struct platform_device *pdev) -- 1.8.3.2 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
