Skip to content

Commit

Permalink
ASoC: wm8991: Verify device ID during probe()
Browse files Browse the repository at this point in the history
Just in case.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Nov 24, 2013
1 parent e463480 commit a0a0591
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sound/soc/codecs/wm8991.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ static int wm8991_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct wm8991_priv *wm8991;
unsigned int val;
int ret;

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

i2c_set_clientdata(i2c, wm8991);

ret = regmap_read(wm8991->regmap, WM8991_RESET, &val);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to read device ID: %d\n", ret);
return ret;
}
if (val != 0x8991) {
dev_err(&i2c->dev, "Device with ID %x is not a WM8991\n", val);
return -EINVAL;
}

ret = regmap_write(wm8991->regmap, WM8991_RESET, 0);
if (ret < 0) {
dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret);
Expand Down

0 comments on commit a0a0591

Please sign in to comment.