diff options
author | Tzung-Bi Shih <tzungbi@google.com> | 2020-12-24 11:06:06 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-12-29 14:18:47 +0100 |
commit | 3128f1c3b53d73e35e1069663736284358fcdd01 (patch) | |
tree | 69d0b4e102c265cee21a9af0c3ccf91416f3a68e /sound/soc/codecs/rt1015.c | |
parent | ASoC: rt1015: return error if any when setting bypass_boost (diff) | |
download | linux-3128f1c3b53d73e35e1069663736284358fcdd01.tar.xz linux-3128f1c3b53d73e35e1069663736284358fcdd01.zip |
ASoC: rt1015: refactor retry loop and rt1015_priv allocation
Refactors retry loop in flush DAC work. It is more clear to use a
for-loop here.
Uses !rt1015 to check if NULL.
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20201224100607.3006171-5-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt1015.c')
-rw-r--r-- | sound/soc/codecs/rt1015.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c index aab5c1b0ece5..cc57529ea877 100644 --- a/sound/soc/codecs/rt1015.c +++ b/sound/soc/codecs/rt1015.c @@ -550,15 +550,14 @@ static void rt1015_flush_work(struct work_struct *work) struct rt1015_priv *rt1015 = container_of(work, struct rt1015_priv, flush_work.work); struct snd_soc_component *component = rt1015->component; - unsigned int val, i = 0, count = 200; + unsigned int val, i; - while (i < count) { + for (i = 0; i < 200; ++i) { usleep_range(1000, 1500); dev_dbg(component->dev, "Flush DAC (retry:%u)\n", i); regmap_read(rt1015->regmap, RT1015_CLK_DET, &val); if (val & 0x800) break; - i++; } regmap_write(rt1015->regmap, RT1015_SYS_RST1, 0x0597); @@ -1167,9 +1166,8 @@ static int rt1015_i2c_probe(struct i2c_client *i2c, int ret; unsigned int val; - rt1015 = devm_kzalloc(&i2c->dev, sizeof(struct rt1015_priv), - GFP_KERNEL); - if (rt1015 == NULL) + rt1015 = devm_kzalloc(&i2c->dev, sizeof(*rt1015), GFP_KERNEL); + if (!rt1015) return -ENOMEM; i2c_set_clientdata(i2c, rt1015); |