ASoC: use 'time_left' instead of 'timeout' with
Merge series from Wolfram Sang <wsa+renesas@sang-engineering.com>: 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.
This commit is contained in:
commit
741e987d04
@ -2886,7 +2886,7 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
|
||||
{
|
||||
struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
|
||||
struct _fll_div fll_div;
|
||||
unsigned long timeout;
|
||||
unsigned long time_left;
|
||||
int ret;
|
||||
int fll1 = 0;
|
||||
|
||||
@ -2974,14 +2974,14 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
|
||||
* higher if we'll error out
|
||||
*/
|
||||
if (wm8962->irq)
|
||||
timeout = msecs_to_jiffies(5);
|
||||
time_left = msecs_to_jiffies(5);
|
||||
else
|
||||
timeout = msecs_to_jiffies(1);
|
||||
time_left = msecs_to_jiffies(1);
|
||||
|
||||
timeout = wait_for_completion_timeout(&wm8962->fll_lock,
|
||||
timeout);
|
||||
time_left = wait_for_completion_timeout(&wm8962->fll_lock,
|
||||
time_left);
|
||||
|
||||
if (timeout == 0 && wm8962->irq) {
|
||||
if (time_left == 0 && wm8962->irq) {
|
||||
dev_err(component->dev, "FLL lock timed out");
|
||||
snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
|
||||
WM8962_FLL_ENA, 0);
|
||||
|
@ -470,7 +470,7 @@ static int _wm8993_set_fll(struct snd_soc_component *component, int fll_id, int
|
||||
struct i2c_client *i2c = to_i2c_client(component->dev);
|
||||
u16 reg1, reg4, reg5;
|
||||
struct _fll_div fll_div;
|
||||
unsigned int timeout;
|
||||
unsigned long time_left;
|
||||
int ret;
|
||||
|
||||
/* Any change? */
|
||||
@ -543,19 +543,19 @@ static int _wm8993_set_fll(struct snd_soc_component *component, int fll_id, int
|
||||
|
||||
/* If we've got an interrupt wired up make sure we get it */
|
||||
if (i2c->irq)
|
||||
timeout = msecs_to_jiffies(20);
|
||||
time_left = msecs_to_jiffies(20);
|
||||
else if (Fref < 1000000)
|
||||
timeout = msecs_to_jiffies(3);
|
||||
time_left = msecs_to_jiffies(3);
|
||||
else
|
||||
timeout = msecs_to_jiffies(1);
|
||||
time_left = msecs_to_jiffies(1);
|
||||
|
||||
try_wait_for_completion(&wm8993->fll_lock);
|
||||
|
||||
/* Enable the FLL */
|
||||
snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1 | WM8993_FLL_ENA);
|
||||
|
||||
timeout = wait_for_completion_timeout(&wm8993->fll_lock, timeout);
|
||||
if (i2c->irq && !timeout)
|
||||
time_left = wait_for_completion_timeout(&wm8993->fll_lock, time_left);
|
||||
if (i2c->irq && !time_left)
|
||||
dev_warn(component->dev, "Timed out waiting for FLL\n");
|
||||
|
||||
dev_dbg(component->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout);
|
||||
|
@ -2210,7 +2210,7 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,
|
||||
int reg_offset, ret;
|
||||
struct fll_div fll;
|
||||
u16 reg, clk1, aif_reg, aif_src;
|
||||
unsigned long timeout;
|
||||
unsigned long time_left;
|
||||
bool was_enabled;
|
||||
struct clk *mclk;
|
||||
|
||||
@ -2403,9 +2403,9 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,
|
||||
WM8994_FLL1_FRAC, reg);
|
||||
|
||||
if (wm8994->fll_locked_irq) {
|
||||
timeout = wait_for_completion_timeout(&wm8994->fll_locked[id],
|
||||
msecs_to_jiffies(10));
|
||||
if (timeout == 0)
|
||||
time_left = wait_for_completion_timeout(&wm8994->fll_locked[id],
|
||||
msecs_to_jiffies(10));
|
||||
if (time_left == 0)
|
||||
dev_warn(component->dev,
|
||||
"Timed out waiting for FLL lock\n");
|
||||
} else {
|
||||
|
@ -655,28 +655,28 @@ static void wait_for_dc_servo(struct snd_soc_component *component, u16 mask)
|
||||
struct i2c_client *i2c = to_i2c_client(component->dev);
|
||||
struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
unsigned long timeout = 200;
|
||||
unsigned long time_left = 200;
|
||||
|
||||
snd_soc_component_write(component, WM8996_DC_SERVO_2, mask);
|
||||
|
||||
/* Use the interrupt if possible */
|
||||
do {
|
||||
if (i2c->irq) {
|
||||
timeout = wait_for_completion_timeout(&wm8996->dcs_done,
|
||||
msecs_to_jiffies(200));
|
||||
if (timeout == 0)
|
||||
time_left = wait_for_completion_timeout(&wm8996->dcs_done,
|
||||
msecs_to_jiffies(200));
|
||||
if (time_left == 0)
|
||||
dev_err(component->dev, "DC servo timed out\n");
|
||||
|
||||
} else {
|
||||
msleep(1);
|
||||
timeout--;
|
||||
time_left--;
|
||||
}
|
||||
|
||||
ret = snd_soc_component_read(component, WM8996_DC_SERVO_2);
|
||||
dev_dbg(component->dev, "DC servo state: %x\n", ret);
|
||||
} while (timeout && ret & mask);
|
||||
} while (time_left && ret & mask);
|
||||
|
||||
if (timeout == 0)
|
||||
if (time_left == 0)
|
||||
dev_err(component->dev, "DC servo timed out for %x\n", mask);
|
||||
else
|
||||
dev_dbg(component->dev, "DC servo complete for %x\n", mask);
|
||||
|
Loading…
x
Reference in New Issue
Block a user