diff options
Diffstat (limited to 'drivers/iio/chemical')
-rw-r--r-- | drivers/iio/chemical/Kconfig | 1 | ||||
-rw-r--r-- | drivers/iio/chemical/Makefile | 2 | ||||
-rw-r--r-- | drivers/iio/chemical/atlas-sensor.c (renamed from drivers/iio/chemical/atlas-ph-sensor.c) | 32 | ||||
-rw-r--r-- | drivers/iio/chemical/sgp30.c | 2 | ||||
-rw-r--r-- | drivers/iio/chemical/sps30.c | 2 |
5 files changed, 25 insertions, 14 deletions
diff --git a/drivers/iio/chemical/Kconfig b/drivers/iio/chemical/Kconfig index fa4586037bb8..0b91de4df8f4 100644 --- a/drivers/iio/chemical/Kconfig +++ b/drivers/iio/chemical/Kconfig @@ -65,6 +65,7 @@ config IAQCORE config PMS7003 tristate "Plantower PMS7003 particulate matter sensor" depends on SERIAL_DEV_BUS + select IIO_BUFFER select IIO_TRIGGERED_BUFFER help Say Y here to build support for the Plantower PMS7003 particulate diff --git a/drivers/iio/chemical/Makefile b/drivers/iio/chemical/Makefile index f97270bc4034..33d3a595dda9 100644 --- a/drivers/iio/chemical/Makefile +++ b/drivers/iio/chemical/Makefile @@ -4,7 +4,7 @@ # # When adding new entries keep the list in alphabetical order -obj-$(CONFIG_ATLAS_PH_SENSOR) += atlas-ph-sensor.o +obj-$(CONFIG_ATLAS_PH_SENSOR) += atlas-sensor.o obj-$(CONFIG_BME680) += bme680_core.o obj-$(CONFIG_BME680_I2C) += bme680_i2c.o obj-$(CONFIG_BME680_SPI) += bme680_spi.o diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-sensor.c index 3a20cb5d9bff..2f0a6fed2589 100644 --- a/drivers/iio/chemical/atlas-ph-sensor.c +++ b/drivers/iio/chemical/atlas-sensor.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * atlas-ph-sensor.c - Support for Atlas Scientific OEM pH-SM sensor + * atlas-sensor.c - Support for Atlas Scientific OEM SM sensors * - * Copyright (C) 2015-2018 Matt Ranostay + * Copyright (C) 2015-2019 Konsulko Group * Author: Matt Ranostay <matt.ranostay@konsulko.com> */ @@ -14,7 +14,6 @@ #include <linux/err.h> #include <linux/irq.h> #include <linux/irq_work.h> -#include <linux/gpio.h> #include <linux/i2c.h> #include <linux/of_device.h> #include <linux/regmap.h> @@ -25,8 +24,8 @@ #include <linux/iio/triggered_buffer.h> #include <linux/pm_runtime.h> -#define ATLAS_REGMAP_NAME "atlas_ph_regmap" -#define ATLAS_DRV_NAME "atlas_ph" +#define ATLAS_REGMAP_NAME "atlas_regmap" +#define ATLAS_DRV_NAME "atlas" #define ATLAS_REG_DEV_TYPE 0x00 #define ATLAS_REG_DEV_VERSION 0x01 @@ -87,6 +86,16 @@ static const struct regmap_config atlas_regmap_config = { .val_bits = 8, }; +static int atlas_buffer_num_channels(const struct iio_chan_spec *spec) +{ + int idx = 0; + + for (; spec->type != IIO_TIMESTAMP; spec++) + idx++; + + return idx; +}; + static const struct iio_chan_spec atlas_ph_channels[] = { { .type = IIO_PH, @@ -323,16 +332,16 @@ static int atlas_buffer_predisable(struct iio_dev *indio_dev) struct atlas_data *data = iio_priv(indio_dev); int ret; - ret = iio_triggered_buffer_predisable(indio_dev); + ret = atlas_set_interrupt(data, false); if (ret) return ret; - ret = atlas_set_interrupt(data, false); + pm_runtime_mark_last_busy(&data->client->dev); + ret = pm_runtime_put_autosuspend(&data->client->dev); if (ret) return ret; - pm_runtime_mark_last_busy(&data->client->dev); - return pm_runtime_put_autosuspend(&data->client->dev); + return iio_triggered_buffer_predisable(indio_dev); } static const struct iio_trigger_ops atlas_interrupt_trigger_ops = { @@ -355,11 +364,12 @@ static irqreturn_t atlas_trigger_handler(int irq, void *private) struct iio_poll_func *pf = private; struct iio_dev *indio_dev = pf->indio_dev; struct atlas_data *data = iio_priv(indio_dev); + int channels = atlas_buffer_num_channels(data->chip->channels); int ret; ret = regmap_bulk_read(data->regmap, data->chip->data_reg, (u8 *) &data->buffer, - sizeof(__be32) * (data->chip->num_channels - 2)); + sizeof(__be32) * channels); if (!ret) iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, @@ -681,5 +691,5 @@ static struct i2c_driver atlas_driver = { module_i2c_driver(atlas_driver); MODULE_AUTHOR("Matt Ranostay <matt.ranostay@konsulko.com>"); -MODULE_DESCRIPTION("Atlas Scientific pH-SM sensor"); +MODULE_DESCRIPTION("Atlas Scientific SM sensors"); MODULE_LICENSE("GPL"); diff --git a/drivers/iio/chemical/sgp30.c b/drivers/iio/chemical/sgp30.c index 8cc8fe5e356d..403e8803471a 100644 --- a/drivers/iio/chemical/sgp30.c +++ b/drivers/iio/chemical/sgp30.c @@ -483,7 +483,7 @@ static void sgp_init(struct sgp_data *data) data->iaq_defval_skip_jiffies = 43 * data->measure_interval_jiffies; break; - }; + } } static const struct iio_info sgp_info = { diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c index edbb956e81e8..acb9f8ecbb3d 100644 --- a/drivers/iio/chemical/sps30.c +++ b/drivers/iio/chemical/sps30.c @@ -117,7 +117,7 @@ static int sps30_do_cmd(struct sps30_state *state, u16 cmd, u8 *data, int size) break; case SPS30_READ_AUTO_CLEANING_PERIOD: buf[0] = SPS30_AUTO_CLEANING_PERIOD >> 8; - buf[1] = (u8)SPS30_AUTO_CLEANING_PERIOD; + buf[1] = (u8)(SPS30_AUTO_CLEANING_PERIOD & 0xff); /* fall through */ case SPS30_READ_DATA_READY_FLAG: case SPS30_READ_DATA: |