linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups
@ 2017-10-19 20:06 Brian Masney
  2017-10-19 20:06 ` [PATCH 01/13] staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to iio_event_spec Brian Masney
                   ` (12 more replies)
  0 siblings, 13 replies; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

Here are some cleanup patches to work towards eventually moving this
driver out of staging. The most interesting changes are converting
in_intensity0_thresh_period and in_proximity0_thresh_period to be
created by the IIO core instead of directly by the driver. The rest of
the changes are trivial code cleanups to improve code readability
that will be required for a staging graduation:

- Convert in_proximity0_calibscale_available to IIO_CONST_ATTR
- Remove unused structures
- Sort #includes
- Remove unnecessary parentheses
- Code alignment cleanups

Brian Masney (13):
  staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to
    iio_event_spec
  staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structure
  staging: iio: tsl2x7x: sort #includes
  staging: iio: tsl2x7x: remove unnecessary struct iio_dev definition
  staging: iio: tsl2x7x: changed #defines to be aligned on the same
    column
  staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to
    use IIO_CONST_ATTR
  staging: iio: tsl2x7x: remove unnecessary parentheses
  staging: iio: tsl2x7x: correct alignment of parenthesis
  staging: iio: tsl2x7x: correct alignment of parenthesis
  staging: iio: tsl2x7x: rename power defines to improve code
    readability
  staging: iio: tsl2x7x: fix alignment of break statements
  staging: iio: tsl2x7x: put function definitions on a single line
  staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW

 drivers/staging/iio/light/tsl2x7x.c | 447 ++++++++++++++----------------------
 drivers/staging/iio/light/tsl2x7x.h |   2 -
 2 files changed, 170 insertions(+), 279 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 01/13] staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to iio_event_spec
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:31   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 02/13] staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structure Brian Masney
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The sysfs attributes in_intensity0_thresh_period and
in_proximity0_thresh_period are currently directly created by the driver.
This patch migrates the creation of these sysfs attributes from the driver
to using the IIO core via iio_event_spec.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
Changes since v1:
- Use IIO_EV_DIR_EITHER instead of IIO_EV_DIR_NONE

 drivers/staging/iio/light/tsl2x7x.c | 196 ++++++++++--------------------------
 1 file changed, 52 insertions(+), 144 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index e6a71f5fc9cb..2dd8c502fd7a 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -932,108 +932,6 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
 	return len;
 }
 
-/* persistence settings */
-static ssize_t in_intensity0_thresh_period_show(struct device *dev,
-					    struct device_attribute *attr,
-					    char *buf)
-{
-	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
-	int y, z, filter_delay;
-
-	/* Determine integration time */
-	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.als_time) + 1;
-	z = y * TSL2X7X_MIN_ITIME;
-	filter_delay = z * (chip->settings.persistence & 0x0F);
-	y = filter_delay / 1000;
-	z = filter_delay % 1000;
-
-	return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
-}
-
-static ssize_t in_intensity0_thresh_period_store(struct device *dev,
-					     struct device_attribute *attr,
-					     const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	struct tsl2x7x_parse_result result;
-	int y, z, filter_delay;
-	int ret;
-
-	ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract);
-	if (ret)
-		return ret;
-
-	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.als_time) + 1;
-	z = y * TSL2X7X_MIN_ITIME;
-
-	filter_delay =
-		DIV_ROUND_UP((result.integer * 1000) + result.fract, z);
-
-	chip->settings.persistence &= 0xF0;
-	chip->settings.persistence |= (filter_delay & 0x0F);
-
-	dev_info(&chip->client->dev, "%s: als persistence = %d",
-		 __func__, filter_delay);
-
-	ret = tsl2x7x_invoke_change(indio_dev);
-	if (ret < 0)
-		return ret;
-
-	return IIO_VAL_INT_PLUS_MICRO;
-}
-
-static ssize_t in_proximity0_thresh_period_show(struct device *dev,
-					     struct device_attribute *attr,
-					     char *buf)
-{
-	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
-	int y, z, filter_delay;
-
-	/* Determine integration time */
-	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.prx_time) + 1;
-	z = y * TSL2X7X_MIN_ITIME;
-	filter_delay = z * ((chip->settings.persistence & 0xF0) >> 4);
-	y = filter_delay / 1000;
-	z = filter_delay % 1000;
-
-	return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
-}
-
-static ssize_t in_proximity0_thresh_period_store(struct device *dev,
-					      struct device_attribute *attr,
-					      const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	struct tsl2x7x_parse_result result;
-	int y, z, filter_delay;
-	int ret;
-
-	ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract);
-	if (ret)
-		return ret;
-
-	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.prx_time) + 1;
-	z = y * TSL2X7X_MIN_ITIME;
-
-	filter_delay =
-		DIV_ROUND_UP((result.integer * 1000) + result.fract, z);
-
-	chip->settings.persistence &= 0x0F;
-	chip->settings.persistence |= ((filter_delay << 4) & 0xF0);
-
-	dev_info(&chip->client->dev, "%s: prox persistence = %d",
-		 __func__, filter_delay);
-
-	ret = tsl2x7x_invoke_change(indio_dev);
-	if (ret < 0)
-		return ret;
-
-
-	return IIO_VAL_INT_PLUS_MICRO;
-}
-
 static ssize_t in_illuminance0_calibrate_store(struct device *dev,
 				    struct device_attribute *attr,
 				    const char *buf, size_t len)
@@ -1198,7 +1096,8 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
 				     int val, int val2)
 {
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret = -EINVAL;
+	int ret = -EINVAL, y, z, filter_delay;
+	u8 time;
 
 	switch (info) {
 	case IIO_EV_INFO_VALUE:
@@ -1230,6 +1129,33 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
 			}
 		}
 		break;
+	case IIO_EV_INFO_PERIOD:
+		if (chan->type == IIO_INTENSITY)
+			time = chip->settings.als_time;
+		else
+			time = chip->settings.prx_time;
+
+		y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
+		z = y * TSL2X7X_MIN_ITIME;
+
+		filter_delay = DIV_ROUND_UP((val * 1000) + val2, z);
+
+		if (chan->type == IIO_INTENSITY) {
+			chip->settings.persistence &= 0xF0;
+			chip->settings.persistence |=
+				(filter_delay & 0x0F);
+			dev_info(&chip->client->dev, "%s: ALS persistence = %d",
+				 __func__, filter_delay);
+		} else {
+			chip->settings.persistence &= 0x0F;
+			chip->settings.persistence |=
+				((filter_delay << 4) & 0xF0);
+			dev_info(&chip->client->dev,
+				 "%s: Proximity persistence = %d",
+				 __func__, filter_delay);
+		}
+		ret = 0;
+		break;
 	default:
 		break;
 	}
@@ -1248,7 +1174,8 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
 				    int *val, int *val2)
 {
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret = -EINVAL;
+	int ret = -EINVAL, filter_delay, mult;
+	u8 time;
 
 	switch (info) {
 	case IIO_EV_INFO_VALUE:
@@ -1280,6 +1207,23 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
 			}
 		}
 		break;
+	case IIO_EV_INFO_PERIOD:
+		if (chan->type == IIO_INTENSITY) {
+			time = chip->settings.als_time;
+			mult = chip->settings.persistence & 0x0F;
+		} else {
+			time = chip->settings.prx_time;
+			mult = (chip->settings.persistence & 0xF0) >> 4;
+		}
+
+		/* Determine integration time */
+		*val = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
+		*val2 = *val * TSL2X7X_MIN_ITIME;
+		filter_delay = *val2 * mult;
+		*val = filter_delay / 1000;
+		*val2 = filter_delay % 1000;
+		ret = IIO_VAL_INT_PLUS_MICRO;
+		break;
 	default:
 		break;
 	}
@@ -1444,10 +1388,6 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
 
 static DEVICE_ATTR_RW(in_illuminance0_lux_table);
 
-static DEVICE_ATTR_RW(in_intensity0_thresh_period);
-
-static DEVICE_ATTR_RW(in_proximity0_thresh_period);
-
 /* Use the default register values to identify the Taos device */
 static int tsl2x7x_device_id(int *id, int target)
 {
@@ -1554,22 +1494,6 @@ static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
 	NULL
 };
 
-static struct attribute *tsl2X7X_ALS_event_attrs[] = {
-	&dev_attr_in_intensity0_thresh_period.attr,
-	NULL,
-};
-
-static struct attribute *tsl2X7X_PRX_event_attrs[] = {
-	&dev_attr_in_proximity0_thresh_period.attr,
-	NULL,
-};
-
-static struct attribute *tsl2X7X_ALSPRX_event_attrs[] = {
-	&dev_attr_in_intensity0_thresh_period.attr,
-	&dev_attr_in_proximity0_thresh_period.attr,
-	NULL,
-};
-
 static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
 	[ALS] = {
 		.attrs = tsl2x7x_ALS_device_attrs,
@@ -1588,25 +1512,9 @@ static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
 	},
 };
 
-static const struct attribute_group tsl2X7X_event_attr_group_tbl[] = {
-	[ALS] = {
-		.attrs = tsl2X7X_ALS_event_attrs,
-		.name = "events",
-	},
-	[PRX] = {
-		.attrs = tsl2X7X_PRX_event_attrs,
-		.name = "events",
-	},
-	[ALSPRX] = {
-		.attrs = tsl2X7X_ALSPRX_event_attrs,
-		.name = "events",
-	},
-};
-
 static const struct iio_info tsl2X7X_device_info[] = {
 	[ALS] = {
 		.attrs = &tsl2X7X_device_attr_group_tbl[ALS],
-		.event_attrs = &tsl2X7X_event_attr_group_tbl[ALS],
 		.read_raw = &tsl2x7x_read_raw,
 		.write_raw = &tsl2x7x_write_raw,
 		.read_event_value = &tsl2x7x_read_event_value,
@@ -1616,7 +1524,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
 	},
 	[PRX] = {
 		.attrs = &tsl2X7X_device_attr_group_tbl[PRX],
-		.event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
 		.read_raw = &tsl2x7x_read_raw,
 		.write_raw = &tsl2x7x_write_raw,
 		.read_event_value = &tsl2x7x_read_event_value,
@@ -1626,7 +1533,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
 	},
 	[ALSPRX] = {
 		.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX],
-		.event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
 		.read_raw = &tsl2x7x_read_raw,
 		.write_raw = &tsl2x7x_write_raw,
 		.read_event_value = &tsl2x7x_read_event_value,
@@ -1636,7 +1542,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
 	},
 	[PRX2] = {
 		.attrs = &tsl2X7X_device_attr_group_tbl[PRX2],
-		.event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
 		.read_raw = &tsl2x7x_read_raw,
 		.write_raw = &tsl2x7x_write_raw,
 		.read_event_value = &tsl2x7x_read_event_value,
@@ -1646,7 +1551,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
 	},
 	[ALSPRX2] = {
 		.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2],
