Skip to content

Commit 741e987

Browse files
committed
ASoC: use 'time_left' instead of 'timeout' with
Merge series from Wolfram Sang <[email protected]>: There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_*() functions causing patterns like: timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code obvious and self explaining. This is part of a tree-wide series. The rest of the patches can be found here (some parts may still be WIP): git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/time_left Because these patches are generated, I audit them before sending. This is why I will send series step by step. Build bot is happy with these patches, though. No functional changes intended.
2 parents d98b071 + 4e1f953 commit 741e987

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

sound/soc/codecs/wm8962.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,7 +2886,7 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
28862886
{
28872887
struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
28882888
struct _fll_div fll_div;
2889-
unsigned long timeout;
2889+
unsigned long time_left;
28902890
int ret;
28912891
int fll1 = 0;
28922892

@@ -2974,14 +2974,14 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
29742974
* higher if we'll error out
29752975
*/
29762976
if (wm8962->irq)
2977-
timeout = msecs_to_jiffies(5);
2977+
time_left = msecs_to_jiffies(5);
29782978
else
2979-
timeout = msecs_to_jiffies(1);
2979+
time_left = msecs_to_jiffies(1);
29802980

2981-
timeout = wait_for_completion_timeout(&wm8962->fll_lock,
2982-
timeout);
2981+
time_left = wait_for_completion_timeout(&wm8962->fll_lock,
2982+
time_left);
29832983

2984-
if (timeout == 0 && wm8962->irq) {
2984+
if (time_left == 0 && wm8962->irq) {
29852985
dev_err(component->dev, "FLL lock timed out");
29862986
snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
29872987
WM8962_FLL_ENA, 0);

sound/soc/codecs/wm8993.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static int _wm8993_set_fll(struct snd_soc_component *component, int fll_id, int
470470
struct i2c_client *i2c = to_i2c_client(component->dev);
471471
u16 reg1, reg4, reg5;
472472
struct _fll_div fll_div;
473-
unsigned int timeout;
473+
unsigned long time_left;
474474
int ret;
475475

476476
/* Any change? */
@@ -543,19 +543,19 @@ static int _wm8993_set_fll(struct snd_soc_component *component, int fll_id, int
543543

544544
/* If we've got an interrupt wired up make sure we get it */
545545
if (i2c->irq)
546-
timeout = msecs_to_jiffies(20);
546+
time_left = msecs_to_jiffies(20);
547547
else if (Fref < 1000000)
548-
timeout = msecs_to_jiffies(3);
548+
time_left = msecs_to_jiffies(3);
549549
else
550-
timeout = msecs_to_jiffies(1);
550+
time_left = msecs_to_jiffies(1);
551551

552552
try_wait_for_completion(&wm8993->fll_lock);
553553

554554
/* Enable the FLL */
555555
snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1 | WM8993_FLL_ENA);
556556

557-
timeout = wait_for_completion_timeout(&wm8993->fll_lock, timeout);
558-
if (i2c->irq && !timeout)
557+
time_left = wait_for_completion_timeout(&wm8993->fll_lock, time_left);
558+
if (i2c->irq && !time_left)
559559
dev_warn(component->dev, "Timed out waiting for FLL\n");
560560

561561
dev_dbg(component->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout);

sound/soc/codecs/wm8994.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,
22102210
int reg_offset, ret;
22112211
struct fll_div fll;
22122212
u16 reg, clk1, aif_reg, aif_src;
2213-
unsigned long timeout;
2213+
unsigned long time_left;
22142214
bool was_enabled;
22152215
struct clk *mclk;
22162216

@@ -2403,9 +2403,9 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,
24032403
WM8994_FLL1_FRAC, reg);
24042404

24052405
if (wm8994->fll_locked_irq) {
2406-
timeout = wait_for_completion_timeout(&wm8994->fll_locked[id],
2407-
msecs_to_jiffies(10));
2408-
if (timeout == 0)
2406+
time_left = wait_for_completion_timeout(&wm8994->fll_locked[id],
2407+
msecs_to_jiffies(10));
2408+
if (time_left == 0)
24092409
dev_warn(component->dev,
24102410
"Timed out waiting for FLL lock\n");
24112411
} else {

sound/soc/codecs/wm8996.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,28 +655,28 @@ static void wait_for_dc_servo(struct snd_soc_component *component, u16 mask)
655655
struct i2c_client *i2c = to_i2c_client(component->dev);
656656
struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
657657
int ret;
658-
unsigned long timeout = 200;
658+
unsigned long time_left = 200;
659659

660660
snd_soc_component_write(component, WM8996_DC_SERVO_2, mask);
661661

662662
/* Use the interrupt if possible */
663663
do {
664664
if (i2c->irq) {
665-
timeout = wait_for_completion_timeout(&wm8996->dcs_done,
666-
msecs_to_jiffies(200));
667-
if (timeout == 0)
665+
time_left = wait_for_completion_timeout(&wm8996->dcs_done,
666+
msecs_to_jiffies(200));
667+
if (time_left == 0)
668668
dev_err(component->dev, "DC servo timed out\n");
669669

670670
} else {
671671
msleep(1);
672-
timeout--;
672+
time_left--;
673673
}
674674

675675
ret = snd_soc_component_read(component, WM8996_DC_SERVO_2);
676676
dev_dbg(component->dev, "DC servo state: %x\n", ret);
677-
} while (timeout && ret & mask);
677+
} while (time_left && ret & mask);
678678

679-
if (timeout == 0)
679+
if (time_left == 0)
680680
dev_err(component->dev, "DC servo timed out for %x\n", mask);
681681
else
682682
dev_dbg(component->dev, "DC servo complete for %x\n", mask);

0 commit comments

Comments
 (0)