17 Dec, 2018

1 commit

  • [ Upstream commit 0145b50566e7de5637e80ecba96c7f0e6fff1aad ]

    Before this commit sensor_hub_input_attr_get_raw_value() failed to take
    the signedness of 16 and 8 bit values into account, returning e.g.
    65436 instead of -100 for the z-axis reading of an accelerometer.

    This commit adds a new is_signed parameter to the function and makes all
    callers pass the appropriate value for this.

    While at it, this commit also fixes up some neighboring lines where
    statements were needlessly split over 2 lines to improve readability.

    Signed-off-by: Hans de Goede
    Acked-by: Srinivas Pandruvada
    Acked-by: Benjamin Tissoires
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Sasha Levin

    Hans de Goede
     

06 Dec, 2018

1 commit

  • commit fe5192ac81ad0d4dfe1395d11f393f0513c15f7f upstream.

    Currently, we enable the device before we enable the device trigger. At
    high frequencies, this can cause interrupts that don't yet have a poll
    function associated with them and are thus treated as spurious. At high
    frequencies with level interrupts, this can even cause an interrupt storm
    of repeated spurious interrupts (~100,000 on my Beagleboard with the
    LSM9DS1 magnetometer). If these repeat too much, the interrupt will get
    disabled and the device will stop functioning.

    To prevent these problems, enable the device prior to enabling the device
    trigger, and disable the divec prior to disabling the trigger. This means
    there's no window of time during which the device creates interrupts but we
    have no trigger to answer them.

    Fixes: 90efe055629 ("iio: st_sensors: harden interrupt handling")
    Signed-off-by: Martin Kelly
    Tested-by: Denis Ciocca
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Martin Kelly
     

25 Dec, 2017

1 commit

  • [ Upstream commit e72a060151e5bb673af24993665e270fc4f674a7 ]

    Introduce register mask for data-ready status register since
    pressure sensors (e.g. LPS22HB) export just two channels
    (BIT(0) and BIT(1)) and BIT(2) is marked reserved while in
    st_sensors_new_samples_available() value read from status register
    is masked using 0x7.
    Moreover do not mask status register using active_scan_mask since
    now status value is properly masked and if the result is not zero the
    interrupt has to be consumed by the driver. This fix an issue on LPS25H
    and LPS331AP where channel definition is swapped respect to status
    register.
    Furthermore that change allows to properly support new devices
    (e.g LIS2DW12) that report just ZYXDA (data-ready) field in status register
    to figure out if the interrupt has been generated by the device.

    Fixes: 97865fe41322 (iio: st_sensors: verify interrupt event to status)
    Signed-off-by: Lorenzo Bianconi
    Reviewed-by: Linus Walleij
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Lorenzo Bianconi
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

25 Sep, 2017

1 commit

  • …/jic23/iio into staging-linus

    Jonathan writes:

    First round of IIO fixes for the 4.14 cycle

    Note this includes fixes from recent merge window. As such the tree
    is based on top of a prior staging/staging-next tree.

    * iio core
    - return and error for a failed read_reg debugfs call rather than
    eating the error.
    * ad7192
    - Use the dedicated reset function in the ad_sigma_delta library
    instead of an spi transfer with the data on the stack which
    could cause problems with DMA.
    * ad7793
    - Implement a dedicate reset function in the ad_sigma_delta library
    and use it to correctly reset this part.
    * bme280
    - ctrl_reg write must occur after any register writes
    for updates to take effect.
    * mcp320x
    - negative voltage readout was broken.
    - Fix an oops on module unload due to spi_set_drvdata not being called
    in probe.
    * st_magn
    - Fix the data ready line configuration for the lis3mdl. It is not
    configurable so the st_magn core was assuming it didn't exist
    and so wasn't consuming interrupts resulting in an unhandled
    interrupt.
    * stm32-adc
    - off by one error on max channels checking.
    * stm32-timer
    - preset should not be buffered - reorganising register writes avoids
    this.
    - fix a corner case in which write preset goes wrong when a timer is
    used first as a trigger then as a counter with preset. Odd case but
    you never know.
    * ti-ads1015
    - Fix setting of comparator polarity by fixing bitfield definition.
    * twl4030
    - Error path handling fix to cleanup in event of regulator
    registration failure.
    - Disable the vusb3v1 regulator correctly in error handling
    - Don't paper over a regulator enable failure.

    Greg Kroah-Hartman
     

04 Sep, 2017

1 commit

  • Data-ready line in LIS3MDL is routed to drdy pin and it is not possible
    to select a different INT pin. st_sensors_set_dataready_irq() assumes
    that if drdy int address is not exported in register map, irq trigger
    is not supported by the sensor and hw_irq_trigger is always false.
    Based on this configuration st_sensors_irq_thread does not consume
    generated interrupt causing an unhandled irq.
    Fix this taking into account status register address in
    st_sensors_set_dataready_irq()

    Fixes: 90efe0556292 (iio: st_sensors: harden interrupt handling)
    Signed-off-by: Lorenzo Bianconi
    Cc:
    Signed-off-by: Jonathan Cameron

    Lorenzo Bianconi
     

