Skip to content

Commit

Permalink
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/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
  • Loading branch information
Linus Torvalds committed Jul 28, 2009
2 parents 655c5d8 + 96f699a commit ddb1d4e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions drivers/i2c/chips/tsl2550.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <linux/delay.h>

#define TSL2550_DRV_NAME "tsl2550"
#define DRIVER_VERSION "1.1.1"
#define DRIVER_VERSION "1.1.2"

/*
* Defines
Expand Down Expand Up @@ -189,13 +189,16 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
u8 r = 128;

/* Avoid division by 0 and count 1 cannot be greater than count 0 */
if (c0 && (c1 <= c0))
r = c1 * 128 / c0;
if (c1 <= c0)
if (c0) {
r = c1 * 128 / c0;

/* Calculate LUX */
lux = ((c0 - c1) * ratio_lut[r]) / 256;
} else
lux = 0;
else
return -1;

/* Calculate LUX */
lux = ((c0 - c1) * ratio_lut[r]) / 256;
return -EAGAIN;

/* LUX range check */
return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux;
Expand Down

0 comments on commit ddb1d4e

Please sign in to comment.