aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Koch <mail@alexanderkoch.net>2016-01-16 11:14:36 -0500
committerJonathan Cameron <jic23@kernel.org>2016-01-30 11:26:12 -0500
commit564cff826fd14b8a2f71e663dec8e53b2243a836 (patch)
tree0059b1ec3628945354f941ca00e7045d285af26e
parentb6acb0cfc21293a1bfc283e9217f58f7474ef728 (diff)
iio: light: opt3001: extract int. time constants
Extract integration times as #define constants. This prepares using them for delay/timeout length determination. Signed-off-by: Alexander Koch <mail@alexanderkoch.net> Signed-off-by: Michael Hornung <mhornung.linux@gmail.com> Tested-by: Andreas Dannenberg <dannenberg@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/light/opt3001.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
index 01e111e72d4b..aefbd7989bda 100644
--- a/drivers/iio/light/opt3001.c
+++ b/drivers/iio/light/opt3001.c
@@ -65,6 +65,9 @@
65#define OPT3001_REG_EXPONENT(n) ((n) >> 12) 65#define OPT3001_REG_EXPONENT(n) ((n) >> 12)
66#define OPT3001_REG_MANTISSA(n) ((n) & 0xfff) 66#define OPT3001_REG_MANTISSA(n) ((n) & 0xfff)
67 67
68#define OPT3001_INT_TIME_LONG 800000
69#define OPT3001_INT_TIME_SHORT 100000
70
68/* 71/*
69 * Time to wait for conversion result to be ready. The device datasheet 72 * Time to wait for conversion result to be ready. The device datasheet
70 * worst-case max value is 880ms. Add some slack to be on the safe side. 73 * worst-case max value is 880ms. Add some slack to be on the safe side.
@@ -325,13 +328,13 @@ static int opt3001_set_int_time(struct opt3001 *opt, int time)
325 reg = ret; 328 reg = ret;
326 329
327 switch (time) { 330 switch (time) {
328 case 100000: 331 case OPT3001_INT_TIME_SHORT:
329 reg &= ~OPT3001_CONFIGURATION_CT; 332 reg &= ~OPT3001_CONFIGURATION_CT;
330 opt->int_time = 100000; 333 opt->int_time = OPT3001_INT_TIME_SHORT;
331 break; 334 break;
332 case 800000: 335 case OPT3001_INT_TIME_LONG:
333 reg |= OPT3001_CONFIGURATION_CT; 336 reg |= OPT3001_CONFIGURATION_CT;
334 opt->int_time = 800000; 337 opt->int_time = OPT3001_INT_TIME_LONG;
335 break; 338 break;
336 default: 339 default:
337 return -EINVAL; 340 return -EINVAL;
@@ -597,9 +600,9 @@ static int opt3001_configure(struct opt3001 *opt)
597 600
598 /* Reflect status of the device's integration time setting */ 601 /* Reflect status of the device's integration time setting */
599 if (reg & OPT3001_CONFIGURATION_CT) 602 if (reg & OPT3001_CONFIGURATION_CT)
600 opt->int_time = 800000; 603 opt->int_time = OPT3001_INT_TIME_LONG;
601 else 604 else
602 opt->int_time = 100000; 605 opt->int_time = OPT3001_INT_TIME_SHORT;
603 606
604 /* Ensure device is in shutdown initially */ 607 /* Ensure device is in shutdown initially */
605 opt3001_set_mode(opt, &reg, OPT3001_CONFIGURATION_M_SHUTDOWN); 608 opt3001_set_mode(opt, &reg, OPT3001_CONFIGURATION_M_SHUTDOWN);