mfd: wm831x: Remove redundant forever while loop
Subsystems (2)
PATCH v2 1/1 mfd: wm831x: Remove redundant forever while loop
Current code excutes 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.
---
V1 -> V2: removed unused variable 'timeout'
drivers/mfd/wm831x-auxadc.c | 48 +++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 26 deletions(-)
drivers/mfd/wm831x-auxadc.c +22 -26
@@ -152,7 +152,7 @@ static irqreturn_t wm831x_auxadc_irq(int irq, void *irq_data)static int wm831x_auxadc_read_polled (struct wm831x *wm831x,enum wm831x_auxadc input) { -int ret, src, timeout; +int ret, src;mutex_lock (&wm831x->auxadc_lock);
@@ -179,32 +179,28 @@ static int wm831x_auxadc_read_polled(struct wm831x *wm831x, goto disable; } -/* If we're not using interrupts then poll the -* interrupt status register */ - timeout =5 ; -while (timeout) { -msleep (1 ); - - ret =wm831x_reg_read (wm831x, -WM831X_INTERRUPT_STATUS_1 ); -if (ret <0 ) { -dev_err (wm831x->dev, -"ISR 1 read failed: %d\n" , ret); - goto disable; - } +/* If we're not using interrupts then read the +* interrupt status register +*/ +msleep (20 ); + ret =wm831x_reg_read (wm831x, +WM831X_INTERRUPT_STATUS_1 ); +if (ret <0 ) { +dev_err (wm831x->dev, +"ISR 1 read failed: %d\n" , ret); + goto disable; + } -/* Did it complete? */ -if (ret &WM831X_AUXADC_DATA_EINT ) { -wm831x_reg_write (wm831x, -WM831X_INTERRUPT_STATUS_1 , -WM831X_AUXADC_DATA_EINT ); -break ; - }else { -dev_err (wm831x->dev, -"AUXADC conversion timeout\n" ); - ret = -EBUSY ; - goto disable; - } +/* Did it complete? */ +if (ret &WM831X_AUXADC_DATA_EINT ) { +wm831x_reg_write (wm831x, +WM831X_INTERRUPT_STATUS_1 , +WM831X_AUXADC_DATA_EINT ); + }else { +dev_err (wm831x->dev, +"AUXADC conversion timeout\n" ); + ret = -EBUSY ; + goto disable; } ret =wm831x_reg_read (wm831x,WM831X_AUXADC_DATA );
--
2.34.1
Quoted 6 lines · Maciej Strozek
Current code excutes 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 Maciej Strozek <[email protected]>---
Thanks,
Charles
Lee Jones
maintainerQuoted 34 lines · Maciej Strozek
Current code excutes 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 Maciej Strozek <[email protected]>---
V1 -> V2: removed unused variable 'timeout'drivers/mfd/wm831x-auxadc.c | 48 +++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 26 deletions(-)drivers/mfd/wm831x-auxadc.c +1
-7@@ -152,7 +152,7 @@ static irqreturn_t wm831x_auxadc_irq(int irq, void *irq_data)static int wm831x_auxadc_read_polled (struct wm831x *wm831x,enum wm831x_auxadc input) { -int ret, src, timeout; +int ret, src;mutex_lock (&wm831x->auxadc_lock);@@ -179,32 +179,28 @@ static int wm831x_auxadc_read_polled(struct wm831x *wm831x, goto disable; } -/* If we're not using interrupts then poll the -* interrupt status register */ - timeout =5 ; -while (timeout) { -msleep (1 ); -
drivers/mfd/wm831x-auxadc.c static int wm831x_auxadc_read_polled(struct wm831x *wm831x, · line 184
Quoted 10 lines
drivers/mfd/wm831x-auxadc.c +3
-7- ret =wm831x_reg_read (wm831x, -WM831X_INTERRUPT_STATUS_1 ); -if (ret <0 ) { -dev_err (wm831x->dev, -"ISR 1 read failed: %d\n" , ret); - goto disable; - } +/* If we're not using interrupts then read the +* interrupt status register +*/
Can someone submit a commit to fix this comment.
drivers/mfd/wm831x-auxadc.c static int wm831x_auxadc_read_polled(struct wm831x *wm831x, · line 185
Quoted 1 line
drivers/mfd/wm831x-auxadc.c +1
-0+msleep (20 );
New line here please.
drivers/mfd/wm831x-auxadc.c static int wm831x_auxadc_read_polled(struct wm831x *wm831x, · line 187
Quoted 2 lines
drivers/mfd/wm831x-auxadc.c +2
-0+ ret =wm831x_reg_read (wm831x, +WM831X_INTERRUPT_STATUS_1 );
Odd line-up.
Quoted 13 lines
drivers/mfd/wm831x-auxadc.c +5
-7+if (ret <0 ) { +dev_err (wm831x->dev, +"ISR 1 read failed: %d\n" , ret); + goto disable; + } -/* Did it complete? */ -if (ret &WM831X_AUXADC_DATA_EINT ) { -wm831x_reg_write (wm831x, -WM831X_INTERRUPT_STATUS_1 , -WM831X_AUXADC_DATA_EINT ); -break ; - }else {
drivers/mfd/wm831x-auxadc.c static int wm831x_auxadc_read_polled(struct wm831x *wm831x, · line 198
Quoted 10 lines
drivers/mfd/wm831x-auxadc.c +5
-5-dev_err (wm831x->dev, -"AUXADC conversion timeout\n" ); - ret = -EBUSY ; - goto disable; - } +/* Did it complete? */ +if (ret &WM831X_AUXADC_DATA_EINT ) { +wm831x_reg_write (wm831x, +WM831X_INTERRUPT_STATUS_1 , +WM831X_AUXADC_DATA_EINT );
Very odd line-up.
Quoted 11 lines
drivers/mfd/wm831x-auxadc.c +5
-1+ }else { +dev_err (wm831x->dev, +"AUXADC conversion timeout\n" ); + ret = -EBUSY ; + goto disable; } ret =wm831x_reg_read (wm831x,WM831X_AUXADC_DATA ); --2.34.1
Signature · 1 line
Lee Jones [李琼斯]