ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value

Fix checking return value of regmap_read().
Also fix reporting the chip_id value. CS42XX8_CHIPID_CHIP_ID_MASK is 0xF0,
so the chip_id value is (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4).

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Paul Handrigan <paul.handrigan@cirrus.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Acked-by: Nicolin Chen <Guangyu.Chen@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
Axel Lin 2014-04-04 11:04:35 +08:00 committed by Mark Brown
parent c159a85013
commit 06b4b81305
1 changed files with 5 additions and 6 deletions

View File

@ -495,17 +495,16 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
regcache_cache_bypass(cs42xx8->regmap, true); regcache_cache_bypass(cs42xx8->regmap, true);
/* Validate the chip ID */ /* Validate the chip ID */
regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val); ret = regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
if (val < 0) { if (ret < 0) {
dev_err(dev, "failed to get device ID: %x", val); dev_err(dev, "failed to get device ID, ret = %d", ret);
ret = -EINVAL;
goto err_enable; goto err_enable;
} }
/* The top four bits of the chip ID should be 0000 */ /* The top four bits of the chip ID should be 0000 */
if ((val & CS42XX8_CHIPID_CHIP_ID_MASK) != 0x00) { if (((val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4) != 0x00) {
dev_err(dev, "unmatched chip ID: %d\n", dev_err(dev, "unmatched chip ID: %d\n",
val & CS42XX8_CHIPID_CHIP_ID_MASK); (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4);
ret = -EINVAL; ret = -EINVAL;
goto err_enable; goto err_enable;
} }