summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/light
AgeCommit message (Collapse)Author
2018-01-08staging: iio: light: Add breaks to lengthy linesGeorge Edward Bulmer
This fixes three instances of checkpatch warning: WARNING: line over 80 characters Signed-off-by: George Edward Bulmer <gebulmer@googlemail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-21staging: iio: tsl2x7x: put function definitions on a single lineBrian Masney
The functions tsl2x7x_invoke_change() and tsl2x7x_prox_calculate() are short enough that the return value and static declaration can be moved onto the same line with the function name. This patch makes that change to increase code readability. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: fix alignment of break statementsBrian Masney
Correct the alignment of the break statements to match the alignment of the rest of the code within the case statements. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: rename power defines to improve code readabilityBrian Masney
The LED power defines are named like TSL2X7X_mAXXX. Rename these values to TSL2X7X_XXX_mA to improve code readability. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: correct alignment of parenthesisBrian Masney
Correct error from checkpatch.pl to improve code readibility: Alignment should match open parenthesis. An unnecessary cast to 'struct tsl2x7x_lux *' was removed and the return value of static definition of in_illuminance0_calibscale_available_show() was put on its own line due to the length of that sysfs attribute. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: correct alignment of parenthesisBrian Masney
Correct error from checkpatch.pl to improve code readibility: Alignment should match open parenthesis. This involved shortening the name of tsl2x7x_als_gainadj and tsl2x7x_prx_gainadj to tsl2x7x_als_gain and tsl2x7x_prx_gain respectively. This also required removing the ch0lux and ch1lux local variables in order to get the line short enough. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: remove unnecessary parenthesesBrian Masney
This patch fixes the error 'Unnecessary parentheses around 'XXX' from checkpatch.pl. It also fixes several other places with unnecessary parentheses that checkpatch.pl did not detect. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: convert in_proximity0_calibscale_available to use ↵Brian Masney
IIO_CONST_ATTR The sysfs attribute in_proximity0_calibscale_available is currently created by using DEVICE_ATTR_RO(). Convert this over to use IIO_CONST_ATTR(). Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: changed #defines to be aligned on the same columnBrian Masney
Some of the existing #defines have tabs between the name, and the value, while others have spaces. The alignment of the values mostly has a consistent layout, but there are some that don't. Change all of the defines so that the name and value is separated by tabs and all of the values start on the same column to increase code readability. This patch also removes the unnecessary parentheses around the value of TSL2X7X_MAX_TIMER_CNT. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: remove unnecessary struct iio_dev definitionBrian Masney
tsl2x7x.h has a blank definition for 'struct iio_dev' that is not needed. This patch removes that definition. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: sort #includesBrian Masney
Sort the #include statements for increased code readability. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: remove unused tsl2x7x_parse_result structureBrian Masney
The structure tsl2x7x_parse_result is not used so this patch removes its definition. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21staging: iio: tsl2x7x: migrate *_thresh_period sysfs attributes to ↵Brian Masney
iio_event_spec The sysfs attributes in_intensity0_thresh_period and in_proximity0_thresh_period are currently directly created by the driver. This patch migrates the creation of these sysfs attributes from the driver to using the IIO core via iio_event_spec. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09staging: iio: tsl2x7x: migrate in_illuminance0_integration_time sysfs ↵Brian Masney
attribute to iio_chan_spec The driver explicitly creates the in_illuminance0_integration_time sysfs attribute outside the IIO core. This attribute is available in the IIO core so this patches migrates the attribute to be created by the iio_chan_spec. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09staging: iio: tsl2x7x: rename tsl2x7x_settings variable to settingsBrian Masney
The length of the 'tsl2x7x_settings' variable within the tsl2X7X_chip structure makes some of the line lengths greater than 80 characters for upcoming patches. This patch shortens the name of the 'tsl2x7x_settings' variable in this structure to just 'settings' to improve code readability. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24staging: iio: tsl2x7x: clean up limit checksDan Carpenter
The background of this code is that we can either use the default tables or load our own table with sysfs. The default tables are three element arrays of struct tsl2x7x_lux. If we load the table with sysfs then we can have as many as nine elements. Which ever way we do it, the last element is always zeroed out. The most interesting part of this patch is in the in_illuminance0_lux_table_show() function. We were using the wrong limit, "TSL2X7X_MAX_LUX_TABLE_SIZE * 3", when it should have been just "TSL2X7X_MAX_LUX_TABLE_SIZE". This creates a static checker warning that we are going of bounds. However, since the last element is always zeroed out, that means we hit the break statement and the code works correctly despite the wrong limit check. I made several related readability changes. The most notable that I changed the MAX_DEFAULT_TABLE_BYTES define which was: I renamed the define to TSL2X7X_DEFAULT_TABLE_BYTES because it's not the max size, it's the only size. Also the size should really be expressed as sizeof(struct tsl2x7x_lux) * 3. In other words, 12 * 3 instead of 4 * 9. It's 36 bytes either way, so this doesn't change the behavior. Finally, I created the TSL2X7X_DEF_LUX_TABLE_SZ define instead of using the magic number 3. I declared the default tables using that define to hopefully signal to future programmers that if they want to use a different size they have to update all the related code. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03staging: iio: tsl2x7x: constify i2c_device_idArvind Yadav
i2c_device_id are not supposed to change at runtime. All functions working with i2c_device_id provided by <linux/i2c.h> work with const i2c_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-08-22staging:iio:light:tsl2x7x drop assignment of driver_moduleJonathan Cameron
The equivalent is now done via macro magic in the register call. Note this is the only case not found by the coccinelle script suggesting that perhaps that script needs to be a little more clever! Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-07-09staging: iio: tsl2x7x: check return value from tsl2x7x_invoke_change()Brian Masney
The return value from tsl2x7x_invoke_change() was not checked in most places in the driver. This patch adds the proper error checks. The return values inside tsl2x7x_invoke_change() are now checked by this patch as well. Previously, if there was an error turning the chip back on, then the driver would attempt to turn the chip off and incorrectly return success. The code to power off the chip is removed by this patch since we should fail fast. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-07-09staging: iio: tsl2x7x: use usleep_range() instead of mdelay()Brian Masney
This driver in some cases can busy wait for upwards of 15ms. Since the kernel at this point is not running in atomic context, and is running in process context, we can safely use usleep_range() instead. This patch changes the two occurrences of mdelay() to usleep_range(). Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-07-09staging: iio: tsl2x7x: refactor {read,write}_event_value to allow handling ↵Brian Masney
multiple iio_event_infos tsl2x7x_read_thresh() and tsl2x7x_write_thresh() currently assumes that IIO_EV_INFO_VALUE is the only iio_event_info that will be passed in. This patch refactors these two functions so that additional iio_event_infos can be passed in. The functions are renamed from tsl2x7x_{read,write}_thresh() to tsl2x7x_{read,write}_event_value(). This patch also adds the missing return value check to tsl2x7x_invoke_change() since this was previously missing. This patch is in preparation for moving the in_intensity0_thresh_period and in_proximity0_thresh_period sysfs attributes to be created by iio_event_spec. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-07-09staging: iio: tsl2x7x: cleaned up i2c calls in tsl2x7x_als_calibrate()Brian Masney
The calibration function calls i2c_smbus_write_byte() and i2c_smbus_read_byte(). These two function calls are replaced with a single call to i2c_smbus_read_byte_data() by this patch. This patch also removes an unnecessary call that reads the CNTRL register a second time. One of the error paths returned -1 if the ADC was not enabled and this patch changes that return value to -EINVAL. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-07-09staging: iio: tsl2x7x: remove tsl2x7x_i2c_read()Brian Masney
tsl2x7x_i2c_read() would call i2c_smbus_write_byte() and i2c_smbus_read_byte(). These two i2c functions can be replaced with a single call to i2c_smbus_read_byte_data(). This patch removes the tsl2x7x_i2c_read() function and replaces all occurrences with a call to i2c_smbus_read_byte_data(). Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-07-09staging: iio: tsl2x7x: remove redundant power_state sysfs attributeBrian Masney
The TSL2X7X driver has a custom power_state sysfs attribute. Remove this attribute since the runtime power management code provides a sysfs attribute to control the power state of the device. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-07-09staging: iio: tsl2x7x: add of_match table for device tree supportBrian Masney
Add device tree support for the tsl2x7x IIO driver with no custom properties. The device tree documentation is in a separate commit so that the changes to trivial-devices.txt can go in via the device tree subsystem. Signed-off-by: Brian Masney <masneyb@onstation.org> CC: Rob Herring <robh+dt@kernel.org> CC: Mark Rutland <mark.rutland@arm.com> CC: devicetree@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-05-21staging: iio: light: Replace symbolic permissions as per coding styleSurender Polsani
Fixed the following checkpatch.pl warnings: octal permissions are more preferable than symbolic permissions Replaced DEVICE_ATTR family macros with DEVICE_ATTR_RW family as suggested by Greg K-H. Changed attributes and function names where ever required to satisfy internal macro definitions like __ATTR__RW(). Signed-off-by: Surender Polsani <surenderpolsani@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-05-07tsl2x7x: remove paragraph about writing to the FSF's mailing addressEnric Balletbo i Serra
Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Enric Balletbo i Serra <eballetbo@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-05-07staging: iio: tsl2x7x: rename driver for consistency with other IIO light ↵Brian Masney
drivers This patch renames the tsl2x7x_core.c file to tsl2x7x.c so that the naming convention is consistent with other IIO light drivers outside of staging. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-26staging: iio: isl29028: move out of stagingBrian Masney
Move ISL29028 ALS / Proximity Sensor out of staging and into mainline. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-26staging: iio: isl29028: correct proximity sleep timesBrian Masney
The sysfs attribute in_proximity_sampling_frequency_available currently shows the values 1 3 5 10 13 20 83 100. These values are supposed to correspond to the sleep values 800 400 200 100 75 50 12.5 0 (all in ms). When passing in a sampling frequency of 3, it actually uses a sleep time of 200ms instead of the expected 400ms value. This patch changes the value shown by this sysfs attribute to use fixed-point numbers so that the correct sampling frequency is shown to the user. This patch also changes the code that updates the proximity sampling frequency to only allow values that are shown in the _available sysfs attribute. The original code showed the value 83 that corresponds to the sleep time 12 ms. The data sheet actually lists 12.5 ms as the sleep time, so the proximity frequency was updated to 80. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-26staging: iio: tsl2x7x: Replace deprecated macros (S_IRUGO, S_IWUSR)Paolo Cretaro
Use octal digits as suggested by checkpatch instead of deprecated macros. Signed-off-by: Paolo Cretaro <melko@frugalware.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-01staging: iio: light: tsl2x7x constify attribute_group structuressimran singhal
As the event_attrs field of iio_info structures is constant, so these attribute_group structures can also be declared constant. File size before: text data bss dec hex filename 15064 1528 0 16592 40d0 drivers/staging/iio/light/tsl2x7x_core.o File size after: text data bss dec hex filename 15192 1400 0 16592 40d0 drivers/staging/iio/light/tsl2x7x_core.o Signed-off-by: simran singhal <singhalsimran0@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25staging: iio: tsl2x7x_core: Fix standard deviation calculationEva Rachel Retuya
Standard deviation is calculated as the square root of the variance where variance is the mean of sample_sum and length. Correct the computation of statP->stddev in accordance to the proper calculation. Fixes: 3c97c08b5735 ("staging: iio: add TAOS tsl2x7x driver") Reported-by: Abhiram Balasubramanian <abhiram@cs.utah.edu> Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11staging: iio: isl29028: add copyrightBrian Masney
Add Brian Masney's copyright to the header for the several rounds of staging cleanups that has been done to this driver. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11staging: iio: isl29028: use the runtime power management for system sleepBrian Masney
With the introduction of runtime power management in commit 2db5054ac28d ("staging: iio: isl29028: add runtime power management support"), the system could go to sleep and turn off the device without notifying the runtime power management code. This patch changes the system suspend and resume to go through the runtime power management. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11staging: iio: isl29028: fix incorrect sleep time when taking initial ↵Brian Masney
proximity reading When proximity is enabled in isl29028_enable_proximity(), the function msleep() is called with the sampling frequency, which is not correct. This patch changes the code to sleep the specified amount of time listed in the datasheet instead. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11staging: iio: isl29028: change mdelay() to msleep()Brian Masney
This driver in some cases can busy wait for upwards of 100 ms. Since the kernel at this point is not running in atomic context, and is running in process context, we can safely use msleep() instead. This patch changes the two occurrences of mdelay() to msleep(). Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: add runtime power management supportBrian Masney
This patch adds runtime power management support to the isl29028 driver. It defaults to powering off the device after two seconds of inactivity. isl29028_chip_init_and_power_on() currently only zeros the CONFIGURE register on the chip, which will cause the chip to turn off. This patch also renames that function to isl29028_clear_configure_reg() since it is now used in several places. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: only set ALS scale when ALS/IR sensing is enabledBrian Masney
isl29028_chip_init_and_power_on() calls isl29028_set_als_scale() and this is not needed until the user actually needs to take a reading from the ALS/IR sensor. This patch moves the isl29028_set_als_scale() call from isl29028_chip_init_and_power_on() to isl29028_set_als_ir_mode(). This sets the stage for faster resume times from runtime power management if the user is only querying the proximity sensor. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: only set proximity sampling rate when proximity is ↵Brian Masney
enabled isl29028_chip_init_and_power_on() calls isl29028_set_proxim_sampling() and this is not needed until the user actually needs to take a proximity reading. This patch moves the isl29028_set_proxim_sampling() call from isl29028_chip_init_and_power_on() to isl29028_enable_proximity(). This sets the stage for faster resume times from the runtime power management if the user is only querying the ALS/IR sensor. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: remove enable flag from isl29028_enable_proximity()Brian Masney
isl29028_enable_proximity() has a boolean argument named enable. This function is only called once and the enable flag is set to true in that call. This patch removes the enable parameter from that function. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: remove unnecessary parenthesisBrian Masney
isl29028_write_raw() contains unnecessary parenthesis when checking to see if the passed in lux scale is valid. This patch removes the unnecessary parenthesis. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: remove out of memory log messageBrian Masney
If the call to devm_iio_device_alloc() fails, then isl29028_probe() logs a message saying that memory cannot be allocated. The user's system most likely has larger issues at this point. This patch removes that error message since the error code is passed on and the message is not necessary. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: remove unnecessary error logging in ↵Brian Masney
isl29028_chip_init_and_power_on() If the call to isl29028_chip_init_and_power_on() in isl29028_probe() fails, then isl29028_probe() will log an error message. All of the error paths in that call path already have error logging in place. This patch removes the unnecessary logging. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: made error messages consistentBrian Masney
The wording and style of the different error messages was not consistent. This patch makes the wording and style consistent throughout the driver. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: move failure logging into isl29028_set_als_scale()Brian Masney
When isl29028_set_als_scale() fails, it was up to both callers to log the failure message. This patch moves the logging into isl29028_set_als_scale() to reduce the overall amount of code in the driver. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: move failure logging into isl29028_set_proxim_sampling()Brian Masney
When isl29028_set_proxim_sampling() fails, it was up to both callers to log the failure message. This patch moves the logging into isl29028_set_proxim_sampling() to reduce the overall amount of code in the driver. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: remove unused define ISL29028_DEV_ATTRBrian Masney
The #define ISL29028_DEV_ATTR was not used so this patch removes the unnecessary code. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: change newlines to improve readabilityBrian Masney
Add and remove newlines to improve code readability in preparation for moving the driver out of staging. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22staging: iio: isl29028: made alignment of variables in struct isl29028_chip ↵Brian Masney
consistent The alignment of the variables in the struct isl29028_chip is not consistent. This changes all of the variables to use consistent alignment to improve the code readability. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>