-		.event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
 		.read_raw = &tsl2x7x_read_raw,
 		.write_raw = &tsl2x7x_write_raw,
 		.read_event_value = &tsl2x7x_read_event_value,
@@ -1667,6 +1571,10 @@ static const struct iio_event_spec tsl2x7x_events[] = {
 		.dir = IIO_EV_DIR_FALLING,
 		.mask_separate = BIT(IIO_EV_INFO_VALUE) |
 			BIT(IIO_EV_INFO_ENABLE),
+	}, {
+		.type = IIO_EV_TYPE_THRESH,
+		.dir = IIO_EV_DIR_EITHER,
+		.mask_separate = BIT(IIO_EV_INFO_PERIOD),
 	},
 };
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 02/13] staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structure
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
  2017-10-19 20:06 ` [PATCH 01/13] staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to iio_event_spec Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:32   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 03/13] staging: iio: tsl2x7x: sort #includes Brian Masney
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The structure tsl2x7x_parse_result is not used so this patch removes its
definition.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 2dd8c502fd7a..094ab76b5d60 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -142,11 +142,6 @@ enum {
 	TSL2X7X_CHIP_SUSPENDED = 2
 };
 
-struct tsl2x7x_parse_result {
-	int integer;
-	int fract;
-};
-
 /* Per-device data */
 struct tsl2x7x_als_info {
 	u16 als_ch0;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 03/13] staging: iio: tsl2x7x: sort #includes
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
  2017-10-19 20:06 ` [PATCH 01/13] staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to iio_event_spec Brian Masney
  2017-10-19 20:06 ` [PATCH 02/13] staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structure Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:34   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 04/13] staging: iio: tsl2x7x: remove unnecessary struct iio_dev definition Brian Masney
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

Sort the #include statements for increased code readability.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 094ab76b5d60..d407c3ad7e2f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -15,14 +15,14 @@
  * more details.
  */
 
-#include <linux/kernel.h>
-#include <linux/i2c.h>
-#include <linux/errno.h>
 #include <linux/delay.h>
-#include <linux/mutex.h>
+#include <linux/errno.h>
+#include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/iio/events.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 04/13] staging: iio: tsl2x7x: remove unnecessary struct iio_dev definition
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (2 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 03/13] staging: iio: tsl2x7x: sort #includes Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:34   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 05/13] staging: iio: tsl2x7x: changed #defines to be aligned on the same column Brian Masney
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

tsl2x7x.h has a blank definition for 'struct iio_dev' that is not
needed. This patch removes that definition.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index a216c6943a84..df00f2ec1719 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -23,8 +23,6 @@
 #define __TSL2X7X_H
 #include <linux/pm.h>
 
-struct iio_dev;
-
 struct tsl2x7x_lux {
 	unsigned int ratio;
 	unsigned int ch0;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 05/13] staging: iio: tsl2x7x: changed #defines to be aligned on the same column
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (3 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 04/13] staging: iio: tsl2x7x: remove unnecessary struct iio_dev definition Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:35   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 06/13] staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to use IIO_CONST_ATTR Brian Masney
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

Some of the existing #defines have tabs between the name, and the value,
while others have spaces. The alignment of the values mostly has a
consistent layout, but there are some that don't. Change all of the
defines so that the name and value is separated by tabs and all of the
values start on the same column to increase code readability. This patch
also removes the unnecessary parentheses around the value of
TSL2X7X_MAX_TIMER_CNT.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 132 ++++++++++++++++++------------------
 1 file changed, 66 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index d407c3ad7e2f..3a3340aadc1a 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -29,98 +29,98 @@
 #include "tsl2x7x.h"
 
 /* Cal defs*/
-#define PROX_STAT_CAL        0
-#define PROX_STAT_SAMP       1
-#define MAX_SAMPLES_CAL      200
+#define PROX_STAT_CAL			0
+#define PROX_STAT_SAMP			1
+#define MAX_SAMPLES_CAL			200
 
 /* TSL2X7X Device ID */
-#define TRITON_ID    0x00
-#define SWORDFISH_ID 0x30
-#define HALIBUT_ID   0x20
+#define TRITON_ID			0x00
+#define SWORDFISH_ID			0x30
+#define HALIBUT_ID			0x20
 
 /* Lux calculation constants */
-#define TSL2X7X_LUX_CALC_OVER_FLOW     65535
+#define TSL2X7X_LUX_CALC_OVER_FLOW	65535
 
 /* TAOS Register definitions - note:
  * depending on device, some of these register are not used and the
  * register address is benign.
  */
 /* 2X7X register offsets */
-#define TSL2X7X_MAX_CONFIG_REG         16
+#define TSL2X7X_MAX_CONFIG_REG		16
 
 /* Device Registers and Masks */
-#define TSL2X7X_CNTRL                  0x00
-#define TSL2X7X_ALS_TIME               0X01
-#define TSL2X7X_PRX_TIME               0x02
-#define TSL2X7X_WAIT_TIME              0x03
-#define TSL2X7X_ALS_MINTHRESHLO        0X04
-#define TSL2X7X_ALS_MINTHRESHHI        0X05
-#define TSL2X7X_ALS_MAXTHRESHLO        0X06
-#define TSL2X7X_ALS_MAXTHRESHHI        0X07
-#define TSL2X7X_PRX_MINTHRESHLO        0X08
-#define TSL2X7X_PRX_MINTHRESHHI        0X09
-#define TSL2X7X_PRX_MAXTHRESHLO        0X0A
-#define TSL2X7X_PRX_MAXTHRESHHI        0X0B
-#define TSL2X7X_PERSISTENCE            0x0C
-#define TSL2X7X_PRX_CONFIG             0x0D
-#define TSL2X7X_PRX_COUNT              0x0E
-#define TSL2X7X_GAIN                   0x0F
-#define TSL2X7X_NOTUSED                0x10
-#define TSL2X7X_REVID                  0x11
-#define TSL2X7X_CHIPID                 0x12
-#define TSL2X7X_STATUS                 0x13
-#define TSL2X7X_ALS_CHAN0LO            0x14
-#define TSL2X7X_ALS_CHAN0HI            0x15
-#define TSL2X7X_ALS_CHAN1LO            0x16
-#define TSL2X7X_ALS_CHAN1HI            0x17
-#define TSL2X7X_PRX_LO                 0x18
-#define TSL2X7X_PRX_HI                 0x19
+#define TSL2X7X_CNTRL			0x00
+#define TSL2X7X_ALS_TIME		0X01
+#define TSL2X7X_PRX_TIME		0x02
+#define TSL2X7X_WAIT_TIME		0x03
+#define TSL2X7X_ALS_MINTHRESHLO		0X04
+#define TSL2X7X_ALS_MINTHRESHHI		0X05
+#define TSL2X7X_ALS_MAXTHRESHLO		0X06
+#define TSL2X7X_ALS_MAXTHRESHHI		0X07
+#define TSL2X7X_PRX_MINTHRESHLO		0X08
+#define TSL2X7X_PRX_MINTHRESHHI		0X09
+#define TSL2X7X_PRX_MAXTHRESHLO		0X0A
+#define TSL2X7X_PRX_MAXTHRESHHI		0X0B
+#define TSL2X7X_PERSISTENCE		0x0C
+#define TSL2X7X_PRX_CONFIG		0x0D
+#define TSL2X7X_PRX_COUNT		0x0E
+#define TSL2X7X_GAIN			0x0F
+#define TSL2X7X_NOTUSED			0x10
+#define TSL2X7X_REVID			0x11
+#define TSL2X7X_CHIPID			0x12
+#define TSL2X7X_STATUS			0x13
+#define TSL2X7X_ALS_CHAN0LO		0x14
+#define TSL2X7X_ALS_CHAN0HI		0x15
+#define TSL2X7X_ALS_CHAN1LO		0x16
+#define TSL2X7X_ALS_CHAN1HI		0x17
+#define TSL2X7X_PRX_LO			0x18
+#define TSL2X7X_PRX_HI			0x19
 
 /* tsl2X7X cmd reg masks */
-#define TSL2X7X_CMD_REG                0x80
-#define TSL2X7X_CMD_SPL_FN             0x60
+#define TSL2X7X_CMD_REG			0x80
+#define TSL2X7X_CMD_SPL_FN		0x60
 
-#define TSL2X7X_CMD_PROX_INT_CLR       0X05
-#define TSL2X7X_CMD_ALS_INT_CLR        0x06
-#define TSL2X7X_CMD_PROXALS_INT_CLR    0X07
+#define TSL2X7X_CMD_PROX_INT_CLR	0X05
+#define TSL2X7X_CMD_ALS_INT_CLR		0x06
+#define TSL2X7X_CMD_PROXALS_INT_CLR	0X07
 
 /* tsl2X7X cntrl reg masks */
-#define TSL2X7X_CNTL_ADC_ENBL          0x02
-#define TSL2X7X_CNTL_PWR_ON            0x01
+#define TSL2X7X_CNTL_ADC_ENBL		0x02
+#define TSL2X7X_CNTL_PWR_ON		0x01
 
 /* tsl2X7X status reg masks */
-#define TSL2X7X_STA_ADC_VALID          0x01
-#define TSL2X7X_STA_PRX_VALID          0x02
-#define TSL2X7X_STA_ADC_PRX_VALID      (TSL2X7X_STA_ADC_VALID |\
-					TSL2X7X_STA_PRX_VALID)
-#define TSL2X7X_STA_ALS_INTR           0x10
-#define TSL2X7X_STA_PRX_INTR           0x20
+#define TSL2X7X_STA_ADC_VALID		0x01
+#define TSL2X7X_STA_PRX_VALID		0x02
+#define TSL2X7X_STA_ADC_PRX_VALID	(TSL2X7X_STA_ADC_VALID | \
+					 TSL2X7X_STA_PRX_VALID)
+#define TSL2X7X_STA_ALS_INTR		0x10
+#define TSL2X7X_STA_PRX_INTR		0x20
 
 /* tsl2X7X cntrl reg masks */
-#define TSL2X7X_CNTL_REG_CLEAR         0x00
-#define TSL2X7X_CNTL_PROX_INT_ENBL     0X20
-#define TSL2X7X_CNTL_ALS_INT_ENBL      0X10
-#define TSL2X7X_CNTL_WAIT_TMR_ENBL     0X08
-#define TSL2X7X_CNTL_PROX_DET_ENBL     0X04
-#define TSL2X7X_CNTL_PWRON             0x01
-#define TSL2X7X_CNTL_ALSPON_ENBL       0x03
-#define TSL2X7X_CNTL_INTALSPON_ENBL    0x13
-#define TSL2X7X_CNTL_PROXPON_ENBL      0x0F
-#define TSL2X7X_CNTL_INTPROXPON_ENBL   0x2F
+#define TSL2X7X_CNTL_REG_CLEAR		0x00
+#define TSL2X7X_CNTL_PROX_INT_ENBL	0X20
+#define TSL2X7X_CNTL_ALS_INT_ENBL	0X10
+#define TSL2X7X_CNTL_WAIT_TMR_ENBL	0X08
+#define TSL2X7X_CNTL_PROX_DET_ENBL	0X04
+#define TSL2X7X_CNTL_PWRON		0x01
+#define TSL2X7X_CNTL_ALSPON_ENBL	0x03
+#define TSL2X7X_CNTL_INTALSPON_ENBL	0x13
+#define TSL2X7X_CNTL_PROXPON_ENBL	0x0F
+#define TSL2X7X_CNTL_INTPROXPON_ENBL	0x2F
 
 /*Prox diode to use */
-#define TSL2X7X_DIODE0                 0x10
-#define TSL2X7X_DIODE1                 0x20
-#define TSL2X7X_DIODE_BOTH             0x30
+#define TSL2X7X_DIODE0			0x10
+#define TSL2X7X_DIODE1			0x20
+#define TSL2X7X_DIODE_BOTH		0x30
 
 /* LED Power */
-#define TSL2X7X_mA100                  0x00
-#define TSL2X7X_mA50                   0x40
-#define TSL2X7X_mA25                   0x80
-#define TSL2X7X_mA13                   0xD0
-#define TSL2X7X_MAX_TIMER_CNT          (0xFF)
+#define TSL2X7X_mA100			0x00
+#define TSL2X7X_mA50			0x40
+#define TSL2X7X_mA25			0x80
+#define TSL2X7X_mA13			0xD0
+#define TSL2X7X_MAX_TIMER_CNT		0xFF
 
-#define TSL2X7X_MIN_ITIME 3
+#define TSL2X7X_MIN_ITIME		3
 
 /* TAOS txx2x7x Device family members */
 enum {
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 06/13] staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to use IIO_CONST_ATTR
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (4 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 05/13] staging: iio: tsl2x7x: changed #defines to be aligned on the same column Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:36   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 07/13] staging: iio: tsl2x7x: remove unnecessary parentheses Brian Masney
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The sysfs attribute in_proximity0_calibscale_available is currently
created by using DEVICE_ATTR_RO(). Convert this over to use
IIO_CONST_ATTR().

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 3a3340aadc1a..80968dd456a0 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -886,12 +886,7 @@ static ssize_t in_illuminance0_calibscale_available_show(struct device *dev,
 	return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
 }
 
-static ssize_t in_proximity0_calibscale_available_show(struct device *dev,
-						struct device_attribute *attr,
-						char *buf)
-{
-		return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8");
-}
+static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
 
 static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
 		".00272 - .696");
@@ -1371,8 +1366,6 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
 	return tsl2x7x_invoke_change(indio_dev);
 }
 
-static DEVICE_ATTR_RO(in_proximity0_calibscale_available);
-
 static DEVICE_ATTR_RO(in_illuminance0_calibscale_available);
 
 static DEVICE_ATTR_RW(in_illuminance0_target_input);
@@ -1468,13 +1461,13 @@ static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
 	&dev_attr_in_illuminance0_target_input.attr,
 	&dev_attr_in_illuminance0_calibrate.attr,
 	&dev_attr_in_illuminance0_lux_table.attr,
-	&dev_attr_in_proximity0_calibrate.attr,
+	&iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
 	NULL
 };
 
 static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
 	&dev_attr_in_proximity0_calibrate.attr,
-	&dev_attr_in_proximity0_calibscale_available.attr,
+	&iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
 	NULL
 };
 
@@ -1485,7 +1478,7 @@ static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
 	&dev_attr_in_illuminance0_calibrate.attr,
 	&dev_attr_in_illuminance0_lux_table.attr,
 	&dev_attr_in_proximity0_calibrate.attr,
-	&dev_attr_in_proximity0_calibscale_available.attr,
+	&iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
 	NULL
 };
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 07/13] staging: iio: tsl2x7x: remove unnecessary parentheses
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (5 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 06/13] staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to use IIO_CONST_ATTR Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:38   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 08/13] staging: iio: tsl2x7x: correct alignment of parenthesis Brian Masney
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

This patch fixes the error 'Unnecessary parentheses around 'XXX' from
checkpatch.pl. It also fixes several other places with unnecessary
parentheses that checkpatch.pl did not detect.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 80968dd456a0..6cc89cd6505e 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -348,9 +348,9 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 
 	/* clear any existing interrupt status */
 	ret = i2c_smbus_write_byte(chip->client,
-				   (TSL2X7X_CMD_REG |
+				   TSL2X7X_CMD_REG |
 				   TSL2X7X_CMD_SPL_FN |
-				   TSL2X7X_CMD_ALS_INT_CLR));
+				   TSL2X7X_CMD_ALS_INT_CLR);
 	if (ret < 0) {
 		dev_err(&chip->client->dev,
 			"i2c_write_command failed - err = %d\n", ret);
@@ -364,7 +364,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	chip->als_cur_info.als_ch0 = ch0;
 	chip->als_cur_info.als_ch1 = ch1;
 
-	if ((ch0 >= chip->als_saturation) || (ch1 >= chip->als_saturation)) {
+	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) {
 		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
 		goto return_max;
 	}
@@ -697,14 +697,14 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 		dev_info(&chip->client->dev, "Setting Up Interrupt(s)\n");
 
 		reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL;
-		if ((chip->settings.interrupts_en == 0x20) ||
-		    (chip->settings.interrupts_en == 0x30))
+		if (chip->settings.interrupts_en == 0x20 ||
+		    chip->settings.interrupts_en == 0x30)
 			reg_val |= TSL2X7X_CNTL_PROX_DET_ENBL;
 
 		reg_val |= chip->settings.interrupts_en;
 		ret = i2c_smbus_write_byte_data(chip->client,
-						(TSL2X7X_CMD_REG |
-						TSL2X7X_CNTRL), reg_val);
+						TSL2X7X_CMD_REG | TSL2X7X_CNTRL,
+						reg_val);
 		if (ret < 0)
 			dev_err(&chip->client->dev,
 				"%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
@@ -1721,7 +1721,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 		return -EINVAL;
 	}
 
-	ret = i2c_smbus_write_byte(clientp, (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
+	ret = i2c_smbus_write_byte(clientp, TSL2X7X_CMD_REG | TSL2X7X_CNTRL);
 	if (ret < 0) {
 		dev_err(&clientp->dev, "write to cmd reg failed. err = %d\n",
 			ret);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 08/13] staging: iio: tsl2x7x: correct alignment of parenthesis
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (6 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 07/13] staging: iio: tsl2x7x: remove unnecessary parentheses Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:40   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 09/13] " Brian Masney
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

Correct error from checkpatch.pl to improve code readibility: Alignment
should match open parenthesis. This involved shortening the name of
tsl2x7x_als_gainadj and tsl2x7x_prx_gainadj to tsl2x7x_als_gain and
tsl2x7x_prx_gain respectively. This also required removing the
ch0lux and ch1lux local variables in order to get the line short
enough.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 6cc89cd6505e..886be9aa3c0f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -243,14 +243,14 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = {
 	.prox_pulse_count = 8
 };
 
-static const s16 tsl2X7X_als_gainadj[] = {
+static const s16 tsl2x7x_als_gain[] = {
 	1,
 	8,
 	16,
 	120
 };
 
-static const s16 tsl2X7X_prx_gainadj[] = {
+static const s16 tsl2x7x_prx_gain[] = {
 	1,
 	2,
 	4,
@@ -384,11 +384,10 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	if (p->ratio == 0) {
 		lux = 0;
 	} else {
-		ch0lux = DIV_ROUND_UP(ch0 * p->ch0,
-			tsl2X7X_als_gainadj[chip->settings.als_gain]);
-		ch1lux = DIV_ROUND_UP(ch1 * p->ch1,
-			tsl2X7X_als_gainadj[chip->settings.als_gain]);
-		lux = ch0lux - ch1lux;
+		lux = DIV_ROUND_UP(ch0 * p->ch0,
+				   tsl2x7x_als_gain[chip->settings.als_gain]) -
+		      DIV_ROUND_UP(ch1 * p->ch1,
+				   tsl2x7x_als_gain[chip->settings.als_gain]);
 	}
 
 	/* note: lux is 31 bit max at this point */
@@ -1263,9 +1262,9 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
 		break;
 	case IIO_CHAN_INFO_CALIBSCALE:
 		if (chan->type == IIO_LIGHT)
-			*val = tsl2X7X_als_gainadj[chip->settings.als_gain];
+			*val = tsl2x7x_als_gain[chip->settings.als_gain];
 		else
-			*val = tsl2X7X_prx_gainadj[chip->settings.prox_gain];
+			*val = tsl2x7x_prx_gain[chip->settings.prox_gain];
 		ret = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_CALIBBIAS:
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 09/13] staging: iio: tsl2x7x: correct alignment of parenthesis
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (7 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 08/13] staging: iio: tsl2x7x: correct alignment of parenthesis Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:41   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 10/13] staging: iio: tsl2x7x: rename power defines to improve code readability Brian Masney
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

Correct error from checkpatch.pl to improve code readibility: Alignment
should match open parenthesis. An unnecessary cast to 'struct
tsl2x7x_lux *' was removed and the return value of static definition of
in_illuminance0_calibscale_available_show() was put on its own line
due to the length of that sysfs attribute.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 886be9aa3c0f..70007117d985 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -521,8 +521,8 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
 		       sizeof(chip->pdata->platform_lux_table));
 	else
 		memcpy(chip->tsl2x7x_device_lux,
-		(struct tsl2x7x_lux *)tsl2x7x_default_lux_table_group[chip->id],
-				TSL2X7X_DEFAULT_TABLE_BYTES);
+		       tsl2x7x_default_lux_table_group[chip->id],
+		       TSL2X7X_DEFAULT_TABLE_BYTES);
 }
 
 /**
@@ -867,9 +867,10 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
 		tsl2x7x_chip_on(indio_dev);
 }
 
-static ssize_t in_illuminance0_calibscale_available_show(struct device *dev,
-					   struct device_attribute *attr,
-					   char *buf)
+static ssize_t
+in_illuminance0_calibscale_available_show(struct device *dev,
+					  struct device_attribute *attr,
+					  char *buf)
 {
 	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
 
@@ -891,8 +892,8 @@ static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
 		".00272 - .696");
 
 static ssize_t in_illuminance0_target_input_show(struct device *dev,
-					   struct device_attribute *attr,
-					   char *buf)
+						 struct device_attribute *attr,
+						 char *buf)
 {
 	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
 
@@ -900,8 +901,8 @@ static ssize_t in_illuminance0_target_input_show(struct device *dev,
 }
 
 static ssize_t in_illuminance0_target_input_store(struct device *dev,
-					    struct device_attribute *attr,
-					    const char *buf, size_t len)
+						  struct device_attribute *attr,
+						  const char *buf, size_t len)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
@@ -922,8 +923,8 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
 }
 
 static ssize_t in_illuminance0_calibrate_store(struct device *dev,
-				    struct device_attribute *attr,
-				    const char *buf, size_t len)
+					       struct device_attribute *attr,
+					       const char *buf, size_t len)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	bool value;
@@ -943,8 +944,8 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
 }
 
 static ssize_t in_illuminance0_lux_table_show(struct device *dev,
-				     struct device_attribute *attr,
-				     char *buf)
+					      struct device_attribute *attr,
+					      char *buf)
 {
 	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
 	int i = 0;
@@ -971,8 +972,8 @@ static ssize_t in_illuminance0_lux_table_show(struct device *dev,
 }
 
 static ssize_t in_illuminance0_lux_table_store(struct device *dev,
-				      struct device_attribute *attr,
-				      const char *buf, size_t len)
+					       struct device_attribute *attr,
+					       const char *buf, size_t len)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
@@ -1013,8 +1014,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev,
 }
 
 static ssize_t in_proximity0_calibrate_store(struct device *dev,
-					 struct device_attribute *attr,
-					 const char *buf, size_t len)
+					     struct device_attribute *attr,
+					     const char *buf, size_t len)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	bool value;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 10/13] staging: iio: tsl2x7x: rename power defines to improve code readability
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (8 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 09/13] " Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:42   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 11/13] staging: iio: tsl2x7x: fix alignment of break statements Brian Masney
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The LED power defines are named like TSL2X7X_mAXXX. Rename these values
to TSL2X7X_XXX_mA to improve code readability.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 70007117d985..bb9fb60509cf 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -114,10 +114,10 @@
 #define TSL2X7X_DIODE_BOTH		0x30
 
 /* LED Power */
-#define TSL2X7X_mA100			0x00
-#define TSL2X7X_mA50			0x40
-#define TSL2X7X_mA25			0x80
-#define TSL2X7X_mA13			0xD0
+#define TSL2X7X_100_mA			0x00
+#define TSL2X7X_50_mA			0x40
+#define TSL2X7X_25_mA			0x80
+#define TSL2X7X_13_mA			0xD0
 #define TSL2X7X_MAX_TIMER_CNT		0xFF
 
 #define TSL2X7X_MIN_ITIME		3
@@ -636,7 +636,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	/* Set the gain based on tsl2x7x_settings struct */
 	chip->tsl2x7x_config[TSL2X7X_GAIN] =
 		chip->settings.als_gain |
-			(TSL2X7X_mA100 | TSL2X7X_DIODE1) |
+			(TSL2X7X_100_mA | TSL2X7X_DIODE1) |
 			(chip->settings.prox_gain << 2);
 
 	/* set chip struct re scaling and saturation */
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 11/13] staging: iio: tsl2x7x: fix alignment of break statements
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (9 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 10/13] staging: iio: tsl2x7x: rename power defines to improve code readability Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:44   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 12/13] staging: iio: tsl2x7x: put function definitions on a single line Brian Masney
  2017-10-19 20:06 ` [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW Brian Masney
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

Correct the alignment of the break statements to match the alignment of
the rest of the code within the case statements.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index bb9fb60509cf..f12ab1239a46 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -466,7 +466,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
 	case tmd2771:
 		if (!(ret & TSL2X7X_STA_ADC_VALID))
 			goto prox_poll_err;
-	break;
+		break;
 	case tsl2572:
 	case tsl2672:
 	case tmd2672:
@@ -474,7 +474,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
 	case tmd2772:
 		if (!(ret & TSL2X7X_STA_PRX_VALID))
 			goto prox_poll_err;
-	break;
+		break;
 	}
 
 	for (i = 0; i < 2; i++) {
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 12/13] staging: iio: tsl2x7x: put function definitions on a single line
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (10 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 11/13] staging: iio: tsl2x7x: fix alignment of break statements Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:45   ` Jonathan Cameron
  2017-10-19 20:06 ` [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW Brian Masney
  12 siblings, 1 reply; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The functions tsl2x7x_invoke_change() and tsl2x7x_prox_calculate() are
short enough that the return value and static declaration can be moved
onto the same line with the function name. This patch makes that change
to increase code readability.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index f12ab1239a46..42ed9c015aaf 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -752,8 +752,7 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
  * put device back into proper state, and unlock
  * resource.
  */
-static
-int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
+static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
 {
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 	int device_status = chip->tsl2x7x_chip_status;
@@ -777,9 +776,8 @@ int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static
-void tsl2x7x_prox_calculate(int *data, int length,
-			    struct tsl2x7x_prox_stat *statP)
+static void tsl2x7x_prox_calculate(int *data, int length,
+				   struct tsl2x7x_prox_stat *statP)
 {
 	int i;
 	int sample_sum;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW
  2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
                   ` (11 preceding siblings ...)
  2017-10-19 20:06 ` [PATCH 12/13] staging: iio: tsl2x7x: put function definitions on a single line Brian Masney
@ 2017-10-19 20:06 ` Brian Masney
  2017-10-21 17:46   ` Jonathan Cameron
  2017-10-23  9:06   ` Dan Carpenter
  12 siblings, 2 replies; 28+ messages in thread
From: Brian Masney @ 2017-10-19 20:06 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

This patch adds a return_max label for the two cases that need to set
the lux to TSL2X7X_LUX_CALC_OVER_FLOW and return.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 42ed9c015aaf..898304d65f64 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -364,10 +364,8 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	chip->als_cur_info.als_ch0 = ch0;
 	chip->als_cur_info.als_ch1 = ch1;
 
-	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) {
-		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
+	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation)
 		goto return_max;
-	}
 
 	if (!ch0) {
 		/* have no data, so return LAST VALUE */
@@ -418,11 +416,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	lux = lux64;
 	lux = (lux + 500) / 1000;
 
-	if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) /* check for overflow */
+	if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) { /* check for overflow */
+return_max:
 		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
+	}
 
 	/* Update the structure with the latest lux. */
-return_max:
 	chip->als_cur_info.lux = lux;
 	ret = lux;
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 01/13] staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to iio_event_spec
  2017-10-19 20:06 ` [PATCH 01/13] staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to iio_event_spec Brian Masney
@ 2017-10-21 17:31   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:31 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:20 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The sysfs attributes in_intensity0_thresh_period and
> in_proximity0_thresh_period are currently directly created by the driver.
> This patch migrates the creation of these sysfs attributes from the driver
> to using the IIO core via iio_event_spec.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Looks good to me.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
> Changes since v1:
> - Use IIO_EV_DIR_EITHER instead of IIO_EV_DIR_NONE
> 
>  drivers/staging/iio/light/tsl2x7x.c | 196 ++++++++++--------------------------
>  1 file changed, 52 insertions(+), 144 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index e6a71f5fc9cb..2dd8c502fd7a 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -932,108 +932,6 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
>  	return len;
>  }
>  
> -/* persistence settings */
> -static ssize_t in_intensity0_thresh_period_show(struct device *dev,
> -					    struct device_attribute *attr,
> -					    char *buf)
> -{
> -	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
> -	int y, z, filter_delay;
> -
> -	/* Determine integration time */
> -	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.als_time) + 1;
> -	z = y * TSL2X7X_MIN_ITIME;
> -	filter_delay = z * (chip->settings.persistence & 0x0F);
> -	y = filter_delay / 1000;
> -	z = filter_delay % 1000;
> -
> -	return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
> -}
> -
> -static ssize_t in_intensity0_thresh_period_store(struct device *dev,
> -					     struct device_attribute *attr,
> -					     const char *buf, size_t len)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	struct tsl2x7x_parse_result result;
> -	int y, z, filter_delay;
> -	int ret;
> -
> -	ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract);
> -	if (ret)
> -		return ret;
> -
> -	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.als_time) + 1;
> -	z = y * TSL2X7X_MIN_ITIME;
> -
> -	filter_delay =
> -		DIV_ROUND_UP((result.integer * 1000) + result.fract, z);
> -
> -	chip->settings.persistence &= 0xF0;
> -	chip->settings.persistence |= (filter_delay & 0x0F);
> -
> -	dev_info(&chip->client->dev, "%s: als persistence = %d",
> -		 __func__, filter_delay);
> -
> -	ret = tsl2x7x_invoke_change(indio_dev);
> -	if (ret < 0)
> -		return ret;
> -
> -	return IIO_VAL_INT_PLUS_MICRO;
> -}
> -
> -static ssize_t in_proximity0_thresh_period_show(struct device *dev,
> -					     struct device_attribute *attr,
> -					     char *buf)
> -{
> -	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
> -	int y, z, filter_delay;
> -
> -	/* Determine integration time */
> -	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.prx_time) + 1;
> -	z = y * TSL2X7X_MIN_ITIME;
> -	filter_delay = z * ((chip->settings.persistence & 0xF0) >> 4);
> -	y = filter_delay / 1000;
> -	z = filter_delay % 1000;
> -
> -	return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
> -}
> -
> -static ssize_t in_proximity0_thresh_period_store(struct device *dev,
> -					      struct device_attribute *attr,
> -					      const char *buf, size_t len)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	struct tsl2x7x_parse_result result;
> -	int y, z, filter_delay;
> -	int ret;
> -
> -	ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract);
> -	if (ret)
> -		return ret;
> -
> -	y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->settings.prx_time) + 1;
> -	z = y * TSL2X7X_MIN_ITIME;
> -
> -	filter_delay =
> -		DIV_ROUND_UP((result.integer * 1000) + result.fract, z);
> -
> -	chip->settings.persistence &= 0x0F;
> -	chip->settings.persistence |= ((filter_delay << 4) & 0xF0);
> -
> -	dev_info(&chip->client->dev, "%s: prox persistence = %d",
> -		 __func__, filter_delay);
> -
> -	ret = tsl2x7x_invoke_change(indio_dev);
> -	if (ret < 0)
> -		return ret;
> -
> -
> -	return IIO_VAL_INT_PLUS_MICRO;
> -}
> -
>  static ssize_t in_illuminance0_calibrate_store(struct device *dev,
>  				    struct device_attribute *attr,
>  				    const char *buf, size_t len)
> @@ -1198,7 +1096,8 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
>  				     int val, int val2)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret = -EINVAL;
> +	int ret = -EINVAL, y, z, filter_delay;
> +	u8 time;
>  
>  	switch (info) {
>  	case IIO_EV_INFO_VALUE:
> @@ -1230,6 +1129,33 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
>  			}
>  		}
>  		break;
> +	case IIO_EV_INFO_PERIOD:
> +		if (chan->type == IIO_INTENSITY)
> +			time = chip->settings.als_time;
> +		else
> +			time = chip->settings.prx_time;
> +
> +		y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
> +		z = y * TSL2X7X_MIN_ITIME;
> +
> +		filter_delay = DIV_ROUND_UP((val * 1000) + val2, z);
> +
> +		if (chan->type == IIO_INTENSITY) {
> +			chip->settings.persistence &= 0xF0;
> +			chip->settings.persistence |=
> +				(filter_delay & 0x0F);
> +			dev_info(&chip->client->dev, "%s: ALS persistence = %d",
> +				 __func__, filter_delay);
> +		} else {
> +			chip->settings.persistence &= 0x0F;
> +			chip->settings.persistence |=
> +				((filter_delay << 4) & 0xF0);
> +			dev_info(&chip->client->dev,
> +				 "%s: Proximity persistence = %d",
> +				 __func__, filter_delay);
> +		}
> +		ret = 0;
> +		break;
>  	default:
>  		break;
>  	}
> @@ -1248,7 +1174,8 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
>  				    int *val, int *val2)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret = -EINVAL;
> +	int ret = -EINVAL, filter_delay, mult;
> +	u8 time;
>  
>  	switch (info) {
>  	case IIO_EV_INFO_VALUE:
> @@ -1280,6 +1207,23 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
>  			}
>  		}
>  		break;
> +	case IIO_EV_INFO_PERIOD:
> +		if (chan->type == IIO_INTENSITY) {
> +			time = chip->settings.als_time;
> +			mult = chip->settings.persistence & 0x0F;
> +		} else {
> +			time = chip->settings.prx_time;
> +			mult = (chip->settings.persistence & 0xF0) >> 4;
> +		}
> +
> +		/* Determine integration time */
> +		*val = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
> +		*val2 = *val * TSL2X7X_MIN_ITIME;
> +		filter_delay = *val2 * mult;
> +		*val = filter_delay / 1000;
> +		*val2 = filter_delay % 1000;
> +		ret = IIO_VAL_INT_PLUS_MICRO;
> +		break;
>  	default:
>  		break;
>  	}
> @@ -1444,10 +1388,6 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
>  
>  static DEVICE_ATTR_RW(in_illuminance0_lux_table);
>  
> -static DEVICE_ATTR_RW(in_intensity0_thresh_period);
> -
> -static DEVICE_ATTR_RW(in_proximity0_thresh_period);
> -
>  /* Use the default register values to identify the Taos device */
>  static int tsl2x7x_device_id(int *id, int target)
>  {
> @@ -1554,22 +1494,6 @@ static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
>  	NULL
>  };
>  
> -static struct attribute *tsl2X7X_ALS_event_attrs[] = {
> -	&dev_attr_in_intensity0_thresh_period.attr,
> -	NULL,
> -};
> -
> -static struct attribute *tsl2X7X_PRX_event_attrs[] = {
> -	&dev_attr_in_proximity0_thresh_period.attr,
> -	NULL,
> -};
> -
> -static struct attribute *tsl2X7X_ALSPRX_event_attrs[] = {
> -	&dev_attr_in_intensity0_thresh_period.attr,
> -	&dev_attr_in_proximity0_thresh_period.attr,
> -	NULL,
> -};
> -
>  static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
>  	[ALS] = {
>  		.attrs = tsl2x7x_ALS_device_attrs,
> @@ -1588,25 +1512,9 @@ static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
>  	},
>  };
>  
> -static const struct attribute_group tsl2X7X_event_attr_group_tbl[] = {
> -	[ALS] = {
> -		.attrs = tsl2X7X_ALS_event_attrs,
> -		.name = "events",
> -	},
> -	[PRX] = {
> -		.attrs = tsl2X7X_PRX_event_attrs,
> -		.name = "events",
> -	},
> -	[ALSPRX] = {
> -		.attrs = tsl2X7X_ALSPRX_event_attrs,
> -		.name = "events",
> -	},
> -};
> -
>  static const struct iio_info tsl2X7X_device_info[] = {
>  	[ALS] = {
>  		.attrs = &tsl2X7X_device_attr_group_tbl[ALS],
> -		.event_attrs = &tsl2X7X_event_attr_group_tbl[ALS],
>  		.read_raw = &tsl2x7x_read_raw,
>  		.write_raw = &tsl2x7x_write_raw,
>  		.read_event_value = &tsl2x7x_read_event_value,
> @@ -1616,7 +1524,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
>  	},
>  	[PRX] = {
>  		.attrs = &tsl2X7X_device_attr_group_tbl[PRX],
> -		.event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
>  		.read_raw = &tsl2x7x_read_raw,
>  		.write_raw = &tsl2x7x_write_raw,
>  		.read_event_value = &tsl2x7x_read_event_value,
> @@ -1626,7 +1533,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
>  	},
>  	[ALSPRX] = {
>  		.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX],
> -		.event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
>  		.read_raw = &tsl2x7x_read_raw,
>  		.write_raw = &tsl2x7x_write_raw,
>  		.read_event_value = &tsl2x7x_read_event_value,
> @@ -1636,7 +1542,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
>  	},
>  	[PRX2] = {
>  		.attrs = &tsl2X7X_device_attr_group_tbl[PRX2],
> -		.event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
>  		.read_raw = &tsl2x7x_read_raw,
>  		.write_raw = &tsl2x7x_write_raw,
>  		.read_event_value = &tsl2x7x_read_event_value,
> @@ -1646,7 +1551,6 @@ static const struct iio_info tsl2X7X_device_info[] = {
>  	},
>  	[ALSPRX2] = {
>  		.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2],
> -		.event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
>  		.read_raw = &tsl2x7x_read_raw,
>  		.write_raw = &tsl2x7x_write_raw,
>  		.read_event_value = &tsl2x7x_read_event_value,
> @@ -1667,6 +1571,10 @@ static const struct iio_event_spec tsl2x7x_events[] = {
>  		.dir = IIO_EV_DIR_FALLING,
>  		.mask_separate = BIT(IIO_EV_INFO_VALUE) |
>  			BIT(IIO_EV_INFO_ENABLE),
> +	}, {
> +		.type = IIO_EV_TYPE_THRESH,
> +		.dir = IIO_EV_DIR_EITHER,
> +		.mask_separate = BIT(IIO_EV_INFO_PERIOD),
>  	},
>  };
>  

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/13] staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structure
  2017-10-19 20:06 ` [PATCH 02/13] staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structure Brian Masney
@ 2017-10-21 17:32   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:32 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:21 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The structure tsl2x7x_parse_result is not used so this patch removes its
> definition.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 2dd8c502fd7a..094ab76b5d60 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -142,11 +142,6 @@ enum {
>  	TSL2X7X_CHIP_SUSPENDED = 2
>  };
>  
> -struct tsl2x7x_parse_result {
> -	int integer;
> -	int fract;
> -};
> -
>  /* Per-device data */
>  struct tsl2x7x_als_info {
>  	u16 als_ch0;

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 03/13] staging: iio: tsl2x7x: sort #includes
  2017-10-19 20:06 ` [PATCH 03/13] staging: iio: tsl2x7x: sort #includes Brian Masney
