aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/accel/bma220_spi.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-07-19iio: accel: bma220: make suspend state setting more robustAlexandru Ardelean1-12/+29
The datasheet mentions that the suspend mode is toggled by reading the suspend register. The reading returns value 0xFF if the system was in suspend mode, otherwise it returns value 0x00. The bma220_deinit() function does up to 2 reads, in case the device was in suspend mode, which suggests a level of paranoia that makes the logic in bma220_suspend() and bma220_resume() look insufficient. This change implements a bma220_power() function which does up to 2 reads of the suspend register to make sure that the chip enters a desired (suspended or normal) mode. If the transition fails, then -EBUSY is returned. Since only a reference to SPI device is required, we can remove the spi_set_drvdata() call and get the SPI device object from the base device object in the suspend/resume routines. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210625140137.362282-2-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-19iio: accel: bma220: convert probe to device-managed functionsAlexandru Ardelean1-33/+11
This change converts the driver to use devm_iio_triggered_buffer_setup() and devm_iio_device_register() for initializing and registering the IIO device. The bma220_deinit() is converted into a callback for a devm_add_action_or_reset() hook, so that the device is put in stand-by when the driver gets uninitialized. The return value of the bma220_deinit() function isn't used as it does not add any value. On the error path of the probe function, this can just override the actual error with -EBUSY, or can even return 0 (no error), on the error path. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210625140137.362282-1-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17iio: accel: bma220: Fix buffer alignment in iio_push_to_buffers_with_timestamp()Jonathan Cameron1-3/+7
To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of this function. Fixes: 194dc4c71413 ("iio: accel: Add triggered buffer support for BMA220") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210501170121.512209-3-jic23@kernel.org
2021-03-25iio: Remove kernel-doc keyword in file header commentGwendal Grignou1-1/+1
Remove kernel-doc keyword from function header comment. It fixes issues spotted by scripts/kernel-doc like: drivers/iio/<driver>.c:3: info: Scanning doc for function <component name> drivers/iio/<driver>.c:X: warning: expecting prototype for <component name>. Prototype was for <function>() instead To reproduce the errors: scripts/kernel-doc -v -none $(find drivers/iio/ -name \*.c \ -exec head -2 {} \+ | grep -B2 -e '\*\*' | grep '==' | cut -d ' ' -f 2) After, confirm these errors are gone with: scripts/kernel-doc -v -none $(git show --name-only | grep -e "^driver") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20210309234314.2208256-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Remove unneeded blank linesAndy Shevchenko1-4/+1
There are few blank lines that split structure definitions with their users. Remove them to increase readability. While here, update copyright year. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-8-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Use BIT() and GENMASK() macrosAndy Shevchenko1-2/+3
Code is better to read when numbers of bit are explicitly used. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-7-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Group IIO headers togetherAndy Shevchenko1-1/+2
Group IIO headers together and follow the common pattern of header inclusion, i.e. more generic first. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-6-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Drop ACPI_PTR() and accompanying ifdefferyAndy Shevchenko1-4/+2
The driver is quite likely used only on ACPI based platforms and rarely build with CONFIG_ACPI=n. Even though, the few dozens of bytes is better than ugly ifdeffery and inclusion of heavy header. As a result, replace acpi.h with mod_devicetable.h. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-5-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Mark PM functions as __maybe_unusedAndy Shevchenko1-9/+3
Instead of using ugly ifdeffery, mark PM functions as __maybe_unused. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-4-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Use dev_get_drvdata() directlyAndy Shevchenko1-4/+2
Instead of using to_spi_dev() + spi_get_drvdata(), use dev_get_drvdata() to make code simpler. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-3-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Convert to use ->read_avail()Andy Shevchenko1-15/+19
Convert to use ->read_avail() instead of open-coded attribute handling. While here, fix the typo in array definition and append comma in case of the future extension. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-2-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit()Andy Shevchenko1-5/+9
Potentially bma220_init() and bma220_deinit() may return positive codes. Fix the logic to return proper error codes instead. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200831090813.78841-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20iio: accel: bma220_spi: Do not define 'struct acpi_device_id' when !CONFIG_ACPILee Jones1-0/+2
Since ACPI_PTR() is used to NULLify the value when !CONFIG_ACPI, struct 'bma220_acpi_id' becomes defined but unused. Fixes the following W=1 kernel build warning(s): drivers/iio/accel/bma220_spi.c:312:36: warning: ‘bma220_acpi_id’ defined but not used [-Wunused-const-variable=] 312 | static const struct acpi_device_id bma220_acpi_id[] = { | ^~~~~~~~~~~~~~ Cc: Tiberiu Breana <tiberiu.a.breana@intel.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14iio: remove explicit IIO device parent assignmentAlexandru Ardelean1-1/+0
This patch applies the semantic patch: @@ expression I, P, SP; @@ I = devm_iio_device_alloc(P, SP); ... - I->dev.parent = P; It updates 302 files and does 307 deletions. This semantic patch also removes some comments like '/* Establish that the iio_dev is a child of the i2c device */' But this is is only done in case where the block is left empty. The patch does not seem to cover all cases. It looks like in some cases a different variable is used in some cases to assign the parent, but it points to the same reference. In other cases, the block covered by ... may be just too big to be covered by the semantic patch. However, this looks pretty good as well, as it does cover a big bulk of the drivers that should remove the parent assignment. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330Thomas Gleixner1-4/+1
Based on 1 normalized pattern(s): this file is subject to the terms and conditions of version 2 of the gnu general public license see the file copying in the main directory of this archive for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 55 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190530000436.108941081@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-22iio:accel: drop assign iio_info.driver_module and iio_trigger_ops.ownerJonathan Cameron1-1/+0
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>
2016-08-15iio: accel: bma220_spi: set up buffer timestamps for non-zero valuesAlison Schofield1-1/+1
Use the iio_pollfunc_store_time parameter during triggered buffer set-up to get valid timestamps. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Reviewed-By: Tiberiu Breana <tiberiu.a.breana@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-21iio: accel: Add triggered buffer support for BMA220Tiberiu Breana1-2/+63
Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-14iio: accel: Add support for Bosch BMA220Tiberiu Breana1-0/+277
This commit adds basic support for the Bosch Sensortec BMA220 digital triaxial acceleration sensor. The device datasheet can be found here: http://www.mouser.com/pdfdocs/BSTBMA220DS00308.PDF Includes: - raw readings - ACPI detection - power management Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>