Commit 77908dbe authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: cs35l33: Minor error paths fixups

Correct some unchecked re-allocations of ret whilst reading the device
ID and ensure the hardware state is returned to off on the error
paths.
Reported-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210510131357.17170-4-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 283160f1
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include "cs35l33.h" #include "cs35l33.h"
#include "cirrus_legacy.h"
#define CS35L33_BOOT_DELAY 50 #define CS35L33_BOOT_DELAY 50
...@@ -1190,12 +1191,12 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client, ...@@ -1190,12 +1191,12 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client,
regcache_cache_only(cs35l33->regmap, false); regcache_cache_only(cs35l33->regmap, false);
/* initialize codec */ /* initialize codec */
ret = regmap_read(cs35l33->regmap, CS35L33_DEVID_AB, &reg); devid = cirrus_read_device_id(cs35l33->regmap, CS35L33_DEVID_AB);
devid = (reg & 0xFF) << 12; if (devid < 0) {
ret = regmap_read(cs35l33->regmap, CS35L33_DEVID_CD, &reg); ret = devid;
devid |= (reg & 0xFF) << 4; dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret);
ret = regmap_read(cs35l33->regmap, CS35L33_DEVID_E, &reg); goto err_enable;
devid |= (reg & 0xF0) >> 4; }
if (devid != CS35L33_CHIP_ID) { if (devid != CS35L33_CHIP_ID) {
dev_err(&i2c_client->dev, dev_err(&i2c_client->dev,
...@@ -1242,6 +1243,8 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client, ...@@ -1242,6 +1243,8 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client,
return 0; return 0;
err_enable: err_enable:
gpiod_set_value_cansleep(cs35l33->reset_gpio, 0);
regulator_bulk_disable(cs35l33->num_core_supplies, regulator_bulk_disable(cs35l33->num_core_supplies,
cs35l33->core_supplies); cs35l33->core_supplies);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment