iio: tsl2x7x: staging cleanups
Subsystems (3)
cover iio: tsl2x7x: staging cleanups
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(-)
Signature · 6 lines
2.14.3 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 1/13 staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel
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
eventsin_illuminance0_calibratein_illuminance0_calibscale_availablein_illuminance0_inputin_illuminance0_lux_tablein_illuminance0_target_inputin_intensity0_calibbiasin_intensity0_calibscalein_intensity0_integration_timein_intensity0_integration_time_availablein_intensity0_rawin_intensity1_rawin_proximity0_calibratein_proximity0_calibscalein_proximity0_calibscale_availablein_proximity0_raw
nameof_node
power
subsystem
uevent
--- drivers/staging/iio/light/tsl2x7x.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +10 -10
@@ -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,
Signature · 6 lines
2.14.3 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Jonathan Cameron
maintainerRe: [PATCH 01/13] staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel
Quoted 28 lines · On Fri, 20 Apr 2018 20:41:41 -0400 Brian Masney <[email protected]> wrote:
The integration_time* attributes are currently associated with the
IIO_LIGHTchannel but should be associated with theIIO_INTENSITYchannel. Directory listing of the sysfs attributes for a TSL2772 with this patch applied:dev
eventsin_illuminance0_calibratein_illuminance0_calibscale_availablein_illuminance0_inputin_illuminance0_lux_tablein_illuminance0_target_inputin_intensity0_calibbiasin_intensity0_calibscalein_intensity0_integration_timein_intensity0_integration_time_availablein_intensity0_rawin_intensity1_rawin_proximity0_calibratein_proximity0_calibscalein_proximity0_calibscale_availablein_proximity0_raw
nameof_node
power
subsystem
uevent
Quoted 1 line
Signed-off-by Brian Masney <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 82 lines
--- drivers/staging/iio/light/tsl2x7x.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/staging/iio/light/tsl2x7x.c +8
-10@@ -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),
drivers/staging/iio/light/tsl2x7x.c static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { · line 1590
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.c +2
-0+ .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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 2/13 staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
In reply to Brian MasneyThe summary text for the GPL is not needed since the SPDX identifier is a legally binding shorthand that can be used instead.
--- drivers/staging/iio/light/tsl2x7x.c | 10 +--------- drivers/staging/iio/light/tsl2x7x.h | 14 +------------- 2 files changed, 2 insertions(+), 22 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +1 -9
@@ -5,15 +5,7 @@* Copyright (c) 2012, TAOS Corporation. * Copyright (c) 2017-2018 Brian Masney <[email protected]> * -* 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>
drivers/staging/iio/light/tsl2x7x.h +1 -13
@@ -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
Signature · 1 line
2.14.3
Jonathan Cameron
maintainerRe: [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
Quoted 4 lines · On Fri, 20 Apr 2018 20:41:42 -0400 Brian Masney <[email protected]> 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 <[email protected]>
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
Quoted 41 lines
--- drivers/staging/iio/light/tsl2x7x.c | 10 +--------- drivers/staging/iio/light/tsl2x7x.h | 14 +------------- 2 files changed, 2 insertions(+), 22 deletions(-)drivers/staging/iio/light/tsl2x7x.c +1
-9@@ -5,15 +5,7 @@* Copyright (c) 2012, TAOS Corporation. * Copyright (c) 2017-2018 Brian Masney <[email protected]> * -* 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> drivers/staging/iio/light/tsl2x7x.h +0
-7@@ -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
drivers/staging/iio/light/tsl2x7x.h line 10
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.h +1
-6-* 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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
Quoted 6 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 20 Apr 2018 20:41:42 -0400 Brian Masney <[email protected]> wrote:
The summary text for the GPL is not needed since the SPDX identifier is a legally binding shorthand that can be used instead.
Quoted 8 lines
Quoted 1 line
Signed-off-by Brian Masney <[email protected]>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
Quoted 51 lines
Quoted 51 lines
--- drivers/staging/iio/light/tsl2x7x.c | 10 +--------- drivers/staging/iio/light/tsl2x7x.h | 14 +------------- 2 files changed, 2 insertions(+), 22 deletions(-)drivers/staging/iio/light/tsl2x7x.c +1
-9@@ -5,15 +5,7 @@* Copyright (c) 2012, TAOS Corporation. * Copyright (c) 2017-2018 Brian Masney <[email protected]> * -* 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> drivers/staging/iio/light/tsl2x7x.h +1
-13@@ -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
PATCH 3/13 staging: iio: tsl2x7x: don't return error in IRQ handler
In reply to Brian Masneytsl2x7x_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.
--- drivers/staging/iio/light/tsl2x7x.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +2 -4
@@ -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 ; }
Signature · 6 lines
2.14.3 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Jonathan Cameron
maintainerRe: [PATCH 03/13] staging: iio: tsl2x7x: don't return error in IRQ handler
Quoted 6 lines · On Fri, 20 Apr 2018 20:41:43 -0400 Brian Masney <[email protected]> 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 returnsIRQ_HANDLED. An error will be logged if one occurs.Signed-off-by Brian Masney <[email protected]>
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
Quoted 18 lines
--- drivers/staging/iio/light/tsl2x7x.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/staging/iio/light/tsl2x7x.c +1
-1@@ -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 ) {
drivers/staging/iio/light/tsl2x7x.c static irqreturn_t tsl2x7x_event_handler(int irq, void *private) · line 1347
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.c +1
-3@@ -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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 4/13 staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
In reply to Brian Masneytsl2x7x_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.
--- drivers/staging/iio/light/tsl2x7x.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +15 -17
@@ -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 ; }
Signature · 6 lines
2.14.3 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 04/13] staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
Quoted 9 lines · On Fri, 20 Apr 2018 20:41:44 -0400 Brian Masney <[email protected]> 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 totsl2x7x_clear_interrupts()were removed. This patch removes thetsl2x7x_clear_interrupts()function and replaces the two callers with thei2c_smbus_write_byte()call instead.Signed-off-by Brian Masney <[email protected]>
Applied
Thanks,
Jonathan
Quoted 52 lines
--- drivers/staging/iio/light/tsl2x7x.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)drivers/staging/iio/light/tsl2x7x.c +8
-17@@ -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 );
drivers/staging/iio/light/tsl2x7x.c static irqreturn_t tsl2x7x_event_handler(int irq, void *private) · line 1345
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.c +7
-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 IRQ_HANDLED ; }
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 5/13 staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume
In reply to Brian Masneytsl2x7x_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.
--- drivers/staging/iio/light/tsl2x7x.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +2 -14
@@ -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)
Signature · 6 lines
2.14.3 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Jonathan Cameron
maintainerRe: [PATCH 05/13] staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume
Quoted 5 lines · On Fri, 20 Apr 2018 20:41:45 -0400 Brian Masney <[email protected]> wrote:
tsl2x7x_suspend()andtsl2x7x_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 <[email protected]>
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
Quoted 28 lines
--- drivers/staging/iio/light/tsl2x7x.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)drivers/staging/iio/light/tsl2x7x.c +1
-9@@ -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);
drivers/staging/iio/light/tsl2x7x.c static int tsl2x7x_probe(struct i2c_client *clientp, · line 1696
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.c +1
-5-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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 6/13 staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
In reply to Brian Masneytsl2x7x_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().
--- drivers/staging/iio/light/tsl2x7x.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +1 -6
@@ -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,
Signature · 1 line
2.14.3
Re: [PATCH 06/13] staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
Quoted 5 lines · On Fri, 20 Apr 2018 20:41:46 -0400 Brian Masney <[email protected]> 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 totsl2x7x_invoke_change().Signed-off-by Brian Masney <[email protected]>
Nice little cleanup.
Applied,
Thanks,
Jonathan
Quoted 18 lines
--- drivers/staging/iio/light/tsl2x7x.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/staging/iio/light/tsl2x7x.c +0
-1@@ -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;
drivers/staging/iio/light/tsl2x7x.c static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev, · line 994
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.c +1
-5- 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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 7/13 staging: iio: tsl2x7x: simplify device id verification
In reply to Brian MasneyThis 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.
--- drivers/staging/iio/light/tsl2x7x.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +5 -6
@@ -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__);
Signature · 1 line
2.14.3
Jonathan Cameron
maintainerRe: [PATCH 07/13] staging: iio: tsl2x7x: simplify device id verification
Quoted 5 lines · On Fri, 20 Apr 2018 20:41:47 -0400 Brian Masney <[email protected]> wrote:
This patch renames
tsl2x7x_device_id()totsl2x7x_device_id_verif(), removes the unnecessary pointer on the id parameter, and only calls the verification function once.Signed-off-by Brian Masney <[email protected]>
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
Quoted 36 lines
--- drivers/staging/iio/light/tsl2x7x.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/iio/light/tsl2x7x.c +4
-4@@ -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 ;
drivers/staging/iio/light/tsl2x7x.c static int tsl2x7x_probe(struct i2c_client *clientp, · line 1618
Quoted 9 lines
drivers/staging/iio/light/tsl2x7x.c +1
-2@@ -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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 8/13 staging: iio: tsl2x7x: add range checking to three sysfs attributes
In reply to Brian MasneyThe 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.
--- drivers/staging/iio/light/tsl2x7x.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +11 -14
@@ -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 )
Signature · 1 line
2.14.3
Jonathan Cameron
maintainerRe: [PATCH 08/13] staging: iio: tsl2x7x: add range checking to three sysfs attributes
Quoted 6 lines · On Fri, 20 Apr 2018 20:41:48 -0400 Brian Masney <[email protected]> wrote:
The sysfs attributes
in_illuminance0_target_input,in_illuminance0_calibrate, andin_proximity0_calibratedid not have proper range checking in place so this patch adds the correct range checks.Signed-off-by Brian Masney <[email protected]>
Comment inline.
Quoted 9 lines
--- drivers/staging/iio/light/tsl2x7x.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)drivers/staging/iio/light/tsl2x7x.c +0
-0
drivers/staging/iio/light/tsl2x7x.c static ssize_t in_illuminance0_target_input_store(struct device *dev, · line 839
Quoted 7 lines
drivers/staging/iio/light/tsl2x7x.c +2
-2@@ -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...
Quoted 33 lines
drivers/staging/iio/light/tsl2x7x.c +6
-8+ 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) {
drivers/staging/iio/light/tsl2x7x.c static ssize_t in_proximity0_calibrate_store(struct device *dev, · line 956
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.c +3
-4- 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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 9/13 staging: iio: tsl2x7x: move power and diode settings into header file
In reply to Brian MasneyThe 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.
--- drivers/staging/iio/light/tsl2x7x.c | 12 ------------ drivers/staging/iio/light/tsl2x7x.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +0 -12
@@ -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 */
drivers/staging/iio/light/tsl2x7x.h +12 -0
@@ -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.
Signature · 6 lines
2.14.3 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 09/13] staging: iio: tsl2x7x: move power and diode settings into header file
Quoted 5 lines · On Fri, 20 Apr 2018 20:41:49 -0400 Brian Masney <[email protected]> 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 <[email protected]>
Makes sense.
Applied,
Jonathan
Quoted 41 lines
--- drivers/staging/iio/light/tsl2x7x.c | 12 ------------ drivers/staging/iio/light/tsl2x7x.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-)drivers/staging/iio/light/tsl2x7x.c +0
-12@@ -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 */ drivers/staging/iio/light/tsl2x7x.h +5
-0@@ -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 +
drivers/staging/iio/light/tsl2x7x.h struct tsl2x7x_lux { · line 40
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.h +7
-0+/* 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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 10/13 staging: iio: tsl2x7x: rename prx to prox for consistency
In reply to Brian MasneyThe 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.
--- drivers/staging/iio/light/tsl2x7x.c | 12 ++++++------ drivers/staging/iio/light/tsl2x7x.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +6 -6
@@ -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 :
drivers/staging/iio/light/tsl2x7x.h +3 -3
@@ -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;
Signature · 1 line
2.14.3
Re: [PATCH 10/13] staging: iio: tsl2x7x: rename prx to prox for consistency
Quoted 9 lines · On Fri, 20 Apr 2018 20:41:50 -0400 Brian Masney <[email protected]> wrote:
The driver mostly uses the 'prox' naming convention for most of the proximity settings, however
prx_timeandtsl2x7x_prx_gainwas present. This patch renames these toprox_timeandtsl2x7x_prox_gainfor consistency with everything else in the driver.The kernel documentation for
prx_gainis corrected toprox_gainso that it matches what is actually in the structure.Signed-off-by Brian Masney <[email protected]>
Applied,
Thanks,
Jonathan
Quoted 80 lines
--- drivers/staging/iio/light/tsl2x7x.c | 12 ++++++------ drivers/staging/iio/light/tsl2x7x.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-)drivers/staging/iio/light/tsl2x7x.c +6
-6@@ -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 :drivers/staging/iio/light/tsl2x7x.h +2
-2@@ -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.
drivers/staging/iio/light/tsl2x7x.h struct tsl2x7x_settings { · line 74
Quoted 8 lines
drivers/staging/iio/light/tsl2x7x.h +1
-1@@ -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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 11/13 staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time
In reply to Brian MasneyThis patch changes the defaults of the als_time, prox_time and wait_time to match the defaults according to the TSL2772 datasheet.
--- drivers/staging/iio/light/tsl2x7x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +3 -3
@@ -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 ,
Signature · 6 lines
2.14.3 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 11/13] staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time
Quoted 4 lines · On Fri, 20 Apr 2018 20:41:51 -0400 Brian Masney <[email protected]> wrote:
This patch changes the defaults of the
als_time,prox_timeandwait_timeto match the defaults according to the TSL2772 datasheet.Signed-off-by Brian Masney <[email protected]>
Applied, thanks,
Jonathan
Quoted 13 lines
--- drivers/staging/iio/light/tsl2x7x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/staging/iio/light/tsl2x7x.c +0
-1@@ -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 */
drivers/staging/iio/light/tsl2x7x.c static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = { · line 211
Quoted 10 lines
drivers/staging/iio/light/tsl2x7x.c +3
-2+ .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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 12/13 staging: iio: tsl2x7x: various comment cleanups
In reply to Brian MasneyThis 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.
--- drivers/staging/iio/light/tsl2x7x.c | 59 +++++++++++++++++-------------------- drivers/staging/iio/light/tsl2x7x.h | 48 +++++++++++++++--------------- 2 files changed, 51 insertions(+), 56 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +27 -32
@@ -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 <[email protected]>
@@ -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" ,
drivers/staging/iio/light/tsl2x7x.h +24 -24
65 lines not on this page · raw message
Signature · 1 line
2.14.3
Re: [PATCH 12/13] staging: iio: tsl2x7x: various comment cleanups
Quoted 7 lines · On Fri, 20 Apr 2018 20:41:52 -0400 Brian Masney <[email protected]> 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 <[email protected]>
Looks sensible
Applied,
Thanks,
Jonathan
Quoted 210 lines
--- drivers/staging/iio/light/tsl2x7x.c | 59 +++++++++++++++++-------------------- drivers/staging/iio/light/tsl2x7x.h | 48 +++++++++++++++--------------- 2 files changed, 51 insertions(+), 56 deletions(-)drivers/staging/iio/light/tsl2x7x.c +27
-32@@ -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 <[email protected]> @@ -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" ,drivers/staging/iio/light/tsl2x7x.h +24
-21@@ -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;
drivers/staging/iio/light/tsl2x7x.h struct tsl2x7x_settings { · line 96
Quoted 9 lines
drivers/staging/iio/light/tsl2x7x.h +0
-3@@ -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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 13/13 staging: iio: tsl2x7x: rename prox_config to als_prox_config
In reply to Brian MasneyThe 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.
--- drivers/staging/iio/light/tsl2x7x.c | 7 ++++--- drivers/staging/iio/light/tsl2x7x.h | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/staging/iio/light/tsl2x7x.c +4 -3
@@ -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 ;
drivers/staging/iio/light/tsl2x7x.h +3 -2
@@ -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;
Signature · 1 line
2.14.3
Re: [PATCH 13/13] staging: iio: tsl2x7x: rename prox_config to als_prox_config
Quoted 8 lines · On Fri, 20 Apr 2018 20:41:53 -0400 Brian Masney <[email protected]> wrote:
The configuration register on the device is represented with the
prox_configmember on thetsl2x7x_settingsstructure. 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 renamesprox_configtoals_prox_configsince ALS settings can be stored here as well.Signed-off-by Brian Masney <[email protected]>
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
Quoted 52 lines
--- drivers/staging/iio/light/tsl2x7x.c | 7 ++++--- drivers/staging/iio/light/tsl2x7x.h | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-)drivers/staging/iio/light/tsl2x7x.c +4
-3@@ -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 ;drivers/staging/iio/light/tsl2x7x.h +2
-1@@ -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
drivers/staging/iio/light/tsl2x7x.h struct tsl2x7x_settings { · line 80
Quoted 8 lines
drivers/staging/iio/light/tsl2x7x.h +1
-1@@ -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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel