Commit 4fc81bc8 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: cs53l30: 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-11-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e2bb1077
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <sound/tlv.h> #include <sound/tlv.h>
#include "cs53l30.h" #include "cs53l30.h"
#include "cirrus_legacy.h"
#define CS53L30_NUM_SUPPLIES 2 #define CS53L30_NUM_SUPPLIES 2
static const char *const cs53l30_supply_names[CS53L30_NUM_SUPPLIES] = { static const char *const cs53l30_supply_names[CS53L30_NUM_SUPPLIES] = {
...@@ -920,9 +921,8 @@ static int cs53l30_i2c_probe(struct i2c_client *client, ...@@ -920,9 +921,8 @@ static int cs53l30_i2c_probe(struct i2c_client *client,
const struct device_node *np = client->dev.of_node; const struct device_node *np = client->dev.of_node;
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct cs53l30_private *cs53l30; struct cs53l30_private *cs53l30;
unsigned int devid = 0;
unsigned int reg; unsigned int reg;
int ret = 0, i; int ret = 0, i, devid;
u8 val; u8 val;
cs53l30 = devm_kzalloc(dev, sizeof(*cs53l30), GFP_KERNEL); cs53l30 = devm_kzalloc(dev, sizeof(*cs53l30), GFP_KERNEL);
...@@ -951,7 +951,7 @@ static int cs53l30_i2c_probe(struct i2c_client *client, ...@@ -951,7 +951,7 @@ static int cs53l30_i2c_probe(struct i2c_client *client,
GPIOD_OUT_LOW); GPIOD_OUT_LOW);
if (IS_ERR(cs53l30->reset_gpio)) { if (IS_ERR(cs53l30->reset_gpio)) {
ret = PTR_ERR(cs53l30->reset_gpio); ret = PTR_ERR(cs53l30->reset_gpio);
goto error; goto error_supplies;
} }
gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); gpiod_set_value_cansleep(cs53l30->reset_gpio, 1);
...@@ -968,14 +968,12 @@ static int cs53l30_i2c_probe(struct i2c_client *client, ...@@ -968,14 +968,12 @@ static int cs53l30_i2c_probe(struct i2c_client *client,
} }
/* Initialize codec */ /* Initialize codec */
ret = regmap_read(cs53l30->regmap, CS53L30_DEVID_AB, &reg); devid = cirrus_read_device_id(cs53l30->regmap, CS53L30_DEVID_AB);
devid = reg << 12; if (devid < 0) {
ret = devid;
ret = regmap_read(cs53l30->regmap, CS53L30_DEVID_CD, &reg); dev_err(dev, "Failed to read device ID: %d\n", ret);
devid |= reg << 4; goto error;
}
ret = regmap_read(cs53l30->regmap, CS53L30_DEVID_E, &reg);
devid |= (reg & 0xF0) >> 4;
if (devid != CS53L30_DEVID) { if (devid != CS53L30_DEVID) {
ret = -ENODEV; ret = -ENODEV;
...@@ -1037,6 +1035,8 @@ static int cs53l30_i2c_probe(struct i2c_client *client, ...@@ -1037,6 +1035,8 @@ static int cs53l30_i2c_probe(struct i2c_client *client,
return 0; return 0;
error: error:
gpiod_set_value_cansleep(cs53l30->reset_gpio, 0);
error_supplies:
regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies), regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies),
cs53l30->supplies); cs53l30->supplies);
return ret; return ret;
......
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