28 Aug, 2017

1 commit


20 Aug, 2017

6 commits


17 Aug, 2017

1 commit


02 Jul, 2017

2 commits


01 Jul, 2017

2 commits

  • Move st_sensors_of_i2c_probe() in st_sensors_core and rename it in
    st_sensors_of_name_probe(). That change is necessary to add device-tree
    support in spi code otherwise the rest of the autodetection will fail
    since spi->modalias (and indio_dev->name) will be set using compatible
    string value that differs from standard sensor name

    Signed-off-by: Lorenzo Bianconi
    Signed-off-by: Jonathan Cameron

    Lorenzo Bianconi
     
  • Enable multiread by default for LIS3MDL since using I2C interface
    the subaddr Msb is used to automatically increase the slave address
    during multiple data read/write. In the same way, using SPI interface,
    bit 1 in register address is used to enable auto-increment of the slave
    address in multiple read/write.

    Fixes: 872e79add756 (iio:magn: Add STMicroelectronics magn driver)
    Signed-off-by: Lorenzo Bianconi
    Signed-off-by: Jonathan Cameron

    Lorenzo Bianconi
     

11 Jun, 2017

1 commit


27 Mar, 2017

1 commit


19 Mar, 2017

2 commits

  • The driver doesn't have a struct of_device_id table but supported devices
    are registered via Device Trees. This is working on the assumption that a
    I2C device registered via OF will always match a legacy I2C device ID and
    that the MODALIAS reported will always be of the form i2c:.

    But this could change in the future so the correct approach is to have an
    OF device ID table if the devices are registered via OF.

    Signed-off-by: Javier Martinez Canillas
    Signed-off-by: Jonathan Cameron

    Javier Martinez Canillas
     
  • The driver doesn't have a struct of_device_id table but supported devices
    are registered via Device Trees. This is working on the assumption that a
    I2C device registered via OF will always match a legacy I2C device ID and
    that the MODALIAS reported will always be of the form i2c:.

    But this could change in the future so the correct approach is to have an
    OF device ID table if the devices are registered via OF.

    Signed-off-by: Javier Martinez Canillas
    Signed-off-by: Jonathan Cameron

    Javier Martinez Canillas
     

05 Mar, 2017

1 commit

  • Even if bus is not hot-pluggable, devices can be unbound from the
    driver via sysfs, so we should not be using __exit annotations on
    remove() methods. The only exception is drivers registered with
    platform_driver_probe() which specifically disables sysfs bind/unbind
    attributes.

    Signed-off-by: Dmitry Torokhov
    Reviewed-by: Linus Walleij
    Cc:
    Signed-off-by: Jonathan Cameron

    Dmitry Torokhov
     

21 Jan, 2017

1 commit


14 Jan, 2017

1 commit


25 Nov, 2016

1 commit

  • …or 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>

    Ooi, Joyce
     

12 Nov, 2016

1 commit

  • 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
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     

04 Oct, 2016

1 commit


28 Sep, 2016

1 commit


30 Aug, 2016

2 commits

  • Remove .owner field if calls are used which set it automatically.

    Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

    Signed-off-by: Wei Yongjun
    Acked-by: Linus Walleij
    Signed-off-by: Jonathan Cameron

    Wei Yongjun
     
  • The ak8974_configure() function is used only from the PM code,
    but that can be hidden when CONFIG_PM is disabled:

    drivers/iio/magnetometer/ak8974.c:201:12: error: 'ak8974_configure' defined but not used [-Werror=unused-function]

    This replaces the #ifdef with a __maybe_unused annotation, which
    will work correctly in all configurations and avoid the warning,
    as the compiler can now see where ak8974_configure is called from.

    Signed-off-by: Arnd Bergmann
    Fixes: 7c94a8b2ee8c ("iio: magn: add a driver for AK8974")
    Signed-off-by: Jonathan Cameron

    Arnd Bergmann
     

22 Aug, 2016

1 commit


15 Aug, 2016