@ 2017-10-21 17:34   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:34 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:22 -0400
Brian Masney <masneyb@onstation.org> wrote:

> Sort the #include statements for increased code readability.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 094ab76b5d60..d407c3ad7e2f 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -15,14 +15,14 @@
>   * more details.
>   */
>  
> -#include <linux/kernel.h>
> -#include <linux/i2c.h>
> -#include <linux/errno.h>
>  #include <linux/delay.h>
> -#include <linux/mutex.h>
> +#include <linux/errno.h>
> +#include <linux/i2c.h>
>  #include <linux/interrupt.h>
> -#include <linux/slab.h>
> +#include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/slab.h>
>  #include <linux/iio/events.h>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 04/13] staging: iio: tsl2x7x: remove unnecessary struct iio_dev definition
  2017-10-19 20:06 ` [PATCH 04/13] staging: iio: tsl2x7x: remove unnecessary struct iio_dev definition Brian Masney
@ 2017-10-21 17:34   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:34 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:23 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x.h has a blank definition for 'struct iio_dev' that is not
> needed. This patch removes that definition.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x.h | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index a216c6943a84..df00f2ec1719 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -23,8 +23,6 @@
>  #define __TSL2X7X_H
>  #include <linux/pm.h>
>  
> -struct iio_dev;
> -
>  struct tsl2x7x_lux {
>  	unsigned int ratio;
>  	unsigned int ch0;

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 05/13] staging: iio: tsl2x7x: changed #defines to be aligned on the same column
  2017-10-19 20:06 ` [PATCH 05/13] staging: iio: tsl2x7x: changed #defines to be aligned on the same column Brian Masney
@ 2017-10-21 17:35   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:35 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:24 -0400
Brian Masney <masneyb@onstation.org> wrote:

> Some of the existing #defines have tabs between the name, and the value,
> while others have spaces. The alignment of the values mostly has a
> consistent layout, but there are some that don't. Change all of the
> defines so that the name and value is separated by tabs and all of the
> values start on the same column to increase code readability. This patch
> also removes the unnecessary parentheses around the value of
> TSL2X7X_MAX_TIMER_CNT.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 132 ++++++++++++++++++------------------
>  1 file changed, 66 insertions(+), 66 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index d407c3ad7e2f..3a3340aadc1a 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -29,98 +29,98 @@
>  #include "tsl2x7x.h"
>  
>  /* Cal defs*/
> -#define PROX_STAT_CAL        0
> -#define PROX_STAT_SAMP       1
> -#define MAX_SAMPLES_CAL      200
> +#define PROX_STAT_CAL			0
> +#define PROX_STAT_SAMP			1
> +#define MAX_SAMPLES_CAL			200
>  
>  /* TSL2X7X Device ID */
> -#define TRITON_ID    0x00
> -#define SWORDFISH_ID 0x30
> -#define HALIBUT_ID   0x20
> +#define TRITON_ID			0x00
> +#define SWORDFISH_ID			0x30
> +#define HALIBUT_ID			0x20
>  
>  /* Lux calculation constants */
> -#define TSL2X7X_LUX_CALC_OVER_FLOW     65535
> +#define TSL2X7X_LUX_CALC_OVER_FLOW	65535
>  
>  /* TAOS Register definitions - note:
>   * depending on device, some of these register are not used and the
>   * register address is benign.
>   */
>  /* 2X7X register offsets */
> -#define TSL2X7X_MAX_CONFIG_REG         16
> +#define TSL2X7X_MAX_CONFIG_REG		16
>  
>  /* Device Registers and Masks */
> -#define TSL2X7X_CNTRL                  0x00
> -#define TSL2X7X_ALS_TIME               0X01
> -#define TSL2X7X_PRX_TIME               0x02
> -#define TSL2X7X_WAIT_TIME              0x03
> -#define TSL2X7X_ALS_MINTHRESHLO        0X04
> -#define TSL2X7X_ALS_MINTHRESHHI        0X05
> -#define TSL2X7X_ALS_MAXTHRESHLO        0X06
> -#define TSL2X7X_ALS_MAXTHRESHHI        0X07
> -#define TSL2X7X_PRX_MINTHRESHLO        0X08
> -#define TSL2X7X_PRX_MINTHRESHHI        0X09
> -#define TSL2X7X_PRX_MAXTHRESHLO        0X0A
> -#define TSL2X7X_PRX_MAXTHRESHHI        0X0B
> -#define TSL2X7X_PERSISTENCE            0x0C
> -#define TSL2X7X_PRX_CONFIG             0x0D
> -#define TSL2X7X_PRX_COUNT              0x0E
> -#define TSL2X7X_GAIN                   0x0F
> -#define TSL2X7X_NOTUSED                0x10
> -#define TSL2X7X_REVID                  0x11
> -#define TSL2X7X_CHIPID                 0x12
> -#define TSL2X7X_STATUS                 0x13
> -#define TSL2X7X_ALS_CHAN0LO            0x14
> -#define TSL2X7X_ALS_CHAN0HI            0x15
> -#define TSL2X7X_ALS_CHAN1LO            0x16
> -#define TSL2X7X_ALS_CHAN1HI            0x17
> -#define TSL2X7X_PRX_LO                 0x18
> -#define TSL2X7X_PRX_HI                 0x19
> +#define TSL2X7X_CNTRL			0x00
> +#define TSL2X7X_ALS_TIME		0X01
> +#define TSL2X7X_PRX_TIME		0x02
> +#define TSL2X7X_WAIT_TIME		0x03
> +#define TSL2X7X_ALS_MINTHRESHLO		0X04
> +#define TSL2X7X_ALS_MINTHRESHHI		0X05
> +#define TSL2X7X_ALS_MAXTHRESHLO		0X06
> +#define TSL2X7X_ALS_MAXTHRESHHI		0X07
> +#define TSL2X7X_PRX_MINTHRESHLO		0X08
> +#define TSL2X7X_PRX_MINTHRESHHI		0X09
> +#define TSL2X7X_PRX_MAXTHRESHLO		0X0A
> +#define TSL2X7X_PRX_MAXTHRESHHI		0X0B
> +#define TSL2X7X_PERSISTENCE		0x0C
> +#define TSL2X7X_PRX_CONFIG		0x0D
> +#define TSL2X7X_PRX_COUNT		0x0E
> +#define TSL2X7X_GAIN			0x0F
> +#define TSL2X7X_NOTUSED			0x10
> +#define TSL2X7X_REVID			0x11
> +#define TSL2X7X_CHIPID			0x12
> +#define TSL2X7X_STATUS			0x13
> +#define TSL2X7X_ALS_CHAN0LO		0x14
> +#define TSL2X7X_ALS_CHAN0HI		0x15
> +#define TSL2X7X_ALS_CHAN1LO		0x16
> +#define TSL2X7X_ALS_CHAN1HI		0x17
> +#define TSL2X7X_PRX_LO			0x18
> +#define TSL2X7X_PRX_HI			0x19
>  
>  /* tsl2X7X cmd reg masks */
> -#define TSL2X7X_CMD_REG                0x80
> -#define TSL2X7X_CMD_SPL_FN             0x60
> +#define TSL2X7X_CMD_REG			0x80
> +#define TSL2X7X_CMD_SPL_FN		0x60
>  
> -#define TSL2X7X_CMD_PROX_INT_CLR       0X05
> -#define TSL2X7X_CMD_ALS_INT_CLR        0x06
> -#define TSL2X7X_CMD_PROXALS_INT_CLR    0X07
> +#define TSL2X7X_CMD_PROX_INT_CLR	0X05
> +#define TSL2X7X_CMD_ALS_INT_CLR		0x06
> +#define TSL2X7X_CMD_PROXALS_INT_CLR	0X07
>  
>  /* tsl2X7X cntrl reg masks */
> -#define TSL2X7X_CNTL_ADC_ENBL          0x02
> -#define TSL2X7X_CNTL_PWR_ON            0x01
> +#define TSL2X7X_CNTL_ADC_ENBL		0x02
> +#define TSL2X7X_CNTL_PWR_ON		0x01
>  
>  /* tsl2X7X status reg masks */
> -#define TSL2X7X_STA_ADC_VALID          0x01
> -#define TSL2X7X_STA_PRX_VALID          0x02
> -#define TSL2X7X_STA_ADC_PRX_VALID      (TSL2X7X_STA_ADC_VALID |\
> -					TSL2X7X_STA_PRX_VALID)
> -#define TSL2X7X_STA_ALS_INTR           0x10
> -#define TSL2X7X_STA_PRX_INTR           0x20
> +#define TSL2X7X_STA_ADC_VALID		0x01
> +#define TSL2X7X_STA_PRX_VALID		0x02
> +#define TSL2X7X_STA_ADC_PRX_VALID	(TSL2X7X_STA_ADC_VALID | \
> +					 TSL2X7X_STA_PRX_VALID)
> +#define TSL2X7X_STA_ALS_INTR		0x10
> +#define TSL2X7X_STA_PRX_INTR		0x20
>  
>  /* tsl2X7X cntrl reg masks */
> -#define TSL2X7X_CNTL_REG_CLEAR         0x00
> -#define TSL2X7X_CNTL_PROX_INT_ENBL     0X20
> -#define TSL2X7X_CNTL_ALS_INT_ENBL      0X10
> -#define TSL2X7X_CNTL_WAIT_TMR_ENBL     0X08
> -#define TSL2X7X_CNTL_PROX_DET_ENBL     0X04
> -#define TSL2X7X_CNTL_PWRON             0x01
> -#define TSL2X7X_CNTL_ALSPON_ENBL       0x03
> -#define TSL2X7X_CNTL_INTALSPON_ENBL    0x13
> -#define TSL2X7X_CNTL_PROXPON_ENBL      0x0F
> -#define TSL2X7X_CNTL_INTPROXPON_ENBL   0x2F
> +#define TSL2X7X_CNTL_REG_CLEAR		0x00
> +#define TSL2X7X_CNTL_PROX_INT_ENBL	0X20
> +#define TSL2X7X_CNTL_ALS_INT_ENBL	0X10
> +#define TSL2X7X_CNTL_WAIT_TMR_ENBL	0X08
> +#define TSL2X7X_CNTL_PROX_DET_ENBL	0X04
> +#define TSL2X7X_CNTL_PWRON		0x01
> +#define TSL2X7X_CNTL_ALSPON_ENBL	0x03
> +#define TSL2X7X_CNTL_INTALSPON_ENBL	0x13
> +#define TSL2X7X_CNTL_PROXPON_ENBL	0x0F
> +#define TSL2X7X_CNTL_INTPROXPON_ENBL	0x2F
>  
>  /*Prox diode to use */
> -#define TSL2X7X_DIODE0                 0x10
> -#define TSL2X7X_DIODE1                 0x20
> -#define TSL2X7X_DIODE_BOTH             0x30
> +#define TSL2X7X_DIODE0			0x10
> +#define TSL2X7X_DIODE1			0x20
> +#define TSL2X7X_DIODE_BOTH		0x30
>  
>  /* LED Power */
> -#define TSL2X7X_mA100                  0x00
> -#define TSL2X7X_mA50                   0x40
> -#define TSL2X7X_mA25                   0x80
> -#define TSL2X7X_mA13                   0xD0
> -#define TSL2X7X_MAX_TIMER_CNT          (0xFF)
> +#define TSL2X7X_mA100			0x00
> +#define TSL2X7X_mA50			0x40
> +#define TSL2X7X_mA25			0x80
> +#define TSL2X7X_mA13			0xD0
> +#define TSL2X7X_MAX_TIMER_CNT		0xFF
>  
> -#define TSL2X7X_MIN_ITIME 3
> +#define TSL2X7X_MIN_ITIME		3
>  
>  /* TAOS txx2x7x Device family members */
>  enum {

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 06/13] staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to use IIO_CONST_ATTR
  2017-10-19 20:06 ` [PATCH 06/13] staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to use IIO_CONST_ATTR Brian Masney
@ 2017-10-21 17:36   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:36 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:25 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The sysfs attribute in_proximity0_calibscale_available is currently
> created by using DEVICE_ATTR_RO(). Convert this over to use
> IIO_CONST_ATTR().
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 3a3340aadc1a..80968dd456a0 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -886,12 +886,7 @@ static ssize_t in_illuminance0_calibscale_available_show(struct device *dev,
>  	return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
>  }
>  
> -static ssize_t in_proximity0_calibscale_available_show(struct device *dev,
> -						struct device_attribute *attr,
> -						char *buf)
> -{
> -		return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8");
> -}
> +static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
>  
>  static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
>  		".00272 - .696");
> @@ -1371,8 +1366,6 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
>  	return tsl2x7x_invoke_change(indio_dev);
>  }
>  
> -static DEVICE_ATTR_RO(in_proximity0_calibscale_available);
> -
>  static DEVICE_ATTR_RO(in_illuminance0_calibscale_available);
>  
>  static DEVICE_ATTR_RW(in_illuminance0_target_input);
> @@ -1468,13 +1461,13 @@ static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
>  	&dev_attr_in_illuminance0_target_input.attr,
>  	&dev_attr_in_illuminance0_calibrate.attr,
>  	&dev_attr_in_illuminance0_lux_table.attr,
> -	&dev_attr_in_proximity0_calibrate.attr,
> +	&iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
>  	NULL
>  };
>  
>  static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
>  	&dev_attr_in_proximity0_calibrate.attr,
> -	&dev_attr_in_proximity0_calibscale_available.attr,
> +	&iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
>  	NULL
>  };
>  
> @@ -1485,7 +1478,7 @@ static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
>  	&dev_attr_in_illuminance0_calibrate.attr,
>  	&dev_attr_in_illuminance0_lux_table.attr,
>  	&dev_attr_in_proximity0_calibrate.attr,
> -	&dev_attr_in_proximity0_calibscale_available.attr,
> +	&iio_const_attr_in_proximity0_calibscale_available.dev_attr.attr,
>  	NULL
>  };
>  

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 07/13] staging: iio: tsl2x7x: remove unnecessary parentheses
  2017-10-19 20:06 ` [PATCH 07/13] staging: iio: tsl2x7x: remove unnecessary parentheses Brian Masney
@ 2017-10-21 17:38   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:38 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:26 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch fixes the error 'Unnecessary parentheses around 'XXX' from
> checkpatch.pl. It also fixes several other places with unnecessary
> parentheses that checkpatch.pl did not detect.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Some of these are completely pointless, others can be argued either
way (from a readability point of view).  I don't care much on those though so
Applied to the togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 80968dd456a0..6cc89cd6505e 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -348,9 +348,9 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  
>  	/* clear any existing interrupt status */
>  	ret = i2c_smbus_write_byte(chip->client,
> -				   (TSL2X7X_CMD_REG |
> +				   TSL2X7X_CMD_REG |
>  				   TSL2X7X_CMD_SPL_FN |
> -				   TSL2X7X_CMD_ALS_INT_CLR));
> +				   TSL2X7X_CMD_ALS_INT_CLR);
>  	if (ret < 0) {
>  		dev_err(&chip->client->dev,
>  			"i2c_write_command failed - err = %d\n", ret);
> @@ -364,7 +364,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	chip->als_cur_info.als_ch0 = ch0;
>  	chip->als_cur_info.als_ch1 = ch1;
>  
> -	if ((ch0 >= chip->als_saturation) || (ch1 >= chip->als_saturation)) {
> +	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) {
>  		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
>  		goto return_max;
>  	}
> @@ -697,14 +697,14 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  		dev_info(&chip->client->dev, "Setting Up Interrupt(s)\n");
>  
>  		reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL;
> -		if ((chip->settings.interrupts_en == 0x20) ||
> -		    (chip->settings.interrupts_en == 0x30))
> +		if (chip->settings.interrupts_en == 0x20 ||
> +		    chip->settings.interrupts_en == 0x30)
>  			reg_val |= TSL2X7X_CNTL_PROX_DET_ENBL;
>  
>  		reg_val |= chip->settings.interrupts_en;
>  		ret = i2c_smbus_write_byte_data(chip->client,
> -						(TSL2X7X_CMD_REG |
> -						TSL2X7X_CNTRL), reg_val);
> +						TSL2X7X_CMD_REG | TSL2X7X_CNTRL,
> +						reg_val);
>  		if (ret < 0)
>  			dev_err(&chip->client->dev,
>  				"%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
> @@ -1721,7 +1721,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
>  		return -EINVAL;
>  	}
>  
> -	ret = i2c_smbus_write_byte(clientp, (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
> +	ret = i2c_smbus_write_byte(clientp, TSL2X7X_CMD_REG | TSL2X7X_CNTRL);
>  	if (ret < 0) {
>  		dev_err(&clientp->dev, "write to cmd reg failed. err = %d\n",
>  			ret);

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 08/13] staging: iio: tsl2x7x: correct alignment of parenthesis
  2017-10-19 20:06 ` [PATCH 08/13] staging: iio: tsl2x7x: correct alignment of parenthesis Brian Masney
@ 2017-10-21 17:40   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:40 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:27 -0400
Brian Masney <masneyb@onstation.org> wrote:

> Correct error from checkpatch.pl to improve code readibility: Alignment
> should match open parenthesis. This involved shortening the name of
> tsl2x7x_als_gainadj and tsl2x7x_prx_gainadj to tsl2x7x_als_gain and
> tsl2x7x_prx_gain respectively. This also required removing the
> ch0lux and ch1lux local variables in order to get the line short
> enough.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 6cc89cd6505e..886be9aa3c0f 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -243,14 +243,14 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = {
>  	.prox_pulse_count = 8
>  };
>  
> -static const s16 tsl2X7X_als_gainadj[] = {
> +static const s16 tsl2x7x_als_gain[] = {
>  	1,
>  	8,
>  	16,
>  	120
>  };
>  
> -static const s16 tsl2X7X_prx_gainadj[] = {
> +static const s16 tsl2x7x_prx_gain[] = {
>  	1,
>  	2,
>  	4,
> @@ -384,11 +384,10 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	if (p->ratio == 0) {
>  		lux = 0;
>  	} else {
> -		ch0lux = DIV_ROUND_UP(ch0 * p->ch0,
> -			tsl2X7X_als_gainadj[chip->settings.als_gain]);
> -		ch1lux = DIV_ROUND_UP(ch1 * p->ch1,
> -			tsl2X7X_als_gainadj[chip->settings.als_gain]);
> -		lux = ch0lux - ch1lux;
> +		lux = DIV_ROUND_UP(ch0 * p->ch0,
> +				   tsl2x7x_als_gain[chip->settings.als_gain]) -
> +		      DIV_ROUND_UP(ch1 * p->ch1,
> +				   tsl2x7x_als_gain[chip->settings.als_gain]);
>  	}
>  
>  	/* note: lux is 31 bit max at this point */
> @@ -1263,9 +1262,9 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
>  		break;
>  	case IIO_CHAN_INFO_CALIBSCALE:
>  		if (chan->type == IIO_LIGHT)
> -			*val = tsl2X7X_als_gainadj[chip->settings.als_gain];
> +			*val = tsl2x7x_als_gain[chip->settings.als_gain];
>  		else
> -			*val = tsl2X7X_prx_gainadj[chip->settings.prox_gain];
> +			*val = tsl2x7x_prx_gain[chip->settings.prox_gain];
>  		ret = IIO_VAL_INT;
>  		break;
>  	case IIO_CHAN_INFO_CALIBBIAS:

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 09/13] staging: iio: tsl2x7x: correct alignment of parenthesis
  2017-10-19 20:06 ` [PATCH 09/13] " Brian Masney
@ 2017-10-21 17:41   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:41 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:28 -0400
Brian Masney <masneyb@onstation.org> wrote:

> Correct error from checkpatch.pl to improve code readibility: Alignment
> should match open parenthesis. An unnecessary cast to 'struct
> tsl2x7x_lux *' was removed and the return value of static definition of
> in_illuminance0_calibscale_available_show() was put on its own line
> due to the length of that sysfs attribute.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Not sure I'd have bothered to take it quite this far!

Anyhow, applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 35 ++++++++++++++++++-----------------
>  1 file changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 886be9aa3c0f..70007117d985 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -521,8 +521,8 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
>  		       sizeof(chip->pdata->platform_lux_table));
>  	else
>  		memcpy(chip->tsl2x7x_device_lux,
> -		(struct tsl2x7x_lux *)tsl2x7x_default_lux_table_group[chip->id],
> -				TSL2X7X_DEFAULT_TABLE_BYTES);
> +		       tsl2x7x_default_lux_table_group[chip->id],
> +		       TSL2X7X_DEFAULT_TABLE_BYTES);
>  }
>  
>  /**
> @@ -867,9 +867,10 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
>  		tsl2x7x_chip_on(indio_dev);
>  }
>  
> -static ssize_t in_illuminance0_calibscale_available_show(struct device *dev,
> -					   struct device_attribute *attr,
> -					   char *buf)
> +static ssize_t
> +in_illuminance0_calibscale_available_show(struct device *dev,
> +					  struct device_attribute *attr,
> +					  char *buf)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
>  
> @@ -891,8 +892,8 @@ static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
>  		".00272 - .696");
>  
>  static ssize_t in_illuminance0_target_input_show(struct device *dev,
> -					   struct device_attribute *attr,
> -					   char *buf)
> +						 struct device_attribute *attr,
> +						 char *buf)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
>  
> @@ -900,8 +901,8 @@ static ssize_t in_illuminance0_target_input_show(struct device *dev,
>  }
>  
>  static ssize_t in_illuminance0_target_input_store(struct device *dev,
> -					    struct device_attribute *attr,
> -					    const char *buf, size_t len)
> +						  struct device_attribute *attr,
> +						  const char *buf, size_t len)
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> @@ -922,8 +923,8 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
>  }
>  
>  static ssize_t in_illuminance0_calibrate_store(struct device *dev,
> -				    struct device_attribute *attr,
> -				    const char *buf, size_t len)
> +					       struct device_attribute *attr,
> +					       const char *buf, size_t len)
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	bool value;
> @@ -943,8 +944,8 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
>  }
>  
>  static ssize_t in_illuminance0_lux_table_show(struct device *dev,
> -				     struct device_attribute *attr,
> -				     char *buf)
> +					      struct device_attribute *attr,
> +					      char *buf)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
>  	int i = 0;
> @@ -971,8 +972,8 @@ static ssize_t in_illuminance0_lux_table_show(struct device *dev,
>  }
>  
>  static ssize_t in_illuminance0_lux_table_store(struct device *dev,
> -				      struct device_attribute *attr,
> -				      const char *buf, size_t len)
> +					       struct device_attribute *attr,
> +					       const char *buf, size_t len)
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> @@ -1013,8 +1014,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev,
>  }
>  
>  static ssize_t in_proximity0_calibrate_store(struct device *dev,
> -					 struct device_attribute *attr,
> -					 const char *buf, size_t len)
> +					     struct device_attribute *attr,
> +					     const char *buf, size_t len)
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	bool value;

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 10/13] staging: iio: tsl2x7x: rename power defines to improve code readability
  2017-10-19 20:06 ` [PATCH 10/13] staging: iio: tsl2x7x: rename power defines to improve code readability Brian Masney
@ 2017-10-21 17:42   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:42 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:29 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The LED power defines are named like TSL2X7X_mAXXX. Rename these values
> to TSL2X7X_XXX_mA to improve code readability.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 70007117d985..bb9fb60509cf 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -114,10 +114,10 @@
>  #define TSL2X7X_DIODE_BOTH		0x30
>  
>  /* LED Power */
> -#define TSL2X7X_mA100			0x00
> -#define TSL2X7X_mA50			0x40
> -#define TSL2X7X_mA25			0x80
> -#define TSL2X7X_mA13			0xD0
> +#define TSL2X7X_100_mA			0x00
> +#define TSL2X7X_50_mA			0x40
> +#define TSL2X7X_25_mA			0x80
> +#define TSL2X7X_13_mA			0xD0
>  #define TSL2X7X_MAX_TIMER_CNT		0xFF
>  
>  #define TSL2X7X_MIN_ITIME		3
> @@ -636,7 +636,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  	/* Set the gain based on tsl2x7x_settings struct */
>  	chip->tsl2x7x_config[TSL2X7X_GAIN] =
>  		chip->settings.als_gain |
> -			(TSL2X7X_mA100 | TSL2X7X_DIODE1) |
> +			(TSL2X7X_100_mA | TSL2X7X_DIODE1) |
>  			(chip->settings.prox_gain << 2);
>  
>  	/* set chip struct re scaling and saturation */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 11/13] staging: iio: tsl2x7x: fix alignment of break statements
  2017-10-19 20:06 ` [PATCH 11/13] staging: iio: tsl2x7x: fix alignment of break statements Brian Masney
@ 2017-10-21 17:44   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:44 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:30 -0400
Brian Masney <masneyb@onstation.org> wrote:

> Correct the alignment of the break statements to match the alignment of
> the rest of the code within the case statements.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index bb9fb60509cf..f12ab1239a46 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -466,7 +466,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
>  	case tmd2771:
>  		if (!(ret & TSL2X7X_STA_ADC_VALID))
>  			goto prox_poll_err;
> -	break;
> +		break;
>  	case tsl2572:
>  	case tsl2672:
>  	case tmd2672:
> @@ -474,7 +474,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
>  	case tmd2772:
>  		if (!(ret & TSL2X7X_STA_PRX_VALID))
>  			goto prox_poll_err;
> -	break;
> +		break;
>  	}
>  
>  	for (i = 0; i < 2; i++) {

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 12/13] staging: iio: tsl2x7x: put function definitions on a single line
  2017-10-19 20:06 ` [PATCH 12/13] staging: iio: tsl2x7x: put function definitions on a single line Brian Masney
@ 2017-10-21 17:45   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:45 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:31 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The functions tsl2x7x_invoke_change() and tsl2x7x_prox_calculate() are
> short enough that the return value and static declaration can be moved
> onto the same line with the function name. This patch makes that change
> to increase code readability.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index f12ab1239a46..42ed9c015aaf 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -752,8 +752,7 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
>   * put device back into proper state, and unlock
>   * resource.
>   */
> -static
> -int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
> +static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
>  	int device_status = chip->tsl2x7x_chip_status;
> @@ -777,9 +776,8 @@ int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
>  	return ret;
>  }
>  
> -static
> -void tsl2x7x_prox_calculate(int *data, int length,
> -			    struct tsl2x7x_prox_stat *statP)
> +static void tsl2x7x_prox_calculate(int *data, int length,
> +				   struct tsl2x7x_prox_stat *statP)
>  {
>  	int i;
>  	int sample_sum;

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW
  2017-10-19 20:06 ` [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW Brian Masney
@ 2017-10-21 17:46   ` Jonathan Cameron
  2017-10-23  9:06   ` Dan Carpenter
  1 sibling, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-10-21 17:46 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Thu, 19 Oct 2017 16:06:32 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch adds a return_max label for the two cases that need to set
> the lux to TSL2X7X_LUX_CALC_OVER_FLOW and return.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Sorry - don't like this last one.  I think it hurts readability.  Leave
this as it was.

Thanks

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 42ed9c015aaf..898304d65f64 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -364,10 +364,8 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	chip->als_cur_info.als_ch0 = ch0;
>  	chip->als_cur_info.als_ch1 = ch1;
>  
> -	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) {
> -		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
> +	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation)
>  		goto return_max;
> -	}
>  
>  	if (!ch0) {
>  		/* have no data, so return LAST VALUE */
> @@ -418,11 +416,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	lux = lux64;
>  	lux = (lux + 500) / 1000;
>  
> -	if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) /* check for overflow */
> +	if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) { /* check for overflow */
> +return_max:
>  		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
> +	}
>  
>  	/* Update the structure with the latest lux. */
> -return_max:
>  	chip->als_cur_info.lux = lux;
>  	ret = lux;
>  

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW
  2017-10-19 20:06 ` [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW Brian Masney
  2017-10-21 17:46   ` Jonathan Cameron
@ 2017-10-23  9:06   ` Dan Carpenter
  1 sibling, 0 replies; 28+ messages in thread
From: Dan Carpenter @ 2017-10-23  9:06 UTC (permalink / raw)
  To: Brian Masney
  Cc: jic23, linux-iio, devel, lars, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Thu, Oct 19, 2017 at 04:06:32PM -0400, Brian Masney wrote:
> This patch adds a return_max label for the two cases that need to set
> the lux to TSL2X7X_LUX_CALC_OVER_FLOW and return.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 42ed9c015aaf..898304d65f64 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -364,10 +364,8 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	chip->als_cur_info.als_ch0 = ch0;
>  	chip->als_cur_info.als_ch1 = ch1;
>  
> -	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) {
> -		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
> +	if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation)
>  		goto return_max;
> -	}
>  
>  	if (!ch0) {
>  		/* have no data, so return LAST VALUE */
> @@ -418,11 +416,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	lux = lux64;
>  	lux = (lux + 500) / 1000;
>  
> -	if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) /* check for overflow */
> +	if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) { /* check for overflow */
> +return_max:
>  		lux = TSL2X7X_LUX_CALC_OVER_FLOW;
> +	}

