18 Apr, 2019

5 commits


06 Apr, 2019

1 commit

  • [ Upstream commit e0f0ae838a25464179d37f355d763f9ec139fc15 ]

    The pm8xxx_get_channel() implementation is unclear, and causes gcc to
    suddenly generate odd warnings. The trigger for the warning (at least
    for me) was the entirely unrelated commit 79a4e91d1bb2 ("device.h: Add
    __cold to dev_ logging functions"), which apparently changes gcc
    code generation in the caller function enough to cause this:

    drivers/iio/adc/qcom-pm8xxx-xoadc.c: In function ‘pm8xxx_xoadc_probe’:
    drivers/iio/adc/qcom-pm8xxx-xoadc.c:633:8: warning: ‘ch’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    ret = pm8xxx_read_channel_rsv(adc, ch, AMUX_RSV4,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    &read_nomux_rsv4, true);
    ~~~~~~~~~~~~~~~~~~~~~~~
    drivers/iio/adc/qcom-pm8xxx-xoadc.c:426:27: note: ‘ch’ was declared here
    struct pm8xxx_chan_info *ch;
    ^~

    because gcc for some reason then isn't able to see that the termination
    condition for the "for( )" loop in that function is also the condition
    for returning NULL.

    So it's not _actually_ uninitialized, but the function is admittedly
    just unnecessarily oddly written.

    Simplify and clarify the function, making gcc also see that it always
    returns a valid initialized value.

    Cc: Joe Perches
    Cc: Greg Kroah-Hartman
    Cc: Andy Gross
    Cc: David Brown
    Cc: Jonathan Cameron
    Cc: Hartmut Knaack
    Cc: Lars-Peter Clausen
    Cc: Peter Meerwald-Stadler
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Linus Torvalds
     

24 Mar, 2019

1 commit

  • commit 2ea8bab4dd2a9014e723b28091831fa850b82d83 upstream.

    Fix NULL pointer exception on device unbind when device tree does not
    contain "has-touchscreen" property. In such case the input device is
    not registered so it should not be unregistered.

    $ echo "12d10000.adc" > /sys/bus/platform/drivers/exynos-adc/unbind

    Unable to handle kernel NULL pointer dereference at virtual address 00000474
    ...
    (input_unregister_device) from [] (exynos_adc_remove+0x20/0x80)
    (exynos_adc_remove) from [] (platform_drv_remove+0x20/0x40)
    (platform_drv_remove) from [] (device_release_driver_internal+0xdc/0x1ac)
    (device_release_driver_internal) from [] (unbind_store+0x60/0xd4)
    (unbind_store) from [] (kernfs_fop_write+0x100/0x1e0)
    (kernfs_fop_write) from [] (__vfs_write+0x2c/0x17c)
    (__vfs_write) from [] (vfs_write+0xa4/0x184)
    (vfs_write) from [] (ksys_write+0x4c/0xac)
    (ksys_write) from [] (ret_fast_syscall+0x0/0x28)

    Fixes: 2bb8ad9b44c5 ("iio: exynos-adc: add experimental touchscreen support")
    Cc:
    Signed-off-by: Krzysztof Kozlowski
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Krzysztof Kozlowski
     

15 Feb, 2019

3 commits

  • commit f214ff521fb1f861c8d7f7d0af98b06bf61b3369 upstream.

    Per Jonathan Cameron, the buffer needs to allocate room for a
    64 bit timestamp as well as the channels. Change the buffer
    to allocate this additional space.

    Fixes: 2a86487786b5c ("iio: adc: ti-ads8688: add trigger and buffer support")
    Signed-off-by: Dan Murphy
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Dan Murphy
     
  • commit 0808831dc62e90023ad14ff8da4804c7846e904b upstream.

    IIO_TEMP scale value for temperature was incorrect and not in millicelsius
    as required by the ABI documentation.

    Signed-off-by: Matt Ranostay
    Fixes: 27dec00ecf2d (iio: chemical: add Atlas pH-SM sensor support)
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Matt Ranostay
     
  • commit 9bcf15f75cac3c6a00d8f8083a635de9c8537799 upstream.

    Prior to this commit there were 3 issues with our handling of the TS-pin:

    1) There are 2 ways how the firmware can disable monitoring of the TS-pin
    for designs which do not have a temperature-sensor for the battery:
    a) Clearing bit 0 of the AXP20X_ADC_EN1 register
    b) Setting bit 2 of the AXP288_ADC_TS_PIN_CTRL monitoring

    Prior to this commit we were unconditionally setting both bits to the
    value used on devices with a TS. This causes the temperature protection to
    kick in on devices without a TS, such as the Jumper ezbook v2, causing
    them to not charge under Linux.

    This commit fixes this by using regmap_update_bits when updating these 2
    registers, leaving the 2 mentioned bits alone.

    The next 2 problems are related to our handling of the current-source
    for the TS-pin. The current-source used for the battery temp-sensor (TS)
    is shared with the GPADC. For proper fuel-gauge and charger operation the
    TS current-source needs to be permanently on. But to read the GPADC we
    need to temporary switch the TS current-source to ondemand, so that the
    GPADC can use it, otherwise we will always read an all 0 value.

    2) Problem 2 is we were writing hardcoded values to the ADC TS pin-ctrl
    register, overwriting various other unrelated bits. Specifically we were
    overwriting the current-source setting for the TS and GPIO0 pins, forcing
    it to 80ųA independent of its original setting. On a Chuwi Vi10 tablet
    this was causing us to get a too high adc value (due to a too high
    current-source) resulting in the following errors being logged:

    ACPI Error: AE_ERROR, Returned by Handler for [UserDefinedRegion]
    ACPI Error: Method parse/execution failed \_SB.SXP1._TMP, AE_ERROR

    This commit fixes this by using regmap_update_bits to change only the
    relevant bits.

    3) After reading the GPADC channel we were unconditionally enabling the
    TS current-source even on devices where the TS-pin is not used and the
    current-source thus was off before axp288_adc_read_raw call.

    This commit fixes this by making axp288_adc_set_ts a nop on devices where
    the ADC is not enabled for the TS-pin.

    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1610545
    Fixes: 3091141d7803 ("iio: adc: axp288: Fix the GPADC pin ...")
    Signed-off-by: Hans de Goede
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede
     

