提交 a6c255e0 编写于 作者: T Timur Tabi 提交者: Mark Brown

ASoC: fix message display in CS4270 codec driver

Replace printk calls with dev_xxx calls.  Set the 'dev' field of the codec
and codec_dai structures so that these calls work.
Signed-off-by: NTimur Tabi <timur@freescale.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 d9fb7fbd
...@@ -212,7 +212,7 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -212,7 +212,7 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai,
rates &= ~SNDRV_PCM_RATE_KNOT; rates &= ~SNDRV_PCM_RATE_KNOT;
if (!rates) { if (!rates) {
printk(KERN_ERR "cs4270: could not find a valid sample rate\n"); dev_err(codec->dev, "could not find a valid sample rate\n");
return -EINVAL; return -EINVAL;
} }
...@@ -253,7 +253,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -253,7 +253,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK; cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
break; break;
default: default:
printk(KERN_ERR "cs4270: invalid DAI format\n"); dev_err(codec->dev, "invalid dai format\n");
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -284,7 +284,7 @@ static int cs4270_fill_cache(struct snd_soc_codec *codec) ...@@ -284,7 +284,7 @@ static int cs4270_fill_cache(struct snd_soc_codec *codec)
CS4270_FIRSTREG | 0x80, CS4270_NUMREGS, cache); CS4270_FIRSTREG | 0x80, CS4270_NUMREGS, cache);
if (length != CS4270_NUMREGS) { if (length != CS4270_NUMREGS) {
printk(KERN_ERR "cs4270: I2C read failure, addr=0x%x\n", dev_err(codec->dev, "i2c read failure, addr=0x%x\n",
i2c_client->addr); i2c_client->addr);
return -EIO; return -EIO;
} }
...@@ -340,7 +340,7 @@ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg, ...@@ -340,7 +340,7 @@ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg,
if (cache[reg - CS4270_FIRSTREG] != value) { if (cache[reg - CS4270_FIRSTREG] != value) {
struct i2c_client *client = codec->control_data; struct i2c_client *client = codec->control_data;
if (i2c_smbus_write_byte_data(client, reg, value)) { if (i2c_smbus_write_byte_data(client, reg, value)) {
printk(KERN_ERR "cs4270: I2C write failed\n"); dev_err(codec->dev, "i2c write failed\n");
return -EIO; return -EIO;
} }
...@@ -391,7 +391,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ...@@ -391,7 +391,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
if (i == NUM_MCLK_RATIOS) { if (i == NUM_MCLK_RATIOS) {
/* We did not find a matching ratio */ /* We did not find a matching ratio */
printk(KERN_ERR "cs4270: could not find matching ratio\n"); dev_err(codec->dev, "could not find matching ratio\n");
return -EINVAL; return -EINVAL;
} }
...@@ -401,7 +401,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ...@@ -401,7 +401,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC | CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC |
CS4270_PWRCTL_PDN); CS4270_PWRCTL_PDN);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n"); dev_err(codec->dev, "i2c write failed\n");
return ret; return ret;
} }
...@@ -413,7 +413,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ...@@ -413,7 +413,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
ret = snd_soc_write(codec, CS4270_MODE, reg); ret = snd_soc_write(codec, CS4270_MODE, reg);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n"); dev_err(codec->dev, "i2c write failed\n");
return ret; return ret;
} }
...@@ -430,13 +430,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ...@@ -430,13 +430,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ; reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ;
break; break;
default: default:
printk(KERN_ERR "cs4270: unknown format\n"); dev_err(codec->dev, "unknown dai format\n");
return -EINVAL; return -EINVAL;
} }
ret = snd_soc_write(codec, CS4270_FORMAT, reg); ret = snd_soc_write(codec, CS4270_FORMAT, reg);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n"); dev_err(codec->dev, "i2c write failed\n");
return ret; return ret;
} }
...@@ -447,7 +447,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ...@@ -447,7 +447,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg &= ~CS4270_MUTE_AUTO; reg &= ~CS4270_MUTE_AUTO;
ret = snd_soc_write(codec, CS4270_MUTE, reg); ret = snd_soc_write(codec, CS4270_MUTE, reg);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n"); dev_err(codec->dev, "i2c write failed\n");
return ret; return ret;
} }
...@@ -460,7 +460,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ...@@ -460,7 +460,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO); reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO);
ret = cs4270_i2c_write(codec, CS4270_TRANS, reg); ret = cs4270_i2c_write(codec, CS4270_TRANS, reg);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "I2C write failed\n"); dev_err(codec->dev, "i2c write failed\n");
return ret; return ret;
} }
...@@ -468,7 +468,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ...@@ -468,7 +468,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
ret = snd_soc_write(codec, CS4270_PWRCTL, 0); ret = snd_soc_write(codec, CS4270_PWRCTL, 0);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n"); dev_err(codec->dev, "i2c write failed\n");
return ret; return ret;
} }
...@@ -570,7 +570,7 @@ static int cs4270_probe(struct platform_device *pdev) ...@@ -570,7 +570,7 @@ static int cs4270_probe(struct platform_device *pdev)
/* Register PCMs */ /* Register PCMs */
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: failed to create PCMs\n"); dev_err(codec->dev, "failed to create pcms\n");
return ret; return ret;
} }
...@@ -580,7 +580,7 @@ static int cs4270_probe(struct platform_device *pdev) ...@@ -580,7 +580,7 @@ static int cs4270_probe(struct platform_device *pdev)
kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);
if (!kctrl) { if (!kctrl) {
printk(KERN_ERR "cs4270: error creating control '%s'\n", dev_err(codec->dev, "error creating control '%s'\n",
cs4270_snd_controls[i].name); cs4270_snd_controls[i].name);
ret = -ENOMEM; ret = -ENOMEM;
goto error_free_pcms; goto error_free_pcms;
...@@ -588,7 +588,7 @@ static int cs4270_probe(struct platform_device *pdev) ...@@ -588,7 +588,7 @@ static int cs4270_probe(struct platform_device *pdev)
ret = snd_ctl_add(codec->card, kctrl); ret = snd_ctl_add(codec->card, kctrl);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: error adding control '%s'\n", dev_err(codec->dev, "error adding control '%s'\n",
cs4270_snd_controls[i].name); cs4270_snd_controls[i].name);
goto error_free_pcms; goto error_free_pcms;
} }
...@@ -597,7 +597,7 @@ static int cs4270_probe(struct platform_device *pdev) ...@@ -597,7 +597,7 @@ static int cs4270_probe(struct platform_device *pdev)
/* And finally, register the socdev */ /* And finally, register the socdev */
ret = snd_soc_init_card(socdev); ret = snd_soc_init_card(socdev);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: failed to register card\n"); dev_err(codec->dev, "failed to register card\n");
goto error_free_pcms; goto error_free_pcms;
} }
...@@ -643,9 +643,9 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, ...@@ -643,9 +643,9 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
* comment for cs4270_codec. * comment for cs4270_codec.
*/ */
if (cs4270_codec) { if (cs4270_codec) {
printk(KERN_ERR "cs4270: ignoring CS4270 at addr %X\n", dev_err(&i2c_client->dev, "ignoring CS4270 at addr %X\n",
i2c_client->addr); i2c_client->addr);
printk(KERN_ERR "cs4270: only one CS4270 per board allowed\n"); dev_err(&i2c_client->dev, "only one per board allowed\n");
/* Should we return something other than ENODEV here? */ /* Should we return something other than ENODEV here? */
return -ENODEV; return -ENODEV;
} }
...@@ -654,35 +654,35 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, ...@@ -654,35 +654,35 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID); ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: failed to read I2C at addr %X\n", dev_err(&i2c_client->dev, "failed to read i2c at addr %X\n",
i2c_client->addr); i2c_client->addr);
return ret; return ret;
} }
/* The top four bits of the chip ID should be 1100. */ /* The top four bits of the chip ID should be 1100. */
if ((ret & 0xF0) != 0xC0) { if ((ret & 0xF0) != 0xC0) {
printk(KERN_ERR "cs4270: device at addr %X is not a CS4270\n", dev_err(&i2c_client->dev, "device at addr %X is not a CS4270\n",
i2c_client->addr); i2c_client->addr);
return -ENODEV; return -ENODEV;
} }
printk(KERN_INFO "cs4270: found device at I2C address %X\n", dev_info(&i2c_client->dev, "found device at i2c address %X\n",
i2c_client->addr); i2c_client->addr);
printk(KERN_INFO "cs4270: hardware revision %X\n", ret & 0xF); dev_info(&i2c_client->dev, "hardware revision %X\n", ret & 0xF);
/* Allocate enough space for the snd_soc_codec structure /* Allocate enough space for the snd_soc_codec structure
and our private data together. */ and our private data together. */
cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL); cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL);
if (!cs4270) { if (!cs4270) {
printk(KERN_ERR "cs4270: Could not allocate codec structure\n"); dev_err(&i2c_client->dev, "could not allocate codec\n");
return -ENOMEM; return -ENOMEM;
} }
codec = &cs4270->codec; codec = &cs4270->codec;
cs4270_codec = codec;
mutex_init(&codec->mutex); mutex_init(&codec->mutex);
INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths); INIT_LIST_HEAD(&codec->dapm_paths);
codec->dev = &i2c_client->dev;
codec->name = "CS4270"; codec->name = "CS4270";
codec->owner = THIS_MODULE; codec->owner = THIS_MODULE;
codec->dai = &cs4270_dai; codec->dai = &cs4270_dai;
...@@ -698,17 +698,25 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, ...@@ -698,17 +698,25 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
ret = cs4270_fill_cache(codec); ret = cs4270_fill_cache(codec);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: failed to fill register cache\n"); dev_err(&i2c_client->dev, "failed to fill register cache\n");
goto error_free_codec; goto error_free_codec;
} }
/* Initialize the DAI. Normally, we'd prefer to have a kmalloc'd DAI
* structure for each CS4270 device, but the machine driver needs to
* have a pointer to the DAI structure, so for now it must be a global
* variable.
*/
cs4270_dai.dev = &i2c_client->dev;
/* Register the DAI. If all the other ASoC driver have already /* Register the DAI. If all the other ASoC driver have already
* registered, then this will call our probe function, so * registered, then this will call our probe function, so
* cs4270_codec needs to be ready. * cs4270_codec needs to be ready.
*/ */
cs4270_codec = codec;
ret = snd_soc_register_dai(&cs4270_dai); ret = snd_soc_register_dai(&cs4270_dai);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "cs4270: failed to register DAIe\n"); dev_err(&i2c_client->dev, "failed to register DAIe\n");
goto error_free_codec; goto error_free_codec;
} }
...@@ -718,6 +726,8 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, ...@@ -718,6 +726,8 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
error_free_codec: error_free_codec:
kfree(cs4270); kfree(cs4270);
cs4270_codec = NULL;
cs4270_dai.dev = NULL;
return ret; return ret;
} }
...@@ -733,6 +743,8 @@ static int cs4270_i2c_remove(struct i2c_client *i2c_client) ...@@ -733,6 +743,8 @@ static int cs4270_i2c_remove(struct i2c_client *i2c_client)
struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client); struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client);
kfree(cs4270); kfree(cs4270);
cs4270_codec = NULL;
cs4270_dai.dev = NULL;
return 0; return 0;
} }
...@@ -776,7 +788,7 @@ EXPORT_SYMBOL_GPL(soc_codec_device_cs4270); ...@@ -776,7 +788,7 @@ EXPORT_SYMBOL_GPL(soc_codec_device_cs4270);
static int __init cs4270_init(void) static int __init cs4270_init(void)
{ {
printk(KERN_INFO "Cirrus Logic CS4270 ALSA SoC Codec Driver\n"); pr_info("Cirrus Logic CS4270 ALSA SoC Codec Driver\n");
return i2c_add_driver(&cs4270_i2c_driver); return i2c_add_driver(&cs4270_i2c_driver);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册