Commit efe4c790 authored by Maciej Strozek's avatar Maciej Strozek Committed by Lee Jones

mfd: wm831x: Remove redundant forever while loop

Current code executes only once despite the while loop, so remove the
loop. Also msleep(1) will likely result in a larger sleep, so increase
its value for clarity while keeping the same behaviour.
Signed-off-by: default avatarMaciej Strozek <mstrozek@opensource.cirrus.com>
Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20240123154259.81258-1-mstrozek@opensource.cirrus.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 944e823d
...@@ -152,7 +152,7 @@ static irqreturn_t wm831x_auxadc_irq(int irq, void *irq_data) ...@@ -152,7 +152,7 @@ static irqreturn_t wm831x_auxadc_irq(int irq, void *irq_data)
static int wm831x_auxadc_read_polled(struct wm831x *wm831x, static int wm831x_auxadc_read_polled(struct wm831x *wm831x,
enum wm831x_auxadc input) enum wm831x_auxadc input)
{ {
int ret, src, timeout; int ret, src;
mutex_lock(&wm831x->auxadc_lock); mutex_lock(&wm831x->auxadc_lock);
...@@ -179,14 +179,10 @@ static int wm831x_auxadc_read_polled(struct wm831x *wm831x, ...@@ -179,14 +179,10 @@ static int wm831x_auxadc_read_polled(struct wm831x *wm831x,
goto disable; goto disable;
} }
/* If we're not using interrupts then poll the /* If we're not using interrupts then read the interrupt status register */
* interrupt status register */ msleep(20);
timeout = 5;
while (timeout) {
msleep(1);
ret = wm831x_reg_read(wm831x, ret = wm831x_reg_read(wm831x, WM831X_INTERRUPT_STATUS_1);
WM831X_INTERRUPT_STATUS_1);
if (ret < 0) { if (ret < 0) {
dev_err(wm831x->dev, dev_err(wm831x->dev,
"ISR 1 read failed: %d\n", ret); "ISR 1 read failed: %d\n", ret);
...@@ -195,17 +191,14 @@ static int wm831x_auxadc_read_polled(struct wm831x *wm831x, ...@@ -195,17 +191,14 @@ static int wm831x_auxadc_read_polled(struct wm831x *wm831x,
/* Did it complete? */ /* Did it complete? */
if (ret & WM831X_AUXADC_DATA_EINT) { if (ret & WM831X_AUXADC_DATA_EINT) {
wm831x_reg_write(wm831x, wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1,
WM831X_INTERRUPT_STATUS_1,
WM831X_AUXADC_DATA_EINT); WM831X_AUXADC_DATA_EINT);
break;
} else { } else {
dev_err(wm831x->dev, dev_err(wm831x->dev,
"AUXADC conversion timeout\n"); "AUXADC conversion timeout\n");
ret = -EBUSY; ret = -EBUSY;
goto disable; goto disable;
} }
}
ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA); ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA);
if (ret < 0) { if (ret < 0) {
......
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