Commit d6e18b82 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

ASoC: max98925: Return proper error if revision mismatch

Return proper error instead of 0 if the revision does not match.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2bd6bf03
...@@ -579,7 +579,7 @@ static int max98925_i2c_probe(struct i2c_client *i2c, ...@@ -579,7 +579,7 @@ static int max98925_i2c_probe(struct i2c_client *i2c,
ret = PTR_ERR(max98925->regmap); ret = PTR_ERR(max98925->regmap);
dev_err(&i2c->dev, dev_err(&i2c->dev,
"Failed to allocate regmap: %d\n", ret); "Failed to allocate regmap: %d\n", ret);
goto err_out; return ret;
} }
if (!of_property_read_u32(i2c->dev.of_node, "vmon-slot-no", &value)) { if (!of_property_read_u32(i2c->dev.of_node, "vmon-slot-no", &value)) {
...@@ -596,16 +596,20 @@ static int max98925_i2c_probe(struct i2c_client *i2c, ...@@ -596,16 +596,20 @@ static int max98925_i2c_probe(struct i2c_client *i2c,
} }
max98925->i_slot = value; max98925->i_slot = value;
} }
ret = regmap_read(max98925->regmap,
MAX98925_REV_VERSION, &reg); ret = regmap_read(max98925->regmap, MAX98925_REV_VERSION, &reg);
if ((ret < 0) || if (ret < 0) {
((reg != MAX98925_VERSION) && dev_err(&i2c->dev, "Read revision failed\n");
(reg != MAX98925_VERSION1))) { return ret;
dev_err(&i2c->dev, }
"device initialization error (%d 0x%02X)\n",
if ((reg != MAX98925_VERSION) && (reg != MAX98925_VERSION1)) {
ret = -ENODEV;
dev_err(&i2c->dev, "Invalid revision (%d 0x%02X)\n",
ret, reg); ret, reg);
goto err_out; return ret;
} }
dev_info(&i2c->dev, "device version 0x%02X\n", reg); dev_info(&i2c->dev, "device version 0x%02X\n", reg);
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98925, ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98925,
...@@ -613,7 +617,6 @@ static int max98925_i2c_probe(struct i2c_client *i2c, ...@@ -613,7 +617,6 @@ static int max98925_i2c_probe(struct i2c_client *i2c,
if (ret < 0) if (ret < 0)
dev_err(&i2c->dev, dev_err(&i2c->dev,
"Failed to register codec: %d\n", ret); "Failed to register codec: %d\n", ret);
err_out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment