All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] iio: tsl2x7x: staging cleanups
@ 2018-04-21  0:41 ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

Here is another round of staging cleanups for this driver mostly based
on Jonathon's feedback. We're very close to a staging graduation and I
only have a few items remaining on my todo list:
 
- Remove wildcards from the driver name. Jonathan suggested tsl2571.
- Don't make the events/ directory available to user space via sysfs if
  an interrupt pin is not configured.
- Go through the newer ALS part numbers on AMS's site and see if there
  are other part numbers that can be added to this driver.
- I found this week an issue with the integration_time sysfs attribute.

Hopefully I'll have time to wrap this up next week.

Brian Masney (13):
  staging: iio: tsl2x7x: move integration_time* attributes to
    IIO_INTENSITY channel
  staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
  staging: iio: tsl2x7x: don't return error in IRQ handler
  staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
  staging: iio: tsl2x7x: remove unnecessary chip status checks in
    suspend/resume
  staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
  staging: iio: tsl2x7x: simplify device id verification
  staging: iio: tsl2x7x: add range checking to three sysfs attributes
  staging: iio: tsl2x7x: move power and diode settings into header file
  staging: iio: tsl2x7x: rename prx to prox for consistency
  staging: iio: tsl2x7x: use device defaults for als_time, prox_time and
    wait_time
  staging: iio: tsl2x7x: various comment cleanups
  staging: iio: tsl2x7x: rename prox_config to als_prox_config

 drivers/staging/iio/light/tsl2x7x.c | 217 ++++++++++++++----------------------
 drivers/staging/iio/light/tsl2x7x.h |  81 +++++++-------
 2 files changed, 125 insertions(+), 173 deletions(-)

-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 00/13] iio: tsl2x7x: staging cleanups
@ 2018-04-21  0:41 ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

Here is another round of staging cleanups for this driver mostly based
on Jonathon's feedback. We're very close to a staging graduation and I
only have a few items remaining on my todo list:
 
- Remove wildcards from the driver name. Jonathan suggested tsl2571.
- Don't make the events/ directory available to user space via sysfs if
  an interrupt pin is not configured.
- Go through the newer ALS part numbers on AMS's site and see if there
  are other part numbers that can be added to this driver.
- I found this week an issue with the integration_time sysfs attribute.

Hopefully I'll have time to wrap this up next week.

Brian Masney (13):
  staging: iio: tsl2x7x: move integration_time* attributes to
    IIO_INTENSITY channel
  staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
  staging: iio: tsl2x7x: don't return error in IRQ handler
  staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
  staging: iio: tsl2x7x: remove unnecessary chip status checks in
    suspend/resume
  staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
  staging: iio: tsl2x7x: simplify device id verification
  staging: iio: tsl2x7x: add range checking to three sysfs attributes
  staging: iio: tsl2x7x: move power and diode settings into header file
  staging: iio: tsl2x7x: rename prx to prox for consistency
  staging: iio: tsl2x7x: use device defaults for als_time, prox_time and
    wait_time
  staging: iio: tsl2x7x: various comment cleanups
  staging: iio: tsl2x7x: rename prox_config to als_prox_config

 drivers/staging/iio/light/tsl2x7x.c | 217 ++++++++++++++----------------------
 drivers/staging/iio/light/tsl2x7x.h |  81 +++++++-------
 2 files changed, 125 insertions(+), 173 deletions(-)

-- 
2.14.3


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

* [PATCH 01/13] staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

The integration_time* attributes are currently associated with the
IIO_LIGHT channel but should be associated with the IIO_INTENSITY
channel. Directory listing of the sysfs attributes for a TSL2772
with this patch applied:

dev
events
in_illuminance0_calibrate
in_illuminance0_calibscale_available
in_illuminance0_input
in_illuminance0_lux_table
in_illuminance0_target_input
in_intensity0_calibbias
in_intensity0_calibscale
in_intensity0_integration_time
in_intensity0_integration_time_available
in_intensity0_raw
in_intensity1_raw
in_proximity0_calibrate
in_proximity0_calibscale
in_proximity0_calibscale_available
in_proximity0_raw
name
of_node
power
subsystem
uevent

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 9991b0483956..eeccfbb0eb1f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -827,7 +827,7 @@ in_illuminance0_calibscale_available_show(struct device *dev,
 
 static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
 
-static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
+static IIO_CONST_ATTR(in_intensity0_integration_time_available,
 		".00272 - .696");
 
 static ssize_t in_illuminance0_target_input_show(struct device *dev,
@@ -1358,7 +1358,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
 	&dev_attr_in_illuminance0_calibscale_available.attr,
-	&iio_const_attr_in_illuminance0_integration_time_available
+	&iio_const_attr_in_intensity0_integration_time_available
 		.dev_attr.attr,
 	&dev_attr_in_illuminance0_target_input.attr,
 	&dev_attr_in_illuminance0_calibrate.attr,
@@ -1373,7 +1373,7 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
 	&dev_attr_in_illuminance0_calibscale_available.attr,
-	&iio_const_attr_in_illuminance0_integration_time_available
+	&iio_const_attr_in_intensity0_integration_time_available
 		.dev_attr.attr,
 	&dev_attr_in_illuminance0_target_input.attr,
 	&dev_attr_in_illuminance0_calibrate.attr,
@@ -1389,7 +1389,7 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
 	&dev_attr_in_illuminance0_calibscale_available.attr,
-	&iio_const_attr_in_illuminance0_integration_time_available
+	&iio_const_attr_in_intensity0_integration_time_available
 		.dev_attr.attr,
 	&dev_attr_in_illuminance0_target_input.attr,
 	&dev_attr_in_illuminance0_calibrate.attr,
@@ -1489,13 +1489,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
 			.type = IIO_LIGHT,
 			.indexed = 1,
 			.channel = 0,
-			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-					      BIT(IIO_CHAN_INFO_INT_TIME),
+			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
 			}, {
 			.type = IIO_INTENSITY,
 			.indexed = 1,
 			.channel = 0,
 			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_CALIBSCALE) |
 				BIT(IIO_CHAN_INFO_CALIBBIAS),
 			.event_spec = tsl2x7x_events,
@@ -1529,13 +1529,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
 			.type = IIO_LIGHT,
 			.indexed = 1,
 			.channel = 0,
-			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-					      BIT(IIO_CHAN_INFO_INT_TIME),
+			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
 			}, {
 			.type = IIO_INTENSITY,
 			.indexed = 1,
 			.channel = 0,
 			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_CALIBSCALE) |
 				BIT(IIO_CHAN_INFO_CALIBBIAS),
 			.event_spec = tsl2x7x_events,
@@ -1578,13 +1578,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
 			.type = IIO_LIGHT,
 			.indexed = 1,
 			.channel = 0,
-			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-					      BIT(IIO_CHAN_INFO_INT_TIME),
+			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
 			}, {
 			.type = IIO_INTENSITY,
 			.indexed = 1,
 			.channel = 0,
 			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_CALIBSCALE) |
 				BIT(IIO_CHAN_INFO_CALIBBIAS),
 			.event_spec = tsl2x7x_events,
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 01/13] staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The integration_time* attributes are currently associated with the
IIO_LIGHT channel but should be associated with the IIO_INTENSITY
channel. Directory listing of the sysfs attributes for a TSL2772
with this patch applied:

dev
events
in_illuminance0_calibrate
in_illuminance0_calibscale_available
in_illuminance0_input
in_illuminance0_lux_table
in_illuminance0_target_input
in_intensity0_calibbias
in_intensity0_calibscale
in_intensity0_integration_time
in_intensity0_integration_time_available
in_intensity0_raw
in_intensity1_raw
in_proximity0_calibrate
in_proximity0_calibscale
in_proximity0_calibscale_available
in_proximity0_raw
name
of_node
power
subsystem
uevent

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 9991b0483956..eeccfbb0eb1f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -827,7 +827,7 @@ in_illuminance0_calibscale_available_show(struct device *dev,
 
 static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
 
-static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
+static IIO_CONST_ATTR(in_intensity0_integration_time_available,
 		".00272 - .696");
 
 static ssize_t in_illuminance0_target_input_show(struct device *dev,
@@ -1358,7 +1358,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
 	&dev_attr_in_illuminance0_calibscale_available.attr,
-	&iio_const_attr_in_illuminance0_integration_time_available
+	&iio_const_attr_in_intensity0_integration_time_available
 		.dev_attr.attr,
 	&dev_attr_in_illuminance0_target_input.attr,
 	&dev_attr_in_illuminance0_calibrate.attr,
@@ -1373,7 +1373,7 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
 	&dev_attr_in_illuminance0_calibscale_available.attr,
-	&iio_const_attr_in_illuminance0_integration_time_available
+	&iio_const_attr_in_intensity0_integration_time_available
 		.dev_attr.attr,
 	&dev_attr_in_illuminance0_target_input.attr,
 	&dev_attr_in_illuminance0_calibrate.attr,
@@ -1389,7 +1389,7 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
 	&dev_attr_in_illuminance0_calibscale_available.attr,
-	&iio_const_attr_in_illuminance0_integration_time_available
+	&iio_const_attr_in_intensity0_integration_time_available
 		.dev_attr.attr,
 	&dev_attr_in_illuminance0_target_input.attr,
 	&dev_attr_in_illuminance0_calibrate.attr,
@@ -1489,13 +1489,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
 			.type = IIO_LIGHT,
 			.indexed = 1,
 			.channel = 0,
-			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-					      BIT(IIO_CHAN_INFO_INT_TIME),
+			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
 			}, {
 			.type = IIO_INTENSITY,
 			.indexed = 1,
 			.channel = 0,
 			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_CALIBSCALE) |
 				BIT(IIO_CHAN_INFO_CALIBBIAS),
 			.event_spec = tsl2x7x_events,
@@ -1529,13 +1529,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
 			.type = IIO_LIGHT,
 			.indexed = 1,
 			.channel = 0,
-			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-					      BIT(IIO_CHAN_INFO_INT_TIME),
+			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
 			}, {
 			.type = IIO_INTENSITY,
 			.indexed = 1,
 			.channel = 0,
 			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_CALIBSCALE) |
 				BIT(IIO_CHAN_INFO_CALIBBIAS),
 			.event_spec = tsl2x7x_events,
@@ -1578,13 +1578,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
 			.type = IIO_LIGHT,
 			.indexed = 1,
 			.channel = 0,
-			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-					      BIT(IIO_CHAN_INFO_INT_TIME),
+			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
 			}, {
 			.type = IIO_INTENSITY,
 			.indexed = 1,
 			.channel = 0,
 			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_CALIBSCALE) |
 				BIT(IIO_CHAN_INFO_CALIBBIAS),
 			.event_spec = tsl2x7x_events,
-- 
2.14.3


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

* [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

The summary text for the GPL is not needed since the SPDX identifier
is a legally binding shorthand that can be used instead.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 10 +---------
 drivers/staging/iio/light/tsl2x7x.h | 14 +-------------
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index eeccfbb0eb1f..9cdcc8c9e812 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -5,15 +5,7 @@
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
+ * SPDX-License-Identifier: GPL-2.0+
  */
 
 #include <linux/delay.h>
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index d382cdbb976e..992ee2465609 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -4,19 +4,7 @@
  *
  * Copyright (c) 2012, TAOS Corporation.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA	02110-1301, USA.
+ * SPDX-License-Identifier: GPL-2.0+
  */
 
 #ifndef __TSL2X7X_H
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The summary text for the GPL is not needed since the SPDX identifier
is a legally binding shorthand that can be used instead.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 10 +---------
 drivers/staging/iio/light/tsl2x7x.h | 14 +-------------
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index eeccfbb0eb1f..9cdcc8c9e812 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -5,15 +5,7 @@
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
+ * SPDX-License-Identifier: GPL-2.0+
  */
 
 #include <linux/delay.h>
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index d382cdbb976e..992ee2465609 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -4,19 +4,7 @@
  *
  * Copyright (c) 2012, TAOS Corporation.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA	02110-1301, USA.
+ * SPDX-License-Identifier: GPL-2.0+
  */
 
 #ifndef __TSL2X7X_H
-- 
2.14.3

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

* [PATCH 03/13] staging: iio: tsl2x7x: don't return error in IRQ handler
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

tsl2x7x_event_handler() could return an error and this could cause the
interrupt to remain masked. We shouldn't return an error in the
interrupt handler so this patch always returns IRQ_HANDLED. An error
will be logged if one occurs.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 9cdcc8c9e812..95a00b965c5e 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1320,7 +1320,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 
 	ret = tsl2x7x_read_status(chip);
 	if (ret < 0)
-		return ret;
+		return IRQ_HANDLED;
 
 	/* What type of interrupt do we need to process */
 	if (ret & TSL2X7X_STA_PRX_INTR) {
@@ -1341,9 +1341,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 			       timestamp);
 	}
 
-	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
-	if (ret < 0)
-		return ret;
+	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
 
 	return IRQ_HANDLED;
 }
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 03/13] staging: iio: tsl2x7x: don't return error in IRQ handler
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

tsl2x7x_event_handler() could return an error and this could cause the
interrupt to remain masked. We shouldn't return an error in the
interrupt handler so this patch always returns IRQ_HANDLED. An error
will be logged if one occurs.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 9cdcc8c9e812..95a00b965c5e 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1320,7 +1320,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 
 	ret = tsl2x7x_read_status(chip);
 	if (ret < 0)
-		return ret;
+		return IRQ_HANDLED;
 
 	/* What type of interrupt do we need to process */
 	if (ret & TSL2X7X_STA_PRX_INTR) {
@@ -1341,9 +1341,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 			       timestamp);
 	}
 
-	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
-	if (ret < 0)
-		return ret;
+	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
 
 	return IRQ_HANDLED;
 }
-- 
2.14.3


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

* [PATCH 04/13] staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

tsl2x7x_clear_interrupts() takes a reg argument but there are only
two callers to this function and both callers pass the same value.
Since this function was introduced, interrupts are now working
properly for this driver, and several unnecessary calls to
tsl2x7x_clear_interrupts() were removed. This patch removes the
tsl2x7x_clear_interrupts() function and replaces the two callers
with the i2c_smbus_write_byte() call instead.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 95a00b965c5e..f37fc74b8fbc 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -271,20 +271,6 @@ static const u8 device_channel_config[] = {
 	ALSPRX2
 };
 
-static int tsl2x7x_clear_interrupts(struct tsl2X7X_chip *chip, int reg)
-{
-	int ret;
-
-	ret = i2c_smbus_write_byte(chip->client,
-				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | reg);
-	if (ret < 0)
-		dev_err(&chip->client->dev,
-			"%s: failed to clear interrupt status %x: %d\n",
-			__func__, reg, ret);
-
-	return ret;
-}
-
 static int tsl2x7x_read_status(struct tsl2X7X_chip *chip)
 {
 	int ret;
@@ -714,9 +700,15 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	if (ret < 0)
 		return ret;
 
-	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
-	if (ret < 0)
+	ret = i2c_smbus_write_byte(chip->client,
+				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+				   TSL2X7X_CMD_PROXALS_INT_CLR);
+	if (ret < 0) {
+		dev_err(&chip->client->dev,
+			"%s: failed to clear interrupt status: %d\n",
+			__func__, ret);
 		return ret;
+	}
 
 	chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
 
@@ -1341,7 +1333,13 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 			       timestamp);
 	}
 
-	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
+	ret = i2c_smbus_write_byte(chip->client,
+				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+				   TSL2X7X_CMD_PROXALS_INT_CLR);
+	if (ret < 0)
+		dev_err(&chip->client->dev,
+			"%s: failed to clear interrupt status: %d\n",
+			__func__, ret);
 
 	return IRQ_HANDLED;
 }
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 04/13] staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

tsl2x7x_clear_interrupts() takes a reg argument but there are only
two callers to this function and both callers pass the same value.
Since this function was introduced, interrupts are now working
properly for this driver, and several unnecessary calls to
tsl2x7x_clear_interrupts() were removed. This patch removes the
tsl2x7x_clear_interrupts() function and replaces the two callers
with the i2c_smbus_write_byte() call instead.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 95a00b965c5e..f37fc74b8fbc 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -271,20 +271,6 @@ static const u8 device_channel_config[] = {
 	ALSPRX2
 };
 
-static int tsl2x7x_clear_interrupts(struct tsl2X7X_chip *chip, int reg)
-{
-	int ret;
-
-	ret = i2c_smbus_write_byte(chip->client,
-				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | reg);
-	if (ret < 0)
-		dev_err(&chip->client->dev,
-			"%s: failed to clear interrupt status %x: %d\n",
-			__func__, reg, ret);
-
-	return ret;
-}
-
 static int tsl2x7x_read_status(struct tsl2X7X_chip *chip)
 {
 	int ret;
@@ -714,9 +700,15 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	if (ret < 0)
 		return ret;
 
-	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
-	if (ret < 0)
+	ret = i2c_smbus_write_byte(chip->client,
+				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+				   TSL2X7X_CMD_PROXALS_INT_CLR);
+	if (ret < 0) {
+		dev_err(&chip->client->dev,
+			"%s: failed to clear interrupt status: %d\n",
+			__func__, ret);
 		return ret;
+	}
 
 	chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
 
@@ -1341,7 +1333,13 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
 			       timestamp);
 	}
 
-	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
+	ret = i2c_smbus_write_byte(chip->client,
+				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+				   TSL2X7X_CMD_PROXALS_INT_CLR);
+	if (ret < 0)
+		dev_err(&chip->client->dev,
+			"%s: failed to clear interrupt status: %d\n",
+			__func__, ret);
 
 	return IRQ_HANDLED;
 }
-- 
2.14.3


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

* [PATCH 05/13] staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

tsl2x7x_suspend() and tsl2x7x_resume() both check to see what the
current chip status is. These checks are not necessary so this patch
removes those checks.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index f37fc74b8fbc..8d8af0cf9768 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1682,27 +1682,15 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 static int tsl2x7x_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
-	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret = 0;
-
-	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
-		ret = tsl2x7x_chip_off(indio_dev);
-		chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
-	}
 
-	return ret;
+	return tsl2x7x_chip_off(indio_dev);
 }
 
 static int tsl2x7x_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
-	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret = 0;
 
-	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_SUSPENDED)
-		ret = tsl2x7x_chip_on(indio_dev);
-
-	return ret;
+	return tsl2x7x_chip_on(indio_dev);
 }
 
 static int tsl2x7x_remove(struct i2c_client *client)
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 05/13] staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

tsl2x7x_suspend() and tsl2x7x_resume() both check to see what the
current chip status is. These checks are not necessary so this patch
removes those checks.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index f37fc74b8fbc..8d8af0cf9768 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1682,27 +1682,15 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 static int tsl2x7x_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
-	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret = 0;
-
-	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
-		ret = tsl2x7x_chip_off(indio_dev);
-		chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
-	}
 
-	return ret;
+	return tsl2x7x_chip_off(indio_dev);
 }
 
 static int tsl2x7x_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
-	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret = 0;
 
-	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_SUSPENDED)
-		ret = tsl2x7x_chip_on(indio_dev);
-
-	return ret;
+	return tsl2x7x_chip_on(indio_dev);
 }
 
 static int tsl2x7x_remove(struct i2c_client *client)
-- 
2.14.3


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

* [PATCH 06/13] staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

tsl2x7x_write_interrupt_config() has an unnecessary return value check
at the end of the function. This patch changes the function to just
return the value from the call to tsl2x7x_invoke_change().

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 8d8af0cf9768..d202bc7e1f4f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -982,18 +982,13 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
 					  int val)
 {
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret;
 
 	if (chan->type == IIO_INTENSITY)
 		chip->settings.als_interrupt_en = val ? true : false;
 	else
 		chip->settings.prox_interrupt_en = val ? true : false;
 
-	ret = tsl2x7x_invoke_change(indio_dev);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return tsl2x7x_invoke_change(indio_dev);
 }
 
 static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 06/13] staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

tsl2x7x_write_interrupt_config() has an unnecessary return value check
at the end of the function. This patch changes the function to just
return the value from the call to tsl2x7x_invoke_change().

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 8d8af0cf9768..d202bc7e1f4f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -982,18 +982,13 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
 					  int val)
 {
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-	int ret;
 
 	if (chan->type == IIO_INTENSITY)
 		chip->settings.als_interrupt_en = val ? true : false;
 	else
 		chip->settings.prox_interrupt_en = val ? true : false;
 
-	ret = tsl2x7x_invoke_change(indio_dev);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return tsl2x7x_invoke_change(indio_dev);
 }
 
 static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
-- 
2.14.3

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

* [PATCH 07/13] staging: iio: tsl2x7x: simplify device id verification
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

This patch renames tsl2x7x_device_id() to tsl2x7x_device_id_verif(),
removes the unnecessary pointer on the id parameter, and only calls
the verification function once.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index d202bc7e1f4f..56730baea927 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1277,22 +1277,22 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
 static DEVICE_ATTR_RW(in_illuminance0_lux_table);
 
 /* Use the default register values to identify the Taos device */
-static int tsl2x7x_device_id(int *id, int target)
+static int tsl2x7x_device_id_verif(int id, int target)
 {
 	switch (target) {
 	case tsl2571:
 	case tsl2671:
 	case tsl2771:
-		return (*id & 0xf0) == TRITON_ID;
+		return (id & 0xf0) == TRITON_ID;
 	case tmd2671:
 	case tmd2771:
-		return (*id & 0xf0) == HALIBUT_ID;
+		return (id & 0xf0) == HALIBUT_ID;
 	case tsl2572:
 	case tsl2672:
 	case tmd2672:
 	case tsl2772:
 	case tmd2772:
-		return (*id & 0xf0) == SWORDFISH_ID;
+		return (id & 0xf0) == SWORDFISH_ID;
 	}
 
 	return -EINVAL;
@@ -1612,8 +1612,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 	if (ret < 0)
 		return ret;
 
-	if ((!tsl2x7x_device_id(&ret, id->driver_data)) ||
-	    (tsl2x7x_device_id(&ret, id->driver_data) == -EINVAL)) {
+	if (tsl2x7x_device_id_verif(ret, id->driver_data) <= 0) {
 		dev_info(&chip->client->dev,
 			 "%s: i2c device found does not match expected id\n",
 				__func__);
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 07/13] staging: iio: tsl2x7x: simplify device id verification
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

This patch renames tsl2x7x_device_id() to tsl2x7x_device_id_verif(),
removes the unnecessary pointer on the id parameter, and only calls
the verification function once.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index d202bc7e1f4f..56730baea927 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1277,22 +1277,22 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
 static DEVICE_ATTR_RW(in_illuminance0_lux_table);
 
 /* Use the default register values to identify the Taos device */
-static int tsl2x7x_device_id(int *id, int target)
+static int tsl2x7x_device_id_verif(int id, int target)
 {
 	switch (target) {
 	case tsl2571:
 	case tsl2671:
 	case tsl2771:
-		return (*id & 0xf0) == TRITON_ID;
+		return (id & 0xf0) == TRITON_ID;
 	case tmd2671:
 	case tmd2771:
-		return (*id & 0xf0) == HALIBUT_ID;
+		return (id & 0xf0) == HALIBUT_ID;
 	case tsl2572:
 	case tsl2672:
 	case tmd2672:
 	case tsl2772:
 	case tmd2772:
-		return (*id & 0xf0) == SWORDFISH_ID;
+		return (id & 0xf0) == SWORDFISH_ID;
 	}
 
 	return -EINVAL;
@@ -1612,8 +1612,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 	if (ret < 0)
 		return ret;
 
-	if ((!tsl2x7x_device_id(&ret, id->driver_data)) ||
-	    (tsl2x7x_device_id(&ret, id->driver_data) == -EINVAL)) {
+	if (tsl2x7x_device_id_verif(ret, id->driver_data) <= 0) {
 		dev_info(&chip->client->dev,
 			 "%s: i2c device found does not match expected id\n",
 				__func__);
-- 
2.14.3

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

* [PATCH 08/13] staging: iio: tsl2x7x: add range checking to three sysfs attributes
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

The sysfs attributes in_illuminance0_target_input,
in_illuminance0_calibrate, and in_proximity0_calibrate did not have
proper range checking in place so this patch adds the correct range
checks.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 56730baea927..15bc0af1bb6c 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -835,9 +835,10 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
 	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
-	if (value)
-		chip->settings.als_cal_target = value;
+	if (value < 0 || value > 65535)
+		return -ERANGE;
 
+	chip->settings.als_cal_target = value;
 	ret = tsl2x7x_invoke_change(indio_dev);
 	if (ret < 0)
 		return ret;
@@ -853,14 +854,12 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
 	bool value;
 	int ret;
 
-	if (strtobool(buf, &value))
+	if (kstrtobool(buf, &value) || !value)
 		return -EINVAL;
 
-	if (value) {
-		ret = tsl2x7x_als_calibrate(indio_dev);
-		if (ret < 0)
-			return ret;
-	}
+	ret = tsl2x7x_als_calibrate(indio_dev);
+	if (ret < 0)
+		return ret;
 
 	ret = tsl2x7x_invoke_change(indio_dev);
 	if (ret < 0)
@@ -946,14 +945,12 @@ static ssize_t in_proximity0_calibrate_store(struct device *dev,
 	bool value;
 	int ret;
 
-	if (strtobool(buf, &value))
+	if (kstrtobool(buf, &value) || !value)
 		return -EINVAL;
 
-	if (value) {
-		ret = tsl2x7x_prox_cal(indio_dev);
-		if (ret < 0)
-			return ret;
-	}
+	ret = tsl2x7x_prox_cal(indio_dev);
+	if (ret < 0)
+		return ret;
 
 	ret = tsl2x7x_invoke_change(indio_dev);
 	if (ret < 0)
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 08/13] staging: iio: tsl2x7x: add range checking to three sysfs attributes
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The sysfs attributes in_illuminance0_target_input,
in_illuminance0_calibrate, and in_proximity0_calibrate did not have
proper range checking in place so this patch adds the correct range
checks.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 56730baea927..15bc0af1bb6c 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -835,9 +835,10 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
 	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
-	if (value)
-		chip->settings.als_cal_target = value;
+	if (value < 0 || value > 65535)
+		return -ERANGE;
 
+	chip->settings.als_cal_target = value;
 	ret = tsl2x7x_invoke_change(indio_dev);
 	if (ret < 0)
 		return ret;
@@ -853,14 +854,12 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
 	bool value;
 	int ret;
 
-	if (strtobool(buf, &value))
+	if (kstrtobool(buf, &value) || !value)
 		return -EINVAL;
 
-	if (value) {
-		ret = tsl2x7x_als_calibrate(indio_dev);
-		if (ret < 0)
-			return ret;
-	}
+	ret = tsl2x7x_als_calibrate(indio_dev);
+	if (ret < 0)
+		return ret;
 
 	ret = tsl2x7x_invoke_change(indio_dev);
 	if (ret < 0)
@@ -946,14 +945,12 @@ static ssize_t in_proximity0_calibrate_store(struct device *dev,
 	bool value;
 	int ret;
 
-	if (strtobool(buf, &value))
+	if (kstrtobool(buf, &value) || !value)
 		return -EINVAL;
 
-	if (value) {
-		ret = tsl2x7x_prox_cal(indio_dev);
-		if (ret < 0)
-			return ret;
-	}
+	ret = tsl2x7x_prox_cal(indio_dev);
+	if (ret < 0)
+		return ret;
 
 	ret = tsl2x7x_invoke_change(indio_dev);
 	if (ret < 0)
-- 
2.14.3

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

* [PATCH 09/13] staging: iio: tsl2x7x: move power and diode settings into header file
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

The power and diode defines are needed for the platform data so this
patch moves the defines out of the .c file and into the header file. A
comment for the diode is also cleaned up while this code is touched.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 15bc0af1bb6c..87b99deef7a8 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -103,18 +103,6 @@
 #define TSL2X7X_CNTL_PROXPON_ENBL	0x0F
 #define TSL2X7X_CNTL_INTPROXPON_ENBL	0x2F
 
-/*Prox diode to use */
-#define TSL2X7X_DIODE0			0x01
-#define TSL2X7X_DIODE1			0x02
-#define TSL2X7X_DIODE_BOTH		0x03
-
-/* LED Power */
-#define TSL2X7X_100_mA			0x00
-#define TSL2X7X_50_mA			0x01
-#define TSL2X7X_25_mA			0x02
-#define TSL2X7X_13_mA			0x03
-#define TSL2X7X_MAX_TIMER_CNT		0xFF
-
 #define TSL2X7X_MIN_ITIME		3
 
 /* TAOS txx2x7x Device family members */
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 992ee2465609..2c96f0b39b1e 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -23,6 +23,18 @@ struct tsl2x7x_lux {
 #define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
 				     TSL2X7X_DEF_LUX_TABLE_SZ)
 
+/* Proximity diode to use */
+#define TSL2X7X_DIODE0                  0x01
+#define TSL2X7X_DIODE1                  0x02
+#define TSL2X7X_DIODE_BOTH              0x03
+
+/* LED Power */
+#define TSL2X7X_100_mA                  0x00
+#define TSL2X7X_50_mA                   0x01
+#define TSL2X7X_25_mA                   0x02
+#define TSL2X7X_13_mA                   0x03
+#define TSL2X7X_MAX_TIMER_CNT           0xFF
+
 /**
  * struct tsl2x7x_default_settings - power on defaults unless
  *                                   overridden by platform data.
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 09/13] staging: iio: tsl2x7x: move power and diode settings into header file
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The power and diode defines are needed for the platform data so this
patch moves the defines out of the .c file and into the header file. A
comment for the diode is also cleaned up while this code is touched.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 15bc0af1bb6c..87b99deef7a8 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -103,18 +103,6 @@
 #define TSL2X7X_CNTL_PROXPON_ENBL	0x0F
 #define TSL2X7X_CNTL_INTPROXPON_ENBL	0x2F
 
-/*Prox diode to use */
-#define TSL2X7X_DIODE0			0x01
-#define TSL2X7X_DIODE1			0x02
-#define TSL2X7X_DIODE_BOTH		0x03
-
-/* LED Power */
-#define TSL2X7X_100_mA			0x00
-#define TSL2X7X_50_mA			0x01
-#define TSL2X7X_25_mA			0x02
-#define TSL2X7X_13_mA			0x03
-#define TSL2X7X_MAX_TIMER_CNT		0xFF
-
 #define TSL2X7X_MIN_ITIME		3
 
 /* TAOS txx2x7x Device family members */
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 992ee2465609..2c96f0b39b1e 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -23,6 +23,18 @@ struct tsl2x7x_lux {
 #define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
 				     TSL2X7X_DEF_LUX_TABLE_SZ)
 
+/* Proximity diode to use */
+#define TSL2X7X_DIODE0                  0x01
+#define TSL2X7X_DIODE1                  0x02
+#define TSL2X7X_DIODE_BOTH              0x03
+
+/* LED Power */
+#define TSL2X7X_100_mA                  0x00
+#define TSL2X7X_50_mA                   0x01
+#define TSL2X7X_25_mA                   0x02
+#define TSL2X7X_13_mA                   0x03
+#define TSL2X7X_MAX_TIMER_CNT           0xFF
+
 /**
  * struct tsl2x7x_default_settings - power on defaults unless
  *                                   overridden by platform data.
-- 
2.14.3


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

* [PATCH 10/13] staging: iio: tsl2x7x: rename prx to prox for consistency
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

The driver mostly uses the 'prox' naming convention for most of the
proximity settings, however prx_time and tsl2x7x_prx_gain was present.
This patch renames these to prox_time and tsl2x7x_prox_gain for
consistency with everything else in the driver.

The kernel documentation for prx_gain is corrected to prox_gain so that
it matches what is actually in the structure.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 12 ++++++------
 drivers/staging/iio/light/tsl2x7x.h |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 87b99deef7a8..a7b4fcba7935 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -203,7 +203,7 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
 static const struct tsl2x7x_settings tsl2x7x_default_settings = {
 	.als_time = 219, /* 101 ms */
 	.als_gain = 0,
-	.prx_time = 254, /* 5.4 ms */
+	.prox_time = 254, /* 5.4 ms */
 	.prox_gain = 0,
 	.wait_time = 245,
 	.prox_config = 0,
@@ -230,7 +230,7 @@ static const s16 tsl2x7x_als_gain[] = {
 	120
 };
 
-static const s16 tsl2x7x_prx_gain[] = {
+static const s16 tsl2x7x_prox_gain[] = {
 	1,
 	2,
 	4,
@@ -594,7 +594,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	u8 *dev_reg, reg_val;
 
 	/* Non calculated parameters */
-	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time;
+	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
 	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
 	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
 
@@ -1021,7 +1021,7 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
 		if (chan->type == IIO_INTENSITY)
 			time = chip->settings.als_time;
 		else
-			time = chip->settings.prx_time;
+			time = chip->settings.prox_time;
 
 		y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
 		z = y * TSL2X7X_MIN_ITIME;
@@ -1090,7 +1090,7 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
 			time = chip->settings.als_time;
 			mult = chip->settings.als_persistence;
 		} else {
-			time = chip->settings.prx_time;
+			time = chip->settings.prox_time;
 			mult = chip->settings.prox_persistence;
 		}
 
@@ -1153,7 +1153,7 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
 		if (chan->type == IIO_LIGHT)
 			*val = tsl2x7x_als_gain[chip->settings.als_gain];
 		else
-			*val = tsl2x7x_prx_gain[chip->settings.prox_gain];
+			*val = tsl2x7x_prox_gain[chip->settings.prox_gain];
 		ret = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_CALIBBIAS:
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 2c96f0b39b1e..408e5a89edb1 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -44,9 +44,9 @@ struct tsl2x7x_lux {
  *                          aperture effects.
  *  @wait_time:             Time between PRX and ALS cycles
  *                          in 2.7 periods
- *  @prx_time:              5.2ms prox integration time -
+ *  @prox_time:             5.2ms prox integration time -
  *                          decrease in 2.7ms periods
- *  @prx_gain:              Proximity gain index
+ *  @prox_gain:             Proximity gain index
  *  @prox_config:           Prox configuration filters.
  *  @als_cal_target:        Known external ALS reading for
  *                          calibration.
@@ -68,7 +68,7 @@ struct tsl2x7x_settings {
 	int als_gain;
 	int als_gain_trim;
 	int wait_time;
-	int prx_time;
+	int prox_time;
 	int prox_gain;
 	int prox_config;
 	int als_cal_target;
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 10/13] staging: iio: tsl2x7x: rename prx to prox for consistency
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The driver mostly uses the 'prox' naming convention for most of the
proximity settings, however prx_time and tsl2x7x_prx_gain was present.
This patch renames these to prox_time and tsl2x7x_prox_gain for
consistency with everything else in the driver.

The kernel documentation for prx_gain is corrected to prox_gain so that
it matches what is actually in the structure.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 12 ++++++------
 drivers/staging/iio/light/tsl2x7x.h |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 87b99deef7a8..a7b4fcba7935 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -203,7 +203,7 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
 static const struct tsl2x7x_settings tsl2x7x_default_settings = {
 	.als_time = 219, /* 101 ms */
 	.als_gain = 0,
-	.prx_time = 254, /* 5.4 ms */
+	.prox_time = 254, /* 5.4 ms */
 	.prox_gain = 0,
 	.wait_time = 245,
 	.prox_config = 0,
@@ -230,7 +230,7 @@ static const s16 tsl2x7x_als_gain[] = {
 	120
 };
 
-static const s16 tsl2x7x_prx_gain[] = {
+static const s16 tsl2x7x_prox_gain[] = {
 	1,
 	2,
 	4,
@@ -594,7 +594,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	u8 *dev_reg, reg_val;
 
 	/* Non calculated parameters */
-	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time;
+	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
 	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
 	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
 
@@ -1021,7 +1021,7 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
 		if (chan->type == IIO_INTENSITY)
 			time = chip->settings.als_time;
 		else
-			time = chip->settings.prx_time;
+			time = chip->settings.prox_time;
 
 		y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
 		z = y * TSL2X7X_MIN_ITIME;
@@ -1090,7 +1090,7 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
 			time = chip->settings.als_time;
 			mult = chip->settings.als_persistence;
 		} else {
-			time = chip->settings.prx_time;
+			time = chip->settings.prox_time;
 			mult = chip->settings.prox_persistence;
 		}
 
@@ -1153,7 +1153,7 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
 		if (chan->type == IIO_LIGHT)
 			*val = tsl2x7x_als_gain[chip->settings.als_gain];
 		else
-			*val = tsl2x7x_prx_gain[chip->settings.prox_gain];
+			*val = tsl2x7x_prox_gain[chip->settings.prox_gain];
 		ret = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_CALIBBIAS:
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 2c96f0b39b1e..408e5a89edb1 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -44,9 +44,9 @@ struct tsl2x7x_lux {
  *                          aperture effects.
  *  @wait_time:             Time between PRX and ALS cycles
  *                          in 2.7 periods
- *  @prx_time:              5.2ms prox integration time -
+ *  @prox_time:             5.2ms prox integration time -
  *                          decrease in 2.7ms periods
- *  @prx_gain:              Proximity gain index
+ *  @prox_gain:             Proximity gain index
  *  @prox_config:           Prox configuration filters.
  *  @als_cal_target:        Known external ALS reading for
  *                          calibration.
@@ -68,7 +68,7 @@ struct tsl2x7x_settings {
 	int als_gain;
 	int als_gain_trim;
 	int wait_time;
-	int prx_time;
+	int prox_time;
 	int prox_gain;
 	int prox_config;
 	int als_cal_target;
-- 
2.14.3

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

* [PATCH 11/13] staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

This patch changes the defaults of the als_time, prox_time and
wait_time to match the defaults according to the TSL2772 datasheet.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index a7b4fcba7935..293810ff11b9 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -201,11 +201,11 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
 };
 
 static const struct tsl2x7x_settings tsl2x7x_default_settings = {
-	.als_time = 219, /* 101 ms */
+	.als_time = 255, /* 2.73 ms */
 	.als_gain = 0,
-	.prox_time = 254, /* 5.4 ms */
+	.prox_time = 255, /* 2.73 ms */
 	.prox_gain = 0,
-	.wait_time = 245,
+	.wait_time = 255,
 	.prox_config = 0,
 	.als_gain_trim = 1000,
 	.als_cal_target = 150,
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 11/13] staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

This patch changes the defaults of the als_time, prox_time and
wait_time to match the defaults according to the TSL2772 datasheet.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index a7b4fcba7935..293810ff11b9 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -201,11 +201,11 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
 };
 
 static const struct tsl2x7x_settings tsl2x7x_default_settings = {
-	.als_time = 219, /* 101 ms */
+	.als_time = 255, /* 2.73 ms */
 	.als_gain = 0,
-	.prox_time = 254, /* 5.4 ms */
+	.prox_time = 255, /* 2.73 ms */
 	.prox_gain = 0,
-	.wait_time = 245,
+	.wait_time = 255,
 	.prox_config = 0,
 	.als_gain_trim = 1000,
 	.als_cal_target = 150,
-- 
2.14.3


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

* [PATCH 12/13] staging: iio: tsl2x7x: various comment cleanups
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

This patch removes several unnecessary comments, changes some comments
so that the use as much of the allowable 80 characters as possible, adds
the proper whitespace, removes some structure members from the kernel
docs that are no longer present, and improves the existing kernel doc
information for some existing structure members.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 59 +++++++++++++++++--------------------
 drivers/staging/iio/light/tsl2x7x.h | 48 +++++++++++++++---------------
 2 files changed, 51 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 293810ff11b9..05c0f3d5fac0 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1,6 +1,6 @@
 /*
- * Device driver for monitoring ambient light intensity in (lux)
- * and proximity detection (prox) within the TAOS TSL2X7X family of devices.
+ * Device driver for monitoring ambient light intensity in (lux) and proximity
+ * detection (prox) within the TAOS TSL2X7X family of devices.
  *
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
@@ -21,7 +21,7 @@
 #include <linux/iio/sysfs.h>
 #include "tsl2x7x.h"
 
-/* Cal defs*/
+/* Cal defs */
 #define PROX_STAT_CAL			0
 #define PROX_STAT_SAMP			1
 #define MAX_SAMPLES_CAL			200
@@ -34,10 +34,11 @@
 /* Lux calculation constants */
 #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.
+/*
+ * 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
 
@@ -342,15 +343,14 @@ static int tsl2x7x_read_autoinc_regs(struct tsl2X7X_chip *chip, int lower_reg,
  * @indio_dev:	pointer to IIO device
  *
  * The raw ch0 and ch1 values of the ambient light sensed in the last
- * integration cycle are read from the device.
- * Time scale factor array values are adjusted based on the integration time.
- * The raw values are multiplied by a scale factor, and device gain is obtained
- * using gain index. Limit checks are done next, then the ratio of a multiple
- * of ch1 value, to the ch0 value, is calculated. Array tsl2x7x_device_lux[]
- * is then scanned to find the first ratio value that is just above the ratio
- * we just calculated. The ch0 and ch1 multiplier constants in the array are
- * then used along with the time scale factor array values, to calculate the
- * lux.
+ * integration cycle are read from the device. Time scale factor array values
+ * are adjusted based on the integration time. The raw values are multiplied
+ * by a scale factor, and device gain is obtained using gain index. Limit
+ * checks are done next, then the ratio of a multiple of ch1 value, to the
+ * ch0 value, is calculated. Array tsl2x7x_device_lux[] is then scanned to
+ * find the first ratio value that is just above the ratio we just calculated.
+ * The ch0 and ch1 multiplier constants in the array are then used along with
+ * the time scale factor array values, to calculate the lux.
  */
 static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 {
@@ -363,7 +363,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	mutex_lock(&chip->als_mutex);
 
 	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
-		/* device is not enabled */
 		dev_err(&chip->client->dev, "%s: device is not enabled\n",
 			__func__);
 		ret = -EBUSY;
@@ -374,7 +373,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	if (ret < 0)
 		goto out_unlock;
 
-	/* is data new & valid */
 	if (!(ret & TSL2X7X_STA_ADC_VALID)) {
 		dev_err(&chip->client->dev,
 			"%s: data not valid yet\n", __func__);
@@ -430,12 +428,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 		lux = (lux + (chip->als_time_scale >> 1)) /
 			chip->als_time_scale;
 
-	/* adjust for active gain scale
-	 * The tsl2x7x_device_lux tables have a factor of 256 built-in.
-	 * User-specified gain provides a multiplier.
+	/*
+	 * adjust for active gain scale. The tsl2x7x_device_lux tables have a
+	 * factor of 256 built-in. User-specified gain provides a multiplier.
 	 * Apply user-specified gain before shifting right to retain precision.
-	 * Use 64 bits to avoid overflow on multiplication.
-	 * Then go back to 32 bits before division to avoid using div_u64().
+	 * Use 64 bits to avoid overflow on multiplication. Then go back to
+	 * 32 bits before division to avoid using div_u64().
 	 */
 
 	lux64 = lux;
@@ -713,14 +711,13 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
 }
 
 /**
- * tsl2x7x_invoke_change
+ * tsl2x7x_invoke_change - power cycle the device to implement the user
+ *                         parameters
  * @indio_dev:	pointer to IIO device
  *
- * Obtain and lock both ALS and PROX resources,
- * determine and save device state (On/Off),
- * cycle device to implement updated parameter,
- * put device back into proper state, and unlock
- * resource.
+ * Obtain and lock both ALS and PROX resources, determine and save device state
+ * (On/Off), cycle device to implement updated parameter, put device back into
+ * proper state, and unlock resource.
  */
 static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
 {
@@ -895,7 +892,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev,
 
 	get_options(buf, ARRAY_SIZE(value), value);
 
-	/* We now have an array of ints starting at value[1], and
+	/*
+	 * We now have an array of ints starting at value[1], and
 	 * enumerated by value[0].
 	 * We expect each group of three ints is one table entry,
 	 * and the last table entry is all 0.
@@ -1643,9 +1641,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 		}
 	}
 
-	/* Load up the defaults */
 	tsl2x7x_defaults(chip);
-	/* Make sure the chip is on */
 	tsl2x7x_chip_on(indio_dev);
 
 	ret = iio_device_register(indio_dev);
@@ -1719,7 +1715,6 @@ static const struct dev_pm_ops tsl2x7x_pm_ops = {
 	.resume  = tsl2x7x_resume,
 };
 
-/* Driver definition */
 static struct i2c_driver tsl2x7x_driver = {
 	.driver = {
 		.name = "tsl2x7x",
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 408e5a89edb1..85d8fe7a94c8 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -36,32 +36,35 @@ struct tsl2x7x_lux {
 #define TSL2X7X_MAX_TIMER_CNT           0xFF
 
 /**
- * struct tsl2x7x_default_settings - power on defaults unless
- *                                   overridden by platform data.
- *  @als_time:              ALS Integration time - multiple of 50mS
- *  @als_gain:              Index into the ALS gain table.
- *  @als_gain_trim:         default gain trim to account for
- *                          aperture effects.
- *  @wait_time:             Time between PRX and ALS cycles
- *                          in 2.7 periods
- *  @prox_time:             5.2ms prox integration time -
- *                          decrease in 2.7ms periods
- *  @prox_gain:             Proximity gain index
+ * struct tsl2x7x_settings - Settings for the tsl2x7x driver
+ *  @als_time:              Integration time of the ALS channel ADCs in 2.73 ms
+ *                          increments. Total integration time is
+ *                          (256 - als_time) * 2.73.
+ *  @als_gain:              Index into the tsl2x7x_als_gain array.
+ *  @als_gain_trim:         Default gain trim to account for aperture effects.
+ *  @wait_time:             Time between proximity and ALS cycles in 2.73
+ *                          periods.
+ *  @prox_time:             Integration time of the proximity ADC in 2.73 ms
+ *                          increments. Total integration time is
+ *                          (256 - prx_time) * 2.73.
+ *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
  *  @prox_config:           Prox configuration filters.
- *  @als_cal_target:        Known external ALS reading for
- *                          calibration.
- *  @als_persistence:       H/W Filters, Number of 'out of limits'
- *                          ALS readings.
+ *  @als_cal_target:        Known external ALS reading for calibration.
+ *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
  *  @als_interrupt_en:      Enable/Disable ALS interrupts
  *  @als_thresh_low:        CH0 'low' count to trigger interrupt.
  *  @als_thresh_high:       CH0 'high' count to trigger interrupt.
- *  @prox_persistence:      H/W Filters, Number of 'out of limits'
- *                          proximity readings.
- *  @prox_interrupt_en:     Enable/Disable proximity interrupts
+ *  @prox_persistence:      H/W Filters, Number of 'out of limits' proximity
+ *                          readings.
+ *  @prox_interrupt_en:     Enable/Disable proximity interrupts.
  *  @prox_thres_low:        Low threshold proximity detection.
- *  @prox_thres_high:       High threshold proximity detection
- *  @prox_pulse_count:      Number if proximity emitter pulses
- *  @prox_max_samples_cal:  Used for prox cal.
+ *  @prox_thres_high:       High threshold proximity detection.
+ *  @prox_pulse_count:      Number if proximity emitter pulses.
+ *  @prox_max_samples_cal:  The number of samples that are taken when performing
+ *                          a proximity calibration.
+ *  @prox_diode             Which diode(s) to use for driving the external
+ *                          LED(s) for proximity sensing.
+ *  @prox_power             The amount of power to use for the external LED(s).
  */
 struct tsl2x7x_settings {
 	int als_time;
@@ -88,9 +91,6 @@ struct tsl2x7x_settings {
 
 /**
  * struct tsl2X7X_platform_data - Platform callback, glass and defaults
- * @platform_power:            Suspend/resume platform callback
- * @power_on:                  Power on callback
- * @power_off:                 Power off callback
  * @platform_lux_table:        Device specific glass coefficents
  * @platform_default_settings: Device specific power on defaults
  *
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 12/13] staging: iio: tsl2x7x: various comment cleanups
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

This patch removes several unnecessary comments, changes some comments
so that the use as much of the allowable 80 characters as possible, adds
the proper whitespace, removes some structure members from the kernel
docs that are no longer present, and improves the existing kernel doc
information for some existing structure members.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2x7x.c | 59 +++++++++++++++++--------------------
 drivers/staging/iio/light/tsl2x7x.h | 48 +++++++++++++++---------------
 2 files changed, 51 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 293810ff11b9..05c0f3d5fac0 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1,6 +1,6 @@
 /*
- * Device driver for monitoring ambient light intensity in (lux)
- * and proximity detection (prox) within the TAOS TSL2X7X family of devices.
+ * Device driver for monitoring ambient light intensity in (lux) and proximity
+ * detection (prox) within the TAOS TSL2X7X family of devices.
  *
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
@@ -21,7 +21,7 @@
 #include <linux/iio/sysfs.h>
 #include "tsl2x7x.h"
 
-/* Cal defs*/
+/* Cal defs */
 #define PROX_STAT_CAL			0
 #define PROX_STAT_SAMP			1
 #define MAX_SAMPLES_CAL			200
@@ -34,10 +34,11 @@
 /* Lux calculation constants */
 #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.
+/*
+ * 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
 
@@ -342,15 +343,14 @@ static int tsl2x7x_read_autoinc_regs(struct tsl2X7X_chip *chip, int lower_reg,
  * @indio_dev:	pointer to IIO device
  *
  * The raw ch0 and ch1 values of the ambient light sensed in the last
- * integration cycle are read from the device.
- * Time scale factor array values are adjusted based on the integration time.
- * The raw values are multiplied by a scale factor, and device gain is obtained
- * using gain index. Limit checks are done next, then the ratio of a multiple
- * of ch1 value, to the ch0 value, is calculated. Array tsl2x7x_device_lux[]
- * is then scanned to find the first ratio value that is just above the ratio
- * we just calculated. The ch0 and ch1 multiplier constants in the array are
- * then used along with the time scale factor array values, to calculate the
- * lux.
+ * integration cycle are read from the device. Time scale factor array values
+ * are adjusted based on the integration time. The raw values are multiplied
+ * by a scale factor, and device gain is obtained using gain index. Limit
+ * checks are done next, then the ratio of a multiple of ch1 value, to the
+ * ch0 value, is calculated. Array tsl2x7x_device_lux[] is then scanned to
+ * find the first ratio value that is just above the ratio we just calculated.
+ * The ch0 and ch1 multiplier constants in the array are then used along with
+ * the time scale factor array values, to calculate the lux.
  */
 static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 {
@@ -363,7 +363,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	mutex_lock(&chip->als_mutex);
 
 	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
-		/* device is not enabled */
 		dev_err(&chip->client->dev, "%s: device is not enabled\n",
 			__func__);
 		ret = -EBUSY;
@@ -374,7 +373,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	if (ret < 0)
 		goto out_unlock;
 
-	/* is data new & valid */
 	if (!(ret & TSL2X7X_STA_ADC_VALID)) {
 		dev_err(&chip->client->dev,
 			"%s: data not valid yet\n", __func__);
@@ -430,12 +428,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 		lux = (lux + (chip->als_time_scale >> 1)) /
 			chip->als_time_scale;
 
-	/* adjust for active gain scale
-	 * The tsl2x7x_device_lux tables have a factor of 256 built-in.
-	 * User-specified gain provides a multiplier.
+	/*
+	 * adjust for active gain scale. The tsl2x7x_device_lux tables have a
+	 * factor of 256 built-in. User-specified gain provides a multiplier.
 	 * Apply user-specified gain before shifting right to retain precision.
-	 * Use 64 bits to avoid overflow on multiplication.
-	 * Then go back to 32 bits before division to avoid using div_u64().
+	 * Use 64 bits to avoid overflow on multiplication. Then go back to
+	 * 32 bits before division to avoid using div_u64().
 	 */
 
 	lux64 = lux;
@@ -713,14 +711,13 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
 }
 
 /**
- * tsl2x7x_invoke_change
+ * tsl2x7x_invoke_change - power cycle the device to implement the user
+ *                         parameters
  * @indio_dev:	pointer to IIO device
  *
- * Obtain and lock both ALS and PROX resources,
- * determine and save device state (On/Off),
- * cycle device to implement updated parameter,
- * put device back into proper state, and unlock
- * resource.
+ * Obtain and lock both ALS and PROX resources, determine and save device state
+ * (On/Off), cycle device to implement updated parameter, put device back into
+ * proper state, and unlock resource.
  */
 static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
 {
@@ -895,7 +892,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev,
 
 	get_options(buf, ARRAY_SIZE(value), value);
 
-	/* We now have an array of ints starting at value[1], and
+	/*
+	 * We now have an array of ints starting at value[1], and
 	 * enumerated by value[0].
 	 * We expect each group of three ints is one table entry,
 	 * and the last table entry is all 0.
@@ -1643,9 +1641,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 		}
 	}
 
-	/* Load up the defaults */
 	tsl2x7x_defaults(chip);
-	/* Make sure the chip is on */
 	tsl2x7x_chip_on(indio_dev);
 
 	ret = iio_device_register(indio_dev);
@@ -1719,7 +1715,6 @@ static const struct dev_pm_ops tsl2x7x_pm_ops = {
 	.resume  = tsl2x7x_resume,
 };
 
-/* Driver definition */
 static struct i2c_driver tsl2x7x_driver = {
 	.driver = {
 		.name = "tsl2x7x",
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 408e5a89edb1..85d8fe7a94c8 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -36,32 +36,35 @@ struct tsl2x7x_lux {
 #define TSL2X7X_MAX_TIMER_CNT           0xFF
 
 /**
- * struct tsl2x7x_default_settings - power on defaults unless
- *                                   overridden by platform data.
- *  @als_time:              ALS Integration time - multiple of 50mS
- *  @als_gain:              Index into the ALS gain table.
- *  @als_gain_trim:         default gain trim to account for
- *                          aperture effects.
- *  @wait_time:             Time between PRX and ALS cycles
- *                          in 2.7 periods
- *  @prox_time:             5.2ms prox integration time -
- *                          decrease in 2.7ms periods
- *  @prox_gain:             Proximity gain index
+ * struct tsl2x7x_settings - Settings for the tsl2x7x driver
+ *  @als_time:              Integration time of the ALS channel ADCs in 2.73 ms
+ *                          increments. Total integration time is
+ *                          (256 - als_time) * 2.73.
+ *  @als_gain:              Index into the tsl2x7x_als_gain array.
+ *  @als_gain_trim:         Default gain trim to account for aperture effects.
+ *  @wait_time:             Time between proximity and ALS cycles in 2.73
+ *                          periods.
+ *  @prox_time:             Integration time of the proximity ADC in 2.73 ms
+ *                          increments. Total integration time is
+ *                          (256 - prx_time) * 2.73.
+ *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
  *  @prox_config:           Prox configuration filters.
- *  @als_cal_target:        Known external ALS reading for
- *                          calibration.
- *  @als_persistence:       H/W Filters, Number of 'out of limits'
- *                          ALS readings.
+ *  @als_cal_target:        Known external ALS reading for calibration.
+ *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
  *  @als_interrupt_en:      Enable/Disable ALS interrupts
  *  @als_thresh_low:        CH0 'low' count to trigger interrupt.
  *  @als_thresh_high:       CH0 'high' count to trigger interrupt.
- *  @prox_persistence:      H/W Filters, Number of 'out of limits'
- *                          proximity readings.
- *  @prox_interrupt_en:     Enable/Disable proximity interrupts
+ *  @prox_persistence:      H/W Filters, Number of 'out of limits' proximity
+ *                          readings.
+ *  @prox_interrupt_en:     Enable/Disable proximity interrupts.
  *  @prox_thres_low:        Low threshold proximity detection.
- *  @prox_thres_high:       High threshold proximity detection
- *  @prox_pulse_count:      Number if proximity emitter pulses
- *  @prox_max_samples_cal:  Used for prox cal.
+ *  @prox_thres_high:       High threshold proximity detection.
+ *  @prox_pulse_count:      Number if proximity emitter pulses.
+ *  @prox_max_samples_cal:  The number of samples that are taken when performing
+ *                          a proximity calibration.
+ *  @prox_diode             Which diode(s) to use for driving the external
+ *                          LED(s) for proximity sensing.
+ *  @prox_power             The amount of power to use for the external LED(s).
  */
 struct tsl2x7x_settings {
 	int als_time;
@@ -88,9 +91,6 @@ struct tsl2x7x_settings {
 
 /**
  * struct tsl2X7X_platform_data - Platform callback, glass and defaults
- * @platform_power:            Suspend/resume platform callback
- * @power_on:                  Power on callback
- * @power_off:                 Power off callback
  * @platform_lux_table:        Device specific glass coefficents
  * @platform_default_settings: Device specific power on defaults
  *
-- 
2.14.3

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

* [PATCH 13/13] staging: iio: tsl2x7x: rename prox_config to als_prox_config
  2018-04-21  0:41 ` Brian Masney
@ 2018-04-21  0:41   ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: devel, lars, gregkh, linux-kernel, Jon.Brenner, pmeerw, knaack.h

The configuration register on the device is represented with the
prox_config member on the tsl2x7x_settings structure. According to the
TSL2772 data sheet, this register can hold: 1) the proximity drive
level, 2) ALS/Proximity long wait, and 3) the ALS gain level. This
patch renames prox_config to als_prox_config since ALS settings can
be stored here as well.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 05c0f3d5fac0..708b2c6bdf4b 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -56,7 +56,7 @@
 #define TSL2X7X_PRX_MAXTHRESHLO		0X0A
 #define TSL2X7X_PRX_MAXTHRESHHI		0X0B
 #define TSL2X7X_PERSISTENCE		0x0C
-#define TSL2X7X_PRX_CONFIG		0x0D
+#define TSL2X7X_ALS_PRX_CONFIG		0x0D
 #define TSL2X7X_PRX_COUNT		0x0E
 #define TSL2X7X_GAIN			0x0F
 #define TSL2X7X_NOTUSED			0x10
@@ -207,7 +207,7 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = {
 	.prox_time = 255, /* 2.73 ms */
 	.prox_gain = 0,
 	.wait_time = 255,
-	.prox_config = 0,
+	.als_prox_config = 0,
 	.als_gain_trim = 1000,
 	.als_cal_target = 150,
 	.als_persistence = 1,
@@ -594,7 +594,8 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	/* Non calculated parameters */
 	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
 	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
-	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
+	chip->tsl2x7x_config[TSL2X7X_ALS_PRX_CONFIG] =
+		chip->settings.als_prox_config;
 
 	chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
 		(chip->settings.als_thresh_low) & 0xFF;
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 85d8fe7a94c8..6e30e71a2127 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -48,7 +48,8 @@ struct tsl2x7x_lux {
  *                          increments. Total integration time is
  *                          (256 - prx_time) * 2.73.
  *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
- *  @prox_config:           Prox configuration filters.
+ *  @als_prox_config:       The value of the ALS / Proximity configuration
+ *                          register.
  *  @als_cal_target:        Known external ALS reading for calibration.
  *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
  *  @als_interrupt_en:      Enable/Disable ALS interrupts
@@ -73,7 +74,7 @@ struct tsl2x7x_settings {
 	int wait_time;
 	int prox_time;
 	int prox_gain;
-	int prox_config;
+	int als_prox_config;
 	int als_cal_target;
 	u8 als_persistence;
 	bool als_interrupt_en;
-- 
2.14.3

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 13/13] staging: iio: tsl2x7x: rename prox_config to als_prox_config
@ 2018-04-21  0:41   ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21  0:41 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: gregkh, devel, knaack.h, lars, pmeerw, linux-kernel, Jon.Brenner

The configuration register on the device is represented with the
prox_config member on the tsl2x7x_settings structure. According to the
TSL2772 data sheet, this register can hold: 1) the proximity drive
level, 2) ALS/Proximity long wait, and 3) the ALS gain level. This
patch renames prox_config to als_prox_config since ALS settings can
be stored here as well.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index 05c0f3d5fac0..708b2c6bdf4b 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -56,7 +56,7 @@
 #define TSL2X7X_PRX_MAXTHRESHLO		0X0A
 #define TSL2X7X_PRX_MAXTHRESHHI		0X0B
 #define TSL2X7X_PERSISTENCE		0x0C
-#define TSL2X7X_PRX_CONFIG		0x0D
+#define TSL2X7X_ALS_PRX_CONFIG		0x0D
 #define TSL2X7X_PRX_COUNT		0x0E
 #define TSL2X7X_GAIN			0x0F
 #define TSL2X7X_NOTUSED			0x10
@@ -207,7 +207,7 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = {
 	.prox_time = 255, /* 2.73 ms */
 	.prox_gain = 0,
 	.wait_time = 255,
-	.prox_config = 0,
+	.als_prox_config = 0,
 	.als_gain_trim = 1000,
 	.als_cal_target = 150,
 	.als_persistence = 1,
@@ -594,7 +594,8 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	/* Non calculated parameters */
 	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
 	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
-	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
+	chip->tsl2x7x_config[TSL2X7X_ALS_PRX_CONFIG] =
+		chip->settings.als_prox_config;
 
 	chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
 		(chip->settings.als_thresh_low) & 0xFF;
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 85d8fe7a94c8..6e30e71a2127 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -48,7 +48,8 @@ struct tsl2x7x_lux {
  *                          increments. Total integration time is
  *                          (256 - prx_time) * 2.73.
  *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
- *  @prox_config:           Prox configuration filters.
+ *  @als_prox_config:       The value of the ALS / Proximity configuration
+ *                          register.
  *  @als_cal_target:        Known external ALS reading for calibration.
  *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
  *  @als_interrupt_en:      Enable/Disable ALS interrupts
@@ -73,7 +74,7 @@ struct tsl2x7x_settings {
 	int wait_time;
 	int prox_time;
 	int prox_gain;
-	int prox_config;
+	int als_prox_config;
 	int als_cal_target;
 	u8 als_persistence;
 	bool als_interrupt_en;
-- 
2.14.3

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

* Re: [PATCH 01/13] staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:13     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:13 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:41 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The integration_time* attributes are currently associated with the
> IIO_LIGHT channel but should be associated with the IIO_INTENSITY
> channel. Directory listing of the sysfs attributes for a TSL2772
> with this patch applied:
> 
> dev
> events
> in_illuminance0_calibrate
> in_illuminance0_calibscale_available
> in_illuminance0_input
> in_illuminance0_lux_table
> in_illuminance0_target_input
> in_intensity0_calibbias
> in_intensity0_calibscale
> in_intensity0_integration_time
> in_intensity0_integration_time_available
> in_intensity0_raw
> in_intensity1_raw
> in_proximity0_calibrate
> in_proximity0_calibscale
> in_proximity0_calibscale_available
> in_proximity0_raw
> name
> of_node
> power
> subsystem
> uevent
> 
> 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 | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 9991b0483956..eeccfbb0eb1f 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -827,7 +827,7 @@ in_illuminance0_calibscale_available_show(struct device *dev,
>  
>  static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
>  
> -static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
> +static IIO_CONST_ATTR(in_intensity0_integration_time_available,
>  		".00272 - .696");
>  
>  static ssize_t in_illuminance0_target_input_show(struct device *dev,
> @@ -1358,7 +1358,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  
>  static struct attribute *tsl2x7x_ALS_device_attrs[] = {
>  	&dev_attr_in_illuminance0_calibscale_available.attr,
> -	&iio_const_attr_in_illuminance0_integration_time_available
> +	&iio_const_attr_in_intensity0_integration_time_available
>  		.dev_attr.attr,
>  	&dev_attr_in_illuminance0_target_input.attr,
>  	&dev_attr_in_illuminance0_calibrate.attr,
> @@ -1373,7 +1373,7 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
>  
>  static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
>  	&dev_attr_in_illuminance0_calibscale_available.attr,
> -	&iio_const_attr_in_illuminance0_integration_time_available
> +	&iio_const_attr_in_intensity0_integration_time_available
>  		.dev_attr.attr,
>  	&dev_attr_in_illuminance0_target_input.attr,
>  	&dev_attr_in_illuminance0_calibrate.attr,
> @@ -1389,7 +1389,7 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
>  
>  static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
>  	&dev_attr_in_illuminance0_calibscale_available.attr,
> -	&iio_const_attr_in_illuminance0_integration_time_available
> +	&iio_const_attr_in_intensity0_integration_time_available
>  		.dev_attr.attr,
>  	&dev_attr_in_illuminance0_target_input.attr,
>  	&dev_attr_in_illuminance0_calibrate.attr,
> @@ -1489,13 +1489,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
>  			.type = IIO_LIGHT,
>  			.indexed = 1,
>  			.channel = 0,
> -			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> -					      BIT(IIO_CHAN_INFO_INT_TIME),
> +			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
>  			}, {
>  			.type = IIO_INTENSITY,
>  			.indexed = 1,
>  			.channel = 0,
>  			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				BIT(IIO_CHAN_INFO_INT_TIME) |
>  				BIT(IIO_CHAN_INFO_CALIBSCALE) |
>  				BIT(IIO_CHAN_INFO_CALIBBIAS),
>  			.event_spec = tsl2x7x_events,
> @@ -1529,13 +1529,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
>  			.type = IIO_LIGHT,
>  			.indexed = 1,
>  			.channel = 0,
> -			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> -					      BIT(IIO_CHAN_INFO_INT_TIME),
> +			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
>  			}, {
>  			.type = IIO_INTENSITY,
>  			.indexed = 1,
>  			.channel = 0,
>  			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				BIT(IIO_CHAN_INFO_INT_TIME) |
>  				BIT(IIO_CHAN_INFO_CALIBSCALE) |
>  				BIT(IIO_CHAN_INFO_CALIBBIAS),
>  			.event_spec = tsl2x7x_events,
> @@ -1578,13 +1578,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
>  			.type = IIO_LIGHT,
>  			.indexed = 1,
>  			.channel = 0,
> -			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> -					      BIT(IIO_CHAN_INFO_INT_TIME),
> +			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
>  			}, {
>  			.type = IIO_INTENSITY,
>  			.indexed = 1,
>  			.channel = 0,
>  			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				BIT(IIO_CHAN_INFO_INT_TIME) |
>  				BIT(IIO_CHAN_INFO_CALIBSCALE) |
>  				BIT(IIO_CHAN_INFO_CALIBBIAS),
>  			.event_spec = tsl2x7x_events,

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 01/13] staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel
@ 2018-04-21 16:13     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:13 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:41 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The integration_time* attributes are currently associated with the
> IIO_LIGHT channel but should be associated with the IIO_INTENSITY
> channel. Directory listing of the sysfs attributes for a TSL2772
> with this patch applied:
> 
> dev
> events
> in_illuminance0_calibrate
> in_illuminance0_calibscale_available
> in_illuminance0_input
> in_illuminance0_lux_table
> in_illuminance0_target_input
> in_intensity0_calibbias
> in_intensity0_calibscale
> in_intensity0_integration_time
> in_intensity0_integration_time_available
> in_intensity0_raw
> in_intensity1_raw
> in_proximity0_calibrate
> in_proximity0_calibscale
> in_proximity0_calibscale_available
> in_proximity0_raw
> name
> of_node
> power
> subsystem
> uevent
> 
> 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 | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 9991b0483956..eeccfbb0eb1f 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -827,7 +827,7 @@ in_illuminance0_calibscale_available_show(struct device *dev,
>  
>  static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
>  
> -static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
> +static IIO_CONST_ATTR(in_intensity0_integration_time_available,
>  		".00272 - .696");
>  
>  static ssize_t in_illuminance0_target_input_show(struct device *dev,
> @@ -1358,7 +1358,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  
>  static struct attribute *tsl2x7x_ALS_device_attrs[] = {
>  	&dev_attr_in_illuminance0_calibscale_available.attr,
> -	&iio_const_attr_in_illuminance0_integration_time_available
> +	&iio_const_attr_in_intensity0_integration_time_available
>  		.dev_attr.attr,
>  	&dev_attr_in_illuminance0_target_input.attr,
>  	&dev_attr_in_illuminance0_calibrate.attr,
> @@ -1373,7 +1373,7 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
>  
>  static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
>  	&dev_attr_in_illuminance0_calibscale_available.attr,
> -	&iio_const_attr_in_illuminance0_integration_time_available
> +	&iio_const_attr_in_intensity0_integration_time_available
>  		.dev_attr.attr,
>  	&dev_attr_in_illuminance0_target_input.attr,
>  	&dev_attr_in_illuminance0_calibrate.attr,
> @@ -1389,7 +1389,7 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
>  
>  static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
>  	&dev_attr_in_illuminance0_calibscale_available.attr,
> -	&iio_const_attr_in_illuminance0_integration_time_available
> +	&iio_const_attr_in_intensity0_integration_time_available
>  		.dev_attr.attr,
>  	&dev_attr_in_illuminance0_target_input.attr,
>  	&dev_attr_in_illuminance0_calibrate.attr,
> @@ -1489,13 +1489,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
>  			.type = IIO_LIGHT,
>  			.indexed = 1,
>  			.channel = 0,
> -			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> -					      BIT(IIO_CHAN_INFO_INT_TIME),
> +			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
>  			}, {
>  			.type = IIO_INTENSITY,
>  			.indexed = 1,
>  			.channel = 0,
>  			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				BIT(IIO_CHAN_INFO_INT_TIME) |
>  				BIT(IIO_CHAN_INFO_CALIBSCALE) |
>  				BIT(IIO_CHAN_INFO_CALIBBIAS),
>  			.event_spec = tsl2x7x_events,
> @@ -1529,13 +1529,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
>  			.type = IIO_LIGHT,
>  			.indexed = 1,
>  			.channel = 0,
> -			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> -					      BIT(IIO_CHAN_INFO_INT_TIME),
> +			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
>  			}, {
>  			.type = IIO_INTENSITY,
>  			.indexed = 1,
>  			.channel = 0,
>  			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				BIT(IIO_CHAN_INFO_INT_TIME) |
>  				BIT(IIO_CHAN_INFO_CALIBSCALE) |
>  				BIT(IIO_CHAN_INFO_CALIBBIAS),
>  			.event_spec = tsl2x7x_events,
> @@ -1578,13 +1578,13 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
>  			.type = IIO_LIGHT,
>  			.indexed = 1,
>  			.channel = 0,
> -			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> -					      BIT(IIO_CHAN_INFO_INT_TIME),
> +			.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
>  			}, {
>  			.type = IIO_INTENSITY,
>  			.indexed = 1,
>  			.channel = 0,
>  			.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				BIT(IIO_CHAN_INFO_INT_TIME) |
>  				BIT(IIO_CHAN_INFO_CALIBSCALE) |
>  				BIT(IIO_CHAN_INFO_CALIBBIAS),
>  			.event_spec = tsl2x7x_events,


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

* Re: [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:16     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:16 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:42 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The summary text for the GPL is not needed since the SPDX identifier
> is a legally binding shorthand that can be used instead.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
I sanity checked against other drivers because I wasn't 100% sure
this wasn't a valid formatting for SPDX.  It doesn't seem to be.
Normally convention is
//SPDX... 
On the first line of the file.
C style comments also fine, but it needs to be a comment line on it's
own.  This is all about making it trivial for automated tools to find.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 10 +---------
>  drivers/staging/iio/light/tsl2x7x.h | 14 +-------------
>  2 files changed, 2 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index eeccfbb0eb1f..9cdcc8c9e812 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -5,15 +5,7 @@
>   * Copyright (c) 2012, TAOS Corporation.
>   * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
>   *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> + * SPDX-License-Identifier: GPL-2.0+
>   */
>  
>  #include <linux/delay.h>
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index d382cdbb976e..992ee2465609 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -4,19 +4,7 @@
>   *
>   * Copyright (c) 2012, TAOS Corporation.
>   *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write to the Free Software Foundation, Inc.,
> - * 51 Franklin Street, Fifth Floor, Boston, MA	02110-1301, USA.
> + * SPDX-License-Identifier: GPL-2.0+
>   */
>  
>  #ifndef __TSL2X7X_H

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
@ 2018-04-21 16:16     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:16 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:42 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The summary text for the GPL is not needed since the SPDX identifier
> is a legally binding shorthand that can be used instead.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
I sanity checked against other drivers because I wasn't 100% sure
this wasn't a valid formatting for SPDX.  It doesn't seem to be.
Normally convention is
//SPDX... 
On the first line of the file.
C style comments also fine, but it needs to be a comment line on it's
own.  This is all about making it trivial for automated tools to find.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 10 +---------
>  drivers/staging/iio/light/tsl2x7x.h | 14 +-------------
>  2 files changed, 2 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index eeccfbb0eb1f..9cdcc8c9e812 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -5,15 +5,7 @@
>   * Copyright (c) 2012, TAOS Corporation.
>   * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
>   *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> + * SPDX-License-Identifier: GPL-2.0+
>   */
>  
>  #include <linux/delay.h>
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index d382cdbb976e..992ee2465609 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -4,19 +4,7 @@
>   *
>   * Copyright (c) 2012, TAOS Corporation.
>   *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write to the Free Software Foundation, Inc.,
> - * 51 Franklin Street, Fifth Floor, Boston, MA	02110-1301, USA.
> + * SPDX-License-Identifier: GPL-2.0+
>   */
>  
>  #ifndef __TSL2X7X_H


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

* Re: [PATCH 03/13] staging: iio: tsl2x7x: don't return error in IRQ handler
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:18     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:18 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:43 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_event_handler() could return an error and this could cause the
> interrupt to remain masked. We shouldn't return an error in the
> interrupt handler so this patch always returns IRQ_HANDLED. An error
> will be logged if one occurs.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
There is a slight argument that we should report an error from the 
interrupt clear if it generates an error, but I'm not that bothered
as that is unlikely to happen and people rarely see these errors in
their logs anyway.

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 | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 9cdcc8c9e812..95a00b965c5e 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1320,7 +1320,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  
>  	ret = tsl2x7x_read_status(chip);
>  	if (ret < 0)
> -		return ret;
> +		return IRQ_HANDLED;
>  
>  	/* What type of interrupt do we need to process */
>  	if (ret & TSL2X7X_STA_PRX_INTR) {
> @@ -1341,9 +1341,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  			       timestamp);
>  	}
>  
> -	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
> -	if (ret < 0)
> -		return ret;
> +	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
>  
>  	return IRQ_HANDLED;
>  }

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 03/13] staging: iio: tsl2x7x: don't return error in IRQ handler
@ 2018-04-21 16:18     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:18 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:43 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_event_handler() could return an error and this could cause the
> interrupt to remain masked. We shouldn't return an error in the
> interrupt handler so this patch always returns IRQ_HANDLED. An error
> will be logged if one occurs.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
There is a slight argument that we should report an error from the 
interrupt clear if it generates an error, but I'm not that bothered
as that is unlikely to happen and people rarely see these errors in
their logs anyway.

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 | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 9cdcc8c9e812..95a00b965c5e 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1320,7 +1320,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  
>  	ret = tsl2x7x_read_status(chip);
>  	if (ret < 0)
> -		return ret;
> +		return IRQ_HANDLED;
>  
>  	/* What type of interrupt do we need to process */
>  	if (ret & TSL2X7X_STA_PRX_INTR) {
> @@ -1341,9 +1341,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  			       timestamp);
>  	}
>  
> -	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
> -	if (ret < 0)
> -		return ret;
> +	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
>  
>  	return IRQ_HANDLED;
>  }


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

* Re: [PATCH 04/13] staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:20     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:20 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:44 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_clear_interrupts() takes a reg argument but there are only
> two callers to this function and both callers pass the same value.
> Since this function was introduced, interrupts are now working
> properly for this driver, and several unnecessary calls to
> tsl2x7x_clear_interrupts() were removed. This patch removes the
> tsl2x7x_clear_interrupts() function and replaces the two callers
> with the i2c_smbus_write_byte() call instead.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 32 +++++++++++++++-----------------
>  1 file changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 95a00b965c5e..f37fc74b8fbc 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -271,20 +271,6 @@ static const u8 device_channel_config[] = {
>  	ALSPRX2
>  };
>  
> -static int tsl2x7x_clear_interrupts(struct tsl2X7X_chip *chip, int reg)
> -{
> -	int ret;
> -
> -	ret = i2c_smbus_write_byte(chip->client,
> -				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | reg);
> -	if (ret < 0)
> -		dev_err(&chip->client->dev,
> -			"%s: failed to clear interrupt status %x: %d\n",
> -			__func__, reg, ret);
> -
> -	return ret;
> -}
> -
>  static int tsl2x7x_read_status(struct tsl2X7X_chip *chip)
>  {
>  	int ret;
> @@ -714,9 +700,15 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
> -	if (ret < 0)
> +	ret = i2c_smbus_write_byte(chip->client,
> +				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
> +				   TSL2X7X_CMD_PROXALS_INT_CLR);
> +	if (ret < 0) {
> +		dev_err(&chip->client->dev,
> +			"%s: failed to clear interrupt status: %d\n",
> +			__func__, ret);
>  		return ret;
> +	}
>  
>  	chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
>  
> @@ -1341,7 +1333,13 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  			       timestamp);
>  	}
>  
> -	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
> +	ret = i2c_smbus_write_byte(chip->client,
> +				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
> +				   TSL2X7X_CMD_PROXALS_INT_CLR);
> +	if (ret < 0)
> +		dev_err(&chip->client->dev,
> +			"%s: failed to clear interrupt status: %d\n",
> +			__func__, ret);
>  
>  	return IRQ_HANDLED;
>  }

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 04/13] staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
@ 2018-04-21 16:20     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:20 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:44 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_clear_interrupts() takes a reg argument but there are only
> two callers to this function and both callers pass the same value.
> Since this function was introduced, interrupts are now working
> properly for this driver, and several unnecessary calls to
> tsl2x7x_clear_interrupts() were removed. This patch removes the
> tsl2x7x_clear_interrupts() function and replaces the two callers
> with the i2c_smbus_write_byte() call instead.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 32 +++++++++++++++-----------------
>  1 file changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 95a00b965c5e..f37fc74b8fbc 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -271,20 +271,6 @@ static const u8 device_channel_config[] = {
>  	ALSPRX2
>  };
>  
> -static int tsl2x7x_clear_interrupts(struct tsl2X7X_chip *chip, int reg)
> -{
> -	int ret;
> -
> -	ret = i2c_smbus_write_byte(chip->client,
> -				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | reg);
> -	if (ret < 0)
> -		dev_err(&chip->client->dev,
> -			"%s: failed to clear interrupt status %x: %d\n",
> -			__func__, reg, ret);
> -
> -	return ret;
> -}
> -
>  static int tsl2x7x_read_status(struct tsl2X7X_chip *chip)
>  {
>  	int ret;
> @@ -714,9 +700,15 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
> -	if (ret < 0)
> +	ret = i2c_smbus_write_byte(chip->client,
> +				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
> +				   TSL2X7X_CMD_PROXALS_INT_CLR);
> +	if (ret < 0) {
> +		dev_err(&chip->client->dev,
> +			"%s: failed to clear interrupt status: %d\n",
> +			__func__, ret);
>  		return ret;
> +	}
>  
>  	chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
>  
> @@ -1341,7 +1333,13 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
>  			       timestamp);
>  	}
>  
> -	tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
> +	ret = i2c_smbus_write_byte(chip->client,
> +				   TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
> +				   TSL2X7X_CMD_PROXALS_INT_CLR);
> +	if (ret < 0)
> +		dev_err(&chip->client->dev,
> +			"%s: failed to clear interrupt status: %d\n",
> +			__func__, ret);
>  
>  	return IRQ_HANDLED;
>  }


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

* Re: [PATCH 05/13] staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:23     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:23 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:45 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_suspend() and tsl2x7x_resume() both check to see what the
> current chip status is. These checks are not necessary so this patch
> removes those checks.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
This description could have been clearer... The key point is we
can always know what state we are in when we hit these functions anyway
(I think).

Anyhow applied as is 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 | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index f37fc74b8fbc..8d8af0cf9768 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1682,27 +1682,15 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
>  static int tsl2x7x_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> -	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret = 0;
> -
> -	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
> -		ret = tsl2x7x_chip_off(indio_dev);
> -		chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
> -	}
>  
> -	return ret;
> +	return tsl2x7x_chip_off(indio_dev);
>  }
>  
>  static int tsl2x7x_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> -	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret = 0;
>  
> -	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_SUSPENDED)
> -		ret = tsl2x7x_chip_on(indio_dev);
> -
> -	return ret;
> +	return tsl2x7x_chip_on(indio_dev);
>  }
>  
>  static int tsl2x7x_remove(struct i2c_client *client)

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 05/13] staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume
@ 2018-04-21 16:23     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:23 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:45 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_suspend() and tsl2x7x_resume() both check to see what the
> current chip status is. These checks are not necessary so this patch
> removes those checks.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
This description could have been clearer... The key point is we
can always know what state we are in when we hit these functions anyway
(I think).

Anyhow applied as is 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 | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index f37fc74b8fbc..8d8af0cf9768 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1682,27 +1682,15 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
>  static int tsl2x7x_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> -	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret = 0;
> -
> -	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
> -		ret = tsl2x7x_chip_off(indio_dev);
> -		chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
> -	}
>  
> -	return ret;
> +	return tsl2x7x_chip_off(indio_dev);
>  }
>  
>  static int tsl2x7x_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> -	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret = 0;
>  
> -	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_SUSPENDED)
> -		ret = tsl2x7x_chip_on(indio_dev);
> -
> -	return ret;
> +	return tsl2x7x_chip_on(indio_dev);
>  }
>  
>  static int tsl2x7x_remove(struct i2c_client *client)


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

* Re: [PATCH 06/13] staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:25     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:25 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:46 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_write_interrupt_config() has an unnecessary return value check
> at the end of the function. This patch changes the function to just
> return the value from the call to tsl2x7x_invoke_change().
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Nice little cleanup.

Applied,

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 8d8af0cf9768..d202bc7e1f4f 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -982,18 +982,13 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
>  					  int val)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret;
>  
>  	if (chan->type == IIO_INTENSITY)
>  		chip->settings.als_interrupt_en = val ? true : false;
>  	else
>  		chip->settings.prox_interrupt_en = val ? true : false;
>  
> -	ret = tsl2x7x_invoke_change(indio_dev);
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> +	return tsl2x7x_invoke_change(indio_dev);
>  }
>  
>  static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 06/13] staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
@ 2018-04-21 16:25     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:25 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:46 -0400
Brian Masney <masneyb@onstation.org> wrote:

> tsl2x7x_write_interrupt_config() has an unnecessary return value check
> at the end of the function. This patch changes the function to just
> return the value from the call to tsl2x7x_invoke_change().
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Nice little cleanup.

Applied,

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 8d8af0cf9768..d202bc7e1f4f 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -982,18 +982,13 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
>  					  int val)
>  {
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
> -	int ret;
>  
>  	if (chan->type == IIO_INTENSITY)
>  		chip->settings.als_interrupt_en = val ? true : false;
>  	else
>  		chip->settings.prox_interrupt_en = val ? true : false;
>  
> -	ret = tsl2x7x_invoke_change(indio_dev);
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> +	return tsl2x7x_invoke_change(indio_dev);
>  }
>  
>  static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,


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

* Re: [PATCH 07/13] staging: iio: tsl2x7x: simplify device id verification
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:26     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:26 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:47 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch renames tsl2x7x_device_id() to tsl2x7x_device_id_verif(),
> removes the unnecessary pointer on the id parameter, and only calls
> the verification function once.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
That double call is just weird..

Anyhow, 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 | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index d202bc7e1f4f..56730baea927 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1277,22 +1277,22 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
>  static DEVICE_ATTR_RW(in_illuminance0_lux_table);
>  
>  /* Use the default register values to identify the Taos device */
> -static int tsl2x7x_device_id(int *id, int target)
> +static int tsl2x7x_device_id_verif(int id, int target)
>  {
>  	switch (target) {
>  	case tsl2571:
>  	case tsl2671:
>  	case tsl2771:
> -		return (*id & 0xf0) == TRITON_ID;
> +		return (id & 0xf0) == TRITON_ID;
>  	case tmd2671:
>  	case tmd2771:
> -		return (*id & 0xf0) == HALIBUT_ID;
> +		return (id & 0xf0) == HALIBUT_ID;
>  	case tsl2572:
>  	case tsl2672:
>  	case tmd2672:
>  	case tsl2772:
>  	case tmd2772:
> -		return (*id & 0xf0) == SWORDFISH_ID;
> +		return (id & 0xf0) == SWORDFISH_ID;
>  	}
>  
>  	return -EINVAL;
> @@ -1612,8 +1612,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
>  	if (ret < 0)
>  		return ret;
>  
> -	if ((!tsl2x7x_device_id(&ret, id->driver_data)) ||
> -	    (tsl2x7x_device_id(&ret, id->driver_data) == -EINVAL)) {
> +	if (tsl2x7x_device_id_verif(ret, id->driver_data) <= 0) {
>  		dev_info(&chip->client->dev,
>  			 "%s: i2c device found does not match expected id\n",
>  				__func__);

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 07/13] staging: iio: tsl2x7x: simplify device id verification
@ 2018-04-21 16:26     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:26 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:47 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch renames tsl2x7x_device_id() to tsl2x7x_device_id_verif(),
> removes the unnecessary pointer on the id parameter, and only calls
> the verification function once.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
That double call is just weird..

Anyhow, 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 | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index d202bc7e1f4f..56730baea927 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1277,22 +1277,22 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
>  static DEVICE_ATTR_RW(in_illuminance0_lux_table);
>  
>  /* Use the default register values to identify the Taos device */
> -static int tsl2x7x_device_id(int *id, int target)
> +static int tsl2x7x_device_id_verif(int id, int target)
>  {
>  	switch (target) {
>  	case tsl2571:
>  	case tsl2671:
>  	case tsl2771:
> -		return (*id & 0xf0) == TRITON_ID;
> +		return (id & 0xf0) == TRITON_ID;
>  	case tmd2671:
>  	case tmd2771:
> -		return (*id & 0xf0) == HALIBUT_ID;
> +		return (id & 0xf0) == HALIBUT_ID;
>  	case tsl2572:
>  	case tsl2672:
>  	case tmd2672:
>  	case tsl2772:
>  	case tmd2772:
> -		return (*id & 0xf0) == SWORDFISH_ID;
> +		return (id & 0xf0) == SWORDFISH_ID;
>  	}
>  
>  	return -EINVAL;
> @@ -1612,8 +1612,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
>  	if (ret < 0)
>  		return ret;
>  
> -	if ((!tsl2x7x_device_id(&ret, id->driver_data)) ||
> -	    (tsl2x7x_device_id(&ret, id->driver_data) == -EINVAL)) {
> +	if (tsl2x7x_device_id_verif(ret, id->driver_data) <= 0) {
>  		dev_info(&chip->client->dev,
>  			 "%s: i2c device found does not match expected id\n",
>  				__func__);


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

* Re: [PATCH 08/13] staging: iio: tsl2x7x: add range checking to three sysfs attributes
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:31     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:31 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:48 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The sysfs attributes in_illuminance0_target_input,
> in_illuminance0_calibrate, and in_proximity0_calibrate did not have
> proper range checking in place so this patch adds the correct range
> checks.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>

Comment inline.


> ---
>  drivers/staging/iio/light/tsl2x7x.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 56730baea927..15bc0af1bb6c 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -835,9 +835,10 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
>  	if (kstrtoul(buf, 0, &value))
>  		return -EINVAL;
>  
> -	if (value)
> -		chip->settings.als_cal_target = value;
> +	if (value < 0 || value > 65535)
> +		return -ERANGE;
How about using kstrtou16 which does this check internally...

>  
> +	chip->settings.als_cal_target = value;
>  	ret = tsl2x7x_invoke_change(indio_dev);
>  	if (ret < 0)
>  		return ret;
> @@ -853,14 +854,12 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
>  	bool value;
>  	int ret;
>  
> -	if (strtobool(buf, &value))
> +	if (kstrtobool(buf, &value) || !value)
>  		return -EINVAL;
>  
> -	if (value) {
> -		ret = tsl2x7x_als_calibrate(indio_dev);
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = tsl2x7x_als_calibrate(indio_dev);
> +	if (ret < 0)
> +		return ret;
>  
>  	ret = tsl2x7x_invoke_change(indio_dev);
>  	if (ret < 0)
> @@ -946,14 +945,12 @@ static ssize_t in_proximity0_calibrate_store(struct device *dev,
>  	bool value;
>  	int ret;
>  
> -	if (strtobool(buf, &value))
> +	if (kstrtobool(buf, &value) || !value)
>  		return -EINVAL;
>  
> -	if (value) {
> -		ret = tsl2x7x_prox_cal(indio_dev);
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = tsl2x7x_prox_cal(indio_dev);
> +	if (ret < 0)
> +		return ret;
>  
>  	ret = tsl2x7x_invoke_change(indio_dev);
>  	if (ret < 0)

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 08/13] staging: iio: tsl2x7x: add range checking to three sysfs attributes
@ 2018-04-21 16:31     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:31 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:48 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The sysfs attributes in_illuminance0_target_input,
> in_illuminance0_calibrate, and in_proximity0_calibrate did not have
> proper range checking in place so this patch adds the correct range
> checks.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>

Comment inline.


> ---
>  drivers/staging/iio/light/tsl2x7x.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 56730baea927..15bc0af1bb6c 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -835,9 +835,10 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
>  	if (kstrtoul(buf, 0, &value))
>  		return -EINVAL;
>  
> -	if (value)
> -		chip->settings.als_cal_target = value;
> +	if (value < 0 || value > 65535)
> +		return -ERANGE;
How about using kstrtou16 which does this check internally...

>  
> +	chip->settings.als_cal_target = value;
>  	ret = tsl2x7x_invoke_change(indio_dev);
>  	if (ret < 0)
>  		return ret;
> @@ -853,14 +854,12 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
>  	bool value;
>  	int ret;
>  
> -	if (strtobool(buf, &value))
> +	if (kstrtobool(buf, &value) || !value)
>  		return -EINVAL;
>  
> -	if (value) {
> -		ret = tsl2x7x_als_calibrate(indio_dev);
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = tsl2x7x_als_calibrate(indio_dev);
> +	if (ret < 0)
> +		return ret;
>  
>  	ret = tsl2x7x_invoke_change(indio_dev);
>  	if (ret < 0)
> @@ -946,14 +945,12 @@ static ssize_t in_proximity0_calibrate_store(struct device *dev,
>  	bool value;
>  	int ret;
>  
> -	if (strtobool(buf, &value))
> +	if (kstrtobool(buf, &value) || !value)
>  		return -EINVAL;
>  
> -	if (value) {
> -		ret = tsl2x7x_prox_cal(indio_dev);
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = tsl2x7x_prox_cal(indio_dev);
> +	if (ret < 0)
> +		return ret;
>  
>  	ret = tsl2x7x_invoke_change(indio_dev);
>  	if (ret < 0)


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

* Re: [PATCH 09/13] staging: iio: tsl2x7x: move power and diode settings into header file
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:33     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:33 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:49 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The power and diode defines are needed for the platform data so this
> patch moves the defines out of the .c file and into the header file. A
> comment for the diode is also cleaned up while this code is touched.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Makes sense.

Applied,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 12 ------------
>  drivers/staging/iio/light/tsl2x7x.h | 12 ++++++++++++
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 15bc0af1bb6c..87b99deef7a8 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -103,18 +103,6 @@
>  #define TSL2X7X_CNTL_PROXPON_ENBL	0x0F
>  #define TSL2X7X_CNTL_INTPROXPON_ENBL	0x2F
>  
> -/*Prox diode to use */
> -#define TSL2X7X_DIODE0			0x01
> -#define TSL2X7X_DIODE1			0x02
> -#define TSL2X7X_DIODE_BOTH		0x03
> -
> -/* LED Power */
> -#define TSL2X7X_100_mA			0x00
> -#define TSL2X7X_50_mA			0x01
> -#define TSL2X7X_25_mA			0x02
> -#define TSL2X7X_13_mA			0x03
> -#define TSL2X7X_MAX_TIMER_CNT		0xFF
> -
>  #define TSL2X7X_MIN_ITIME		3
>  
>  /* TAOS txx2x7x Device family members */
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 992ee2465609..2c96f0b39b1e 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -23,6 +23,18 @@ struct tsl2x7x_lux {
>  #define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
>  				     TSL2X7X_DEF_LUX_TABLE_SZ)
>  
> +/* Proximity diode to use */
> +#define TSL2X7X_DIODE0                  0x01
> +#define TSL2X7X_DIODE1                  0x02
> +#define TSL2X7X_DIODE_BOTH              0x03
> +
> +/* LED Power */
> +#define TSL2X7X_100_mA                  0x00
> +#define TSL2X7X_50_mA                   0x01
> +#define TSL2X7X_25_mA                   0x02
> +#define TSL2X7X_13_mA                   0x03
> +#define TSL2X7X_MAX_TIMER_CNT           0xFF
> +
>  /**
>   * struct tsl2x7x_default_settings - power on defaults unless
>   *                                   overridden by platform data.

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 09/13] staging: iio: tsl2x7x: move power and diode settings into header file
@ 2018-04-21 16:33     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:33 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:49 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The power and diode defines are needed for the platform data so this
> patch moves the defines out of the .c file and into the header file. A
> comment for the diode is also cleaned up while this code is touched.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Makes sense.

Applied,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 12 ------------
>  drivers/staging/iio/light/tsl2x7x.h | 12 ++++++++++++
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 15bc0af1bb6c..87b99deef7a8 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -103,18 +103,6 @@
>  #define TSL2X7X_CNTL_PROXPON_ENBL	0x0F
>  #define TSL2X7X_CNTL_INTPROXPON_ENBL	0x2F
>  
> -/*Prox diode to use */
> -#define TSL2X7X_DIODE0			0x01
> -#define TSL2X7X_DIODE1			0x02
> -#define TSL2X7X_DIODE_BOTH		0x03
> -
> -/* LED Power */
> -#define TSL2X7X_100_mA			0x00
> -#define TSL2X7X_50_mA			0x01
> -#define TSL2X7X_25_mA			0x02
> -#define TSL2X7X_13_mA			0x03
> -#define TSL2X7X_MAX_TIMER_CNT		0xFF
> -
>  #define TSL2X7X_MIN_ITIME		3
>  
>  /* TAOS txx2x7x Device family members */
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 992ee2465609..2c96f0b39b1e 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -23,6 +23,18 @@ struct tsl2x7x_lux {
>  #define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
>  				     TSL2X7X_DEF_LUX_TABLE_SZ)
>  
> +/* Proximity diode to use */
> +#define TSL2X7X_DIODE0                  0x01
> +#define TSL2X7X_DIODE1                  0x02
> +#define TSL2X7X_DIODE_BOTH              0x03
> +
> +/* LED Power */
> +#define TSL2X7X_100_mA                  0x00
> +#define TSL2X7X_50_mA                   0x01
> +#define TSL2X7X_25_mA                   0x02
> +#define TSL2X7X_13_mA                   0x03
> +#define TSL2X7X_MAX_TIMER_CNT           0xFF
> +
>  /**
>   * struct tsl2x7x_default_settings - power on defaults unless
>   *                                   overridden by platform data.


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

* Re: [PATCH 10/13] staging: iio: tsl2x7x: rename prx to prox for consistency
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:33     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:33 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:50 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The driver mostly uses the 'prox' naming convention for most of the
> proximity settings, however prx_time and tsl2x7x_prx_gain was present.
> This patch renames these to prox_time and tsl2x7x_prox_gain for
> consistency with everything else in the driver.
> 
> The kernel documentation for prx_gain is corrected to prox_gain so that
> it matches what is actually in the structure.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied,

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 12 ++++++------
>  drivers/staging/iio/light/tsl2x7x.h |  6 +++---
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 87b99deef7a8..a7b4fcba7935 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -203,7 +203,7 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
>  static const struct tsl2x7x_settings tsl2x7x_default_settings = {
>  	.als_time = 219, /* 101 ms */
>  	.als_gain = 0,
> -	.prx_time = 254, /* 5.4 ms */
> +	.prox_time = 254, /* 5.4 ms */
>  	.prox_gain = 0,
>  	.wait_time = 245,
>  	.prox_config = 0,
> @@ -230,7 +230,7 @@ static const s16 tsl2x7x_als_gain[] = {
>  	120
>  };
>  
> -static const s16 tsl2x7x_prx_gain[] = {
> +static const s16 tsl2x7x_prox_gain[] = {
>  	1,
>  	2,
>  	4,
> @@ -594,7 +594,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  	u8 *dev_reg, reg_val;
>  
>  	/* Non calculated parameters */
> -	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time;
> +	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
>  	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
>  	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
>  
> @@ -1021,7 +1021,7 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
>  		if (chan->type == IIO_INTENSITY)
>  			time = chip->settings.als_time;
>  		else
> -			time = chip->settings.prx_time;
> +			time = chip->settings.prox_time;
>  
>  		y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
>  		z = y * TSL2X7X_MIN_ITIME;
> @@ -1090,7 +1090,7 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
>  			time = chip->settings.als_time;
>  			mult = chip->settings.als_persistence;
>  		} else {
> -			time = chip->settings.prx_time;
> +			time = chip->settings.prox_time;
>  			mult = chip->settings.prox_persistence;
>  		}
>  
> @@ -1153,7 +1153,7 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
>  		if (chan->type == IIO_LIGHT)
>  			*val = tsl2x7x_als_gain[chip->settings.als_gain];
>  		else
> -			*val = tsl2x7x_prx_gain[chip->settings.prox_gain];
> +			*val = tsl2x7x_prox_gain[chip->settings.prox_gain];
>  		ret = IIO_VAL_INT;
>  		break;
>  	case IIO_CHAN_INFO_CALIBBIAS:
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 2c96f0b39b1e..408e5a89edb1 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -44,9 +44,9 @@ struct tsl2x7x_lux {
>   *                          aperture effects.
>   *  @wait_time:             Time between PRX and ALS cycles
>   *                          in 2.7 periods
> - *  @prx_time:              5.2ms prox integration time -
> + *  @prox_time:             5.2ms prox integration time -
>   *                          decrease in 2.7ms periods
> - *  @prx_gain:              Proximity gain index
> + *  @prox_gain:             Proximity gain index
>   *  @prox_config:           Prox configuration filters.
>   *  @als_cal_target:        Known external ALS reading for
>   *                          calibration.
> @@ -68,7 +68,7 @@ struct tsl2x7x_settings {
>  	int als_gain;
>  	int als_gain_trim;
>  	int wait_time;
> -	int prx_time;
> +	int prox_time;
>  	int prox_gain;
>  	int prox_config;
>  	int als_cal_target;

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 10/13] staging: iio: tsl2x7x: rename prx to prox for consistency
@ 2018-04-21 16:33     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:33 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:50 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The driver mostly uses the 'prox' naming convention for most of the
> proximity settings, however prx_time and tsl2x7x_prx_gain was present.
> This patch renames these to prox_time and tsl2x7x_prox_gain for
> consistency with everything else in the driver.
> 
> The kernel documentation for prx_gain is corrected to prox_gain so that
> it matches what is actually in the structure.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied,

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 12 ++++++------
>  drivers/staging/iio/light/tsl2x7x.h |  6 +++---
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 87b99deef7a8..a7b4fcba7935 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -203,7 +203,7 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
>  static const struct tsl2x7x_settings tsl2x7x_default_settings = {
>  	.als_time = 219, /* 101 ms */
>  	.als_gain = 0,
> -	.prx_time = 254, /* 5.4 ms */
> +	.prox_time = 254, /* 5.4 ms */
>  	.prox_gain = 0,
>  	.wait_time = 245,
>  	.prox_config = 0,
> @@ -230,7 +230,7 @@ static const s16 tsl2x7x_als_gain[] = {
>  	120
>  };
>  
> -static const s16 tsl2x7x_prx_gain[] = {
> +static const s16 tsl2x7x_prox_gain[] = {
>  	1,
>  	2,
>  	4,
> @@ -594,7 +594,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  	u8 *dev_reg, reg_val;
>  
>  	/* Non calculated parameters */
> -	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time;
> +	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
>  	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
>  	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
>  
> @@ -1021,7 +1021,7 @@ static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
>  		if (chan->type == IIO_INTENSITY)
>  			time = chip->settings.als_time;
>  		else
> -			time = chip->settings.prx_time;
> +			time = chip->settings.prox_time;
>  
>  		y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
>  		z = y * TSL2X7X_MIN_ITIME;
> @@ -1090,7 +1090,7 @@ static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
>  			time = chip->settings.als_time;
>  			mult = chip->settings.als_persistence;
>  		} else {
> -			time = chip->settings.prx_time;
> +			time = chip->settings.prox_time;
>  			mult = chip->settings.prox_persistence;
>  		}
>  
> @@ -1153,7 +1153,7 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
>  		if (chan->type == IIO_LIGHT)
>  			*val = tsl2x7x_als_gain[chip->settings.als_gain];
>  		else
> -			*val = tsl2x7x_prx_gain[chip->settings.prox_gain];
> +			*val = tsl2x7x_prox_gain[chip->settings.prox_gain];
>  		ret = IIO_VAL_INT;
>  		break;
>  	case IIO_CHAN_INFO_CALIBBIAS:
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 2c96f0b39b1e..408e5a89edb1 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -44,9 +44,9 @@ struct tsl2x7x_lux {
>   *                          aperture effects.
>   *  @wait_time:             Time between PRX and ALS cycles
>   *                          in 2.7 periods
> - *  @prx_time:              5.2ms prox integration time -
> + *  @prox_time:             5.2ms prox integration time -
>   *                          decrease in 2.7ms periods
> - *  @prx_gain:              Proximity gain index
> + *  @prox_gain:             Proximity gain index
>   *  @prox_config:           Prox configuration filters.
>   *  @als_cal_target:        Known external ALS reading for
>   *                          calibration.
> @@ -68,7 +68,7 @@ struct tsl2x7x_settings {
>  	int als_gain;
>  	int als_gain_trim;
>  	int wait_time;
> -	int prx_time;
> +	int prox_time;
>  	int prox_gain;
>  	int prox_config;
>  	int als_cal_target;


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

* Re: [PATCH 12/13] staging: iio: tsl2x7x: various comment cleanups
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:37     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:37 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:52 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch removes several unnecessary comments, changes some comments
> so that the use as much of the allowable 80 characters as possible, adds
> the proper whitespace, removes some structure members from the kernel
> docs that are no longer present, and improves the existing kernel doc
> information for some existing structure members.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Looks sensible

Applied,

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 59 +++++++++++++++++--------------------
>  drivers/staging/iio/light/tsl2x7x.h | 48 +++++++++++++++---------------
>  2 files changed, 51 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 293810ff11b9..05c0f3d5fac0 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1,6 +1,6 @@
>  /*
> - * Device driver for monitoring ambient light intensity in (lux)
> - * and proximity detection (prox) within the TAOS TSL2X7X family of devices.
> + * Device driver for monitoring ambient light intensity in (lux) and proximity
> + * detection (prox) within the TAOS TSL2X7X family of devices.
>   *
>   * Copyright (c) 2012, TAOS Corporation.
>   * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
> @@ -21,7 +21,7 @@
>  #include <linux/iio/sysfs.h>
>  #include "tsl2x7x.h"
>  
> -/* Cal defs*/
> +/* Cal defs */
>  #define PROX_STAT_CAL			0
>  #define PROX_STAT_SAMP			1
>  #define MAX_SAMPLES_CAL			200
> @@ -34,10 +34,11 @@
>  /* Lux calculation constants */
>  #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.
> +/*
> + * 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
>  
> @@ -342,15 +343,14 @@ static int tsl2x7x_read_autoinc_regs(struct tsl2X7X_chip *chip, int lower_reg,
>   * @indio_dev:	pointer to IIO device
>   *
>   * The raw ch0 and ch1 values of the ambient light sensed in the last
> - * integration cycle are read from the device.
> - * Time scale factor array values are adjusted based on the integration time.
> - * The raw values are multiplied by a scale factor, and device gain is obtained
> - * using gain index. Limit checks are done next, then the ratio of a multiple
> - * of ch1 value, to the ch0 value, is calculated. Array tsl2x7x_device_lux[]
> - * is then scanned to find the first ratio value that is just above the ratio
> - * we just calculated. The ch0 and ch1 multiplier constants in the array are
> - * then used along with the time scale factor array values, to calculate the
> - * lux.
> + * integration cycle are read from the device. Time scale factor array values
> + * are adjusted based on the integration time. The raw values are multiplied
> + * by a scale factor, and device gain is obtained using gain index. Limit
> + * checks are done next, then the ratio of a multiple of ch1 value, to the
> + * ch0 value, is calculated. Array tsl2x7x_device_lux[] is then scanned to
> + * find the first ratio value that is just above the ratio we just calculated.
> + * The ch0 and ch1 multiplier constants in the array are then used along with
> + * the time scale factor array values, to calculate the lux.
>   */
>  static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  {
> @@ -363,7 +363,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	mutex_lock(&chip->als_mutex);
>  
>  	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
> -		/* device is not enabled */
>  		dev_err(&chip->client->dev, "%s: device is not enabled\n",
>  			__func__);
>  		ret = -EBUSY;
> @@ -374,7 +373,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	if (ret < 0)
>  		goto out_unlock;
>  
> -	/* is data new & valid */
>  	if (!(ret & TSL2X7X_STA_ADC_VALID)) {
>  		dev_err(&chip->client->dev,
>  			"%s: data not valid yet\n", __func__);
> @@ -430,12 +428,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  		lux = (lux + (chip->als_time_scale >> 1)) /
>  			chip->als_time_scale;
>  
> -	/* adjust for active gain scale
> -	 * The tsl2x7x_device_lux tables have a factor of 256 built-in.
> -	 * User-specified gain provides a multiplier.
> +	/*
> +	 * adjust for active gain scale. The tsl2x7x_device_lux tables have a
> +	 * factor of 256 built-in. User-specified gain provides a multiplier.
>  	 * Apply user-specified gain before shifting right to retain precision.
> -	 * Use 64 bits to avoid overflow on multiplication.
> -	 * Then go back to 32 bits before division to avoid using div_u64().
> +	 * Use 64 bits to avoid overflow on multiplication. Then go back to
> +	 * 32 bits before division to avoid using div_u64().
>  	 */
>  
>  	lux64 = lux;
> @@ -713,14 +711,13 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
>  }
>  
>  /**
> - * tsl2x7x_invoke_change
> + * tsl2x7x_invoke_change - power cycle the device to implement the user
> + *                         parameters
>   * @indio_dev:	pointer to IIO device
>   *
> - * Obtain and lock both ALS and PROX resources,
> - * determine and save device state (On/Off),
> - * cycle device to implement updated parameter,
> - * put device back into proper state, and unlock
> - * resource.
> + * Obtain and lock both ALS and PROX resources, determine and save device state
> + * (On/Off), cycle device to implement updated parameter, put device back into
> + * proper state, and unlock resource.
>   */
>  static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
>  {
> @@ -895,7 +892,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev,
>  
>  	get_options(buf, ARRAY_SIZE(value), value);
>  
> -	/* We now have an array of ints starting at value[1], and
> +	/*
> +	 * We now have an array of ints starting at value[1], and
>  	 * enumerated by value[0].
>  	 * We expect each group of three ints is one table entry,
>  	 * and the last table entry is all 0.
> @@ -1643,9 +1641,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
>  		}
>  	}
>  
> -	/* Load up the defaults */
>  	tsl2x7x_defaults(chip);
> -	/* Make sure the chip is on */
>  	tsl2x7x_chip_on(indio_dev);
>  
>  	ret = iio_device_register(indio_dev);
> @@ -1719,7 +1715,6 @@ static const struct dev_pm_ops tsl2x7x_pm_ops = {
>  	.resume  = tsl2x7x_resume,
>  };
>  
> -/* Driver definition */
>  static struct i2c_driver tsl2x7x_driver = {
>  	.driver = {
>  		.name = "tsl2x7x",
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 408e5a89edb1..85d8fe7a94c8 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -36,32 +36,35 @@ struct tsl2x7x_lux {
>  #define TSL2X7X_MAX_TIMER_CNT           0xFF
>  
>  /**
> - * struct tsl2x7x_default_settings - power on defaults unless
> - *                                   overridden by platform data.
> - *  @als_time:              ALS Integration time - multiple of 50mS
> - *  @als_gain:              Index into the ALS gain table.
> - *  @als_gain_trim:         default gain trim to account for
> - *                          aperture effects.
> - *  @wait_time:             Time between PRX and ALS cycles
> - *                          in 2.7 periods
> - *  @prox_time:             5.2ms prox integration time -
> - *                          decrease in 2.7ms periods
> - *  @prox_gain:             Proximity gain index
> + * struct tsl2x7x_settings - Settings for the tsl2x7x driver
> + *  @als_time:              Integration time of the ALS channel ADCs in 2.73 ms
> + *                          increments. Total integration time is
> + *                          (256 - als_time) * 2.73.
> + *  @als_gain:              Index into the tsl2x7x_als_gain array.
> + *  @als_gain_trim:         Default gain trim to account for aperture effects.
> + *  @wait_time:             Time between proximity and ALS cycles in 2.73
> + *                          periods.
> + *  @prox_time:             Integration time of the proximity ADC in 2.73 ms
> + *                          increments. Total integration time is
> + *                          (256 - prx_time) * 2.73.
> + *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
>   *  @prox_config:           Prox configuration filters.
> - *  @als_cal_target:        Known external ALS reading for
> - *                          calibration.
> - *  @als_persistence:       H/W Filters, Number of 'out of limits'
> - *                          ALS readings.
> + *  @als_cal_target:        Known external ALS reading for calibration.
> + *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
>   *  @als_interrupt_en:      Enable/Disable ALS interrupts
>   *  @als_thresh_low:        CH0 'low' count to trigger interrupt.
>   *  @als_thresh_high:       CH0 'high' count to trigger interrupt.
> - *  @prox_persistence:      H/W Filters, Number of 'out of limits'
> - *                          proximity readings.
> - *  @prox_interrupt_en:     Enable/Disable proximity interrupts
> + *  @prox_persistence:      H/W Filters, Number of 'out of limits' proximity
> + *                          readings.
> + *  @prox_interrupt_en:     Enable/Disable proximity interrupts.
>   *  @prox_thres_low:        Low threshold proximity detection.
> - *  @prox_thres_high:       High threshold proximity detection
> - *  @prox_pulse_count:      Number if proximity emitter pulses
> - *  @prox_max_samples_cal:  Used for prox cal.
> + *  @prox_thres_high:       High threshold proximity detection.
> + *  @prox_pulse_count:      Number if proximity emitter pulses.
> + *  @prox_max_samples_cal:  The number of samples that are taken when performing
> + *                          a proximity calibration.
> + *  @prox_diode             Which diode(s) to use for driving the external
> + *                          LED(s) for proximity sensing.
> + *  @prox_power             The amount of power to use for the external LED(s).
>   */
>  struct tsl2x7x_settings {
>  	int als_time;
> @@ -88,9 +91,6 @@ struct tsl2x7x_settings {
>  
>  /**
>   * struct tsl2X7X_platform_data - Platform callback, glass and defaults
> - * @platform_power:            Suspend/resume platform callback
> - * @power_on:                  Power on callback
> - * @power_off:                 Power off callback
>   * @platform_lux_table:        Device specific glass coefficents
>   * @platform_default_settings: Device specific power on defaults
>   *

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 12/13] staging: iio: tsl2x7x: various comment cleanups
@ 2018-04-21 16:37     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:37 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:52 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch removes several unnecessary comments, changes some comments
> so that the use as much of the allowable 80 characters as possible, adds
> the proper whitespace, removes some structure members from the kernel
> docs that are no longer present, and improves the existing kernel doc
> information for some existing structure members.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Looks sensible

Applied,

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 59 +++++++++++++++++--------------------
>  drivers/staging/iio/light/tsl2x7x.h | 48 +++++++++++++++---------------
>  2 files changed, 51 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 293810ff11b9..05c0f3d5fac0 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -1,6 +1,6 @@
>  /*
> - * Device driver for monitoring ambient light intensity in (lux)
> - * and proximity detection (prox) within the TAOS TSL2X7X family of devices.
> + * Device driver for monitoring ambient light intensity in (lux) and proximity
> + * detection (prox) within the TAOS TSL2X7X family of devices.
>   *
>   * Copyright (c) 2012, TAOS Corporation.
>   * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
> @@ -21,7 +21,7 @@
>  #include <linux/iio/sysfs.h>
>  #include "tsl2x7x.h"
>  
> -/* Cal defs*/
> +/* Cal defs */
>  #define PROX_STAT_CAL			0
>  #define PROX_STAT_SAMP			1
>  #define MAX_SAMPLES_CAL			200
> @@ -34,10 +34,11 @@
>  /* Lux calculation constants */
>  #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.
> +/*
> + * 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
>  
> @@ -342,15 +343,14 @@ static int tsl2x7x_read_autoinc_regs(struct tsl2X7X_chip *chip, int lower_reg,
>   * @indio_dev:	pointer to IIO device
>   *
>   * The raw ch0 and ch1 values of the ambient light sensed in the last
> - * integration cycle are read from the device.
> - * Time scale factor array values are adjusted based on the integration time.
> - * The raw values are multiplied by a scale factor, and device gain is obtained
> - * using gain index. Limit checks are done next, then the ratio of a multiple
> - * of ch1 value, to the ch0 value, is calculated. Array tsl2x7x_device_lux[]
> - * is then scanned to find the first ratio value that is just above the ratio
> - * we just calculated. The ch0 and ch1 multiplier constants in the array are
> - * then used along with the time scale factor array values, to calculate the
> - * lux.
> + * integration cycle are read from the device. Time scale factor array values
> + * are adjusted based on the integration time. The raw values are multiplied
> + * by a scale factor, and device gain is obtained using gain index. Limit
> + * checks are done next, then the ratio of a multiple of ch1 value, to the
> + * ch0 value, is calculated. Array tsl2x7x_device_lux[] is then scanned to
> + * find the first ratio value that is just above the ratio we just calculated.
> + * The ch0 and ch1 multiplier constants in the array are then used along with
> + * the time scale factor array values, to calculate the lux.
>   */
>  static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  {
> @@ -363,7 +363,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	mutex_lock(&chip->als_mutex);
>  
>  	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
> -		/* device is not enabled */
>  		dev_err(&chip->client->dev, "%s: device is not enabled\n",
>  			__func__);
>  		ret = -EBUSY;
> @@ -374,7 +373,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	if (ret < 0)
>  		goto out_unlock;
>  
> -	/* is data new & valid */
>  	if (!(ret & TSL2X7X_STA_ADC_VALID)) {
>  		dev_err(&chip->client->dev,
>  			"%s: data not valid yet\n", __func__);
> @@ -430,12 +428,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  		lux = (lux + (chip->als_time_scale >> 1)) /
>  			chip->als_time_scale;
>  
> -	/* adjust for active gain scale
> -	 * The tsl2x7x_device_lux tables have a factor of 256 built-in.
> -	 * User-specified gain provides a multiplier.
> +	/*
> +	 * adjust for active gain scale. The tsl2x7x_device_lux tables have a
> +	 * factor of 256 built-in. User-specified gain provides a multiplier.
>  	 * Apply user-specified gain before shifting right to retain precision.
> -	 * Use 64 bits to avoid overflow on multiplication.
> -	 * Then go back to 32 bits before division to avoid using div_u64().
> +	 * Use 64 bits to avoid overflow on multiplication. Then go back to
> +	 * 32 bits before division to avoid using div_u64().
>  	 */
>  
>  	lux64 = lux;
> @@ -713,14 +711,13 @@ static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
>  }
>  
>  /**
> - * tsl2x7x_invoke_change
> + * tsl2x7x_invoke_change - power cycle the device to implement the user
> + *                         parameters
>   * @indio_dev:	pointer to IIO device
>   *
> - * Obtain and lock both ALS and PROX resources,
> - * determine and save device state (On/Off),
> - * cycle device to implement updated parameter,
> - * put device back into proper state, and unlock
> - * resource.
> + * Obtain and lock both ALS and PROX resources, determine and save device state
> + * (On/Off), cycle device to implement updated parameter, put device back into
> + * proper state, and unlock resource.
>   */
>  static int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
>  {
> @@ -895,7 +892,8 @@ static ssize_t in_illuminance0_lux_table_store(struct device *dev,
>  
>  	get_options(buf, ARRAY_SIZE(value), value);
>  
> -	/* We now have an array of ints starting at value[1], and
> +	/*
> +	 * We now have an array of ints starting at value[1], and
>  	 * enumerated by value[0].
>  	 * We expect each group of three ints is one table entry,
>  	 * and the last table entry is all 0.
> @@ -1643,9 +1641,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
>  		}
>  	}
>  
> -	/* Load up the defaults */
>  	tsl2x7x_defaults(chip);
> -	/* Make sure the chip is on */
>  	tsl2x7x_chip_on(indio_dev);
>  
>  	ret = iio_device_register(indio_dev);
> @@ -1719,7 +1715,6 @@ static const struct dev_pm_ops tsl2x7x_pm_ops = {
>  	.resume  = tsl2x7x_resume,
>  };
>  
> -/* Driver definition */
>  static struct i2c_driver tsl2x7x_driver = {
>  	.driver = {
>  		.name = "tsl2x7x",
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 408e5a89edb1..85d8fe7a94c8 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -36,32 +36,35 @@ struct tsl2x7x_lux {
>  #define TSL2X7X_MAX_TIMER_CNT           0xFF
>  
>  /**
> - * struct tsl2x7x_default_settings - power on defaults unless
> - *                                   overridden by platform data.
> - *  @als_time:              ALS Integration time - multiple of 50mS
> - *  @als_gain:              Index into the ALS gain table.
> - *  @als_gain_trim:         default gain trim to account for
> - *                          aperture effects.
> - *  @wait_time:             Time between PRX and ALS cycles
> - *                          in 2.7 periods
> - *  @prox_time:             5.2ms prox integration time -
> - *                          decrease in 2.7ms periods
> - *  @prox_gain:             Proximity gain index
> + * struct tsl2x7x_settings - Settings for the tsl2x7x driver
> + *  @als_time:              Integration time of the ALS channel ADCs in 2.73 ms
> + *                          increments. Total integration time is
> + *                          (256 - als_time) * 2.73.
> + *  @als_gain:              Index into the tsl2x7x_als_gain array.
> + *  @als_gain_trim:         Default gain trim to account for aperture effects.
> + *  @wait_time:             Time between proximity and ALS cycles in 2.73
> + *                          periods.
> + *  @prox_time:             Integration time of the proximity ADC in 2.73 ms
> + *                          increments. Total integration time is
> + *                          (256 - prx_time) * 2.73.
> + *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
>   *  @prox_config:           Prox configuration filters.
> - *  @als_cal_target:        Known external ALS reading for
> - *                          calibration.
> - *  @als_persistence:       H/W Filters, Number of 'out of limits'
> - *                          ALS readings.
> + *  @als_cal_target:        Known external ALS reading for calibration.
> + *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
>   *  @als_interrupt_en:      Enable/Disable ALS interrupts
>   *  @als_thresh_low:        CH0 'low' count to trigger interrupt.
>   *  @als_thresh_high:       CH0 'high' count to trigger interrupt.
> - *  @prox_persistence:      H/W Filters, Number of 'out of limits'
> - *                          proximity readings.
> - *  @prox_interrupt_en:     Enable/Disable proximity interrupts
> + *  @prox_persistence:      H/W Filters, Number of 'out of limits' proximity
> + *                          readings.
> + *  @prox_interrupt_en:     Enable/Disable proximity interrupts.
>   *  @prox_thres_low:        Low threshold proximity detection.
> - *  @prox_thres_high:       High threshold proximity detection
> - *  @prox_pulse_count:      Number if proximity emitter pulses
> - *  @prox_max_samples_cal:  Used for prox cal.
> + *  @prox_thres_high:       High threshold proximity detection.
> + *  @prox_pulse_count:      Number if proximity emitter pulses.
> + *  @prox_max_samples_cal:  The number of samples that are taken when performing
> + *                          a proximity calibration.
> + *  @prox_diode             Which diode(s) to use for driving the external
> + *                          LED(s) for proximity sensing.
> + *  @prox_power             The amount of power to use for the external LED(s).
>   */
>  struct tsl2x7x_settings {
>  	int als_time;
> @@ -88,9 +91,6 @@ struct tsl2x7x_settings {
>  
>  /**
>   * struct tsl2X7X_platform_data - Platform callback, glass and defaults
> - * @platform_power:            Suspend/resume platform callback
> - * @power_on:                  Power on callback
> - * @power_off:                 Power off callback
>   * @platform_lux_table:        Device specific glass coefficents
>   * @platform_default_settings: Device specific power on defaults
>   *


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

* Re: [PATCH 13/13] staging: iio: tsl2x7x: rename prox_config to als_prox_config
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:38     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:38 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:53 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The configuration register on the device is represented with the
> prox_config member on the tsl2x7x_settings structure. According to the
> TSL2772 data sheet, this register can hold: 1) the proximity drive
> level, 2) ALS/Proximity long wait, and 3) the ALS gain level. This
> patch renames prox_config to als_prox_config since ALS settings can
> be stored here as well.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied to the togreg branch of iio.git.

So I think I picked up all but 2 where there were minor suggestions.

Looking forward to the final set!

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 7 ++++---
>  drivers/staging/iio/light/tsl2x7x.h | 5 +++--
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 05c0f3d5fac0..708b2c6bdf4b 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -56,7 +56,7 @@
>  #define TSL2X7X_PRX_MAXTHRESHLO		0X0A
>  #define TSL2X7X_PRX_MAXTHRESHHI		0X0B
>  #define TSL2X7X_PERSISTENCE		0x0C
> -#define TSL2X7X_PRX_CONFIG		0x0D
> +#define TSL2X7X_ALS_PRX_CONFIG		0x0D
>  #define TSL2X7X_PRX_COUNT		0x0E
>  #define TSL2X7X_GAIN			0x0F
>  #define TSL2X7X_NOTUSED			0x10
> @@ -207,7 +207,7 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = {
>  	.prox_time = 255, /* 2.73 ms */
>  	.prox_gain = 0,
>  	.wait_time = 255,
> -	.prox_config = 0,
> +	.als_prox_config = 0,
>  	.als_gain_trim = 1000,
>  	.als_cal_target = 150,
>  	.als_persistence = 1,
> @@ -594,7 +594,8 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  	/* Non calculated parameters */
>  	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
>  	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
> -	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
> +	chip->tsl2x7x_config[TSL2X7X_ALS_PRX_CONFIG] =
> +		chip->settings.als_prox_config;
>  
>  	chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
>  		(chip->settings.als_thresh_low) & 0xFF;
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 85d8fe7a94c8..6e30e71a2127 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -48,7 +48,8 @@ struct tsl2x7x_lux {
>   *                          increments. Total integration time is
>   *                          (256 - prx_time) * 2.73.
>   *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
> - *  @prox_config:           Prox configuration filters.
> + *  @als_prox_config:       The value of the ALS / Proximity configuration
> + *                          register.
>   *  @als_cal_target:        Known external ALS reading for calibration.
>   *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
>   *  @als_interrupt_en:      Enable/Disable ALS interrupts
> @@ -73,7 +74,7 @@ struct tsl2x7x_settings {
>  	int wait_time;
>  	int prox_time;
>  	int prox_gain;
> -	int prox_config;
> +	int als_prox_config;
>  	int als_cal_target;
>  	u8 als_persistence;
>  	bool als_interrupt_en;

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 13/13] staging: iio: tsl2x7x: rename prox_config to als_prox_config
@ 2018-04-21 16:38     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:38 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:53 -0400
Brian Masney <masneyb@onstation.org> wrote:

> The configuration register on the device is represented with the
> prox_config member on the tsl2x7x_settings structure. According to the
> TSL2772 data sheet, this register can hold: 1) the proximity drive
> level, 2) ALS/Proximity long wait, and 3) the ALS gain level. This
> patch renames prox_config to als_prox_config since ALS settings can
> be stored here as well.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied to the togreg branch of iio.git.

So I think I picked up all but 2 where there were minor suggestions.

Looking forward to the final set!

Thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 7 ++++---
>  drivers/staging/iio/light/tsl2x7x.h | 5 +++--
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 05c0f3d5fac0..708b2c6bdf4b 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -56,7 +56,7 @@
>  #define TSL2X7X_PRX_MAXTHRESHLO		0X0A
>  #define TSL2X7X_PRX_MAXTHRESHHI		0X0B
>  #define TSL2X7X_PERSISTENCE		0x0C
> -#define TSL2X7X_PRX_CONFIG		0x0D
> +#define TSL2X7X_ALS_PRX_CONFIG		0x0D
>  #define TSL2X7X_PRX_COUNT		0x0E
>  #define TSL2X7X_GAIN			0x0F
>  #define TSL2X7X_NOTUSED			0x10
> @@ -207,7 +207,7 @@ static const struct tsl2x7x_settings tsl2x7x_default_settings = {
>  	.prox_time = 255, /* 2.73 ms */
>  	.prox_gain = 0,
>  	.wait_time = 255,
> -	.prox_config = 0,
> +	.als_prox_config = 0,
>  	.als_gain_trim = 1000,
>  	.als_cal_target = 150,
>  	.als_persistence = 1,
> @@ -594,7 +594,8 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
>  	/* Non calculated parameters */
>  	chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
>  	chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
> -	chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
> +	chip->tsl2x7x_config[TSL2X7X_ALS_PRX_CONFIG] =
> +		chip->settings.als_prox_config;
>  
>  	chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
>  		(chip->settings.als_thresh_low) & 0xFF;
> diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> index 85d8fe7a94c8..6e30e71a2127 100644
> --- a/drivers/staging/iio/light/tsl2x7x.h
> +++ b/drivers/staging/iio/light/tsl2x7x.h
> @@ -48,7 +48,8 @@ struct tsl2x7x_lux {
>   *                          increments. Total integration time is
>   *                          (256 - prx_time) * 2.73.
>   *  @prox_gain:             Index into the tsl2x7x_prx_gain array.
> - *  @prox_config:           Prox configuration filters.
> + *  @als_prox_config:       The value of the ALS / Proximity configuration
> + *                          register.
>   *  @als_cal_target:        Known external ALS reading for calibration.
>   *  @als_persistence:       H/W Filters, Number of 'out of limits' ALS readings.
>   *  @als_interrupt_en:      Enable/Disable ALS interrupts
> @@ -73,7 +74,7 @@ struct tsl2x7x_settings {
>  	int wait_time;
>  	int prox_time;
>  	int prox_gain;
> -	int prox_config;
> +	int als_prox_config;
>  	int als_cal_target;
>  	u8 als_persistence;
>  	bool als_interrupt_en;


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

* Re: [PATCH 11/13] staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time
  2018-04-21  0:41   ` Brian Masney
@ 2018-04-21 16:39     ` Jonathan Cameron
  -1 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:39 UTC (permalink / raw)
  To: Brian Masney
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Fri, 20 Apr 2018 20:41:51 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch changes the defaults of the als_time, prox_time and
> wait_time to match the defaults according to the TSL2772 datasheet.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied, thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index a7b4fcba7935..293810ff11b9 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -201,11 +201,11 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
>  };
>  
>  static const struct tsl2x7x_settings tsl2x7x_default_settings = {
> -	.als_time = 219, /* 101 ms */
> +	.als_time = 255, /* 2.73 ms */
>  	.als_gain = 0,
> -	.prox_time = 254, /* 5.4 ms */
> +	.prox_time = 255, /* 2.73 ms */
>  	.prox_gain = 0,
> -	.wait_time = 245,
> +	.wait_time = 255,
>  	.prox_config = 0,
>  	.als_gain_trim = 1000,
>  	.als_cal_target = 150,

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 11/13] staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time
@ 2018-04-21 16:39     ` Jonathan Cameron
  0 siblings, 0 replies; 56+ messages in thread
From: Jonathan Cameron @ 2018-04-21 16:39 UTC (permalink / raw)
  To: Brian Masney
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Fri, 20 Apr 2018 20:41:51 -0400
Brian Masney <masneyb@onstation.org> wrote:

> This patch changes the defaults of the als_time, prox_time and
> wait_time to match the defaults according to the TSL2772 datasheet.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied, thanks,

Jonathan

> ---
>  drivers/staging/iio/light/tsl2x7x.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index a7b4fcba7935..293810ff11b9 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -201,11 +201,11 @@ static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
>  };
>  
>  static const struct tsl2x7x_settings tsl2x7x_default_settings = {
> -	.als_time = 219, /* 101 ms */
> +	.als_time = 255, /* 2.73 ms */
>  	.als_gain = 0,
> -	.prox_time = 254, /* 5.4 ms */
> +	.prox_time = 255, /* 2.73 ms */
>  	.prox_gain = 0,
> -	.wait_time = 245,
> +	.wait_time = 255,
>  	.prox_config = 0,
>  	.als_gain_trim = 1000,
>  	.als_cal_target = 150,


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

* Re: [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
  2018-04-21 16:16     ` Jonathan Cameron
@ 2018-04-21 17:04       ` Brian Masney
  -1 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21 17:04 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: devel, lars, linux-iio, gregkh, linux-kernel, Jon.Brenner,
	pmeerw, knaack.h

On Sat, Apr 21, 2018 at 05:16:38PM +0100, Jonathan Cameron wrote:
> On Fri, 20 Apr 2018 20:41:42 -0400
> Brian Masney <masneyb@onstation.org> wrote:
> 
> > The summary text for the GPL is not needed since the SPDX identifier
> > is a legally binding shorthand that can be used instead.
> > 
> > Signed-off-by: Brian Masney <masneyb@onstation.org>
> I sanity checked against other drivers because I wasn't 100% sure
> this wasn't a valid formatting for SPDX.  It doesn't seem to be.
> Normally convention is
> //SPDX... 
> On the first line of the file.
> C style comments also fine, but it needs to be a comment line on it's
> own.  This is all about making it trivial for automated tools to find.

The style that you referenced is the most common style, however I saw
quite a few places in the kernel use the style used by this patch so I
thought that it may be acceptable.

$ grep -r SPDX arch/ drivers/ include/ | grep \* | grep -v ":\/"

I'll resubmit the patch next week with hopefully the last bit of
cleanups to get this driver out of staging.

Brian



> > ---
> >  drivers/staging/iio/light/tsl2x7x.c | 10 +---------
> >  drivers/staging/iio/light/tsl2x7x.h | 14 +-------------
> >  2 files changed, 2 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> > index eeccfbb0eb1f..9cdcc8c9e812 100644
> > --- a/drivers/staging/iio/light/tsl2x7x.c
> > +++ b/drivers/staging/iio/light/tsl2x7x.c
> > @@ -5,15 +5,7 @@
> >   * Copyright (c) 2012, TAOS Corporation.
> >   * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
> >   *
> > - * This program is free software; you can redistribute it and/or modify
> > - * it under the terms of the GNU General Public License as published by
> > - * the Free Software Foundation; either version 2 of the License, or
> > - * (at your option) any later version.
> > - *
> > - * This program is distributed in the hope that it will be useful, but WITHOUT
> > - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> > - * more details.
> > + * SPDX-License-Identifier: GPL-2.0+
> >   */
> >  
> >  #include <linux/delay.h>
> > diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> > index d382cdbb976e..992ee2465609 100644
> > --- a/drivers/staging/iio/light/tsl2x7x.h
> > +++ b/drivers/staging/iio/light/tsl2x7x.h
> > @@ -4,19 +4,7 @@
> >   *
> >   * Copyright (c) 2012, TAOS Corporation.
> >   *
> > - * This program is free software; you can redistribute it and/or modify
> > - * it under the terms of the GNU General Public License as published by
> > - * the Free Software Foundation; either version 2 of the License, or
> > - * (at your option) any later version.
> > - *
> > - * This program is distributed in the hope that it will be useful, but WITHOUT
> > - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> > - * more details.
> > - *
> > - * You should have received a copy of the GNU General Public License along
> > - * with this program; if not, write to the Free Software Foundation, Inc.,
> > - * 51 Franklin Street, Fifth Floor, Boston, MA	02110-1301, USA.
> > + * SPDX-License-Identifier: GPL-2.0+
> >   */
> >  
> >  #ifndef __TSL2X7X_H
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
@ 2018-04-21 17:04       ` Brian Masney
  0 siblings, 0 replies; 56+ messages in thread
From: Brian Masney @ 2018-04-21 17:04 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, gregkh, devel, knaack.h, lars, pmeerw, linux-kernel,
	Jon.Brenner

On Sat, Apr 21, 2018 at 05:16:38PM +0100, Jonathan Cameron wrote:
> On Fri, 20 Apr 2018 20:41:42 -0400
> Brian Masney <masneyb@onstation.org> wrote:
> 
> > The summary text for the GPL is not needed since the SPDX identifier
> > is a legally binding shorthand that can be used instead.
> > 
> > Signed-off-by: Brian Masney <masneyb@onstation.org>
> I sanity checked against other drivers because I wasn't 100% sure
> this wasn't a valid formatting for SPDX.  It doesn't seem to be.
> Normally convention is
> //SPDX... 
> On the first line of the file.
> C style comments also fine, but it needs to be a comment line on it's
> own.  This is all about making it trivial for automated tools to find.

The style that you referenced is the most common style, however I saw
quite a few places in the kernel use the style used by this patch so I
thought that it may be acceptable.

$ grep -r SPDX arch/ drivers/ include/ | grep \* | grep -v ":\/"

I'll resubmit the patch next week with hopefully the last bit of
cleanups to get this driver out of staging.

Brian



> > ---
> >  drivers/staging/iio/light/tsl2x7x.c | 10 +---------
> >  drivers/staging/iio/light/tsl2x7x.h | 14 +-------------
> >  2 files changed, 2 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> > index eeccfbb0eb1f..9cdcc8c9e812 100644
> > --- a/drivers/staging/iio/light/tsl2x7x.c
> > +++ b/drivers/staging/iio/light/tsl2x7x.c
> > @@ -5,15 +5,7 @@
> >   * Copyright (c) 2012, TAOS Corporation.
> >   * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
> >   *
> > - * This program is free software; you can redistribute it and/or modify
> > - * it under the terms of the GNU General Public License as published by
> > - * the Free Software Foundation; either version 2 of the License, or
> > - * (at your option) any later version.
> > - *
> > - * This program is distributed in the hope that it will be useful, but WITHOUT
> > - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> > - * more details.
> > + * SPDX-License-Identifier: GPL-2.0+
> >   */
> >  
> >  #include <linux/delay.h>
> > diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
> > index d382cdbb976e..992ee2465609 100644
> > --- a/drivers/staging/iio/light/tsl2x7x.h
> > +++ b/drivers/staging/iio/light/tsl2x7x.h
> > @@ -4,19 +4,7 @@
> >   *
> >   * Copyright (c) 2012, TAOS Corporation.
> >   *
> > - * This program is free software; you can redistribute it and/or modify
> > - * it under the terms of the GNU General Public License as published by
> > - * the Free Software Foundation; either version 2 of the License, or
> > - * (at your option) any later version.
> > - *
> > - * This program is distributed in the hope that it will be useful, but WITHOUT
> > - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> > - * more details.
> > - *
> > - * You should have received a copy of the GNU General Public License along
> > - * with this program; if not, write to the Free Software Foundation, Inc.,
> > - * 51 Franklin Street, Fifth Floor, Boston, MA	02110-1301, USA.
> > + * SPDX-License-Identifier: GPL-2.0+
> >   */
> >  
> >  #ifndef __TSL2X7X_H

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

end of thread, other threads:[~2018-04-21 17:04 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-21  0:41 [PATCH 00/13] iio: tsl2x7x: staging cleanups Brian Masney
2018-04-21  0:41 ` Brian Masney
2018-04-21  0:41 ` [PATCH 01/13] staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:13   ` Jonathan Cameron
2018-04-21 16:13     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:16   ` Jonathan Cameron
2018-04-21 16:16     ` Jonathan Cameron
2018-04-21 17:04     ` Brian Masney
2018-04-21 17:04       ` Brian Masney
2018-04-21  0:41 ` [PATCH 03/13] staging: iio: tsl2x7x: don't return error in IRQ handler Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:18   ` Jonathan Cameron
2018-04-21 16:18     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 04/13] staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:20   ` Jonathan Cameron
2018-04-21 16:20     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 05/13] staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:23   ` Jonathan Cameron
2018-04-21 16:23     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 06/13] staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:25   ` Jonathan Cameron
2018-04-21 16:25     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 07/13] staging: iio: tsl2x7x: simplify device id verification Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:26   ` Jonathan Cameron
2018-04-21 16:26     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 08/13] staging: iio: tsl2x7x: add range checking to three sysfs attributes Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:31   ` Jonathan Cameron
2018-04-21 16:31     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 09/13] staging: iio: tsl2x7x: move power and diode settings into header file Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:33   ` Jonathan Cameron
2018-04-21 16:33     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 10/13] staging: iio: tsl2x7x: rename prx to prox for consistency Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:33   ` Jonathan Cameron
2018-04-21 16:33     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 11/13] staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:39   ` Jonathan Cameron
2018-04-21 16:39     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 12/13] staging: iio: tsl2x7x: various comment cleanups Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:37   ` Jonathan Cameron
2018-04-21 16:37     ` Jonathan Cameron
2018-04-21  0:41 ` [PATCH 13/13] staging: iio: tsl2x7x: rename prox_config to als_prox_config Brian Masney
2018-04-21  0:41   ` Brian Masney
2018-04-21 16:38   ` Jonathan Cameron
2018-04-21 16:38     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.