Commit 0a0eb567 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: cs42l42: 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-8-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1a46b7b8
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <dt-bindings/sound/cs42l42.h> #include <dt-bindings/sound/cs42l42.h>
#include "cs42l42.h" #include "cs42l42.h"
#include "cirrus_legacy.h"
static const struct reg_default cs42l42_reg_defaults[] = { static const struct reg_default cs42l42_reg_defaults[] = {
{ CS42L42_FRZ_CTL, 0x00 }, { CS42L42_FRZ_CTL, 0x00 },
...@@ -1816,8 +1817,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, ...@@ -1816,8 +1817,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct cs42l42_private *cs42l42; struct cs42l42_private *cs42l42;
int ret, i; int ret, i, devid;
unsigned int devid = 0;
unsigned int reg; unsigned int reg;
cs42l42 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l42_private), cs42l42 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l42_private),
...@@ -1880,14 +1880,12 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, ...@@ -1880,14 +1880,12 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,
"Failed to request IRQ: %d\n", ret); "Failed to request IRQ: %d\n", ret);
/* initialize codec */ /* initialize codec */
ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_AB, &reg); devid = cirrus_read_device_id(cs42l42->regmap, CS42L42_DEVID_AB);
devid = (reg & 0xFF) << 12; if (devid < 0) {
ret = devid;
ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_CD, &reg); dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret);
devid |= (reg & 0xFF) << 4; goto err_disable;
}
ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_E, &reg);
devid |= (reg & 0xF0) >> 4;
if (devid != CS42L42_CHIP_ID) { if (devid != CS42L42_CHIP_ID) {
ret = -ENODEV; ret = -ENODEV;
......
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