Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1462961 > unrolled thread
| Started by | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| First post | 2016-08-15 18:10 +0200 |
| Last post | 2016-08-16 00:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] iio: magnetometer: mag3110: claim direct mode during raw reads Jonathan Cameron <jic23@kernel.org> - 2016-08-15 18:10 +0200
Re: [PATCH] iio: magnetometer: mag3110: claim direct mode during raw reads Alison Schofield <amsfield22@gmail.com> - 2016-08-16 00:20 +0200
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2016-08-15 18:10 +0200 |
| Subject | Re: [PATCH] iio: magnetometer: mag3110: claim direct mode during raw reads |
| Message-ID | <s6sCC-7KV-13@gated-at.bofh.it> |
On 01/08/16 16:48, Alison Schofield wrote:
> Driver was checking for direct mode but not locking it. Use
> claim/release helper functions to guarantee the device stays
> in direct mode during raw reads.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> Cc: Daniel Baluta <daniel.baluta@gmail.com>
> ---
> drivers/iio/magnetometer/mag3110.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
> index f2be4a0..90574ff 100644
> --- a/drivers/iio/magnetometer/mag3110.c
> +++ b/drivers/iio/magnetometer/mag3110.c
> @@ -154,34 +154,39 @@ static int mag3110_read_raw(struct iio_dev *indio_dev,
>
> switch (mask) {
> case IIO_CHAN_INFO_RAW:
> - if (iio_buffer_enabled(indio_dev))
> - return -EBUSY;
> + ret = iio_device_claim_direct_mode(indio_dev);
> + if (ret)
> + return ret;
>
> switch (chan->type) {
> case IIO_MAGN: /* in 0.1 uT / LSB */
> ret = mag3110_read(data, buffer);
> if (ret < 0)
> - return ret;
> + goto release;
> *val = sign_extend32(
> be16_to_cpu(buffer[chan->scan_index]), 15);
> - return IIO_VAL_INT;
> + ret = IIO_VAL_INT;
No break?
> case IIO_TEMP: /* in 1 C / LSB */
> mutex_lock(&data->lock);
> ret = mag3110_request(data);
> if (ret < 0) {
> mutex_unlock(&data->lock);
> - return ret;
> + goto release;
> }
> ret = i2c_smbus_read_byte_data(data->client,
> MAG3110_DIE_TEMP);
> mutex_unlock(&data->lock);
> if (ret < 0)
> - return ret;
> + goto release;
> *val = sign_extend32(ret, 7);
> - return IIO_VAL_INT;
> + ret = IIO_VAL_INT;
No break here either....
> default:
> - return -EINVAL;
> + ret = -EINVAL;
> }
> +release:
> + iio_device_release_direct_mode(indio_dev);
> + return ret;
> +
> case IIO_CHAN_INFO_SCALE:
> switch (chan->type) {
> case IIO_MAGN:
>
[toc] | [next] | [standalone]
| From | Alison Schofield <amsfield22@gmail.com> |
|---|---|
| Date | 2016-08-16 00:20 +0200 |
| Message-ID | <s6yoG-35D-21@gated-at.bofh.it> |
| In reply to | #1462961 |
On Mon, Aug 15, 2016 at 05:04:24PM +0100, Jonathan Cameron wrote:
> On 01/08/16 16:48, Alison Schofield wrote:
> > Driver was checking for direct mode but not locking it. Use
> > claim/release helper functions to guarantee the device stays
> > in direct mode during raw reads.
> >
> > Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> > Cc: Daniel Baluta <daniel.baluta@gmail.com>
> > ---
> > drivers/iio/magnetometer/mag3110.c | 21 +++++++++++++--------
> > 1 file changed, 13 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
> > index f2be4a0..90574ff 100644
> > --- a/drivers/iio/magnetometer/mag3110.c
> > +++ b/drivers/iio/magnetometer/mag3110.c
> > @@ -154,34 +154,39 @@ static int mag3110_read_raw(struct iio_dev *indio_dev,
> >
> > switch (mask) {
> > case IIO_CHAN_INFO_RAW:
> > - if (iio_buffer_enabled(indio_dev))
> > - return -EBUSY;
> > + ret = iio_device_claim_direct_mode(indio_dev);
> > + if (ret)
> > + return ret;
> >
> > switch (chan->type) {
> > case IIO_MAGN: /* in 0.1 uT / LSB */
> > ret = mag3110_read(data, buffer);
> > if (ret < 0)
> > - return ret;
> > + goto release;
> > *val = sign_extend32(
> > be16_to_cpu(buffer[chan->scan_index]), 15);
> > - return IIO_VAL_INT;
> > + ret = IIO_VAL_INT;
> No break?
oops...needs one and the next case too. Thanks!
> > case IIO_TEMP: /* in 1 C / LSB */
> > mutex_lock(&data->lock);
> > ret = mag3110_request(data);
> > if (ret < 0) {
> > mutex_unlock(&data->lock);
> > - return ret;
> > + goto release;
> > }
> > ret = i2c_smbus_read_byte_data(data->client,
> > MAG3110_DIE_TEMP);
> > mutex_unlock(&data->lock);
> > if (ret < 0)
> > - return ret;
> > + goto release;
> > *val = sign_extend32(ret, 7);
> > - return IIO_VAL_INT;
> > + ret = IIO_VAL_INT;
> No break here either....
> > default:
> > - return -EINVAL;
> > + ret = -EINVAL;
> > }
> > +release:
> > + iio_device_release_direct_mode(indio_dev);
> > + return ret;
> > +
> > case IIO_CHAN_INFO_SCALE:
> > switch (chan->type) {
> > case IIO_MAGN:
> >
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web