Commit 60ba916d authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: cs35l35: 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-6-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8cb9b001
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/completion.h> #include <linux/completion.h>
#include "cs35l35.h" #include "cs35l35.h"
#include "cirrus_legacy.h"
/* /*
* Some fields take zero as a valid value so use a high bit flag that won't * Some fields take zero as a valid value so use a high bit flag that won't
...@@ -1471,9 +1472,8 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client, ...@@ -1471,9 +1472,8 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
struct cs35l35_private *cs35l35; struct cs35l35_private *cs35l35;
struct device *dev = &i2c_client->dev; struct device *dev = &i2c_client->dev;
struct cs35l35_platform_data *pdata = dev_get_platdata(dev); struct cs35l35_platform_data *pdata = dev_get_platdata(dev);
int i; int i, devid;
int ret; int ret;
unsigned int devid = 0;
unsigned int reg; unsigned int reg;
cs35l35 = devm_kzalloc(dev, sizeof(struct cs35l35_private), GFP_KERNEL); cs35l35 = devm_kzalloc(dev, sizeof(struct cs35l35_private), GFP_KERNEL);
...@@ -1552,13 +1552,12 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client, ...@@ -1552,13 +1552,12 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
goto err; goto err;
} }
/* initialize codec */ /* initialize codec */
ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_AB, &reg); devid = cirrus_read_device_id(cs35l35->regmap, CS35L35_DEVID_AB);
if (devid < 0) {
devid = (reg & 0xFF) << 12; ret = devid;
ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_CD, &reg); dev_err(dev, "Failed to read device ID: %d\n", ret);
devid |= (reg & 0xFF) << 4; goto err;
ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_E, &reg); }
devid |= (reg & 0xF0) >> 4;
if (devid != CS35L35_CHIP_ID) { if (devid != CS35L35_CHIP_ID) {
dev_err(dev, "CS35L35 Device ID (%X). Expected ID %X\n", dev_err(dev, "CS35L35 Device ID (%X). Expected ID %X\n",
......
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