diff options
author | Mark Brown <broonie@linaro.org> | 2013-11-22 08:34:48 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-11-24 08:53:27 -0500 |
commit | a0a05916cf67a007f4ee0071fd0fa04e45137a38 (patch) | |
tree | 6241107da319e8551b953398673f0cd405c897f9 | |
parent | e4634804cacce6fe1ec34d92786f764fcb75cb97 (diff) |
ASoC: wm8991: Verify device ID during probe()
Just in case.
Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/wm8991.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index 5fdcf788e990..dba0306c42a5 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c | |||
@@ -1335,6 +1335,7 @@ static int wm8991_i2c_probe(struct i2c_client *i2c, | |||
1335 | const struct i2c_device_id *id) | 1335 | const struct i2c_device_id *id) |
1336 | { | 1336 | { |
1337 | struct wm8991_priv *wm8991; | 1337 | struct wm8991_priv *wm8991; |
1338 | unsigned int val; | ||
1338 | int ret; | 1339 | int ret; |
1339 | 1340 | ||
1340 | wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL); | 1341 | wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL); |
@@ -1347,6 +1348,16 @@ static int wm8991_i2c_probe(struct i2c_client *i2c, | |||
1347 | 1348 | ||
1348 | i2c_set_clientdata(i2c, wm8991); | 1349 | i2c_set_clientdata(i2c, wm8991); |
1349 | 1350 | ||
1351 | ret = regmap_read(wm8991->regmap, WM8991_RESET, &val); | ||
1352 | if (ret != 0) { | ||
1353 | dev_err(&i2c->dev, "Failed to read device ID: %d\n", ret); | ||
1354 | return ret; | ||
1355 | } | ||
1356 | if (val != 0x8991) { | ||
1357 | dev_err(&i2c->dev, "Device with ID %x is not a WM8991\n", val); | ||
1358 | return -EINVAL; | ||
1359 | } | ||
1360 | |||
1350 | ret = regmap_write(wm8991->regmap, WM8991_RESET, 0); | 1361 | ret = regmap_write(wm8991->regmap, WM8991_RESET, 0); |
1351 | if (ret < 0) { | 1362 | if (ret < 0) { |
1352 | dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); | 1363 | dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); |