Commit Graph

8 Commits

Author SHA1 Message Date
Jonathan Cameron 9275b1eaf0 iio: adc: mxs-lradc: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
[ Upstream commit 6a6be221b8bd561b053f0701ec752a5ed9007f69 ]

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.
Add a comment on why the buffer is the size it is as not immediately
obvious.

Found during an audit of all calls of this function.

Fixes: 6dd112b9f8 ("iio: adc: mxs-lradc: Add support for ADC driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210613152301.571002-4-jic23@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-14 16:53:43 +02:00
Thomas Gleixner c942fddf87 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
Based on 3 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version this program is distributed in the
  hope that it will be useful but without any warranty without even
  the implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [kishon] [vijay] [abraham]
  [i] [kishon]@[ti] [com] this program is distributed in the hope that
  it will be useful but without any warranty without even the implied
  warranty of merchantability or fitness for a particular purpose see
  the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [graeme] [gregory]
  [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
  [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
  [hk] [hemahk]@[ti] [com] this program is distributed in the hope
  that it will be useful but without any warranty without even the
  implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1105 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:37 -07:00
Kangjie Lu 13814627c9 iio: adc: fix a potential NULL pointer dereference
devm_iio_trigger_alloc may fail and return NULL. The fix returns
ENOMEM when it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:53 +01:00
Jonathan Cameron 52b31bcc93 iio:adc: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:22:25 +01:00
Greg Kroah-Hartman dd36a2d9ad Second set of IIO new device support, features and cleanups for the 4.13 cycle.
A few reverts here. One was a general failure to notice a device was already
 supported by another driver.  The second is due to a review comment pointing
 out that the original patch was a bad idea and would break existing systems.
 
 Reverts
 * bma180
   - Revert addition of support for the BMA250E it is already supported by
     the bmc150-accel and better supported at that. Oops.
 * hi8435
   - The fix for cleanup of the reset gpio stuff isn't a good way to go.  It
     breaks systems where an inverting level convertor is used.  The right fix
     is to make the original devicetree correct - even if it involves patching
     the devicetree in kernel.
 
 New Device Support
 * stm32-adc
   - STM32H7 support and bindings.
 
 Features
 * core
   - add a hardware triggered operating mode for systems in which the actual
     trigger is never seen by the kernel.  This is typically only used when
     a device 'can' use other triggers, but if a particular magic one is
     enabled the interrupt is effectively handled in hardware and we never see
     it.
 * st-lsm6dsx
   - support active low interrupts.
 * stm32-adc
   - Make the core adc clock optional as not all hardware supported requires it.
   - Make the bus clock optional in the per instance driver as it may be shared
     by all instances of the ADC and is handled by the core.
   - Rework to have a data structure representing the device type specific
     elements.
 * stm32-trigger (and counter)
   - Use the INDIO_HARDWARE_TRIGGERED_MODE where appropriate.
   - Add an attribute to configure device modes for quadrature counting etc.
 
 Clean ups and minor fixes
 * IIO core.
   - use __sysfs_match_string() helper rather than open coding the same.
 * ad7791
   - use sysfs_match_string() helper rather than open coding the same.
 * aspeed-adc
   - handle return value of clk_prepare_enable
 * cpcap
   - Fix default register values and ensure the battery thermistor is enabled
     correctly.
   - Fix the reported die temperature where we can - docs are lacking.
   - Remove the hung interrupt quirk as no longer happens due to fix in the
     mfd driver.
 * hi8435
   - Remove &s from hi8435_info definition as unneeded and inconsistent.
 * hid-sensor-trgger
   - Add kconfig depends on IIO_BUFFER (fixes patch in previous series)
 * ina2xx
   - Make the use of iio_info_mask* elements consistent for all channels.
     This doesn't have any visible effect, but acts as clear documentation of
     which channels various resulting attributes apply to.
 * lpc32xx
   - handle the return value of clk_prepare_enable.
 * meson-saradc
   - NULL instead of 0 for pointer.
 * mma9551
   - use NULL for GPIO connection ID to aid implementation fo ACPI support.
     Here the connection ID doesn't actually tell us anything and it is much
     easier to deal with the driver if it's not there.
 * mpu6050
   - Fix lock issues through use of a local mux.
   - Replace sprintf with scnprintf as appropriate.
   - Check whoami against all known values.  This allows for a small number of
     boards where we are really fishing for the part not being present at all.
     It is unfortunately common to have undescribed changes to use newer chips.
     We paper over this but just emitting a warning for those cases as long as
     we know about.
 * mxs-lradc
   - Fix some non static warnings.
 * rcar-adc
   - Part of making the naming for this part consistent across the kernel.
 * st_accel
   - drop some spi_device_id entries for variants with no SPI support
 * st_magn
   - drop some spi_device_id entries for variants with no SPI support.
 * sx9500
   - Use devm_gpiod_get instead of indexed value with an index of 0 on all
     occasions.
 * twl4030
   - Drop unused twl4030_get_madc_conversion as callers removed now throughout
     kernel.
   - Unexport twl4030_madc_conversion() as no used only within this driver.
   - Drop twl4030_madc_user_params as not used now.
   - Drop twl4030_madc_request.func_cb as not used now.
   - Fold the twl4030-madc.h header into the driver as no longer used anywhere
     else in the kernel.
 * xilinx
   - Handle the return value of clk_prepare_enable
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAllJSCURHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogTTQ//bbAzHKB0qTwusFN5jrz1JqjGj3+bMXH/
 KumP4nj7NzwKBe4tDe40FsdkZ4c+Um8pK2Aj7iJZojwTcCi02VVjbM++Gj0akMTZ
 MIlrEkTvqVsmVFG085hloSiFU2xXfTnfQmp19M9QtyDnHkgBMo9sOFnBK3EG+Se4
 NIliUvq8PJzCjTRVafSeSFNoDMwXXQTIKhfq8TDSeOG9o5mCTgAdy8yGiZ2ag/Ok
 peFfwauGs9Gg6tRour7UxccawuLnuzPNzwzUUSG3gkdIUTQVD6YHAzXzwblnB5P6
 0ZcErJpGSLAYcHQH310ZRTizhhW+vi+ftWUkps81xqpmFp3+EydVnJS0MZXYgM2o
 Cv6wbohp9w22I5/B9TMEfL7vnj1i4iZoJfi00Su1HBDHBiNpXISRc/fnkRMWavhr
 gvypyxngQmXm1JN/R8UMbJQsSpH3TN07AYF1qx0Tktfyx4S18rdW4hwt+kBNe9ni
 5G9xQU8IhmN8yvHMsTvZHbAmbuOR6iaghx3arf65qdHPvKSQ/nTSlran9U1JPvyJ
 tWVKtPaY5zEGgkQBmWee+qWkWOBGYDC4nmTwijB0u61Deq+5hGg55cZPd0fSXLMg
 6ecNg2v7zrdYldulOpfdNUEOrXa/NYBEAuYUNvccp8DArOqdazkCyO3DlDFDUXRw
 RKNE7Btx/rU=
 =2fJI
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.13b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of IIO new device support, features and cleanups for the 4.13 cycle.

A few reverts here. One was a general failure to notice a device was already
supported by another driver.  The second is due to a review comment pointing
out that the original patch was a bad idea and would break existing systems.

Reverts
* bma180
  - Revert addition of support for the BMA250E it is already supported by
    the bmc150-accel and better supported at that. Oops.
* hi8435
  - The fix for cleanup of the reset gpio stuff isn't a good way to go.  It
    breaks systems where an inverting level convertor is used.  The right fix
    is to make the original devicetree correct - even if it involves patching
    the devicetree in kernel.

New Device Support
* stm32-adc
  - STM32H7 support and bindings.

Features
* core
  - add a hardware triggered operating mode for systems in which the actual
    trigger is never seen by the kernel.  This is typically only used when
    a device 'can' use other triggers, but if a particular magic one is
    enabled the interrupt is effectively handled in hardware and we never see
    it.
* st-lsm6dsx
  - support active low interrupts.
* stm32-adc
  - Make the core adc clock optional as not all hardware supported requires it.
  - Make the bus clock optional in the per instance driver as it may be shared
    by all instances of the ADC and is handled by the core.
  - Rework to have a data structure representing the device type specific
    elements.
* stm32-trigger (and counter)
  - Use the INDIO_HARDWARE_TRIGGERED_MODE where appropriate.
  - Add an attribute to configure device modes for quadrature counting etc.

Clean ups and minor fixes
* IIO core.
  - use __sysfs_match_string() helper rather than open coding the same.
* ad7791
  - use sysfs_match_string() helper rather than open coding the same.
* aspeed-adc
  - handle return value of clk_prepare_enable
* cpcap
  - Fix default register values and ensure the battery thermistor is enabled
    correctly.
  - Fix the reported die temperature where we can - docs are lacking.
  - Remove the hung interrupt quirk as no longer happens due to fix in the
    mfd driver.
* hi8435
  - Remove &s from hi8435_info definition as unneeded and inconsistent.
* hid-sensor-trgger
  - Add kconfig depends on IIO_BUFFER (fixes patch in previous series)
* ina2xx
  - Make the use of iio_info_mask* elements consistent for all channels.
    This doesn't have any visible effect, but acts as clear documentation of
    which channels various resulting attributes apply to.
* lpc32xx
  - handle the return value of clk_prepare_enable.
* meson-saradc
  - NULL instead of 0 for pointer.
* mma9551
  - use NULL for GPIO connection ID to aid implementation fo ACPI support.
    Here the connection ID doesn't actually tell us anything and it is much
    easier to deal with the driver if it's not there.
* mpu6050
  - Fix lock issues through use of a local mux.
  - Replace sprintf with scnprintf as appropriate.
  - Check whoami against all known values.  This allows for a small number of
    boards where we are really fishing for the part not being present at all.
    It is unfortunately common to have undescribed changes to use newer chips.
    We paper over this but just emitting a warning for those cases as long as
    we know about.
* mxs-lradc
  - Fix some non static warnings.
* rcar-adc
  - Part of making the naming for this part consistent across the kernel.
* st_accel
  - drop some spi_device_id entries for variants with no SPI support
* st_magn
  - drop some spi_device_id entries for variants with no SPI support.
* sx9500
  - Use devm_gpiod_get instead of indexed value with an index of 0 on all
    occasions.
* twl4030
  - Drop unused twl4030_get_madc_conversion as callers removed now throughout
    kernel.
  - Unexport twl4030_madc_conversion() as no used only within this driver.
  - Drop twl4030_madc_user_params as not used now.
  - Drop twl4030_madc_request.func_cb as not used now.
  - Fold the twl4030-madc.h header into the driver as no longer used anywhere
    else in the kernel.
* xilinx
  - Handle the return value of clk_prepare_enable
2017-06-26 07:09:23 +02:00
Wei Yongjun 1454e15bc2 iio: adc: mxs-lradc: Fix return value check in mxs_lradc_adc_probe()
In case of error, the function devm_ioremap() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should
be replaced with NULL test. Also add NULL test for iores.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-06-03 10:52:31 +01:00
Paolo Cretaro f4f93bf77d iio: adc: mxs-lradc: fix non-static symbol warnings
Fix sparse warning "symbol foo was not declared. Should it be static?"
for the following symbols:
mx23_lradc_adc_irq_names
mx28_lradc_adc_irq_names
iio_dev_attr_in_voltage0_scale_available
iio_dev_attr_in_voltage1_scale_available
iio_dev_attr_in_voltage2_scale_available
iio_dev_attr_in_voltage3_scale_available
iio_dev_attr_in_voltage4_scale_available
iio_dev_attr_in_voltage5_scale_available
iio_dev_attr_in_voltage6_scale_available
iio_dev_attr_in_voltage7_scale_available
iio_dev_attr_in_voltage10_scale_available
iio_dev_attr_in_voltage11_scale_available
iio_dev_attr_in_voltage12_scale_available
iio_dev_attr_in_voltage13_scale_available
iio_dev_attr_in_voltage14_scale_available
iio_dev_attr_in_voltage15_scale_available

Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-06-03 09:55:25 +01:00
Ksenija Stanojevic 6dd112b9f8 iio: adc: mxs-lradc: Add support for ADC driver
Add support for sixteen-channel 12-bit resolution ADC and its functions,
which include general-purpose ADC readings, battery voltage measurement,
and die temperature measurement.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-03-23 12:28:43 +00:00