diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-07-28 17:31:02 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-07-28 17:31:02 -0400 |
| commit | ddb1d4ede9c8acd2e20ac99bf2b68146ae9f3553 (patch) | |
| tree | cb28782aa447fe84b4f6a3c51e9b4d65766bb1d9 | |
| parent | 655c5d8fc110a9d4f90cc831bd009936f3e8df28 (diff) | |
| parent | 96f699ad09c8b3c55cd229506a9add0047838e3e (diff) | |
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
i2c/tsl2550: Fix lux value in dark environment
| -rw-r--r-- | drivers/i2c/chips/tsl2550.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c index 1a9cc135219f..b96f3025e588 100644 --- a/drivers/i2c/chips/tsl2550.c +++ b/drivers/i2c/chips/tsl2550.c | |||
| @@ -27,7 +27,7 @@ | |||
| 27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
| 28 | 28 | ||
| 29 | #define TSL2550_DRV_NAME "tsl2550" | 29 | #define TSL2550_DRV_NAME "tsl2550" |
| 30 | #define DRIVER_VERSION "1.1.1" | 30 | #define DRIVER_VERSION "1.1.2" |
| 31 | 31 | ||
| 32 | /* | 32 | /* |
| 33 | * Defines | 33 | * Defines |
| @@ -189,13 +189,16 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1) | |||
| 189 | u8 r = 128; | 189 | u8 r = 128; |
| 190 | 190 | ||
| 191 | /* Avoid division by 0 and count 1 cannot be greater than count 0 */ | 191 | /* Avoid division by 0 and count 1 cannot be greater than count 0 */ |
| 192 | if (c0 && (c1 <= c0)) | 192 | if (c1 <= c0) |
| 193 | r = c1 * 128 / c0; | 193 | if (c0) { |
| 194 | r = c1 * 128 / c0; | ||
| 195 | |||
| 196 | /* Calculate LUX */ | ||
| 197 | lux = ((c0 - c1) * ratio_lut[r]) / 256; | ||
| 198 | } else | ||
| 199 | lux = 0; | ||
| 194 | else | 200 | else |
| 195 | return -1; | 201 | return -EAGAIN; |
| 196 | |||
| 197 | /* Calculate LUX */ | ||
| 198 | lux = ((c0 - c1) * ratio_lut[r]) / 256; | ||
| 199 | 202 | ||
| 200 | /* LUX range check */ | 203 | /* LUX range check */ |
| 201 | return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux; | 204 | return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux; |
