Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1310991 > unrolled thread
| Started by | Alexander Koch <mail@alexanderkoch.net> |
|---|---|
| First post | 2016-01-16 17:20 +0100 |
| Last post | 2016-01-24 16:10 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 1/3] iio: light: opt3001: extract int. time constants Alexander Koch <mail@alexanderkoch.net> - 2016-01-16 17:20 +0100
Re: [PATCH v2 1/3] iio: light: opt3001: extract int. time constants Jonathan Cameron <jic23@kernel.org> - 2016-01-24 16:10 +0100
| From | Alexander Koch <mail@alexanderkoch.net> |
|---|---|
| Date | 2016-01-16 17:20 +0100 |
| Subject | [PATCH v2 1/3] iio: light: opt3001: extract int. time constants |
| Message-ID | <qRBK3-6DH-23@gated-at.bofh.it> |
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>
---
drivers/iio/light/opt3001.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
index 01e111e..aefbd79 100644
--- a/drivers/iio/light/opt3001.c
+++ b/drivers/iio/light/opt3001.c
@@ -65,6 +65,9 @@
#define OPT3001_REG_EXPONENT(n) ((n) >> 12)
#define OPT3001_REG_MANTISSA(n) ((n) & 0xfff)
+#define OPT3001_INT_TIME_LONG 800000
+#define OPT3001_INT_TIME_SHORT 100000
+
/*
* Time to wait for conversion result to be ready. The device datasheet
* 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)
reg = ret;
switch (time) {
- case 100000:
+ case OPT3001_INT_TIME_SHORT:
reg &= ~OPT3001_CONFIGURATION_CT;
- opt->int_time = 100000;
+ opt->int_time = OPT3001_INT_TIME_SHORT;
break;
- case 800000:
+ case OPT3001_INT_TIME_LONG:
reg |= OPT3001_CONFIGURATION_CT;
- opt->int_time = 800000;
+ opt->int_time = OPT3001_INT_TIME_LONG;
break;
default:
return -EINVAL;
@@ -597,9 +600,9 @@ static int opt3001_configure(struct opt3001 *opt)
/* Reflect status of the device's integration time setting */
if (reg & OPT3001_CONFIGURATION_CT)
- opt->int_time = 800000;
+ opt->int_time = OPT3001_INT_TIME_LONG;
else
- opt->int_time = 100000;
+ opt->int_time = OPT3001_INT_TIME_SHORT;
/* Ensure device is in shutdown initially */
opt3001_set_mode(opt, ®, OPT3001_CONFIGURATION_M_SHUTDOWN);
--
2.7.0
[toc] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2016-01-24 16:10 +0100 |
| Message-ID | <qUusG-6yj-19@gated-at.bofh.it> |
| In reply to | #1310991 |
On 16/01/16 16:14, Alexander Koch wrote:
> 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>
Applied to the togreg branch of iio.git - initially pushed out as testing
for the autobuilders to play with it.
> ---
> drivers/iio/light/opt3001.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
> index 01e111e..aefbd79 100644
> --- a/drivers/iio/light/opt3001.c
> +++ b/drivers/iio/light/opt3001.c
> @@ -65,6 +65,9 @@
> #define OPT3001_REG_EXPONENT(n) ((n) >> 12)
> #define OPT3001_REG_MANTISSA(n) ((n) & 0xfff)
>
> +#define OPT3001_INT_TIME_LONG 800000
> +#define OPT3001_INT_TIME_SHORT 100000
> +
> /*
> * Time to wait for conversion result to be ready. The device datasheet
> * 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)
> reg = ret;
>
> switch (time) {
> - case 100000:
> + case OPT3001_INT_TIME_SHORT:
> reg &= ~OPT3001_CONFIGURATION_CT;
> - opt->int_time = 100000;
> + opt->int_time = OPT3001_INT_TIME_SHORT;
> break;
> - case 800000:
> + case OPT3001_INT_TIME_LONG:
> reg |= OPT3001_CONFIGURATION_CT;
> - opt->int_time = 800000;
> + opt->int_time = OPT3001_INT_TIME_LONG;
> break;
> default:
> return -EINVAL;
> @@ -597,9 +600,9 @@ static int opt3001_configure(struct opt3001 *opt)
>
> /* Reflect status of the device's integration time setting */
> if (reg & OPT3001_CONFIGURATION_CT)
> - opt->int_time = 800000;
> + opt->int_time = OPT3001_INT_TIME_LONG;
> else
> - opt->int_time = 100000;
> + opt->int_time = OPT3001_INT_TIME_SHORT;
>
> /* Ensure device is in shutdown initially */
> opt3001_set_mode(opt, ®, OPT3001_CONFIGURATION_M_SHUTDOWN);
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web