Skip to contentSkip to conversation

ASoC: rt286: check regmap_read result for ID check

PATCH Applied Bard Liao 2 participants 2 messages Mar 24, 2015

Subsystems (3)
lore
Share & tools
lore

Bard Liao

author
#0 lore raw

PATCH 1/1 ASoC: rt286: check regmap_read result for ID check

It is worth to check the regmap_read result for ID check since it is the first regmap_read. And we can check if there is any i2c issue.

---
 sound/soc/codecs/rt286.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
sound/soc/codecs/rt286.c +9 -5
index 098fc78..ccc0fa0 100644
@@ -1220,7 +1220,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
 {
 	struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	struct rt286_priv *rt286;
-	int i, ret;
+	int i, ret, val;
 
 	rt286 = devm_kzalloc(&i2c->dev,	sizeof(*rt286),
 				GFP_KERNEL);
@@ -1235,11 +1235,15 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
-	regmap_read(rt286->regmap,
-		RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &ret);
-	if (ret != RT286_VENDOR_ID && ret != RT288_VENDOR_ID) {
+	ret = regmap_read(rt286->regmap,
+		RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
+	if (ret != 0) {
+		dev_err(&i2c->dev, "I2C error %d\n", ret);
+		return ret;
+	}
+	if (val != RT286_VENDOR_ID && val != RT288_VENDOR_ID) {
 		dev_err(&i2c->dev,
-			"Device with ID register %x is not rt286\n", ret);
+			"Device with ID register %x is not rt286\n", val);
 		return -ENODEV;
 	}
 
Signature · 1 line
1.8.1.1.439.g50a6b54
maintainer Applied
#1 lore raw
Quoted 3 lines · Bard Liao

It is worth to check the regmap_read result for ID check since it is the first regmap_read. And we can check if there is any i2c issue.

Applied, thanks.