13 Feb, 2019

3 commits

  • [ Upstream commit 7f6232e69539971cf9eaed07a6c14ab4a2361133 ]

    Various 2-in-1's use KIOX010A and KIOX020A as HIDs for 2 KXCJ91008
    accelerometers. The KIOX010A HID is for the one in the base and the
    KIOX020A for the accelerometer in the keyboard.

    Since userspace does not have a way yet to deal with (or ignore) the
    accelerometer in the keyboard, this commit just adds the KIOX010A HID
    for now so that display rotation will work.

    Related: https://github.com/hadess/iio-sensor-proxy/issues/166
    Signed-off-by: Hans de Goede
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Sasha Levin

    Hans de Goede
     
  • [ Upstream commit 50314f98b0ac468218e7c9af8c99f215a35436df ]

    Before this patch we are registering the internal clocks (for example on
    Meson8b, where the SAR ADC IP block implements the divider and gate
    clocks) with the following names:
    - /soc/cbus@c1100000/adc@8680#adc_div
    - /soc/cbus@c1100000/adc@8680#adc_en

    This is bad because the common clock framework uses the clock to create
    a directory in /clk. With such name, the directory creation
    (silently) fails and the debugfs entry ends up being created at the
    debugfs root.

    With this change, the new clock names are:
    - c1108680.adc#adc_div
    - c1108680.adc#adc_en

    This matches the clock naming scheme used in the PWM, Ethernet and MMC
    drivers. It also fixes the problem with debugfs.
    The idea is shamelessly taken from commit b96e9eb62841c5 ("pwm: meson:
    Fix mux clock names").

    Fixes: 3921db46a8c5bc ("iio: Convert to using %pOF instead of full_name")
    Signed-off-by: Martin Blumenstingl
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Sasha Levin

    Martin Blumenstingl
     
  • [ Upstream commit aad172b017617994343e36d8659c69e14cd694fd ]

    devm_kasprintf() may return NULL on failure of internal allocation thus
    the assignments to init.name are not safe if not checked. On error
    meson_sar_adc_clk_init() returns negative values so -ENOMEM in the
    (unlikely) failure case of devm_kasprintf() should be fine here.

    Signed-off-by: Nicholas Mc Guire
    Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
    Acked-by: Martin Blumenstingl
    Tested-by: Martin Blumenstingl
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Sasha Levin

    Nicholas Mc Guire
     

13 Jan, 2019

1 commit

  • commit 0e76df5c978338f3051e5126fc0c4245c57a307a upstream.

    This patch solves the register readback issue with the bit shift. When the
    dac resolution was lower than the register size (ex. 12 bits out of 16
    bits) the readback value was not shifted with the difference in bits and
    the value was higher. Also a mask is applied on the read value in order to
    get the value relative to the actual bit size.

    Fixes: 0357e488b8 ("iio:dac:ad5686: Refactor the driver")
    Signed-off-by: Mircea Caprioru
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Mircea Caprioru
     

06 Dec, 2018

2 commits

  • 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
     
  • commit 0145b50566e7de5637e80ecba96c7f0e6fff1aad upstream.

    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: Greg Kroah-Hartman

    Hans de Goede
     

14 Nov, 2018

4 commits

  • commit aea835f2dc8a682942b859179c49ad1841a6c8b9 upstream.

    When channels are registered, the hardware channel number is not the
    actual iio channel number.
    This is because the driver is probed with a certain number of accessible
    channels. Some pins are routed and some not, depending on the description of
    the board in the DT.
    Because of that, channels 0,1,2,3 can correspond to hardware channels
    2,3,4,5 for example.
    In the buffered triggered case, we need to do the translation accordingly.
    Fixed the channel number to stop reading the wrong channel.

    Fixes: 0e589d5fb ("ARM: AT91: IIO: Add AT91 ADC driver.")
    Cc: Maxime Ripard
    Signed-off-by: Eugen Hristev
    Acked-by: Ludovic Desroches
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Eugen Hristev
     
  • commit bc1b45326223e7e890053cf6266357adfa61942d upstream.

    When doing simple conversions, the driver did not acknowledge the DRDY irq.
    If this irq status is not acked, it will be left pending, and as soon as a
    trigger is enabled, the irq handler will be called, it doesn't know why
    this status has occurred because no channel is pending, and then it will go
    int a irq loop and board will hang.
    To avoid this situation, read the LCDR after a raw conversion is done.

    Fixes: 0e589d5fb ("ARM: AT91: IIO: Add AT91 ADC driver.")
    Cc: Maxime Ripard
    Signed-off-by: Eugen Hristev
    Acked-by: Ludovic Desroches
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Eugen Hristev
     
  • commit d3fa21c73c391975488818b085b894c2980ea052 upstream.

    Leaving for_each_child_of_node loop we should release child device node,
    if it is not stored for future use.

    Found by Linux Driver Verification project (linuxtesting.org).

    JC: I'm not sending this as a quick fix as it's been wrong for years,
    but good to pick up for stable after the merge window.

    Signed-off-by: Alexey Khoroshilov
    Fixes: 6df2e98c3ea56 ("iio: adc: Add imx25-gcq ADC driver")
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Alexey Khoroshilov
     
  • commit 8911a43bc198877fad9f4b0246a866b26bb547ab upstream.

    The correct way to handle errors returned by regualtor_get() and friends is
    to propagate the error since that means that an regulator was specified,
    but something went wrong when requesting it.

    For handling optional regulators, e.g. when the device has an internal
    vref, regulator_get_optional() should be used to avoid getting the dummy
    regulator that the regulator core otherwise provides.

    Signed-off-by: Lars-Peter Clausen
    Cc:
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Lars-Peter Clausen
     

09 Sep, 2018

1 commit

  • …23/iio into staging-linus

    Jonathan writes:

    First set of IIO fixes for the 4.19 cycle.

    * ad9523
    - sysfs write should return the number of characters used or an error, not
    0 which could result in an infinite loop in userspace.
    * lsm6dsx
    - Fix computation of length when updating the watermark to include
    timestamps avoiding the watermark being set earlier than intended.
    * maxim_thermocouple
    - Revert a patch adding the max31856 as it's not actually compatible with
    the register set that this driver supports.
    * si1133
    - Fix an impossible value check so we don't always error out whether the
    passed in value is good or bad.

    Greg Kroah-Hartman
     

03 Sep, 2018

1 commit


02 Sep, 2018

1 commit

  • This reverts commit 535fba29b3e1afef4ba201b3c69a6992583ec0bd.

    Seems the submitter (er me, hang head in shame) didn't look at the datasheet
    enough to see that the registers are quite different.

    This needs to be reverted because a) would never work b) to open it be added
    to a Maxim RTDs (Resistance Temperature Detectors) under development by author

    Signed-off-by: Matt Ranostay
    Signed-off-by: Jonathan Cameron

    Matt Ranostay
     

