Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1517064
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 13/23] staging: iio: tsl2583: change newlines to improve readability |
| Date | 2016-11-08 11:40 +0100 |
| Message-ID | <sBbYS-8bd-23@gated-at.bofh.it> (permalink) |
| References | <sBbFv-84M-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Add and remove newlines to improve code readability in preparation for
moving the driver out of staging.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 8be135b..eff59f37 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -202,7 +202,6 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
ret = i2c_smbus_write_byte(chip->client,
(TSL2583_CMD_REG | TSL2583_CMD_SPL_FN |
TSL2583_CMD_ALS_INT_CLR));
-
if (ret < 0) {
dev_err(&chip->client->dev, "%s failed to clear the interrupt bit\n",
__func__);
@@ -225,8 +224,10 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
chip->als_cur_info.lux = 0;
goto done;
}
+
/* calculate ratio */
ratio = (ch1 << 15) / ch0;
+
/* convert to unscaled lux using the pointer to the table */
for (p = (struct tsl2583_lux *)tsl2583_device_lux;
p->ratio != 0 && p->ratio < ratio; p++)
@@ -273,6 +274,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
lux64 >>= 13;
lux = lux64;
lux = (lux + 500) / 1000;
+
if (lux > TSL2583_LUX_CALC_OVER_FLOW) { /* check for overflow */
return_max:
lux = TSL2583_LUX_CALC_OVER_FLOW;
@@ -318,20 +320,22 @@ static int tsl2583_als_calibrate(struct iio_dev *indio_dev)
"%s failed: STATUS - ADC not valid.\n", __func__);
return -ENODATA;
}
+
lux_val = tsl2583_get_lux(indio_dev);
if (lux_val < 0) {
dev_err(&chip->client->dev, "%s failed to get lux\n", __func__);
return lux_val;
}
+
gain_trim_val = (unsigned int)(((chip->als_settings.als_cal_target)
* chip->als_settings.als_gain_trim) / lux_val);
-
if ((gain_trim_val < 250) || (gain_trim_val > 4000)) {
dev_err(&chip->client->dev,
"%s failed: trim_val of %d is not within the range [250, 4000]\n",
__func__, gain_trim_val);
return -ENODATA;
}
+
chip->als_settings.als_gain_trim = (int)gain_trim_val;
return (int)gain_trim_val;
@@ -525,6 +529,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
}
offset += sprintf(buf + offset, "\n");
+
return offset;
}
@@ -772,6 +777,7 @@ static int tsl2583_probe(struct i2c_client *clientp,
indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip));
if (!indio_dev)
return -ENOMEM;
+
chip = iio_priv(indio_dev);
chip->client = clientp;
i2c_set_clientdata(clientp, indio_dev);
@@ -799,6 +805,7 @@ static int tsl2583_probe(struct i2c_client *clientp,
indio_dev->dev.parent = &clientp->dev;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->name = chip->client->name;
+
ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
if (ret) {
dev_err(&clientp->dev, "%s: iio registration failed\n",
@@ -815,6 +822,7 @@ static int tsl2583_probe(struct i2c_client *clientp,
return ret;
dev_info(&clientp->dev, "Light sensor found.\n");
+
return 0;
}
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v2 00/23] staging: iio: tsl2583: move out of staging Brian Masney <masneyb@onstation.org> - 2016-11-08 11:20 +0100
[PATCH v2 02/23] staging: iio: tsl2583: fix issue with changes to calibscale and int_time not being set on the chip Brian Masney <masneyb@onstation.org> - 2016-11-08 11:20 +0100
[PATCH v2 09/23] staging: iio: tsl2583: cleaned up logging Brian Masney <masneyb@onstation.org> - 2016-11-08 11:20 +0100
Re: [PATCH v2 09/23] staging: iio: tsl2583: cleaned up logging Joe Perches <joe@perches.com> - 2016-11-08 11:30 +0100
Re: [PATCH v2 09/23] staging: iio: tsl2583: cleaned up logging Brian Masney <masneyb@onstation.org> - 2016-11-08 17:00 +0100
[PATCH v2 03/23] staging: iio: tsl2583: check if chip is suspended in in_illuminance_calibrate_store Brian Masney <masneyb@onstation.org> - 2016-11-08 11:20 +0100
[PATCH v2 15/23] staging: iio: tsl2583: fix multiline comment syntax Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 12/23] staging: iio: tsl2583: fix comparison between signed and unsigned integers Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 18/23] staging: iio: tsl2583: change tsl2583_als_calibrate() to return 0 on success Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 20/23] staging: iio: tsl2583: don't assume an unsigned int is 32 bits Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 22/23] staging: iio: tsl2583: updated copyright and MODULE_AUTHOR Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
Re: [PATCH v2 22/23] staging: iio: tsl2583: updated copyright and MODULE_AUTHOR Jonathan Cameron <jic23@kernel.org> - 2016-11-08 21:50 +0100
[PATCH v2 19/23] staging: iio: tsl2583: remove unnecessary parentheses Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 14/23] staging: iio: tsl2583: combine sysfs documentation Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 16/23] staging: iio: tsl2583: updated code comment to match what the code does Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 11/23] staging: iio: tsl2583: fix alignment of #define values Brian Masney <masneyb@onstation.org> - 2016-11-08 11:30 +0100
[PATCH v2 17/23] staging: iio: tsl2583: moved code block inside else statement Brian Masney <masneyb@onstation.org> - 2016-11-08 11:40 +0100
[PATCH v2 21/23] staging: iio: tsl2583: move from a global to a per device lux table Brian Masney <masneyb@onstation.org> - 2016-11-08 11:40 +0100
[PATCH v2 13/23] staging: iio: tsl2583: change newlines to improve readability Brian Masney <masneyb@onstation.org> - 2016-11-08 11:40 +0100
csiph-web