1. 05 Jun, 2018 4 commits
    • Eugen Hristev's avatar
      iio: adc: select buffer for at91-sama5d2_adc · 6d67a723
      Eugen Hristev authored
      commit 76974ef9 upstream.
      We need to select the buffer code, otherwise we get build errors
      with undefined functions on the trigger and buffer,
      if we select just IIO and then AT91_SAMA5D2_ADC from menuconfig
      This adds a Kconfig 'select' statement like other ADC
      drivers have it already.
      Fixes: 5e1a1da0 ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support")
      Signed-off-by: Eugen Hristev's avatarEugen Hristev <eugen.hristev@microchip.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Martin Kelly's avatar
      iio:kfifo_buf: check for uint overflow · 838f25e3
      Martin Kelly authored
      commit 3d13de4b upstream.
      Currently, the following causes a kernel OOPS in memcpy:
      echo 1073741825 > buffer/length
      echo 1 > buffer/enable
      Note that using 1073741824 instead of 1073741825 causes "write error:
      Cannot allocate memory" but no OOPS.
      This is because 1073741824 == 2^30 and 1073741825 == 2^30+1. Since kfifo
      rounds up to the nearest power of 2, it will actually call kmalloc with
      roundup_pow_of_two(length) * bytes_per_datum.
      Using length == 1073741825 and bytes_per_datum == 2, we get:
      kmalloc(roundup_pow_of_two(1073741825) * 2
      or kmalloc(2147483648 * 2)
      or kmalloc(4294967296)
      or kmalloc(UINT_MAX + 1)
      so this overflows to 0, causing kmalloc to return ZERO_SIZE_PTR and
      subsequent memcpy to fail once the device is enabled.
      Fix this by checking for overflow prior to allocating a kfifo. With this
      check added, the above code returns -EINVAL when enabling the buffer,
      rather than causing an OOPS.
      Signed-off-by: default avatarMartin Kelly <mkelly@xevo.com>
      cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Martin Kelly's avatar
      iio:buffer: make length types match kfifo types · 30ab9366
      Martin Kelly authored
      commit c043ec1c upstream.
      Currently, we use int for buffer length and bytes_per_datum. However,
      kfifo uses unsigned int for length and size_t for element size. We need
      to make sure these matches or we will have bugs related to overflow (in
      the range between INT_MAX and UINT_MAX for length, for example).
      In addition, set_bytes_per_datum uses size_t while bytes_per_datum is an
      int, which would cause bugs for large values of bytes_per_datum.
      Change buffer length to use unsigned int and bytes_per_datum to use
      Signed-off-by: default avatarMartin Kelly <mkelly@xevo.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Michael Nosthoff's avatar
      iio: ad7793: implement IIO_CHAN_INFO_SAMP_FREQ · d30819ab
      Michael Nosthoff authored
      commit 490fba90 upstream.
      This commit is a follow-up to changes made to ad_sigma_delta.h
      in staging: iio: ad7192: implement IIO_CHAN_INFO_SAMP_FREQ
      which broke ad7793 as it was not altered to match those changes.
      This driver predates the availability of IIO_CHAN_INFO_SAMP_FREQ
      attribute wherein usage has some advantages like it can be accessed by
      in-kernel consumers as well as reduces the code size.
      Therefore, use IIO_CHAN_INFO_SAMP_FREQ to implement the
      sampling_frequency attribute instead of using IIO_DEV_ATTR_SAMP_FREQ()
      Move code from the functions associated with IIO_DEV_ATTR_SAMP_FREQ()
      into respective read and write hooks with the mask set to
      Fixes: a13e831f ("staging: iio: ad7192: implement IIO_CHAN_INFO_SAMP_FREQ")
      Signed-off-by: default avatarMichael Nosthoff <committed@heine.so>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  2. 28 Mar, 2018 4 commits
  3. 19 Mar, 2018 2 commits
  4. 28 Feb, 2018 4 commits
    • Lars-Peter Clausen's avatar
      iio: adis_lib: Initialize trigger before requesting interrupt · 6315213f
      Lars-Peter Clausen authored
      commit f027e0b3 upstream.
      The adis_probe_trigger() creates a new IIO trigger and requests an
      interrupt associated with the trigger. The interrupt uses the generic
      iio_trigger_generic_data_rdy_poll() function as its interrupt handler.
      Currently the driver initializes some fields of the trigger structure after
      the interrupt has been requested. But an interrupt can fire as soon as it
      has been requested. This opens up a race condition.
      iio_trigger_generic_data_rdy_poll() will access the trigger data structure
      and dereference the ops field. If the ops field is not yet initialized this
      will result in a NULL pointer deref.
      It is not expected that the device generates an interrupt at this point, so
      typically this issue did not surface unless e.g. due to a hardware
      misconfiguration (wrong interrupt number, wrong polarity, etc.).
      But some newer devices from the ADIS family start to generate periodic
      interrupts in their power-on reset configuration and unfortunately the
      interrupt can not be masked in the device.  This makes the race condition
      much more visible and the following crash has been observed occasionally
      when booting a system using the ADIS16460.
      	Unable to handle kernel NULL pointer dereference at virtual address 00000008
      	pgd = c0004000
      	[00000008] *pgd=00000000
      	Internal error: Oops: 5 [#1] PREEMPT SMP ARM
      	Modules linked in:
      	CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.0-04126-gf9739f0-dirty #257
      	Hardware name: Xilinx Zynq Platform
      	task: ef04f640 task.stack: ef050000
      	PC is at iio_trigger_notify_done+0x30/0x68
      	LR is at iio_trigger_generic_data_rdy_poll+0x18/0x20
      	pc : [<c042d868>]    lr : [<c042d924>]    psr: 60000193
      	sp : ef051bb8  ip : 00000000  fp : ef106400
      	r10: c081d80a  r9 : ef3bfa00  r8 : 00000087
      	r7 : ef051bec  r6 : 00000000  r5 : ef3bfa00  r4 : ee92ab00
      	r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : ee97e400
      	Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
      	Control: 18c5387d  Table: 0000404a  DAC: 00000051
      	Process swapper/0 (pid: 1, stack limit = 0xef050210)
      	[<c042d868>] (iio_trigger_notify_done) from [<c0065b10>] (__handle_irq_event_percpu+0x88/0x118)
      	[<c0065b10>] (__handle_irq_event_percpu) from [<c0065bbc>] (handle_irq_event_percpu+0x1c/0x58)
      	[<c0065bbc>] (handle_irq_event_percpu) from [<c0065c30>] (handle_irq_event+0x38/0x5c)
      	[<c0065c30>] (handle_irq_event) from [<c0068e28>] (handle_level_irq+0xa4/0x130)
      	[<c0068e28>] (handle_level_irq) from [<c0064e74>] (generic_handle_irq+0x24/0x34)
      	[<c0064e74>] (generic_handle_irq) from [<c021ab7c>] (zynq_gpio_irqhandler+0xb8/0x13c)
      	[<c021ab7c>] (zynq_gpio_irqhandler) from [<c0064e74>] (generic_handle_irq+0x24/0x34)
      	[<c0064e74>] (generic_handle_irq) from [<c0065370>] (__handle_domain_irq+0x5c/0xb4)
      	[<c0065370>] (__handle_domain_irq) from [<c000940c>] (gic_handle_irq+0x48/0x8c)
      	[<c000940c>] (gic_handle_irq) from [<c0013e8c>] (__irq_svc+0x6c/0xa8)
      To fix this make sure that the trigger is fully initialized before
      requesting the interrupt.
      Fixes: ccd2b52f ("staging:iio: Add common ADIS library")
      Reported-by: default avatarRobin Getz <Robin.Getz@analog.com>
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Stefan Windfeldt-Prytz's avatar
      iio: buffer: check if a buffer has been set up when poll is called · 9dc4030c
      Stefan Windfeldt-Prytz authored
      commit 4cd140bd upstream.
      If no iio buffer has been set up and poll is called return 0.
      Without this check there will be a null pointer dereference when
      calling poll on a iio driver without an iio buffer.
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarStefan Windfeldt-Prytz <stefan.windfeldt@axis.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Andreas Klinger's avatar
      iio: srf08: fix link error "devm_iio_triggered_buffer_setup" undefined · 1b985a6e
      Andreas Klinger authored
      commit 511051d5 upstream.
      Functions for triggered buffer support are needed by this module.
      If they are not defined accidentally by another driver, there's an error
      thrown out while linking.
      Add a select of IIO_BUFFER and IIO_TRIGGERED_BUFFER in the Kconfig file.
      Signed-off-by: default avatarAndreas Klinger <ak@it-klinger.de>
      Fixes: a8319593 ("iio: srf08: add triggered buffer support")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Fabrice Gasnier's avatar
      iio: adc: stm32: fix stm32h7_adc_enable error handling · f4f94e9b
      Fabrice Gasnier authored
      commit a3b5655e upstream.
      Error handling in stm32h7_adc_enable routine doesn't unwind enable
      sequence correctly. ADEN can only be cleared by hardware (e.g. by
      writing one to ADDIS).
      It's also better to clear ADRDY just after it's been set by hardware.
      Fixes: 95e339b6 ("iio: adc: stm32: add support for STM32H7")
      Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  5. 25 Feb, 2018 2 commits
  6. 07 Feb, 2018 1 commit
  7. 03 Feb, 2018 2 commits
  8. 25 Dec, 2017 1 commit
  9. 14 Dec, 2017 5 commits
  10. 10 Dec, 2017 2 commits
  11. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      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 <5
      All documentation files were explicitly excluded.
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
         For non */uapi/* files that summary was:
         SPDX license identifier                            # files
         GPL-2.0                                              11139
         and resulted in the first patch in this series.
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
         SPDX license identifier                            # files
         GPL-2.0 WITH Linux-syscall-note                        930
         and resulted in the second patch in this series.
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
         SPDX license identifier                            # files
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
         and that resulted in the third patch in this series.
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  12. 14 Oct, 2017 1 commit
  13. 08 Oct, 2017 1 commit
  14. 01 Oct, 2017 1 commit
  15. 25 Sep, 2017 2 commits
  16. 24 Sep, 2017 7 commits