Skip to content

Commit a0a0591

Browse files
committed
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>
1 parent e463480 commit a0a0591

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎sound/soc/codecs/wm8991.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ static int wm8991_i2c_probe(struct i2c_client *i2c,
13351335
const struct i2c_device_id *id)
13361336
{
13371337
struct wm8991_priv *wm8991;
1338+
unsigned int val;
13381339
int ret;
13391340

13401341
wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL);
@@ -1347,6 +1348,16 @@ static int wm8991_i2c_probe(struct i2c_client *i2c,
13471348

13481349
i2c_set_clientdata(i2c, wm8991);
13491350

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+
13501361
ret = regmap_write(wm8991->regmap, WM8991_RESET, 0);
13511362
if (ret < 0) {
13521363
dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret);

0 commit comments

Comments
 (0)