Ugh...  Wow.  No.  This terrible anti-pattern is spreading.  Don't do
this.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2017-10-23  9:07 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-19 20:06 [PATCH 00/13] staging: iio: tsl2x7x: staging cleanups Brian Masney
2017-10-19 20:06 ` [PATCH 01/13] staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to iio_event_spec Brian Masney
2017-10-21 17:31   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 02/13] staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structure Brian Masney
2017-10-21 17:32   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 03/13] staging: iio: tsl2x7x: sort #includes Brian Masney
2017-10-21 17:34   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 04/13] staging: iio: tsl2x7x: remove unnecessary struct iio_dev definition Brian Masney
2017-10-21 17:34   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 05/13] staging: iio: tsl2x7x: changed #defines to be aligned on the same column Brian Masney
2017-10-21 17:35   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 06/13] staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to use IIO_CONST_ATTR Brian Masney
2017-10-21 17:36   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 07/13] staging: iio: tsl2x7x: remove unnecessary parentheses Brian Masney
2017-10-21 17:38   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 08/13] staging: iio: tsl2x7x: correct alignment of parenthesis Brian Masney
2017-10-21 17:40   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 09/13] " Brian Masney
2017-10-21 17:41   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 10/13] staging: iio: tsl2x7x: rename power defines to improve code readability Brian Masney
2017-10-21 17:42   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 11/13] staging: iio: tsl2x7x: fix alignment of break statements Brian Masney
2017-10-21 17:44   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 12/13] staging: iio: tsl2x7x: put function definitions on a single line Brian Masney
2017-10-21 17:45   ` Jonathan Cameron
2017-10-19 20:06 ` [PATCH 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW Brian Masney
2017-10-21 17:46   ` Jonathan Cameron
2017-10-23  9:06   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).