summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorDerek Fang <derek.fang@realtek.com>2020-12-09 17:13:08 +0800
committerMark Brown <broonie@kernel.org>2020-12-09 12:13:44 +0000
commit397e089bda327a350c1cb29133cb66795339a5d9 (patch)
tree9c5df0edbb5f85023d8c68610c849e8fd398e2ec /sound
parente648e3f1165354f04a4deed1f41152a287b68d59 (diff)
ASoC: rt1015: check the return value of regmap_read during i2c probe
In some projects, the device ID register is not read correctly. This patch helps to verify the issue is caused from i2c host or client. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20201209091308.2823-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/rt1015.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index ac4c9f43b338..32e6bcf763d1 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -1207,8 +1207,13 @@ static int rt1015_i2c_probe(struct i2c_client *i2c,
rt1015->hw_config = (i2c->addr == 0x29) ? RT1015_HW_29 : RT1015_HW_28;
- regmap_read(rt1015->regmap, RT1015_DEVICE_ID, &val);
- if ((val != RT1015_DEVICE_ID_VAL) && (val != RT1015_DEVICE_ID_VAL2)) {
+ ret = regmap_read(rt1015->regmap, RT1015_DEVICE_ID, &val);
+ if (ret) {
+ dev_err(&i2c->dev,
+ "Failed to read device register: %d\n", ret);
+ return ret;
+ } else if ((val != RT1015_DEVICE_ID_VAL) &&
+ (val != RT1015_DEVICE_ID_VAL2)) {
dev_err(&i2c->dev,
"Device with ID register %x is not rt1015\n", val);
return -ENODEV;