[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200801162958.56000bd0@archlinux>
Date: Sat, 1 Aug 2020 16:29:58 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Christian Eggers <ceggers@...i.de>
Cc: Rob Herring <robh+dt@...nel.org>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
<linux-iio@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 2/2] iio: light: as73211: New driver
On Fri, 31 Jul 2020 09:01:14 +0200
Christian Eggers <ceggers@...i.de> wrote:
> Support for AMS AS73211 JENCOLOR(R) Digital XYZ Sensor.
>
> This driver has no built-in trigger. In order for making triggered
> measurements, an external (software) trigger driver like
> iio-trig-hrtimer or iio-trig-sysfs is required.
>
> The sensor supports single and continuous measurement modes. The latter
> is not used by design as this would require tight timing synchronization
> between hardware and driver without much benefit.
>
> Datasheet: https://ams.com/documents/20143/36005/AS73211_DS000556_3-01.pdf/a65474c0-b302-c2fd-e30a-c98df87616df
> Signed-off-by: Christian Eggers <ceggers@...i.de>
A question inline about flipping to config mode mid capture.
> ---
> MAINTAINERS | 7 +
> drivers/iio/light/Kconfig | 15 +
> drivers/iio/light/Makefile | 1 +
> drivers/iio/light/as73211.c | 780 ++++++++++++++++++++++++++++++++++++
> 4 files changed, 803 insertions(+)
> create mode 100644 drivers/iio/light/as73211.c
>
...
> +
> +static int as73211_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan,
> + int val, int val2, long mask)
> +{
> + struct as73211_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + mutex_lock(&data->mutex);
> +
> + /* Need to switch to config mode ... */
Is this safe whilst we are doing a capture?
You may want to claim_direct_mode for write_raw to ensure we don't get such a
race.
> + if ((data->osr & AS73211_OSR_DOS_MASK) != AS73211_OSR_DOS_CONFIG) {
> + data->osr &= ~AS73211_OSR_DOS_MASK;
> + data->osr |= AS73211_OSR_DOS_CONFIG;
> +
> + ret = i2c_smbus_write_byte_data(data->client, AS73211_REG_OSR, data->osr);
> + if (ret < 0)
> + goto error_release;
> + }
> +
> + ret = _as73211_write_raw(indio_dev, chan, val, val2, mask);
> +
> +error_release:
> + mutex_unlock(&data->mutex);
> + return ret;
> +}
Powered by blists - more mailing lists