summaryrefslogtreecommitdiffstats
path: root/drivers/iio
Commit message (Collapse)AuthorAgeFilesLines
* iio: dht11: Use usleep_range instead of msleep for start signalJohn Brooks2017-01-221-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DHT22 (AM2302) datasheet specifies that the LOW start pulse should not exceed 20ms. However, observations with an oscilloscope of an RPi Model 2B (rev 1.1) communicating with a DHT22 sensor showed that the driver was consistently sending start pulses longer than 20ms: Kernel 4.7.10-v7+ (n=132): Minimum pulse length: 20.20ms Maximum: 29.84ms Mean: 24.96ms StDev: 2.82ms Sensor response rate: 100% Read success rate: 76% On kernel 4.8, the start pulse was so long that the sensor would not even respond 97% of the time: Kernel 4.8.16-v7+ (n=100): Minimum pulse length: 30.4ms Maximum: 74.4ms Mean: 39.3ms StDev: 10.2ms Sensor response rate: 3% Read success rate: 3% The driver would return ETIMEDOUT and write log messages like this: [ 51.430987] dht11 dht11@0: Only 1 signal edges detected [ 66.311019] dht11 dht11@0: Only 0 signal edges detected Replacing msleep(18) with usleep_range(18000, 20000) made the pulse length sane again and restored responsiveness: Kernel 4.8.16-v7+ with usleep_range (n=123): Minimum pulse length: 18.16ms Maximum: 20.20ms Mean: 19.85ms StDev: 0.51ms Sensor response rate: 100% Read success rate: 84% Cc: stable@vger.kernel.org Signed-off-by: John Brooks <john@fastquake.com> Reviewed-by: Harald Geyer <harald@ccbib.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: adc: palmas_gpadc: retrieve a valid iio_dev in suspend/resumeAlison Schofield2017-01-211-2/+2
| | | | | | | | | | The suspend/resume functions were using dev_to_iio_dev() to get the iio_dev. That only works on IIO dev's. Use dev_get_drvdata() for a platform device to get the correct iio_dev. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: health: max30100: fixed parenthesis around FIFO count checkMatt Ranostay2017-01-211-1/+1
| | | | | | | | | | | | | | | FIFO was being read every sample after the "almost full" state was reached. This was due to an incorrect placement of the parenthesis in the while condition check. Note - the fixes tag is not actually correct, but the fix in this patch would also be needed for it to function correctly so we'll go with that one. Backports should pick up both. Signed-off-by: Matt Ranostay <matt@ranostay.consulting> Fixes: b74fccad7 ("iio: health: max30100: correct FIFO check condition") Cc: Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: health: afe4404: retrieve a valid iio_dev in suspend/resumeAlison Schofield2017-01-211-2/+2
| | | | | | | | | | | The suspend/resume functions were using dev_to_iio_dev() to get the iio_dev. That only works on IIO dev's. Replace it with i2c functions to get the correct iio_dev. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Acked-by: Andrew F. Davis <afd@ti.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: health: afe4403: retrieve a valid iio_dev in suspend/resumeAlison Schofield2017-01-211-2/+2
| | | | | | | | | | | The suspend/resume functions were using dev_to_iio_dev() to get the iio_dev. That only works on IIO dev's. Replace it with spi functions to get the correct iio_dev. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Acked-by: Andrew F. Davis <afd@ti.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* Merge tag 'iio-fixes-for-4.10a' of ↵Greg Kroah-Hartman2017-01-027-30/+41
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus Jonathan writes: First round of IIO fixes for the 4.10 cycle. * 104-quad-8 - Fix selecting wrong register when the index control register is desired. - Fix an off by one error when addressing the input/output control register. - Fix inverted logic on the active high / low control * bmi160 - Sleep for worst case rather than best case amount of time after cmd execution begins. * max44000 - typo fix in illuminance_integration_time_available listing. * st-sensors - Fix channel data passing. This one took a while to get tested on 24bit parts. Definitely one for stable asap as the bug broke quite a few parts. - lis3lv02 needs a data alignment bit set and the scaling was wrong. * ti_am335x - depend on HAS_DMA
| * iio: accel: st_accel: fix LIS3LV02 reading and scalingLinus Walleij2016-12-312-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LIS3LV02 has a special bit that need to be set to get the read values left aligned. Before this patch we get gibberish like this: iio_generic_buffer -a -c10 -n lis3lv02dl_accel (...) 0.000000 -0.010042 -0.642688 19155832931907 0.000000 -0.010042 -0.642688 19155858751073 Which is because we read a raw value for 1g as 64 which is the nominal 1024 for 1g shifted 4 bits to the left by being right-aligned rather than left aligned. Since all other sensors are left aligned, add some code to set the special DAS (data alignment setting) bit to 1 so that the right value is now read like this: iio_generic_buffer -a -c10 -n lis3lv02dl_accel (...) 0.000000 -0.147095 -10.120135 24761614364956 -0.029419 -0.176514 -10.120135 24761631624540 The scaling was weird as well: we have a gain of 1000 for 1g and 3000 for 6g. I don't even remember how I came up with the old values but they are wrong. Fixes: 3acddf74f807 ("iio: st-sensors: add support for lis3lv02d accelerometer") Cc: Lorenzo Bianconi <lorenzo.bianconi@st.com> Cc: Giuseppe Barba <giuseppe.barba@st.com> Cc: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: common: st_sensors: fix channel data parsingLorenzo Bianconi2016-12-312-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using realbits as i2c/spi read len, when that value is not byte aligned (e.g 12 bits), lead to skip msb part of out data registers. Fix this taking into account scan_type.shift in addition to scan_type.realbits as read length: read_len = DIV_ROUND_UP(realbits + shift, 8) This fix has been tested on 8, 12, 16, 24 bit sensors Fixes: e7385de5291e ("iio:st_sensors: align on storagebits boundaries") Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com> Tested-by: Linus Walleij <linus.walleij@linaro.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: max44000: correct value in illuminance_integration_time_availableAkinobu Mita2016-12-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the datasheet, the shortest available integration time for ALS ADC conversion is 1.5625ms but illuminance_integration_time_available sysfs file shows wrong value. Cc: Crestez Dan Leonard <leonard.crestez@intel.com> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Fixes: d5d8f49b6 ("max44000: Expose ambient sensor scaling") Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: adc: TI_AM335X_ADC should depend on HAS_DMAGeert Uytterhoeven2016-12-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | If NO_DMA=y: ERROR: "bad_dma_ops" [drivers/iio/adc/ti_am335x_adc.ko] undefined! Add a dependency on HAS_DMA to fix this. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Fixes: f438b9da (" drivers: iio: ti_am335x_adc: add dma support") Cc: <stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: bmi160: Fix time needed to sleep after command executionMarcin Niestroj2016-12-301-19/+6Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Datasheet specifies typical and maximum execution times for which CMD register is occupied after previous command execution. We took these values as minimum and maximum time for usleep_range() call before making a new command execution. To be sure, that the CMD register is no longer occupied we need to wait *at least* the maximum time specified by datasheet. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: 104-quad-8: Fix active level mismatch for the preset enable optionWilliam Breathitt Gray2016-12-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The set_to_preset_on_index sysfs attribute provides a boolean configuration option to enable a preset operation on the respective channel's counter when Index occurs. However, the corresponding configuration bit on the Input/Output Control register must be set low to enable the preset operation. This patch inverts the internal driver boolean logic exposed via the set_to_preset_on_index attribute in order to correctly configure the device which expects an active low bit. Fixes: 28e5d3bb0325 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8") Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: 104-quad-8: Fix off-by-one errors when addressing IORWilliam Breathitt Gray2016-12-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The Input/Output Control register (IOR) is offset by 1 from the respective channel data register. This patch fixes off-by-one errors when attempting to write to a channel IOR where the base address was not properly offset. Fixes: 28e5d3bb0325 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8") Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: 104-quad-8: Fix index control configurationWilliam Breathitt Gray2016-12-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The LS7266R1 requires bits 5 & 6 to be high in order to select the Index Control Register. This patch fixes a typo that incorrectly selects the Input/Output Control Register where the Index Control Register was desired. Fixes: 28e5d3bb0325 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8") Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* | ktime: Cleanup ktime_set() usageThomas Gleixner2016-12-251-3/+2Star
|/ | | | | | | | | | ktime_set(S,N) was required for the timespec storage type and is still useful for situations where a Seconds and Nanoseconds part of a time value needs to be converted. For anything where the Seconds argument is 0, this is pointless and can be replaced with a simple assignment. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org>
* iio: magnetometer: separate the values of attributes based on their usage ↵Ooi, Joyce2016-11-241-35/+112
| | | | | | | | | | | | | | | | | | | | | | | | type for HID compass sensor There are 2 usage types (Magnetic Flux and Heading data field) for HID compass sensor, thus the values of offset, scale, and sensitivity should be separated according to their respective usage type. The changes made are as below: 1. Hysteresis: A struct hid_sensor_common rot_attributes is created in struct magn_3d_state to contain the sensitivity for IIO_ROT. 2. Scale: scale_pre_decml and scale_post_decml are separated for IIO_MAGN and IIO_ROT. 3. Offset: Same as scale, value_offset is separated for IIO_MAGN and IIO_ROT. For sensitivity, HID_USAGE_SENSOR_ORIENT_MAGN_FLUX and HID_USAGE_SENSOR_ORIENT_MAGN_HEADING are used for sensivitity fields based on the HID Sensor Usages specifications. Hence, these changes are added on the sensitivity field. Signed-off-by: Ooi, Joyce <joyce.ooi@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: tsl2583: make array large enoughDan Carpenter2016-11-241-1/+1
| | | | | | | | | | | This array is supposed to have 10 elements. Smatch complains that with the current code we can have n == max_ints and read beyond the end of the array. Fixes: ac4f6eee8fe8 ("staging: iio: TAOS tsl258x: Device driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: accel: st_accel: inline per-sensor dataLinus Walleij2016-11-191-396/+206Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | We have #defines for all the individual sensor registers and value/mask pairs #defined at the top of the file and used at exactly one spot. This is usually good if the #defines give a meaning to the opaque magic numbers. However in this case, the semantic meaning is inherent in the name of the C99-addressable fields, and that means duplication of information, and only makes the code hard to maintain since you every time have to add a new #define AND update the site where it is to be used. Get rid of the #defines and just open code the values into the appropriate struct elements. Make sure to explicitly address the .hz and .value fields in the st_sensor_odr_avl struct so that the meaning of all values is clear. This patch is purely syntactic should have no semantic effect. Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Lorenzo Bianconi <lorenzo.bianconi@st.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: adc: Add support for STM32 ADCFabrice Gasnier2016-11-193-0/+529
| | | | | | | | This patch adds support for STMicroelectronics STM32 MCU's analog to digital converter. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: adc: Add support for STM32 ADC coreFabrice Gasnier2016-11-194-0/+368
| | | | | | | | | | | Add core driver for STMicroelectronics STM32 ADC (Analog to Digital Converter). STM32 ADC can be composed of up to 3 ADCs with shared resources like clock prescaler, common interrupt line and analog reference voltage. This core driver basically manages shared resources. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* Merge tag 'iio-for-4.10c' of ↵Greg Kroah-Hartman2016-11-1620-638/+2314
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Third set of IIO new device support, features and cleanup for the 4.10 cycle. Includes Peter Rosin's interesting drivers for a comparator. First complex use we have had with an analog front end made from discrete components. Brian Masney's work on moving the tsl2583 driver out of staging also feature extensively! New Drivers * DAC based on a digital potentiometer - New driver for the use of a dpot as a DAC. Includes bindings and Axentia entry in vendor prefixes. * Envelope detector baed on DAC and a comparator including device tree bindings. Staging Graduation * tsl2583. Core new features - Core provision for _available attributes. This one had been stalled for a long time until Peter picked it up and ran with it! - In kernel interface helpers to retrieve available info from channels. Driver new features * mcp4531 - Add range of available raw values (used for the dpot dac driver). Driver cleanups and fixes for issues introduced * ad7766 - Testing the wrong variable following devm_regulator_bulk_get introduced with the driver earlier in this cycle. * ad9832 - Fix a wrong ordering in the probe introduced in the previous set of patches. A use before allocation bug. * cros_ec_sensors - Testing for an error in a u8 will never work. * mpu3050 - Remove duplicate initializer for the module owner. - Add missing i2c dependency. - Inform the i2c mux core how it is used - step one in implifying device tree bindings. * st-sensors - Get rid of large number of uninformative defines in favour of putting the constants where they are relevant. It is clear what they are from where they are used. * tsl2583 - Fix unused function warning when CONFIG_PM disabled and remove the ifdefs in favour of __maybe_unused. - Refactor taos_chip_on to only read relevant registers. - Make sure calibscale and integration time are being set. - Verify chip is in ready to be used before calibration. - Remove some repeated checks for chip status (it's protected by a mutex so can't change until it's released) - Change current state storage from a tristate enum to a boolean seeing as only two values are actually used now. - Drop a redundant write to the control regiser in taos_probe (it's a noop) - Drop the FSF mailing address. - Clean up logging to not use hard coded function names (use __func__ instead). - Cleanup up variable and function name prefixes. - Alignment of #define fixes. - Fix comparison between signed and unsigned integer warnings. - Add some newlines in favour of readability. - Combine the two sysfs ABI docs that somehow ended up in different places. - Fix multiline comment syntax. - Move a code block to inside an else statement as it makes more sense there. - Change tsl2583_als_calibrate to return 0 rather than a value nothing reads. - Drop some pointless brackets - Don't assume 32bit unsigned int. - Change to a per device instance lux table. - Add missing tsl2583 to the list of supported devices in the intro comments. - Improve commment on clearing of interrupts. - Drop some uninformative comments. - Drop a memset call that doesn't do anything useful any more. - Don't initialize some return variables that are always set. - Add Brian Masney as a module author after all these changes.
| * staging: iio: tsl2583: move out of stagingBrian Masney2016-11-133-0/+921
| | | | | | | | | | | | | | Move tsl2580, tsl2581, tsl2583 driver out of staging into mainline. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: envelope-detector: ADC driver based on a DAC and a comparatorPeter Rosin2016-11-133-0/+433
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DAC is used to find the peak level of an alternating voltage input signal by a binary search using the output of a comparator wired to an interrupt pin. Like so: _ | \ input +------>-------|+ \ | \ .-------. | }---. | | | / | | dac|-->--|- / | | | |_/ | | | | | | | | irq|------<-------' | | '-------' Signed-off-by: Peter Rosin <peda@axentia.se> Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: dpot-dac: DAC driver based on a digital potentiometerPeter Rosin2016-11-133-0/+277
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is assumed that the dpot is used as a voltage divider between the current dpot wiper setting and the maximum resistance of the dpot. The divided voltage is provided by a vref regulator. .------. .-----------. | | | vref |--' .---. | regulator |--. | | '-----------' | | d | | | p | | | o | wiper | | t |<---------+ | | | | '---' dac output voltage | | '------+------------+ Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: mcp4531: provide range of available raw valuesPeter Rosin2016-11-131-42/+62
| | | | | | | | | | | | | | | | | | | | | | | | Example: $ cat '/sys/bus/iio/devices/iio:device0/out_resistance_raw_available' [0 1 256] Meaning: min 0, step 1 and max 256. Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: inkern: add helpers to query available values from channelsPeter Rosin2016-11-131-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | Specifically a helper for reading the available maximum raw value of a channel and a helper for forwarding read_avail requests for raw values from one iio driver to an iio channel that is consumed. These rather specific helpers are in turn built with generic helpers making it easy to build more helpers for available values as needed. Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio:core: add a callback to allow drivers to provide _available attributesJonathan Cameron2016-11-131-33/+226
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A large number of attributes can only take a limited range of values. Currently in IIO this is handled by directly registering additional *_available attributes thus providing this information to userspace. It is desirable to provide this information via the core for much the same reason this was done for the actual channel information attributes in the first place. If it isn't there, then it can only really be accessed from userspace. Other in kernel IIO consumers have no access to what valid parameters are. Two forms are currently supported: * list of values in one particular IIO_VAL_* format. e.g. 1.300000 1.500000 1.730000 * range specification with a step size: e.g. [1.000000 0.500000 2.500000] equivalent to 1.000000 1.5000000 2.000000 2.500000 An addition set of masks are used to allow different sharing rules for the *_available attributes generated. This allows for example: in_accel_x_offset in_accel_y_offset in_accel_offset_available. We could have gone with having a specification for each and every info_mask element but that would have meant changing the existing userspace ABI. This approach does not. Signed-off-by: Jonathan Cameron <jic23@kernel.org> [forward ported, added some docs and fixed buffer overflows /peda] Acked-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: pressure: st_pressure: inline per-sensor dataLinus Walleij2016-11-121-165/+92Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have #defines for all the individual sensor registers and value/mask pairs #defined at the top of the file and used at exactly one spot. This is usually good if the #defines give a meaning to the opaque magic numbers. However in this case, the semantic meaning is inherent in the name of the C99-addressable fields, and that means duplication of information, and only makes the code hard to maintain since you every time have to add a new #define AND update the site where it is to be used. Get rid of the #defines and just open code the values into the appropriate struct elements. Make sure to explicitly address the .hz and .value fields in the st_sensor_odr_avl struct so that the meaning of all values is clear. This patch is purely syntactic should have no semantic effect. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: magn: st_magn: inline per-sensor dataLinus Walleij2016-11-121-251/+125Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have #defines for all the individual sensor registers and value/mask pairs #defined at the top of the file and used at exactly one spot. This is usually good if the #defines give a meaning to the opaque magic numbers. However in this case, the semantic meaning is inherent in the name of the C99-addressable fields, and that means duplication of information, and only makes the code hard to maintain since you every time have to add a new #define AND update the site where it is to be used. Get rid of the #defines and just open code the values into the appropriate struct elements. Make sure to explicitly address the .hz and .value fields in the st_sensor_odr_avl struct so that the meaning of all values is clear. This patch is purely syntactic should have no semantic effect. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: gyro: st_gyro: inline per-sensor dataLinus Walleij2016-11-121-139/+66Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have #defines for all the individual sensor registers and value/mask pairs #defined at the top of the file and used at exactly one spot. This is usually good if the #defines give a meaning to the opaque magic numbers. However in this case, the semantic meaning is inherent in the name of the C99-addressable fields, and that means duplication of information, and only makes the code hard to maintain since you every time have to add a new #define AND update the site where it is to be used. Get rid of the #defines and just open code the values into the appropriate struct elements. Make sure to explicitly address the .hz and .value fields in the st_sensor_odr_avl struct so that the meaning of all values is clear. This patch is purely syntactic should have no semantic effect. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: imu: inv_mpu6050: inform the i2c mux core about how it is usedPeter Rosin2016-11-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The i2c mux core can then take appropriate action depending on if it is used for an actual i2c mux, or for an arbitrator or gate. In this case it is used as a gate. This will make devicetree bindings simpler when they are eventually added. Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: cros_ec_sensors_core: fix unsigned compared less than zero on statusColin Ian King2016-11-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | status is a u8 hence the check if status is less than zero has no effect. Fix this by replacing status with int ret so the less than zero compare will correctly detect errors. Issue found with static analysis with CoverityScan, CID 1375919 Signed-off-by: Colin Ian King <colin.king@canonical.com> Fixes: 974e6f02e27e ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub") Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio:adc: ad7766: testing the wrong variable in probeDan Carpenter2016-11-121-2/+2
| | | | | | | | | | | | | | | | | | We should be testing "ret" here. Fixes: aa16c6bd0e09 ("iio:adc: Add support for AD7766/AD7767") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: gyro: mpu3050: add I2C dependencyArnd Bergmann2016-11-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new mpu3050 driver fails to build if I2C is disabled: drivers/iio/built-in.o: In function `mpu3050_i2c_driver_exit': mpu3050-i2c.c:(.exit.text+0x17f): undefined reference to `i2c_del_driver' drivers/iio/built-in.o: In function `mpu3050_i2c_driver_init': mpu3050-i2c.c:(.init.text+0x215): undefined reference to `i2c_register_driver' This adds a Kconfig dependency to ensure we only build it when I2C is available. Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: gyro: mpu3050: remove duplicate initializerArnd Bergmann2016-11-081-1/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The newly added mpu3050 driver has two initializations for the module owner, which causes a warning for 'make W=1': include/linux/export.h:37:21: error: initialized field overwritten [-Werror=override-init] drivers/iio/gyro/mpu3050-core.c:749:19: note: in expansion of macro 'THIS_MODULE' This removes one of the two. Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* | Merge 4.9-rc5 into staging-nextGreg Kroah-Hartman2016-11-144-35/+42
|\ \ | |/ |/| | | | | | | | | We want the staging/iio fixes in here as well to resolve issues and merge problems. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * iio: maxim_thermocouple: detect invalid storage size in read()Arnd Bergmann2016-11-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As found by gcc -Wmaybe-uninitialized, having a storage_bytes value other than 2 or 4 will result in undefined behavior: drivers/iio/temperature/maxim_thermocouple.c: In function 'maxim_thermocouple_read': drivers/iio/temperature/maxim_thermocouple.c:141:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized] This probably cannot happen, but returning -EINVAL here is appropriate and makes gcc happy and the code more robust. Fixes: 231147ee77f3 ("iio: maxim_thermocouple: Align 16 bit big endian value of raw reads") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org> (cherry picked from commit 32cb7d27e65df9daa7cee8f1fdf7b259f214bee2) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * iio: hid-sensors: Increase the precision of scale to fix wrong reading ↵Song Hongyan2016-11-051-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | interpretation. While testing, it was observed that on some platforms the scale value from iio sysfs for gyroscope is always 0 (E.g. Yoga 260). This results in the final angular velocity component values to be zeros. This is caused by insufficient precision of scale value displayed in sysfs. If the precision is changed to nano from current micro, then this is sufficient to display the scale value on this platform. Since this can be a problem for all other HID sensors, increase scale precision of all HID sensors to nano from current micro. Results on Yoga 260: name scale before scale now -------------------------------------------- gyro_3d 0.000000 0.000000174 als 0.001000 0.001000000 magn_3d 0.000001 0.000001000 accel_3d 0.000009 0.000009806 Signed-off-by: Song Hongyan <hongyan.song@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: orientation: hid-sensor-rotation: Add PM function (fix non working driver)Song Hongyan2016-11-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fix makes newer ISH hubs work. Previous ones worked by lucky coincidence. Rotation sensor function does not work due to miss PM function. Add common hid sensor iio pm function for rotation sensor. Further clarification from Srinivas: If CONFIG_PM is not defined, then this prevents this sensor to function. So above commit caused this. This sensor was supposed to be always on to trigger wake up in prior external hubs. But with the new ISH hub this is not the case. Signed-off-by: Song Hongyan <hongyan.song@intel.com> Fixes: 2b89635e9a9e ("iio: hid_sensor_hub: Common PM functions") Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * iio: st_sensors: fix scale configuration for h3lis331dlLorenzo Bianconi2016-10-302-7/+13
| | | | | | | | | | | | | | | | | | | | fix scale configuration/parsing for h3lis331dl accel driver when sensitivity is higher than 1(m/s^2)/digit Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com> Fixes: 1e52fefc9b0c ("iio: accel: Add support for the h3lis331dl accelerometer") Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* | Merge tag 'iio-for-4.10b' of ↵Greg Kroah-Hartman2016-11-0723-7/+2797
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-testing Jonathan writes: Second round of new device support, cleanups and fixes for IIO in the 4.10 cycle This includes two branch merges for elements that may also go via MFD. New device support * cros_ec - new driver to support these Chrome OS contiguous sensors which are behind the Chrome OS embedded controller. Requires a few minor MFD and chrome platform changes. One follow up fix deals with some dependency issues in Kconfig. * mpu-3050 - new driver and device tree bindings for this venerable device. * st_accel - support for the lng2dm an Driver features * ad7192 - Add DVdd regulator handling * ad9832 - Add DVDD regulator handling * at91 - Suspend and resume support * si7020 - Device tree bindings * ti-am335x - DMA support - uses dma to accelerate short bursts of read back rather than full blown DMA buffer support. Greatly improved performance. Includes an MFD addition to give access to the address needed for DMA. * tsl2583 - Device tree bindings Cleanups and minor fixes * ad7192 - Fix regulator naming to match datasheet - Handle regulator errors correctly (so as to not break deferred probing) - Rename reg variable to reflect which regulator it is * ad5933 - Fix regulator naming to match datasheet - Handle regulator errors correctly (so as to not break deferred probing) * ad7746 - Fix a missing return value (fallout from previous patch set) * ad7780 - Fix regulator naming to match datasheet - Handle regulator errors correctly (so as to not break deferred probing) * ad9832 - Fix regulator naming to match datasheet - Handle regulator errors correctly (so as to not break deferred probing) - Rename reg regulator to reflect which one it is * ad9834 - Fix regulator naming to match datasheet - Handle regulator errors correctly (so as to not break deferred probing) * hts221 - Remove a duplicated include * maxim thermocouple - Handle a wrong storage side in read function. Prevent any problems that might be introduced by additions to this driver in future. * tsl2583 - big set from Brian Masney to drive this towards a staging graduation. - Convert to iio_chan_spec and read_raw / write_raw (in a couple of steps) - Improved error handling in various functions - Drop redundant power_state custom sysfs attribute. - Use IIO_*_ATTR* macros for remaining attributes. - Return an error code to userspace on invalid parameters being writen to sysfs files. - Add locking to various attribute accesses to remove possible races. - Add defines for various magic numbers. - Use smbus_read_byte_data instead of a write_byte followed by read_byte. - Query only relevant registers in probe. - Tidy up ordering of code comments. - Remove a pointless power off sequence in taos_chip_on. - Don't bother shutting down the chip when updating the lux table. The table is held entirely in the driver and doesn't effect the chip at all. - Drop a redundant i2c call in taos_als_calibrate where the same register is read twice in a row.
| * \ Merge branch 'ib-iio-mfd-ti335x_dma' into togregJonathan Cameron2016-11-051-3/+145
| |\ \ | | | | | | | | | | | | | | | | | | | | A local branch created as Lee requested these two patches were applied in a fashion that would later let him merge the same branch into MFD if needed.
| | * | drivers: iio: ti_am335x_adc: add dma supportMugunthan V N2016-11-051-3/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the required pieces to ti_am335x_adc driver for DMA support Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * | | iio: adc: at91: add suspend and resume callbackWenyou Yang2016-11-051-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add suspend/resume callback, support the pinctrl sleep state when the system suspend as well. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * | | iio: hid-sensor-attributes: Check sample_frequency/hysteresis write data ↵Song Hongyan2016-11-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | legitimacy Neither sample frequency value nor hysteresis value can be set to be a negative number, check and return "Invalid argument" if they are negative. If not do this change, sample_frequency will be set into some unknown value, read hysteresis value after write negative number will return "Invalid argument". Signed-off-by: Song Hongyan <hongyan.song@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| * | | Merge branch 'ib-iio-mfd-4.9rc1' into togregJonathan Cameron2016-11-017-0/+977
| |\ \ \ | | | | | | | | | | | | | | | Immutable branch to allow mfd changes to also be available in Lee's MFD tree.
| | * | | iio:cros_ec_sensors: Swap from a select to a depends in KconfigJonathan Cameron2016-11-011-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Would have merged this into the original patch as a fixup but I've already pushed that out as an immutable branch for others to use so it'll have to be a separate patch. The original select had a typo as well. Trying to do this via a select was opening a can of worms due to a tree of other elements that would also have needed selecting. A simple depends seems much mroe straight forward and appropriate in this case. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Cc: Lee Jones <lee.jones@linaro.org> Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
| | * | | platform/chrome: cros_ec_dev - Register cros-ec sensorsEnric Balletbo i Serra2016-10-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check whether the ChromeOS Embedded Controller is a sensor hub and in such case issue a command to get the number of sensors and register them all. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Reviewed-by: Guenter Roeck <groeck@chromium.org> Acked-by: Olof Johansson <olof@lixom.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| | * | | iio: cros_ec_sensors: add ChromeOS EC Contiguous Sensors driverEnric Balletbo i Serra2016-10-253-0/+332
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handle 3d contiguous sensors like Accelerometers, Gyroscope and Magnetometer that are presented by the ChromeOS EC Sensor hub. Signed-off-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| | * | | iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.Enric Balletbo i Serra2016-10-256-0/+646
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the core functions to be able to support the sensors attached behind the ChromeOS Embedded Controller and used by other IIO cros-ec sensor drivers. The cros_ec_sensor_core driver matches with current driver in ChromeOS 4.4 tree, so it includes all the fixes at the moment. The support for this driver was made by Gwendal Grignou. The original patch and all the fixes has been squashed and rebased on top of mainline. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Guenter Roeck <groeck@chromium.org> [eballetbo: split, squash and rebase on top of mainline the patches found in ChromeOS tree] Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>