1 commit

  • This adds a driver for the Asahi Kasei AK8974 and its sibling
    AMI305 magnetometers. It was deployed on scale in 2009 on a
    multitude of devices. It is distincly different from AK8973
    and AK8975 and needs its own driver.

    This patch is based on the long lost work of Samu Onkalo at Nokia,
    who made a misc character device driver for the Maemo/MeeGo Nokia
    devices, before the time of the IIO subsystem. It was mounted in e.g.
    the Nokia N950, N8, N86, N97 etc. It is also mounted on the
    ST-Ericsson HREF reference designs.

    It works nicely in sysfs:

    $ cat in_magn_x_raw && cat in_magn_y_raw && cat in_magn_z_raw
    -55
    -101
    161

    And with buffered reads using a simple HRTimer trigger:
    $ generic_buffer -c10 -a -n ak8974 -t foo
    iio device number being used is 3
    iio trigger number being used is 2
    No channels are enabled, enabling all channels
    Enabling: in_magn_x_en
    Enabling: in_magn_y_en
    Enabling: in_magn_z_en
    Enabling: in_timestamp_en
    /sys/bus/iio/devices/iio:device3 foo
    -58.000000 -102.000000 157.000000 946684970985321044
    -60.000000 -98.000000 159.000000 946684971012237548
    -60.000000 -106.000000 163.000000 946684971032257080
    -62.000000 -94.000000 169.000000 946684971052185058
    -58.000000 -98.000000 163.000000 946684971072204589
    -54.000000 -100.000000 163.000000 946684971092224121
    -53.000000 -103.000000 164.000000 946684971112731933
    -50.000000 -102.000000 165.000000 946684971132232666
    -61.000000 -101.000000 164.000000 946684971152191162
    -57.000000 -99.000000 168.000000 946684971172210693
    Disabling: in_magn_x_en
    Disabling: in_magn_y_en
    Disabling: in_magn_z_en
    Disabling: in_timestamp_en

    I cannot currently scale these raw values to gauss. This is
    because of lack of documentation. I have sent a request for
    a datasheet to Asahi Kasei.

    The driver can optionally use a DRDY line IRQ to capture data,
    else it will sleep and poll.

    Cc: Samu Onkalo
    Cc: Sebastian Reichel
    Cc: Peter Meerwald-Stadler
    Tested-By: Sebastian Reichel
    Signed-off-by: Linus Walleij
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     

01 Jul, 2016

7 commits

  • This adds runtime PM support to the AK8975 driver. It solves two
    problems:

    - After reading the first value the chip was left in MODE_ONCE,
    meaning (presumably) it may be consuming more power. Now the
    runtime PM hooks kick in and set it to POWER_DOWN.

    - Regulators were simply enabled and left on, making it
    impossible to turn the power consuming regulators off because
    of the increased refcount. We now disable the regulators at
    autosuspend.

    - We also handle system suspend: by using pm_runtime_force_suspend()
    and pm_runtime_force_resume() from the system PM sleep hooks,
    the runtime PM code is managing the power also for this case.
    It is currently not completely optimal: when the system resumes
    the AK8975 goes into active mode even if noone is going to use
    it: currently the force calls need to be paired, but the runtime
    PM people are working on making it possible to leave devices
    runtime suspended when coming back from sleep.

    Inspired by my work on the BH1780 light sensor driver.

    Signed-off-by: Linus Walleij
    Reviewed-by: Ulf Hansson
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     
  • The code was not powering the magnetometer down properly at
    remove(): just cutting the regulators without first setting the
    device in power off mode. Fix this.

    Signed-off-by: Linus Walleij
    Reviewed-by: Ulf Hansson
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     
  • The datasheet actually specifies that we need to wait atleast
    500us after powering on the device before trying to set mode.

    Signed-off-by: Linus Walleij
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     
  • Move the regulator_get() calls directly into the probe() function,
    keep only the power_on()/power_off() functions to flick the
    regulators on/off.

    Signed-off-by: Linus Walleij
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     
  • The AK8975 has two power sources: Vdd (analog voltage supply)
    and Vid (digital voltage supply). Optionally also obtain the Vid
    supply regulator and enable it.

    If an error occurs when enabling one of the regulators: bail out.

    Cc: Gregor Boirie
    Cc: Richard Leitner
    Cc: Krzysztof Kozlowski
    Cc: Lars-Peter Clausen
    Signed-off-by: Linus Walleij
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     
  • IS_ERR_OR_NULL() should never be used with regulators because
    a NULL pointer may be a perfectly valid dummy regulator

    We should always succeed to fetch and enable a regulator, but
    it may be a dummy. That is fine, so bail out for any real
    errors or probe deferrals

    Include the error code in the warning print so we know what
    kind of problem we're dealing with (for example it is nice to
    see if it is a probe deferral).

    As we will bail out of probe if the regulator is erroneous,
    just issue regulator_disable() on the poweroff path: it will
    succeed.

    Cc: Mark Brown
    Cc: Lars-Peter Clausen Lars-Peter Clausen
    Signed-off-by: Linus Walleij
    Signed-off-by: Jonathan Cameron

    Linus Walleij
     
  • Adds a new per-device sysfs attribute "current_timestamp_clock" to allow
    userspace to select a particular POSIX clock for buffered samples and
    events timestamping.

    Following clocks, as listed in clock_gettime(2), are supported:
    CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW,
    CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME and
    CLOCK_TAI.

    Signed-off-by: Gregor Boirie
    Acked-by: Sanchayan Maity
    Signed-off-by: Jonathan Cameron

    Gregor Boirie