summaryrefslogtreecommitdiff
path: root/drivers/iio/pressure/bmp280-core.c
AgeCommit message (Collapse)AuthorFilesLines
2024-06-25iio: pressure: bmp280-core: make use of regmap_clear_bits()Trevor Gamblin1-2/+2
Instead of using regmap_update_bits() and passing val = 0, use regmap_clear_bits(). Suggested-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Tested-By: Vasileios Amoiridis <vassilisamir@gmail.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://patch.msgid.link/20240617-review-v3-35-88d1338c4cca@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-06-17Merge tag 'v6.10-rc4' into char-misc-nextGreg Kroah-Hartman1-5/+5
We need the char-misc and iio fixes in here as well to build on top of. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-27iio: pressure: bmp280: Fix BMP580 temperature readingAdam Rizkalla1-5/+5
Fix overflow issue when storing BMP580 temperature reading and properly preserve sign of 24-bit data. Signed-off-by: Adam Rizkalla <ajarizzo@gmail.com> Tested-By: Vasileios Amoiridis <vassilisamir@gmail.com> Acked-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/Zin2udkXRD0+GrML@adam-asahi.lan Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Introduce new cleanup routinesVasileios Amoiridis1-81/+84
Introduce new linux/cleanup.h with the guard(mutex) functionality. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240512230524.53990-3-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Refactorize reading functionsVasileios Amoiridis1-127/+224
For BMP18x, BMP28x, BME280, BMP38x the reading of the pressure value requires an update of the t_fine variable which happens through reading the temperature value. So all the bmpxxx_read_press() functions of the above sensors are internally calling the equivalent bmpxxx_read_temp() function in order to update the t_fine value. By just looking at the code this functionality is a bit hidden and is not easy to understand why those channels are not independent. This commit tries to clear these things a bit by splitting the bmpxxx_{read/compensate}_{temp/press/humid}() to the following: i. bmpxxx_read_{temp/press/humid}_adc(): read the raw value from the sensor. ii. bmpxx_calc_t_fine(): calculate the t_fine variable. iii. bmpxxx_get_t_fine(): get the t_fine variable. iv. bmpxxx_compensate_{temp/press/humid}(): compensate the adc values and return the calculated value. v. bmpxxx_read_{temp/press/humid}(): combine calls of the aforementioned functions to return the requested value. Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240512230524.53990-2-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Use unsigned data types for raw sensor dataVasileios Amoiridis1-23/+22
The raw sensor data that have not been compensated yet cannot be signed values, so use unsigned ones. Also, compensated pressure values cannot be negative so use unsigned also there. Also, drop redundant cast of data->t_fine variable from s32 to s32. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240508165207.145554-5-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Make error checks consistentVasileios Amoiridis1-20/+20
The form 'if (ret)' is used in this driver in order to check for returned error values. There are also some places that 'if (ret < 0)' is used but for no specific reason. Change them to 'if (ret)' to make the driver more consistent. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240508165207.145554-4-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Remove, add and update error messagesVasileios Amoiridis1-17/+38
Remove duplicate error messages, add missing error messages and update redundant ones. Add one missing error check. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240508165207.145554-3-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Remove dead error checksVasileios Amoiridis1-4/+0
The ret value is being checked already in all the previous paths which exit in case of error, so this path can never become true. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240508165207.145554-2-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Add more intuitive name for bmp180_measure()Vasileios Amoiridis1-8/+8
The bmp180_measure() function essentially waits for the end of the current conversion in order to read the values from the sensors. The name bmp180_measure() could be misinterpreted because it could be translated as "measure sensor values" even though it was probably trying to say "measure time for eoc". Give a more intuitive name to this function to be less confusing. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240429190046.24252-5-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Use BME prefix for BME280 specificsVasileios Amoiridis1-19/+18
Change the rest of the defines and function names that are used specifically by the BME280 humidity sensor to BME280 as it is done for the rest of the BMP{0,1,3,5}80 sensors. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240429190046.24252-3-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: pressure: bmp280: Improve indentation and line wrappingVasileios Amoiridis1-49/+59
Fix indentations that are not following the standards, remove extra white lines and add missing white lines. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240429190046.24252-2-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-08Merge 6.9-rc7 into char-misc-testingGreg Kroah-Hartman1-0/+1
We need the char-misc changes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-28iio: pressure: BMP280 core driver headers sortingVasileios Amoiridis1-8/+8
Sort headers in alphabetical order. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240319002925.2121016-2-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-03-24iio: pressure: Fixes SPI support for BMP3xx devicesVasileios Amoiridis1-0/+1
Bosch does not use unique BMPxxx_CHIP_ID for the different versions of the device which leads to misidentification of devices if their ID is used. Use a new value in the chip_info structure instead of the BMPxxx_CHIP_ID, in order to choose the correct regmap_bus to be used. Fixes: a9dd9ba32311 ("iio: pressure: Fixes BMP38x and BMP390 SPI support") Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://lore.kernel.org/r/20240316110743.1998400-3-vassilisamir@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-11-16iio: pressure: bmp280: Add support for BMP390Angel Iglesias1-1/+2
Add BMP390 device ID to the supported IDs on bmp380 sensor family Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/d6a9e9ca4670c7401545d0d086cd3059e29044c8.1697994521.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-11-16iio: pressure: bmp280: Allow multiple chips id per family of devicesAngel Iglesias1-9/+26
Improve device detection in certain chip families known to have various chip IDs. When no ID matches, give a warning but follow along what device said on the firmware side and try to configure it. Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/eade22d11e9de4405ea19fdaa5a8249143ae94df.1697994521.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-11-16iio: pressure: fix some word spelling errorsLi peiyu1-3/+3
They are appear to be spelling mistakes, drivers/iio/pressure/bmp280.h:413 endianess->endianness drivers/iio/pressure/bmp280-core.c:923 dregrees->degrees drivers/iio/pressure/bmp280-core.c:1388 reescale->rescale drivers/iio/pressure/bmp280-core.c:1415 reescale->rescale Signed-off-by: Li peiyu <579lpy@gmail.com> Link: https://lore.kernel.org/r/20231021070903.6051-1-579lpy@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11iio: pressure: bmp280: Fix NULL pointer exceptionPhil Elwell1-1/+1
The bmp085 EOC IRQ support is optional, but the driver's common probe function queries the IRQ properties whether or not it exists, which can trigger a NULL pointer exception. Avoid any exception by making the query conditional on the possession of a valid IRQ. Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt") Signed-off-by: Phil Elwell <phil@raspberrypi.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230811155829.51208-1-phil@raspberrypi.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11iio: pressure: bmp280: Add nvmem operations for BMP580Angel Iglesias1-1/+209
The pressure sensor BMP580 contains a non-volatile memory that stores trimming and configuration params. That memory provides an programmable user range of three 2-byte words. Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/f3f453d9b2c0f7820ca9c56e24e2165b6c39bb67.1676823250.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11iio: pressure: bmp280: Add support for new sensor BMP580Angel Iglesias1-8/+336
Adds compatibility with the new sensor generation, the BMP580. The measurement and initialization codepaths are adapted from the device datasheet and the repository from manufacturer at https://github.com/boschsensortec/BMP5-Sensor-API. Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/f899fceec9b48bc173bd4b7555f0a237fa32d520.1676823250.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11iio: pressure: bmp280: Make read calibration callback optionalAngel Iglesias1-4/+6
Newer models do not require read the calibration parameters and apply the compensation algorithms in the sensor. Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/bb1b95ab3f4e71d3c76543370325c5c9aaa07add.1676823250.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11iio: pressure: bmp280: Add preinit callbackAngel Iglesias1-5/+12
Adds preinit callback to execute operations on probe before applying initial configuration. Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/fa9513ffad37a6a43b6d46df9d8319ccab6f5870.1676823250.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11iio: pressure: bmp280: Use chip_info pointers for each chip as driver dataAngel Iglesias1-171/+19
Refactor driver I2C and SPI implementations using pointers for each variant's chip_info as the driver data. Adds the regmap configuration to the chip_info struct. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/a48cfa756be48d61dbf656c65daff6e9a1290e6f.1676823250.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: Add more tunable config parameters for BMP380Angel Iglesias1-9/+238
Allows sampling frequency and IIR filter coefficients configuration using sysfs ABI. The IIR filter coefficient is configurable using the sysfs attribute "filter_low_pass_3db_frequency". Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/876f8a2277f71672488e99aa02aae4239d530f51.1663025017.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: Add support for BMP380 sensor familyAngel Iglesias1-0/+386
Adds compatibility with the new generation of this sensor, the BMP380. Includes basic sensor initialization to do pressure and temp measurements and allows tuning oversampling settings for each channel. The compensation algorithms are adapted from the device datasheet and the repository https://github.com/BoschSensortec/BMP3-Sensor-API. Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/f1da2a2f1bc5bb083f318335c23b4f3d9bb8e536.1663025017.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: Fix alignment for DMA safetyAngel Iglesias1-57/+74
Adds DMA-safe buffers to driver data struct to store raw data from sensors The multiple buffers used thorough the driver share the same memory allocated as part of the device data instance. The union containing the buffers is aligned to allow safe usage with DMA operations, such as regmap bulk read calls. Updated measurement and calibration reading functions to use the safe DMA buffers. Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/7919793f7f63224d5ce413c66d648029683c17ac.1663025017.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: simplify driver initialization logicAngel Iglesias1-43/+83
Simplified common initialization logic of different sensor types unifying calibration and initial configuration recovery. Default config param values of each sensor type are stored inside chip_info structure and used to initialize sensor data struct instance. The helper functions for read each sensor type calibration are converted to a callback available on the chip_info struct. Separated bme280 specific calibration code from bmp280 function. Dropped the additional chip_id argument in bmp280 code as is not longer required. Now both bmp280/bme280 calibration function use same signature as bmp180. Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/584c90f309e4f24bf2e4aa2b15c8577d288f978d.1663025017.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: Simplify bmp280 calibration data readingAngel Iglesias1-35/+23
On bmp280 and bme280, the temperature and pressure calibration parameters are available on a contiguous memory region. Considering this arrangement, simplified the calibration reading function by using only one buffer to read in batch temperature and pressure registers. Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/96d81282c95006d857f4d836d2ff3ee0740a85a0.1663025017.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: use FIELD_GET, FIELD_PREP and GENMASKAngel Iglesias1-9/+16
Cleaned and simplified register values construction and extraction converting to use FIELD_PREP and FIELD_GET macros. Replaced hardcoded bit masks with GENMASK macro. Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/3cbe56f29c2a46bc5dc23c5b72e1b43c9207f44d.1663025017.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: reorder local variables following reverse xmas treeAngel Iglesias1-32/+33
Reordered definitions of local variables following the reverse christmas tree convention. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/363a106afbfe30ce590b80b1494c8b3322870f8a.1663025017.git.ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: pressure: bmp280: fix datasheet linksAngel Iglesias1-3/+9
Updated links for BMP280 and BME280 datasheets on Bosch website. Datasheet of BMP180 is no longer available on the manufacturer's website, changed the link to a copy hosted by a third party. Reported-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Link: https://lore.kernel.org/r/20220912222645.377874-1-ang.iglesiasg@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-21iio: pressure: bmp280: Move symbol exports to IIO_BMP280 namespaceJonathan Cameron1-1/+1
Avoid unnecessary pollution of the global symbol namespace by moving library functions in to a specific namespace and import that into the drivers that make use of the functions. For more info: https://lwn.net/Articles/760045/ Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20220220173701.502331-3-jic23@kernel.org Reviewed-By: Joe Simmons-Talbott <joetalbott@gmail.com> Link: https://lore.kernel.org/r/20220604155306.422937-3-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-12iio: pressure: bmp280: Use new PM macrosPaul Cercueil1-9/+2
Use the new EXPORT_RUNTIME_DEV_PM_OPS() macro. It allows the underlying dev_pm_ops struct as well as the suspend/resume callbacks to be detected as dead code in the case where CONFIG_PM is disabled, without having to wrap everything inside #ifdef CONFIG_PM guards. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2020-05-11iio: bmp280: fix compensation of humidityAndreas Klinger1-0/+2
Limit the output of humidity compensation to the range between 0 and 100 percent. Depending on the calibration parameters of the individual sensor it happens, that a humidity above 100 percent or below 0 percent is calculated, which don't make sense in terms of relative humidity. Add a clamp to the compensation formula as described in the datasheet of the sensor in chapter 4.2.3. Although this clamp is documented, it was never in the driver of the kernel. It depends on the circumstances (calibration parameters, temperature, humidity) if one can see a value above 100 percent without the clamp. The writer of this patch was working with this type of sensor without noting this error. So it seems to be a rare event when this bug occures. Signed-off-by: Andreas Klinger <ak@it-klinger.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Join string literals backAndy Shevchenko1-2/+1
For easy grepping on debug purposes join string literals back in the messages. No functional change. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Drop unneeded explicit castingsAndy Shevchenko1-10/+7
In few places the unnecessary explicit castings are being used. Drop them for good. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Explicitly mark GPIO optionalAndy Shevchenko1-2/+2
Show by using a corresponding API call that GPIO is optional. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Convert to use ->read_avail()Andy Shevchenko1-44/+25
Convert to use ->read_avail() instead of open-coded attribute handling. Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Tolerate IRQ before registeringAndy Shevchenko1-1/+4
With DEBUG_SHIRQ enabled we have a kernel crash [ 116.482696] BUG: kernel NULL pointer dereference, address: 0000000000000000 ... [ 116.606571] Call Trace: [ 116.609023] <IRQ> [ 116.611047] complete+0x34/0x50 [ 116.614206] bmp085_eoc_irq+0x9/0x10 [bmp280] because DEBUG_SHIRQ mechanism fires an IRQ before registration and drivers ought to be able to handle an interrupt happening before request_irq() returns. Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: pressure: bmp280: use devm action and remove labels from probeBartosz Golaszewski1-32/+30
We can drop some duplicate code if we use devm_action for disabling regulators and pm and the managed variant of iio_device_register(). This allows us to completely remove all remove() callbacks from both i2c and spi code. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: pressure: bmp280: use bulk regulator opsBartosz Golaszewski1-39/+30
The vddd and vdda supplies are always operated on together. We can shrink the code a bit by using the bulk regulator helpers. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-18iio: pressure: bmp280 endian tidy upsJonathan Cameron1-7/+9
There is a somewhat interesting mixture of be16 and le16 going on in this one function. Changes here formalize that a little more. CHECK drivers/iio/pressure/bmp280-core.c drivers/iio/pressure/bmp280-core.c:215:35: warning: cast to restricted __le16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:237:37: warning: cast to restricted __le16 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
2019-10-13iio: pressure: bmp280: remove stray newlineBartosz Golaszewski1-1/+0
Remove a stray newline from the probe callback. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner1-4/+1
Based on 2 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 version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-04iio: pressure: bmp280: BMP280 calibration to entropyLinus Walleij1-0/+6
The BMP280/BME280 calibration data should also go into the entropy pool, like we do for BMP180. This just adds the temperature and pressure calibration, the humidity calibration seems like too much annoying calls to add. Cc: Tomasz Duszynski <tduszyns@gmail.com> Cc: Stefan Tatschner <stefan.tatschner@gmail.com> Cc: Andreas Klinger <ak@it-klinger.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-24iio: pressure: bmp280: fix relative humidity unitTomasz Duszynski1-3/+2
According to IIO ABI relative humidity reading should be returned in milli percent. This patch addresses that by applying proper scaling and returning integer instead of fractional format type specifier. Note that the fixes tag is before the driver was heavily refactored to introduce spi support, so the patch won't apply that far back. Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com> Fixes: 14beaa8f5ab1 ("iio: pressure: bmp280: add humidity support") Acked-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-01-08iio:pressure:bmp280: Read calibration data in probeStefan Tatschner1-71/+132
This patch affects BME280 and BMP280. The readout of the calibration data is moved to the probe function. Each sensor data access triggered reading the full calibration data before this patch. According to the datasheet, Section 4.4.2., the calibration data is stored in non-volatile memory. Since the calibration data does not change, and cannot be changed by the user, we can reduce bus traffic by reading the calibration data once. Additionally, proper organization of the data types enables removing some odd casts in the compensation formulas. Signed-off-by: Stefan Tatschner <stefan.tatschner@gmail.com> Tested-by: Andreas Klinger <ak@it-klinger.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-09Merge 4.14-rc4 into staging-nextGreg Kroah-Hartman1-1/+1
We want the staging/iio fixes in here as well to handle merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>