24 Aug, 2018

1 commit

  • Almost all files in the kernel are either plain text or UTF-8 encoded. A
    couple however are ISO_8859-1, usually just a few characters in a C
    comments, for historic reasons.

    This converts them all to UTF-8 for consistency.

    Link: http://lkml.kernel.org/r/20180724111600.4158975-1-arnd@arndb.de
    Signed-off-by: Arnd Bergmann
    Acked-by: Simon Horman [IPVS portion]
    Acked-by: Jonathan Cameron [IIO]
    Acked-by: Michael Ellerman [powerpc]
    Acked-by: Rob Herring
    Cc: Joe Perches
    Cc: Arnd Bergmann
    Cc: Samuel Ortiz
    Cc: "David S. Miller"
    Cc: Rob Herring
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

22 Aug, 2018

1 commit

  • Pull i2c updates from Wolfram Sang:

    - the core has now a lockless variant of i2c_smbus_xfer. Some open
    coded versions of this got removed in drivers. This also enables
    proper SCCB support in regmap.

    - locking got a more precise naming. i2c_{un}lock_adapter() had to go,
    and we know use i2c_lock_bus() consistently with flags like
    I2C_LOCK_ROOT_ADAPTER and I2C_LOCK_SEGMENT to avoid ambiguity.

    - the gpio fault injector got a new delicate testcase

    - the bus recovery procedure got fixed to handle the new testcase
    correctly

    - a new quirk flag for controllers not able to handle zero length
    messages together with driver updates to use it

    - new drivers: FSI bus attached I2C masters, GENI I2C controller, Owl
    family S900

    - and a good set of driver improvements and bugfixes

    * 'i2c/for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (77 commits)
    i2c: rcar: implement STOP and REP_START according to docs
    i2c: rcar: refactor private flags
    i2c: core: ACPI: Make acpi_gsb_i2c_read_bytes() check i2c_transfer return value
    i2c: core: ACPI: Properly set status byte to 0 for multi-byte writes
    dt-bindings: i2c: rcar: Add r8a774a1 support
    dt-bindings: i2c: sh_mobile: Add r8a774a1 support
    i2c: imx: Simplify stopped state tracking
    i2c: imx: Fix race condition in dma read
    i2c: pasemi: remove hardcoded bus numbers on smbus
    i2c: designware: Add SPDX license tag
    i2c: designware: Convert to use struct i2c_timings
    i2c: core: Parse SDA hold time from firmware
    i2c: designware-pcidrv: Mark expected switch fall-through
    i2c: amd8111: Mark expected switch fall-through
    i2c: sh_mobile: use core to detect 'no zero length read' quirk
    i2c: xlr: use core to detect 'no zero length' quirk
    i2c: rcar: use core to detect 'no zero length' quirk
    i2c: stu300: use core to detect 'no zero length' quirk
    i2c: pmcmsp: use core to detect 'no zero length' quirk
    i2c: mxs: use core to detect 'no zero length' quirk
    ...

    Linus Torvalds
     

