aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/wm831x-core.c47
-rw-r--r--include/linux/mfd/wm831x/core.h1
2 files changed, 32 insertions, 16 deletions
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
index 58f033b57efe..480abc18f9f3 100644
--- a/drivers/mfd/wm831x-core.c
+++ b/drivers/mfd/wm831x-core.c
@@ -376,6 +376,16 @@ int wm831x_auxadc_read(struct wm831x *wm831x, enum wm831x_auxadc input)
376 goto disable; 376 goto disable;
377 } 377 }
378 } 378 }
379
380 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA);
381 if (ret < 0) {
382 dev_err(wm831x->dev,
383 "Failed to read AUXADC data: %d\n", ret);
384 goto disable;
385 }
386
387 wm831x->auxadc_data = ret;
388
379 } else { 389 } else {
380 /* If we are using interrupts then wait for the 390 /* If we are using interrupts then wait for the
381 * interrupt to complete. Use an extremely long 391 * interrupt to complete. Use an extremely long
@@ -390,23 +400,18 @@ int wm831x_auxadc_read(struct wm831x *wm831x, enum wm831x_auxadc input)
390 } 400 }
391 } 401 }
392 402
393 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA); 403 src = ((wm831x->auxadc_data & WM831X_AUX_DATA_SRC_MASK)
394 if (ret < 0) { 404 >> WM831X_AUX_DATA_SRC_SHIFT) - 1;
395 dev_err(wm831x->dev, "Failed to read AUXADC data: %d\n", ret); 405
406 if (src == 14)
407 src = WM831X_AUX_CAL;
408
409 if (src != input) {
410 dev_err(wm831x->dev, "Data from source %d not %d\n",
411 src, input);
412 ret = -EINVAL;
396 } else { 413 } else {
397 src = ((ret & WM831X_AUX_DATA_SRC_MASK) 414 ret = wm831x->auxadc_data & WM831X_AUX_DATA_MASK;
398 >> WM831X_AUX_DATA_SRC_SHIFT) - 1;
399
400 if (src == 14)
401 src = WM831X_AUX_CAL;
402
403 if (src != input) {
404 dev_err(wm831x->dev, "Data from source %d not %d\n",
405 src, input);
406 ret = -EINVAL;
407 } else {
408 ret &= WM831X_AUX_DATA_MASK;
409 }
410 } 415 }
411 416
412disable: 417disable:
@@ -420,6 +425,16 @@ EXPORT_SYMBOL_GPL(wm831x_auxadc_read);
420static irqreturn_t wm831x_auxadc_irq(int irq, void *irq_data) 425static irqreturn_t wm831x_auxadc_irq(int irq, void *irq_data)
421{ 426{
422 struct wm831x *wm831x = irq_data; 427 struct wm831x *wm831x = irq_data;
428 int ret;
429
430 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA);
431 if (ret < 0) {
432 dev_err(wm831x->dev,
433 "Failed to read AUXADC data: %d\n", ret);
434 wm831x->auxadc_data = 0xffff;
435 } else {
436 wm831x->auxadc_data = ret;
437 }
423 438
424 complete(&wm831x->auxadc_done); 439 complete(&wm831x->auxadc_done);
425 440
diff --git a/include/linux/mfd/wm831x/core.h b/include/linux/mfd/wm831x/core.h
index 9564cf315276..592e4fd6ab3f 100644
--- a/include/linux/mfd/wm831x/core.h
+++ b/include/linux/mfd/wm831x/core.h
@@ -278,6 +278,7 @@ struct wm831x {
278 278
279 struct mutex auxadc_lock; 279 struct mutex auxadc_lock;
280 struct completion auxadc_done; 280 struct completion auxadc_done;
281 u16 auxadc_data;
281 282
282 /* The WM831x has a security key blocking access to certain 283 /* The WM831x has a security key blocking access to certain
283 * registers. The mutex is taken by the accessors for locking 284 * registers. The mutex is taken by the accessors for locking