summaryrefslogtreecommitdiff
path: root/drivers/staging/iio
diff options
context:
space:
mode:
authorBrian Masney <masneyb@onstation.org>2016-11-12 13:19:30 -0500
committerJonathan Cameron <jic23@kernel.org>2016-11-13 13:07:26 +0000
commited9125566b80af9f944fdbc69bb3720f786324cb (patch)
tree3dc09a8ad43daa614032f29a80dd0537349c980f /drivers/staging/iio
parent043c1da79472d7b030a4f7df40e2889e15c979a5 (diff)
staging: iio: tsl2583: moved code block inside else statement
The check for ch1lux > ch0lux inside tsl2583_get_lux is only valid if the ratio is not equal to zero. Move the code block inside the else statement. This does away with the need to initialize the variables to zero. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r--drivers/staging/iio/light/tsl2583.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index e11820e8c710..a319ed0a7245 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -167,8 +167,6 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
struct tsl2583_lux *p;
struct tsl2583_chip *chip = iio_priv(indio_dev);
int i, ret;
- u32 ch0lux = 0;
- u32 ch1lux = 0;
ret = i2c_smbus_read_byte_data(chip->client, TSL2583_CMD_REG);
if (ret < 0) {
@@ -242,22 +240,25 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
if (p->ratio == 0) {
lux = 0;
} else {
+ u32 ch0lux, ch1lux;
+
ch0lux = ((ch0 * p->ch0) +
(gainadj[chip->als_settings.als_gain].ch0 >> 1))
/ gainadj[chip->als_settings.als_gain].ch0;
ch1lux = ((ch1 * p->ch1) +
(gainadj[chip->als_settings.als_gain].ch1 >> 1))
/ gainadj[chip->als_settings.als_gain].ch1;
- lux = ch0lux - ch1lux;
- }
- /* note: lux is 31 bit max at this point */
- if (ch1lux > ch0lux) {
- dev_dbg(&chip->client->dev, "%s: No Data - Returning 0\n",
- __func__);
- ret = 0;
- chip->als_cur_info.lux = 0;
- goto done;
+ /* note: lux is 31 bit max at this point */
+ if (ch1lux > ch0lux) {
+ dev_dbg(&chip->client->dev, "%s: No Data - Returning 0\n",
+ __func__);
+ ret = 0;
+ chip->als_cur_info.lux = 0;
+ goto done;
+ }
+
+ lux = ch0lux - ch1lux;
}
/* adjust for active time scale */