Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1520343 > unrolled thread
| Started by | Brian Masney <masneyb@onstation.org> |
|---|---|
| First post | 2016-11-12 19:30 +0100 |
| Last post | 2016-11-13 17:20 +0100 |
| Articles | 13 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v4 00/26] staging: iio: tsl2583: move out of staging Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
[PATCH v4 14/26] staging: iio: tsl2583: updated code comment to match what the code does Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
[PATCH v4 24/26] staging: iio: tsl2583: remove unnecessary variable initialization Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
[PATCH v4 08/26] staging: iio: tsl2583: unify function and variable prefix to tsl2583_ Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
[PATCH v4 22/26] staging: iio: tsl2583: remove comment for tsl2583_probe() Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
Re: [PATCH v4 22/26] staging: iio: tsl2583: remove comment for tsl2583_probe() Jonathan Cameron <jic23@kernel.org> - 2016-11-13 13:30 +0100
[PATCH v4 21/26] staging: iio: tsl2583: clarified comment about clearing interrupts Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
[PATCH v4 10/26] staging: iio: tsl2583: fix comparison between signed and unsigned integers Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
[PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
Re: [PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store Jonathan Cameron <jic23@kernel.org> - 2016-11-13 13:00 +0100
[PATCH v4 03/26] staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
Re: [PATCH v4 03/26] staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume Jonathan Cameron <jic23@kernel.org> - 2016-11-13 13:00 +0100
Re: [PATCH v4 26/26] staging: iio: tsl2583: move out of staging Brian Masney <masneyb@onstation.org> - 2016-11-13 17:20 +0100
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 00/26] staging: iio: tsl2583: move out of staging |
| Message-ID | <sCLdT-5L4-5@gated-at.bofh.it> |
This patch set continues my work to clean up the tsl2583 driver to move
it out of staging. Some highlights include:
- Eliminated some unnecessary i2c calls to the sensor.
- Fixed issue with changes to calibscale and int_time not being set on
the chip.
- Moved from a global lux table to a per device lux table.
- Combined redundant sysfs ABI documentation.
- Made log messages clearer.
- Fixes for some return values that were not checked.
- Chip state is now represented as a boolean instead of a tristate.
- Removed unnecessary chip status checks.
- Use a unified prefix for all symbols (tsl2583_).
- Code style and formatting cleanups.
- Comment cleanups.
- Staging graduation.
I verified that the driver functions correctly using a TSL2581 hooked
up to a Raspberry Pi 2.
Changes from V3 to V4
- Fixed patch 03/28 so that it compiles properly. It was fixed later
in the old series but this needs to be corrected so that people can
use git bisect. I verified that every patch in this series compiles
when incrementally applied.
- Clarified comment on patch 14 in this series.
- Use sizeof(value[1]) instead of sizeof(unsigned int) when updating
the lux table on patch 18 of this series.
Changes from V2 to V3
- Fixed patch #09 to use "%s: <message>", __func__ consistently. Added
missing terminating "\n" to one of the log messages. Issues reported
by Joe Perches.
- Fixed issues found by Jonathan Cameron: comment cleanups, improved the
wording of two log messages, removed an unnecessary memset call,
removed unnecessary variable initialization, and multiple driver
authors can be specified with multiple calls to MODULE_AUTHOR().
- Fixed warning found by make C=1 in the per device lux table:
warning: Variable length array is used.
Changes from V1 to V2
- The first 7 patches in this series contains version 2 of the patches
7-9 that I sent out on 2016-11-03. The only change is that the patches
are split up further to make the code review easier.
Brian Masney (26):
staging: iio: tsl2583: check if chip is in a working state in
in_illuminance_calibrate_store
staging: iio: tsl2583: remove unnecessary chip status check in
taos_get_lux
staging: iio: tsl2583: remove unnecessary chip status checks in
suspend/resume
staging: iio: tsl2583: change current chip state from a tristate to a
bool
staging: iio: tsl2583: remove redundant write to the control register
in taos_probe()
staging: iio: tsl2583: remove the FSF's mailing address
staging: iio: tsl2583: cleaned up logging
staging: iio: tsl2583: unify function and variable prefix to tsl2583_
staging: iio: tsl2583: fix alignment of #define values
staging: iio: tsl2583: fix comparison between signed and unsigned
integers
staging: iio: tsl2583: change newlines to improve readability
staging: iio: tsl2583: combine sysfs documentation
staging: iio: tsl2583: fix multiline comment syntax
staging: iio: tsl2583: updated code comment to match what the code
does
staging: iio: tsl2583: moved code block inside else statement
staging: iio: tsl2583: change tsl2583_als_calibrate() to return 0 on
success
staging: iio: tsl2583: remove unnecessary parentheses
staging: iio: tsl2583: don't assume an unsigned int is 32 bits
staging: iio: tsl2583: move from a global to a per device lux table
staging: iio: tsl2583: add tsl2583 to list of supported devices in the
header
staging: iio: tsl2583: clarified comment about clearing interrupts
staging: iio: tsl2583: remove comment for tsl2583_probe()
staging: iio: tsl2583: remove unnecessary memset call
staging: iio: tsl2583: remove unnecessary variable initialization
staging: iio: tsl2583: add copyright and MODULE_AUTHOR
staging: iio: tsl2583: move out of staging
.../ABI/testing/sysfs-bus-iio-light-tsl2583 | 20 +
drivers/iio/light/Kconfig | 7 +
drivers/iio/light/Makefile | 1 +
drivers/iio/light/tsl2583.c | 913 +++++++++++++++++++++
.../light/sysfs-bus-iio-light-tsl2583 | 6 -
.../iio/Documentation/sysfs-bus-iio-light-tsl2583 | 20 -
drivers/staging/iio/light/Kconfig | 7 -
drivers/staging/iio/light/Makefile | 1 -
drivers/staging/iio/light/tsl2583.c | 896 --------------------
9 files changed, 941 insertions(+), 930 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583
create mode 100644 drivers/iio/light/tsl2583.c
delete mode 100644 drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
delete mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583
delete mode 100644 drivers/staging/iio/light/tsl2583.c
--
2.7.4
[toc] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 14/26] staging: iio: tsl2583: updated code comment to match what the code does |
| Message-ID | <sCLdU-5L4-45@gated-at.bofh.it> |
| In reply to | #1520343 |
If channel 0 does not have any data, then the code sets the lux to zero.
The corresponding comment says that the last value is returned. This
updates the comment to correctly reflect what the code does. It also
clarifies the comment about why 0 is returned.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 52a39a6..dbb7f6a 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -221,7 +221,11 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
goto return_max;
if (!ch0) {
- /* have no data, so return LAST VALUE */
+ /*
+ * The sensor appears to be in total darkness so set the
+ * calculated lux to 0 and return early to avoid a division by
+ * zero below when calculating the ratio.
+ */
ret = 0;
chip->als_cur_info.lux = 0;
goto done;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 24/26] staging: iio: tsl2583: remove unnecessary variable initialization |
| Message-ID | <sCLdV-5L4-71@gated-at.bofh.it> |
| In reply to | #1520343 |
The ret variable in tsl2583_suspend() and tsl2583_resume() was
initialized to 0. This is not necessary so this patch removes the
initialization.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 712f753..b787952 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -849,7 +849,7 @@ static int __maybe_unused tsl2583_suspend(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct tsl2583_chip *chip = iio_priv(indio_dev);
- int ret = 0;
+ int ret;
mutex_lock(&chip->als_mutex);
@@ -865,7 +865,7 @@ static int __maybe_unused tsl2583_resume(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct tsl2583_chip *chip = iio_priv(indio_dev);
- int ret = 0;
+ int ret;
mutex_lock(&chip->als_mutex);
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 08/26] staging: iio: tsl2583: unify function and variable prefix to tsl2583_ |
| Message-ID | <sCLdV-5L4-73@gated-at.bofh.it> |
| In reply to | #1520343 |
Some functions and variables were prefixed with either taos, tsl258x,
taos2583, or tsl2583. Change everything to use the tsl2583 prefix since
that is the name of the .c file. The taos_settings member inside the
taos_settings struct was renamed to als_settings.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 214 ++++++++++++++++++------------------
1 file changed, 107 insertions(+), 107 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 5d74e0c1..5a82a26 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -28,35 +28,35 @@
#include <linux/iio/sysfs.h>
/* Device Registers and Masks */
-#define TSL258X_CNTRL 0x00
-#define TSL258X_ALS_TIME 0X01
-#define TSL258X_INTERRUPT 0x02
-#define TSL258X_GAIN 0x07
-#define TSL258X_REVID 0x11
-#define TSL258X_CHIPID 0x12
-#define TSL258X_ALS_CHAN0LO 0x14
-#define TSL258X_ALS_CHAN0HI 0x15
-#define TSL258X_ALS_CHAN1LO 0x16
-#define TSL258X_ALS_CHAN1HI 0x17
-#define TSL258X_TMR_LO 0x18
-#define TSL258X_TMR_HI 0x19
+#define TSL2583_CNTRL 0x00
+#define TSL2583_ALS_TIME 0X01
+#define TSL2583_INTERRUPT 0x02
+#define TSL2583_GAIN 0x07
+#define TSL2583_REVID 0x11
+#define TSL2583_CHIPID 0x12
+#define TSL2583_ALS_CHAN0LO 0x14
+#define TSL2583_ALS_CHAN0HI 0x15
+#define TSL2583_ALS_CHAN1LO 0x16
+#define TSL2583_ALS_CHAN1HI 0x17
+#define TSL2583_TMR_LO 0x18
+#define TSL2583_TMR_HI 0x19
/* tsl2583 cmd reg masks */
-#define TSL258X_CMD_REG 0x80
-#define TSL258X_CMD_SPL_FN 0x60
-#define TSL258X_CMD_ALS_INT_CLR 0X01
+#define TSL2583_CMD_REG 0x80
+#define TSL2583_CMD_SPL_FN 0x60
+#define TSL2583_CMD_ALS_INT_CLR 0X01
/* tsl2583 cntrl reg masks */
-#define TSL258X_CNTL_ADC_ENBL 0x02
-#define TSL258X_CNTL_PWR_OFF 0x00
-#define TSL258X_CNTL_PWR_ON 0x01
+#define TSL2583_CNTL_ADC_ENBL 0x02
+#define TSL2583_CNTL_PWR_OFF 0x00
+#define TSL2583_CNTL_PWR_ON 0x01
/* tsl2583 status reg masks */
-#define TSL258X_STA_ADC_VALID 0x01
-#define TSL258X_STA_ADC_INTR 0x10
+#define TSL2583_STA_ADC_VALID 0x01
+#define TSL2583_STA_ADC_INTR 0x10
/* Lux calculation constants */
-#define TSL258X_LUX_CALC_OVER_FLOW 65535
+#define TSL2583_LUX_CALC_OVER_FLOW 65535
#define TSL2583_INTERRUPT_DISABLED 0x00
@@ -64,13 +64,13 @@
#define TSL2583_CHIP_ID_MASK 0xf0
/* Per-device data */
-struct taos_als_info {
+struct tsl2583_als_info {
u16 als_ch0;
u16 als_ch1;
u16 lux;
};
-struct taos_settings {
+struct tsl2583_settings {
int als_time;
int als_gain;
int als_gain_trim;
@@ -80,14 +80,14 @@ struct taos_settings {
struct tsl2583_chip {
struct mutex als_mutex;
struct i2c_client *client;
- struct taos_als_info als_cur_info;
- struct taos_settings taos_settings;
+ struct tsl2583_als_info als_cur_info;
+ struct tsl2583_settings als_settings;
int als_time_scale;
int als_saturation;
bool suspended;
};
-struct taos_lux {
+struct tsl2583_lux {
unsigned int ratio;
unsigned int ch0;
unsigned int ch1;
@@ -96,7 +96,7 @@ struct taos_lux {
/* This structure is intentionally large to accommodate updates via sysfs. */
/* Sized to 11 = max 10 segments + 1 termination segment */
/* Assumption is one and only one type of glass used */
-static struct taos_lux taos_device_lux[11] = {
+static struct tsl2583_lux tsl2583_device_lux[11] = {
{ 9830, 8520, 15729 },
{ 12452, 10807, 23344 },
{ 14746, 6383, 11705 },
@@ -121,25 +121,25 @@ static const struct gainadj gainadj[] = {
* Provides initial operational parameter defaults.
* These defaults may be changed through the device's sysfs files.
*/
-static void taos_defaults(struct tsl2583_chip *chip)
+static void tsl2583_defaults(struct tsl2583_chip *chip)
{
/*
* The integration time must be a multiple of 50ms and within the
* range [50, 600] ms.
*/
- chip->taos_settings.als_time = 100;
+ chip->als_settings.als_time = 100;
/*
* This is an index into the gainadj table. Assume clear glass as the
* default.
*/
- chip->taos_settings.als_gain = 0;
+ chip->als_settings.als_gain = 0;
/* Default gain trim to account for aperture effects */
- chip->taos_settings.als_gain_trim = 1000;
+ chip->als_settings.als_gain_trim = 1000;
/* Known external ALS reading used for calibration */
- chip->taos_settings.als_cal_target = 130;
+ chip->als_settings.als_cal_target = 130;
}
/*
@@ -149,26 +149,26 @@ static void taos_defaults(struct tsl2583_chip *chip)
* Time scale factor array values are adjusted based on the integration time.
* The raw values are multiplied by a scale factor, and device gain is obtained
* using gain index. Limit checks are done next, then the ratio of a multiple
- * of ch1 value, to the ch0 value, is calculated. The array taos_device_lux[]
+ * of ch1 value, to the ch0 value, is calculated. The array tsl2583_device_lux[]
* declared above is then scanned to find the first ratio value that is just
* above the ratio we just calculated. The ch0 and ch1 multiplier constants in
* the array are then used along with the time scale factor array values, to
* calculate the lux.
*/
-static int taos_get_lux(struct iio_dev *indio_dev)
+static int tsl2583_get_lux(struct iio_dev *indio_dev)
{
u16 ch0, ch1; /* separated ch0/ch1 data from device */
u32 lux; /* raw lux calculated from device data */
u64 lux64;
u32 ratio;
u8 buf[5];
- struct taos_lux *p;
+ 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, TSL258X_CMD_REG);
+ ret = i2c_smbus_read_byte_data(chip->client, TSL2583_CMD_REG);
if (ret < 0) {
dev_err(&chip->client->dev, "%s: failed to read CMD_REG register\n",
__func__);
@@ -176,7 +176,7 @@ static int taos_get_lux(struct iio_dev *indio_dev)
}
/* is data new & valid */
- if (!(ret & TSL258X_STA_ADC_INTR)) {
+ if (!(ret & TSL2583_STA_ADC_INTR)) {
dev_err(&chip->client->dev, "%s: data not valid; returning last value\n",
__func__);
ret = chip->als_cur_info.lux; /* return LAST VALUE */
@@ -184,7 +184,7 @@ static int taos_get_lux(struct iio_dev *indio_dev)
}
for (i = 0; i < 4; i++) {
- int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i);
+ int reg = TSL2583_CMD_REG | (TSL2583_ALS_CHAN0LO + i);
ret = i2c_smbus_read_byte_data(chip->client, reg);
if (ret < 0) {
@@ -200,8 +200,8 @@ static int taos_get_lux(struct iio_dev *indio_dev)
* we use the bit anyway - don't forget 0x80 - this is a command
*/
ret = i2c_smbus_write_byte(chip->client,
- (TSL258X_CMD_REG | TSL258X_CMD_SPL_FN |
- TSL258X_CMD_ALS_INT_CLR));
+ (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",
@@ -228,7 +228,7 @@ static int taos_get_lux(struct iio_dev *indio_dev)
/* calculate ratio */
ratio = (ch1 << 15) / ch0;
/* convert to unscaled lux using the pointer to the table */
- for (p = (struct taos_lux *)taos_device_lux;
+ for (p = (struct tsl2583_lux *)tsl2583_device_lux;
p->ratio != 0 && p->ratio < ratio; p++)
;
@@ -236,11 +236,11 @@ static int taos_get_lux(struct iio_dev *indio_dev)
lux = 0;
} else {
ch0lux = ((ch0 * p->ch0) +
- (gainadj[chip->taos_settings.als_gain].ch0 >> 1))
- / gainadj[chip->taos_settings.als_gain].ch0;
+ (gainadj[chip->als_settings.als_gain].ch0 >> 1))
+ / gainadj[chip->als_settings.als_gain].ch0;
ch1lux = ((ch1 * p->ch1) +
- (gainadj[chip->taos_settings.als_gain].ch1 >> 1))
- / gainadj[chip->taos_settings.als_gain].ch1;
+ (gainadj[chip->als_settings.als_gain].ch1 >> 1))
+ / gainadj[chip->als_settings.als_gain].ch1;
lux = ch0lux - ch1lux;
}
@@ -261,7 +261,7 @@ static int taos_get_lux(struct iio_dev *indio_dev)
chip->als_time_scale;
/* Adjust for active gain scale.
- * The taos_device_lux tables above have a factor of 8192 built in,
+ * The tsl2583_device_lux tables above have a factor of 8192 built in,
* so we need to shift right.
* User-specified gain provides a multiplier.
* Apply user-specified gain before shifting right to retain precision.
@@ -269,13 +269,13 @@ static int taos_get_lux(struct iio_dev *indio_dev)
* Then go back to 32 bits before division to avoid using div_u64().
*/
lux64 = lux;
- lux64 = lux64 * chip->taos_settings.als_gain_trim;
+ lux64 = lux64 * chip->als_settings.als_gain_trim;
lux64 >>= 13;
lux = lux64;
lux = (lux + 500) / 1000;
- if (lux > TSL258X_LUX_CALC_OVER_FLOW) { /* check for overflow */
+ if (lux > TSL2583_LUX_CALC_OVER_FLOW) { /* check for overflow */
return_max:
- lux = TSL258X_LUX_CALC_OVER_FLOW;
+ lux = TSL2583_LUX_CALC_OVER_FLOW;
}
/* Update the structure with the latest VALID lux. */
@@ -291,7 +291,7 @@ static int taos_get_lux(struct iio_dev *indio_dev)
* to derive actual lux).
* Return updated gain_trim value.
*/
-static int taos_als_calibrate(struct iio_dev *indio_dev)
+static int tsl2583_als_calibrate(struct iio_dev *indio_dev)
{
struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned int gain_trim_val;
@@ -299,7 +299,7 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
int lux_val;
ret = i2c_smbus_read_byte_data(chip->client,
- TSL258X_CMD_REG | TSL258X_CNTRL);
+ TSL2583_CMD_REG | TSL2583_CNTRL);
if (ret < 0) {
dev_err(&chip->client->dev,
"%s: failed to read from the CNTRL register\n",
@@ -307,26 +307,26 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
return ret;
}
- if ((ret & (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON))
- != (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) {
+ if ((ret & (TSL2583_CNTL_ADC_ENBL | TSL2583_CNTL_PWR_ON))
+ != (TSL2583_CNTL_ADC_ENBL | TSL2583_CNTL_PWR_ON)) {
dev_err(&chip->client->dev,
"%s: Device is not powered on and/or ADC is not enabled\n",
__func__);
return -EINVAL;
- } else if ((ret & TSL258X_STA_ADC_VALID) != TSL258X_STA_ADC_VALID) {
+ } else if ((ret & TSL2583_STA_ADC_VALID) != TSL2583_STA_ADC_VALID) {
dev_err(&chip->client->dev,
"%s: The two ADC channels have not completed an integration cycle\n",
__func__);
return -ENODATA;
}
- lux_val = taos_get_lux(indio_dev);
+ 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->taos_settings.als_cal_target)
- * chip->taos_settings.als_gain_trim) / 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,
@@ -334,7 +334,7 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
__func__, gain_trim_val);
return -ENODATA;
}
- chip->taos_settings.als_gain_trim = (int)gain_trim_val;
+ chip->als_settings.als_gain_trim = (int)gain_trim_val;
return (int)gain_trim_val;
}
@@ -345,7 +345,7 @@ static int tsl2583_set_als_time(struct tsl2583_chip *chip)
u8 val;
/* determine als integration register */
- als_count = (chip->taos_settings.als_time * 100 + 135) / 270;
+ als_count = (chip->als_settings.als_time * 100 + 135) / 270;
if (!als_count)
als_count = 1; /* ensure at least one cycle */
@@ -354,7 +354,7 @@ static int tsl2583_set_als_time(struct tsl2583_chip *chip)
val = 256 - als_count;
ret = i2c_smbus_write_byte_data(chip->client,
- TSL258X_CMD_REG | TSL258X_ALS_TIME,
+ TSL2583_CMD_REG | TSL2583_ALS_TIME,
val);
if (ret < 0) {
dev_err(&chip->client->dev, "%s: failed to set the als time to %d\n",
@@ -373,14 +373,14 @@ static int tsl2583_set_als_gain(struct tsl2583_chip *chip)
{
int ret;
- /* Set the gain based on taos_settings struct */
+ /* Set the gain based on als_settings struct */
ret = i2c_smbus_write_byte_data(chip->client,
- TSL258X_CMD_REG | TSL258X_GAIN,
- chip->taos_settings.als_gain);
+ TSL2583_CMD_REG | TSL2583_GAIN,
+ chip->als_settings.als_gain);
if (ret < 0)
dev_err(&chip->client->dev,
"%s: failed to set the gain to %d\n", __func__,
- chip->taos_settings.als_gain);
+ chip->als_settings.als_gain);
return ret;
}
@@ -390,7 +390,7 @@ static int tsl2583_set_power_state(struct tsl2583_chip *chip, u8 state)
int ret;
ret = i2c_smbus_write_byte_data(chip->client,
- TSL258X_CMD_REG | TSL258X_CNTRL, state);
+ TSL2583_CMD_REG | TSL2583_CNTRL, state);
if (ret < 0)
dev_err(&chip->client->dev,
"%s: failed to set the power state to %d\n", __func__,
@@ -409,12 +409,12 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev)
int ret;
/* Power on the device; ADC off. */
- ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_ON);
+ ret = tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_ON);
if (ret < 0)
return ret;
ret = i2c_smbus_write_byte_data(chip->client,
- TSL258X_CMD_REG | TSL258X_INTERRUPT,
+ TSL2583_CMD_REG | TSL2583_INTERRUPT,
TSL2583_INTERRUPT_DISABLED);
if (ret < 0) {
dev_err(&chip->client->dev,
@@ -432,8 +432,8 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev)
usleep_range(3000, 3500);
- ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_ON |
- TSL258X_CNTL_ADC_ENBL);
+ ret = tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_ON |
+ TSL2583_CNTL_ADC_ENBL);
if (ret < 0)
return ret;
@@ -453,7 +453,7 @@ static ssize_t in_illuminance_input_target_show(struct device *dev,
int ret;
mutex_lock(&chip->als_mutex);
- ret = sprintf(buf, "%d\n", chip->taos_settings.als_cal_target);
+ ret = sprintf(buf, "%d\n", chip->als_settings.als_cal_target);
mutex_unlock(&chip->als_mutex);
return ret;
@@ -471,7 +471,7 @@ static ssize_t in_illuminance_input_target_store(struct device *dev,
return -EINVAL;
mutex_lock(&chip->als_mutex);
- chip->taos_settings.als_cal_target = value;
+ chip->als_settings.als_cal_target = value;
mutex_unlock(&chip->als_mutex);
return len;
@@ -495,7 +495,7 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
goto done;
}
- ret = taos_als_calibrate(indio_dev);
+ ret = tsl2583_als_calibrate(indio_dev);
if (ret < 0)
goto done;
@@ -513,12 +513,12 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
int i;
int offset = 0;
- for (i = 0; i < ARRAY_SIZE(taos_device_lux); i++) {
+ for (i = 0; i < ARRAY_SIZE(tsl2583_device_lux); i++) {
offset += sprintf(buf + offset, "%u,%u,%u,",
- taos_device_lux[i].ratio,
- taos_device_lux[i].ch0,
- taos_device_lux[i].ch1);
- if (taos_device_lux[i].ratio == 0) {
+ tsl2583_device_lux[i].ratio,
+ tsl2583_device_lux[i].ch0,
+ tsl2583_device_lux[i].ch1);
+ if (tsl2583_device_lux[i].ratio == 0) {
/*
* We just printed the first "0" entry.
* Now get rid of the extra "," and break.
@@ -532,7 +532,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
return offset;
}
-#define TSL2583_MAX_LUX_INTS ((ARRAY_SIZE(taos_device_lux) - 1) * 3)
+#define TSL2583_MAX_LUX_INTS ((ARRAY_SIZE(tsl2583_device_lux) - 1) * 3)
static ssize_t in_illuminance_lux_table_store(struct device *dev,
struct device_attribute *attr,
@@ -540,7 +540,7 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev,
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
- int value[ARRAY_SIZE(taos_device_lux) * 3 + 1];
+ int value[ARRAY_SIZE(tsl2583_device_lux) * 3 + 1];
int n, ret = -EINVAL;
mutex_lock(&chip->als_mutex);
@@ -566,8 +566,8 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev,
}
/* Zero out the table */
- memset(taos_device_lux, 0, sizeof(taos_device_lux));
- memcpy(taos_device_lux, &value[1], (value[0] * 4));
+ memset(tsl2583_device_lux, 0, sizeof(tsl2583_device_lux));
+ memcpy(tsl2583_device_lux, &value[1], (value[0] * 4));
ret = len;
@@ -636,7 +636,7 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
if (chan->type == IIO_LIGHT) {
- ret = taos_get_lux(indio_dev);
+ ret = tsl2583_get_lux(indio_dev);
if (ret < 0)
goto read_done;
@@ -659,7 +659,7 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_PROCESSED:
if (chan->type == IIO_LIGHT) {
- ret = taos_get_lux(indio_dev);
+ ret = tsl2583_get_lux(indio_dev);
if (ret < 0)
goto read_done;
@@ -669,20 +669,20 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_CALIBBIAS:
if (chan->type == IIO_LIGHT) {
- *val = chip->taos_settings.als_gain_trim;
+ *val = chip->als_settings.als_gain_trim;
ret = IIO_VAL_INT;
}
break;
case IIO_CHAN_INFO_CALIBSCALE:
if (chan->type == IIO_LIGHT) {
- *val = gainadj[chip->taos_settings.als_gain].mean;
+ *val = gainadj[chip->als_settings.als_gain].mean;
ret = IIO_VAL_INT;
}
break;
case IIO_CHAN_INFO_INT_TIME:
if (chan->type == IIO_LIGHT) {
*val = 0;
- *val2 = chip->taos_settings.als_time;
+ *val2 = chip->als_settings.als_time;
ret = IIO_VAL_INT_PLUS_MICRO;
}
break;
@@ -713,7 +713,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_CALIBBIAS:
if (chan->type == IIO_LIGHT) {
- chip->taos_settings.als_gain_trim = val;
+ chip->als_settings.als_gain_trim = val;
ret = 0;
}
break;
@@ -723,7 +723,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
for (i = 0; i < ARRAY_SIZE(gainadj); i++) {
if (gainadj[i].mean == val) {
- chip->taos_settings.als_gain = i;
+ chip->als_settings.als_gain = i;
ret = tsl2583_set_als_gain(chip);
break;
}
@@ -733,7 +733,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_INT_TIME:
if (chan->type == IIO_LIGHT && !val && val2 >= 50 &&
val2 <= 650 && !(val2 % 50)) {
- chip->taos_settings.als_time = val2;
+ chip->als_settings.als_time = val2;
ret = tsl2583_set_als_time(chip);
}
break;
@@ -758,8 +758,8 @@ static const struct iio_info tsl2583_info = {
* Client probe function - When a valid device is found, the driver's device
* data structure is updated, and initialization completes successfully.
*/
-static int taos_probe(struct i2c_client *clientp,
- const struct i2c_device_id *idp)
+static int tsl2583_probe(struct i2c_client *clientp,
+ const struct i2c_device_id *idp)
{
int ret;
struct tsl2583_chip *chip;
@@ -783,7 +783,7 @@ static int taos_probe(struct i2c_client *clientp,
chip->suspended = true;
ret = i2c_smbus_read_byte_data(clientp,
- TSL258X_CMD_REG | TSL258X_CHIPID);
+ TSL2583_CMD_REG | TSL2583_CHIPID);
if (ret < 0) {
dev_err(&clientp->dev,
"%s: failed to read the chip ID register\n", __func__);
@@ -810,7 +810,7 @@ static int taos_probe(struct i2c_client *clientp,
}
/* Load up the V2 defaults (these are hard coded defaults for now) */
- taos_defaults(chip);
+ tsl2583_defaults(chip);
/* Make sure the chip is on */
ret = tsl2583_chip_init_and_power_on(indio_dev);
@@ -821,7 +821,7 @@ static int taos_probe(struct i2c_client *clientp,
return 0;
}
-static int __maybe_unused taos_suspend(struct device *dev)
+static int __maybe_unused tsl2583_suspend(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct tsl2583_chip *chip = iio_priv(indio_dev);
@@ -829,14 +829,14 @@ static int __maybe_unused taos_suspend(struct device *dev)
mutex_lock(&chip->als_mutex);
- ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
+ ret = tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_OFF);
chip->suspended = true;
mutex_unlock(&chip->als_mutex);
return ret;
}
-static int __maybe_unused taos_resume(struct device *dev)
+static int __maybe_unused tsl2583_resume(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct tsl2583_chip *chip = iio_priv(indio_dev);
@@ -850,35 +850,35 @@ static int __maybe_unused taos_resume(struct device *dev)
return ret;
}
-static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume);
+static SIMPLE_DEV_PM_OPS(tsl2583_pm_ops, tsl2583_suspend, tsl2583_resume);
-static struct i2c_device_id taos_idtable[] = {
+static struct i2c_device_id tsl2583_idtable[] = {
{ "tsl2580", 0 },
{ "tsl2581", 1 },
{ "tsl2583", 2 },
{}
};
-MODULE_DEVICE_TABLE(i2c, taos_idtable);
+MODULE_DEVICE_TABLE(i2c, tsl2583_idtable);
-static const struct of_device_id taos2583_of_match[] = {
+static const struct of_device_id tsl2583_of_match[] = {
{ .compatible = "amstaos,tsl2580", },
{ .compatible = "amstaos,tsl2581", },
{ .compatible = "amstaos,tsl2583", },
{ },
};
-MODULE_DEVICE_TABLE(of, taos2583_of_match);
+MODULE_DEVICE_TABLE(of, tsl2583_of_match);
/* Driver definition */
-static struct i2c_driver taos_driver = {
+static struct i2c_driver tsl2583_driver = {
.driver = {
.name = "tsl2583",
- .pm = &taos_pm_ops,
- .of_match_table = taos2583_of_match,
+ .pm = &tsl2583_pm_ops,
+ .of_match_table = tsl2583_of_match,
},
- .id_table = taos_idtable,
- .probe = taos_probe,
+ .id_table = tsl2583_idtable,
+ .probe = tsl2583_probe,
};
-module_i2c_driver(taos_driver);
+module_i2c_driver(tsl2583_driver);
MODULE_AUTHOR("J. August Brenner<jbrenner@taosinc.com>");
MODULE_DESCRIPTION("TAOS tsl2583 ambient light sensor driver");
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 22/26] staging: iio: tsl2583: remove comment for tsl2583_probe() |
| Message-ID | <sCLdV-5L4-77@gated-at.bofh.it> |
| In reply to | #1520343 |
The comment for tsl2583_probe() does not provide any useful value.
This patch removes the comment.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 727ed49..9db191f 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -782,10 +782,6 @@ static const struct iio_info tsl2583_info = {
.write_raw = tsl2583_write_raw,
};
-/*
- * Client probe function - When a valid device is found, the driver's device
- * data structure is updated, and initialization completes successfully.
- */
static int tsl2583_probe(struct i2c_client *clientp,
const struct i2c_device_id *idp)
{
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2016-11-13 13:30 +0100 |
| Subject | Re: [PATCH v4 22/26] staging: iio: tsl2583: remove comment for tsl2583_probe() |
| Message-ID | <sD254-cs-21@gated-at.bofh.it> |
| In reply to | #1520347 |
On 12/11/16 18:19, Brian Masney wrote:
> The comment for tsl2583_probe() does not provide any useful value.
> This patch removes the comment.
>
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied
> ---
> drivers/staging/iio/light/tsl2583.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index 727ed49..9db191f 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -782,10 +782,6 @@ static const struct iio_info tsl2583_info = {
> .write_raw = tsl2583_write_raw,
> };
>
> -/*
> - * Client probe function - When a valid device is found, the driver's device
> - * data structure is updated, and initialization completes successfully.
> - */
> static int tsl2583_probe(struct i2c_client *clientp,
> const struct i2c_device_id *idp)
> {
>
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 21/26] staging: iio: tsl2583: clarified comment about clearing interrupts |
| Message-ID | <sCLdV-5L4-81@gated-at.bofh.it> |
| In reply to | #1520343 |
The comment that describes the code that clears the interrupt bit was vague and didn't provide much value. This patch adds more detail about why that bit needs to be cleared. Signed-off-by: Brian Masney <masneyb@onstation.org> --- drivers/staging/iio/light/tsl2583.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 806cb0a..727ed49 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -205,8 +205,9 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) } /* - * clear status, really interrupt status (interrupts are off), but - * we use the bit anyway - don't forget 0x80 - this is a command + * Clear the pending interrupt status bit on the chip to allow the next + * integration cycle to start. This has to be done even though this + * driver currently does not support interrupts. */ ret = i2c_smbus_write_byte(chip->client, (TSL2583_CMD_REG | TSL2583_CMD_SPL_FN | -- 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 10/26] staging: iio: tsl2583: fix comparison between signed and unsigned integers |
| Message-ID | <sCLdU-5L4-53@gated-at.bofh.it> |
| In reply to | #1520343 |
Fixed warning found by make W=2:
warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index d482a84..be3cbae 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -510,7 +510,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- int i;
+ unsigned int i;
int offset = 0;
for (i = 0; i < ARRAY_SIZE(tsl2583_device_lux); i++) {
@@ -541,7 +541,8 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
int value[ARRAY_SIZE(tsl2583_device_lux) * 3 + 1];
- int n, ret = -EINVAL;
+ int ret = -EINVAL;
+ unsigned int n;
mutex_lock(&chip->als_mutex);
@@ -719,7 +720,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_CALIBSCALE:
if (chan->type == IIO_LIGHT) {
- int i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(gainadj); i++) {
if (gainadj[i].mean == val) {
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store |
| Message-ID | <sCLdV-5L4-65@gated-at.bofh.it> |
| In reply to | #1520343 |
in_illuminance_calibrate_store() did not check to see if the chip is
in a working state. This patch adds the proper check. The return value
from taos_als_calibrate() was also not checked in this function, so the
proper check was also added while changes are being made here.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 1a7be12..de54e74 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -501,16 +501,27 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
- int value;
+ int value, ret;
if (kstrtoint(buf, 0, &value) || value != 1)
return -EINVAL;
mutex_lock(&chip->als_mutex);
- taos_als_calibrate(indio_dev);
+
+ if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+ ret = -EBUSY;
+ goto done;
+ }
+
+ ret = taos_als_calibrate(indio_dev);
+ if (ret < 0)
+ goto done;
+
+ ret = len;
+done:
mutex_unlock(&chip->als_mutex);
- return len;
+ return ret;
}
static ssize_t in_illuminance_lux_table_show(struct device *dev,
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2016-11-13 13:00 +0100 |
| Subject | Re: [PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store |
| Message-ID | <sD1C2-89M-15@gated-at.bofh.it> |
| In reply to | #1520350 |
On 12/11/16 18:19, Brian Masney wrote:
> in_illuminance_calibrate_store() did not check to see if the chip is
> in a working state. This patch adds the proper check. The return value
> from taos_als_calibrate() was also not checked in this function, so the
> proper check was also added while changes are being made here.
>
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied
> ---
> drivers/staging/iio/light/tsl2583.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index 1a7be12..de54e74 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -501,16 +501,27 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
> {
> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> struct tsl2583_chip *chip = iio_priv(indio_dev);
> - int value;
> + int value, ret;
>
> if (kstrtoint(buf, 0, &value) || value != 1)
> return -EINVAL;
>
> mutex_lock(&chip->als_mutex);
> - taos_als_calibrate(indio_dev);
> +
> + if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
> + ret = -EBUSY;
> + goto done;
> + }
> +
> + ret = taos_als_calibrate(indio_dev);
> + if (ret < 0)
> + goto done;
> +
> + ret = len;
> +done:
> mutex_unlock(&chip->als_mutex);
>
> - return len;
> + return ret;
> }
>
> static ssize_t in_illuminance_lux_table_show(struct device *dev,
>
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-12 19:30 +0100 |
| Subject | [PATCH v4 03/26] staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume |
| Message-ID | <sCLdU-5L4-63@gated-at.bofh.it> |
| In reply to | #1520343 |
The device probing and the suspend/resume code checks a flag internal to
the driver that determines whether or not the chip is in a working
state. These checks are not needed. This patch removes the unnecessary
checks. It will do no harm to the hardware if the chip is
reinitialized if it is already powered on.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index a550023..40aa78e 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -412,13 +412,6 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev)
struct tsl2583_chip *chip = iio_priv(indio_dev);
int ret;
- /* and make sure we're not already on */
- if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
- /* if forcing a register update - turn off, then on */
- dev_info(&chip->client->dev, "device is already enabled\n");
- return -EINVAL;
- }
-
/* Power on the device; ADC off. */
ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_ON);
if (ret < 0)
@@ -841,10 +834,8 @@ static int __maybe_unused taos_suspend(struct device *dev)
mutex_lock(&chip->als_mutex);
- if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
- ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
- chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
- }
+ ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
+ chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
mutex_unlock(&chip->als_mutex);
return ret;
@@ -858,8 +849,7 @@ static int __maybe_unused taos_resume(struct device *dev)
mutex_lock(&chip->als_mutex);
- if (chip->taos_chip_status == TSL258X_CHIP_SUSPENDED)
- ret = tsl2583_chip_init_and_power_on(indio_dev);
+ ret = tsl2583_chip_init_and_power_on(indio_dev);
mutex_unlock(&chip->als_mutex);
return ret;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2016-11-13 13:00 +0100 |
| Subject | Re: [PATCH v4 03/26] staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume |
| Message-ID | <sD1C2-89M-23@gated-at.bofh.it> |
| In reply to | #1520352 |
On 12/11/16 18:19, Brian Masney wrote:
> The device probing and the suspend/resume code checks a flag internal to
> the driver that determines whether or not the chip is in a working
> state. These checks are not needed. This patch removes the unnecessary
> checks. It will do no harm to the hardware if the chip is
> reinitialized if it is already powered on.
>
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.
> ---
> drivers/staging/iio/light/tsl2583.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index a550023..40aa78e 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -412,13 +412,6 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev)
> struct tsl2583_chip *chip = iio_priv(indio_dev);
> int ret;
>
> - /* and make sure we're not already on */
> - if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
> - /* if forcing a register update - turn off, then on */
> - dev_info(&chip->client->dev, "device is already enabled\n");
> - return -EINVAL;
> - }
> -
> /* Power on the device; ADC off. */
> ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_ON);
> if (ret < 0)
> @@ -841,10 +834,8 @@ static int __maybe_unused taos_suspend(struct device *dev)
>
> mutex_lock(&chip->als_mutex);
>
> - if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
> - ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
> - chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
> - }
> + ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
> + chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
>
> mutex_unlock(&chip->als_mutex);
> return ret;
> @@ -858,8 +849,7 @@ static int __maybe_unused taos_resume(struct device *dev)
>
> mutex_lock(&chip->als_mutex);
>
> - if (chip->taos_chip_status == TSL258X_CHIP_SUSPENDED)
> - ret = tsl2583_chip_init_and_power_on(indio_dev);
> + ret = tsl2583_chip_init_and_power_on(indio_dev);
>
> mutex_unlock(&chip->als_mutex);
> return ret;
>
[toc] | [prev] | [next] | [standalone]
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Date | 2016-11-13 17:20 +0100 |
| Subject | Re: [PATCH v4 26/26] staging: iio: tsl2583: move out of staging |
| Message-ID | <sD5FE-2CH-13@gated-at.bofh.it> |
| In reply to | #1520343 |
On Sun, Nov 13, 2016 at 12:57:25PM +0000, Jonathan Cameron wrote: > On 12/11/16 18:19, Brian Masney wrote: > > Move tsl2580, tsl2581, tsl2583 driver out of staging into mainline. > > > > Signed-off-by: Brian Masney <masneyb@onstation.org> > I had another read through on this one. A few oddites. > > I fixed up the indentation one way back in your patch fixing alignment. > Made applying this patch more entertaining than it should have been but > I think got that right in the end. > > Can't find myself caring enough about the unused data element in that > id table to hold this patch on that so... > > Applied to the togreg branch of iio.git and pushed out as testing for > the autobuilders to play with it. > > Thanks for all your hard work on this! Thanks Jonathan for all of your feedback and working with me on this. I learned a lot cleaning up this driver. I'm going to work on the ISL29028 light driver next since I have one mounted on a breakout board. The driver appears to not need any major work so it should be easy. After that, I'm taking requests for an existing IIO staging driver to clean up. I'm looking for a driver that needs more than just style cleanups (like this driver that I just finished). Ideally, one where a company or person could loan me the sensor. I'll mail it back when I am finished. Otherwise, I'll see what I can pick up for low cost on Digikey that has an existing staging driver that meets my criteria. Brian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web