aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/cs42l42.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2021-05-11 09:06:01 +0100
committerMark Brown <broonie@kernel.org>2021-05-11 09:06:01 +0100
commitb8ded8af30a9d9d8a26ac69ab15f11d9694bc773 (patch)
treee9fbb4ed94658994897dfa176e929ee604178cfc /sound/soc/codecs/cs42l42.c
parentMerge series "ASoC: cppcheck fixes of the week" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>: (diff)
parentASoC: cs53l30: Minor error paths fixups (diff)
downloadlinux-dev-b8ded8af30a9d9d8a26ac69ab15f11d9694bc773.tar.xz
linux-dev-b8ded8af30a9d9d8a26ac69ab15f11d9694bc773.zip
Merge series "Tidy up device ID reading on legacy Cirrus parts" from Charles Keepax <ckeepax@opensource.cirrus.com>:
Pierre requested I have a look at some cppcheck warnings in the cs42l42 driver, since it is reassigning the ret variable without ever checking the result. Looking a bit more broadly this happens in quite a few legacy Cirrus parts, as they all use the same process to read the ID, factor out a small helper so they can all share the same code. Whilst in there fix up a couple of other trivial error path issues as well. Thanks, Charles Charles Keepax (10): ASoC: cirrus: Add helper function for reading the device ID ASoC: cs35l32: Minor error paths fixups ASoC: cs35l33: Minor error paths fixups ASoC: cs35l34: Minor error paths fixups ASoC: cs35l35: Minor error paths fixups ASoC: cs35l35: Correct errata handling ASoC: cs42l42: Minor error paths fixups ASoC: cs42l73: Minor error paths fixups ASoC: cs43130: Minor error paths fixups ASoC: cs53l30: Minor error paths fixups sound/soc/codecs/cirrus_legacy.h | 21 +++++++++++++++++++++ sound/soc/codecs/cs35l32.c | 34 ++++++++++++++++++---------------- sound/soc/codecs/cs35l33.c | 15 +++++++++------ sound/soc/codecs/cs35l34.c | 39 ++++++++++++++++++++++----------------- sound/soc/codecs/cs35l35.c | 21 ++++++++++----------- sound/soc/codecs/cs35l35.h | 1 + sound/soc/codecs/cs42l42.c | 18 ++++++++---------- sound/soc/codecs/cs42l73.c | 30 +++++++++++++++++------------- sound/soc/codecs/cs43130.c | 31 +++++++++++++++++++------------ sound/soc/codecs/cs53l30.c | 22 +++++++++++----------- 10 files changed, 136 insertions(+), 96 deletions(-) create mode 100644 sound/soc/codecs/cirrus_legacy.h -- 2.11.0
Diffstat (limited to 'sound/soc/codecs/cs42l42.c')
-rw-r--r--sound/soc/codecs/cs42l42.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index d9f8da7a68d0..d7fb6b38fd7c 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -36,6 +36,7 @@
#include <dt-bindings/sound/cs42l42.h>
#include "cs42l42.h"
+#include "cirrus_legacy.h"
static const struct reg_default cs42l42_reg_defaults[] = {
{ CS42L42_FRZ_CTL, 0x00 },
@@ -1814,8 +1815,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,
const struct i2c_device_id *id)
{
struct cs42l42_private *cs42l42;
- int ret, i;
- unsigned int devid = 0;
+ int ret, i, devid;
unsigned int reg;
cs42l42 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l42_private),
@@ -1878,14 +1878,12 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,
"Failed to request IRQ: %d\n", ret);
/* initialize codec */
- ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_AB, &reg);
- devid = (reg & 0xFF) << 12;
-
- ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_CD, &reg);
- devid |= (reg & 0xFF) << 4;
-
- ret = regmap_read(cs42l42->regmap, CS42L42_DEVID_E, &reg);
- devid |= (reg & 0xF0) >> 4;
+ devid = cirrus_read_device_id(cs42l42->regmap, CS42L42_DEVID_AB);
+ if (devid < 0) {
+ ret = devid;
+ dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret);
+ goto err_disable;
+ }
if (devid != CS42L42_CHIP_ID) {
ret = -ENODEV;