Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 132819
b: refs/heads/master
c: a6c255e
h: refs/heads/master
i:
  132817: 006fdcd
  132815: 5ae5b46
v: v3
  • Loading branch information
Timur Tabi authored and Mark Brown committed Feb 2, 2009
1 parent 0125ab5 commit 758dddd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d9fb7fbddc9a14569aad517984c1a5b0b07002ea
refs/heads/master: a6c255e0945160b76eabe983f59e2129e0c66246
66 changes: 39 additions & 27 deletions trunk/sound/soc/codecs/cs4270.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai,
rates &= ~SNDRV_PCM_RATE_KNOT;

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;
}

Expand Down Expand Up @@ -253,7 +253,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
break;
default:
printk(KERN_ERR "cs4270: invalid DAI format\n");
dev_err(codec->dev, "invalid dai format\n");
ret = -EINVAL;
}

Expand Down Expand Up @@ -284,7 +284,7 @@ static int cs4270_fill_cache(struct snd_soc_codec *codec)
CS4270_FIRSTREG | 0x80, CS4270_NUMREGS, cache);

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);
return -EIO;
}
Expand Down Expand Up @@ -340,7 +340,7 @@ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg,
if (cache[reg - CS4270_FIRSTREG] != value) {
struct i2c_client *client = codec->control_data;
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;
}

Expand Down Expand Up @@ -391,7 +391,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,

if (i == NUM_MCLK_RATIOS) {
/* 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;
}

Expand All @@ -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);
if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n");
dev_err(codec->dev, "i2c write failed\n");
return ret;
}

Expand All @@ -413,7 +413,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,

ret = snd_soc_write(codec, CS4270_MODE, reg);
if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n");
dev_err(codec->dev, "i2c write failed\n");
return ret;
}

Expand All @@ -430,13 +430,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ;
break;
default:
printk(KERN_ERR "cs4270: unknown format\n");
dev_err(codec->dev, "unknown dai format\n");
return -EINVAL;
}

ret = snd_soc_write(codec, CS4270_FORMAT, reg);
if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n");
dev_err(codec->dev, "i2c write failed\n");
return ret;
}

Expand All @@ -447,7 +447,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg &= ~CS4270_MUTE_AUTO;
ret = snd_soc_write(codec, CS4270_MUTE, reg);
if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n");
dev_err(codec->dev, "i2c write failed\n");
return ret;
}

Expand All @@ -460,15 +460,15 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO);
ret = cs4270_i2c_write(codec, CS4270_TRANS, reg);
if (ret < 0) {
printk(KERN_ERR "I2C write failed\n");
dev_err(codec->dev, "i2c write failed\n");
return ret;
}

/* Thaw and power-up the codec */

ret = snd_soc_write(codec, CS4270_PWRCTL, 0);
if (ret < 0) {
printk(KERN_ERR "cs4270: I2C write failed\n");
dev_err(codec->dev, "i2c write failed\n");
return ret;
}

Expand Down Expand Up @@ -570,7 +570,7 @@ static int cs4270_probe(struct platform_device *pdev)
/* Register PCMs */
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
if (ret < 0) {
printk(KERN_ERR "cs4270: failed to create PCMs\n");
dev_err(codec->dev, "failed to create pcms\n");
return ret;
}

Expand All @@ -580,15 +580,15 @@ static int cs4270_probe(struct platform_device *pdev)

kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);
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);
ret = -ENOMEM;
goto error_free_pcms;
}

ret = snd_ctl_add(codec->card, kctrl);
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);
goto error_free_pcms;
}
Expand All @@ -597,7 +597,7 @@ static int cs4270_probe(struct platform_device *pdev)
/* And finally, register the socdev */
ret = snd_soc_init_card(socdev);
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;
}

Expand Down Expand Up @@ -643,9 +643,9 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
* comment for 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);
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? */
return -ENODEV;
}
Expand All @@ -654,35 +654,35 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,

ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID);
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);
return ret;
}
/* The top four bits of the chip ID should be 1100. */
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);
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);
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
and our private data together. */
cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL);
if (!cs4270) {
printk(KERN_ERR "cs4270: Could not allocate codec structure\n");
dev_err(&i2c_client->dev, "could not allocate codec\n");
return -ENOMEM;
}
codec = &cs4270->codec;
cs4270_codec = codec;

mutex_init(&codec->mutex);
INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths);

codec->dev = &i2c_client->dev;
codec->name = "CS4270";
codec->owner = THIS_MODULE;
codec->dai = &cs4270_dai;
Expand All @@ -698,17 +698,25 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,

ret = cs4270_fill_cache(codec);
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;
}

/* 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
* registered, then this will call our probe function, so
* cs4270_codec needs to be ready.
*/
cs4270_codec = codec;
ret = snd_soc_register_dai(&cs4270_dai);
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;
}

Expand All @@ -718,6 +726,8 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,

error_free_codec:
kfree(cs4270);
cs4270_codec = NULL;
cs4270_dai.dev = NULL;

return ret;
}
Expand All @@ -733,6 +743,8 @@ static int cs4270_i2c_remove(struct i2c_client *i2c_client)
struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client);

kfree(cs4270);
cs4270_codec = NULL;
cs4270_dai.dev = NULL;

return 0;
}
Expand Down Expand Up @@ -776,7 +788,7 @@ EXPORT_SYMBOL_GPL(soc_codec_device_cs4270);

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);
}
Expand Down

0 comments on commit 758dddd

Please sign in to comment.