diff options
author | Axel Lin <axel.lin@ingics.com> | 2017-10-12 21:21:01 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-10-12 21:30:56 -0400 |
commit | d6e18b8295593d8f59e92f6634577cbacae14629 (patch) | |
tree | 994feebcaef313d80ddc3c36425367c9acc9396d | |
parent | 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e (diff) |
ASoC: max98925: Return proper error if revision mismatch
Return proper error instead of 0 if the revision does not match.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/max98925.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sound/soc/codecs/max98925.c b/sound/soc/codecs/max98925.c index 327eaa25c9bd..921f95fc396d 100644 --- a/sound/soc/codecs/max98925.c +++ b/sound/soc/codecs/max98925.c | |||
@@ -579,7 +579,7 @@ static int max98925_i2c_probe(struct i2c_client *i2c, | |||
579 | ret = PTR_ERR(max98925->regmap); | 579 | ret = PTR_ERR(max98925->regmap); |
580 | dev_err(&i2c->dev, | 580 | dev_err(&i2c->dev, |
581 | "Failed to allocate regmap: %d\n", ret); | 581 | "Failed to allocate regmap: %d\n", ret); |
582 | goto err_out; | 582 | return ret; |
583 | } | 583 | } |
584 | 584 | ||
585 | if (!of_property_read_u32(i2c->dev.of_node, "vmon-slot-no", &value)) { | 585 | 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 | } | 596 | } |
597 | max98925->i_slot = value; | 597 | max98925->i_slot = value; |
598 | } | 598 | } |
599 | ret = regmap_read(max98925->regmap, | 599 | |
600 | MAX98925_REV_VERSION, ®); | 600 | ret = regmap_read(max98925->regmap, MAX98925_REV_VERSION, ®); |
601 | if ((ret < 0) || | 601 | if (ret < 0) { |
602 | ((reg != MAX98925_VERSION) && | 602 | dev_err(&i2c->dev, "Read revision failed\n"); |
603 | (reg != MAX98925_VERSION1))) { | 603 | return ret; |
604 | dev_err(&i2c->dev, | 604 | } |
605 | "device initialization error (%d 0x%02X)\n", | 605 | |
606 | if ((reg != MAX98925_VERSION) && (reg != MAX98925_VERSION1)) { | ||
607 | ret = -ENODEV; | ||
608 | dev_err(&i2c->dev, "Invalid revision (%d 0x%02X)\n", | ||
606 | ret, reg); | 609 | ret, reg); |
607 | goto err_out; | 610 | return ret; |
608 | } | 611 | } |
612 | |||
609 | dev_info(&i2c->dev, "device version 0x%02X\n", reg); | 613 | dev_info(&i2c->dev, "device version 0x%02X\n", reg); |
610 | 614 | ||
611 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98925, | 615 | 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 | if (ret < 0) | 617 | if (ret < 0) |
614 | dev_err(&i2c->dev, | 618 | dev_err(&i2c->dev, |
615 | "Failed to register codec: %d\n", ret); | 619 | "Failed to register codec: %d\n", ret); |
616 | err_out: | ||
617 | return ret; | 620 | return ret; |
618 | } | 621 | } |
619 | 622 | ||