02 Aug, 2018

2 commits


31 Jul, 2018

1 commit

  • The current check on val always results in true and so the
    call to sii1133_update_adcsens never gets called. Fix this check
    so it returns with -EINVAL only when val is not zero and not one.

    Detected by CoverityScan, CID#1472099 ("Logically dead code")

    Fixes: e01e7eaf37d8 ("iio: light: introduce si1133")
    Signed-off-by: Colin Ian King
    Signed-off-by: Jonathan Cameron

    Colin Ian King
     

29 Jul, 2018

8 commits


28 Jul, 2018

4 commits

  • wait_for_completion_timeout returns unsigned long not int so an appropriate
    variable is declared and the assignment and check fixed up.

    Signed-off-by: Nicholas Mc Guire
    Reviewed-by: Alexandru Ardelean
    Signed-off-by: Jonathan Cameron

    Nicholas Mc Guire
     
  • Bosch BME680 is a 4-in-1 sensor with temperature, pressure, humidity
    and gas sensing capability. It supports both I2C and SPI communication
    protocol for effective data communication.

    The device supports two modes:

    1. Sleep mode
    2. Forced mode

    The measurements only takes place when forced mode is triggered and a
    single TPHG cycle is performed by the sensor. The sensor automatically
    goes to sleep after afterwards.

    The device has various calibration constants/parameters programmed into
    devices' non-volatile memory(NVM) during production and can't be altered
    by the user. These constants are used in the compensation functions to
    get the required compensated readings along with the raw data. The
    compensation functions/algorithms are provided by Bosch Sensortec GmbH
    via their API[1]. As these don't change during the measurement cycle,
    therefore we read and store them at the probe. The default configs
    supplied by Bosch are also set at probe.

    0-day tested with build success.

    GSoC-2018: https://summerofcode.withgoogle.com/projects/#6691473790074880
    Mentor: Daniel Baluta
    [1] https://github.com/BoschSensortec/BME680_driver
    Datasheet:
    https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680-DS001-00.pdf

    Note from Jonathan: The compensation functions are 'interesting' and
    could do with a tidy up in future. However, they work so we can leave that
    for another day.

    Cc: Daniel Baluta
    Signed-off-by: Himanshu Jha
    Signed-off-by: Jonathan Cameron

    Himanshu Jha
     
  • The AD9523 supports external signals for power-down mode, resetting the
    device and sync timing.
    This change add support for specifying values for these signals via the
    gpios and initializing them default values.

    For the reset signal, the GPIO is toggled during probing to re-initialize
    the device to a known state.

    Signed-off-by: Michael Hennerich
    Signed-off-by: Lars-Peter Clausen
    Signed-off-by: Alexandru Ardelean
    Signed-off-by: Jonathan Cameron

    Michael Hennerich
     
  • A sysfs write callback function needs to either return the number of
    consumed characters or an error.

    The ad952x_store() function currently returns 0 if the input value was "0",
    this will signal that no characters have been consumed and the function
    will be called repeatedly in a loop indefinitely. Fix this by returning
    number of supplied characters to indicate that the whole input string has
    been consumed.

    Signed-off-by: Lars-Peter Clausen
    Signed-off-by: Alexandru Ardelean
    Fixes: cd1678f96329 ("iio: frequency: New driver for AD9523 SPI Low Jitter Clock Generator")
    Cc:
    Signed-off-by: Jonathan Cameron

    Lars-Peter Clausen