IIO: Invensense MPU6050/MPU9150 driver submit
Subsystems (3)
PATCH 4/4 IIO: Invensense MPU6050/MPU9150 driver submit
From e2e8294c211bcd6761e3f3e9980722e11dda1afa Mon Sep 17 00:00:00 2001
From: Ge Gao <[email protected]>
Date: Thu, 28 Jun 2012 11:07:35 -0700
Subject: [PATCH 4/4] Invensense MPU6050/MPU9150 driver.
--MPU6050/MPU9150 driver.
--Secondary bus for AKM8975/AKM8963/AKM8972 support. --kernel fix for Kfifo poll support from Jonanthan. --Kfifo bug fix. Need to check available space before store. --add new IIO type for quaternion.
Change-Id I4b301454c0e8af57ac9db7602a14be5a623d5a94
Signed-off-by Ge Gao <[email protected]>
--- drivers/staging/iio/industrialio-buffer.c | 3 +++ drivers/staging/iio/industrialio-core.c | 2 ++ drivers/staging/iio/kfifo_buf.c | 21 ++++++++++++++++++--- drivers/staging/iio/types.h | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-)
drivers/staging/iio/industrialio-buffer.c +3 -0
@@ -56,10 +56,13 @@ unsigned int iio_buffer_poll(struct file *filp, {struct iio_dev *indio_dev = filp->private_data;struct iio_buffer *rb = indio_dev->buffer; +if (rb->stufftoread) +return POLLIN |POLLRDNORM ;poll_wait (filp, &rb->pollq, wait);if (rb->stufftoread)return POLLIN |POLLRDNORM ; +/* need a way of knowing if there may be enough data... */ return 0 ; }
drivers/staging/iio/industrialio-core.c +2 -0
@@ -68,6 +68,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_ANGL] = "angl", [IIO_TIMESTAMP] = "timestamp", [IIO_CAPACITANCE] = "capacitance", + [IIO_QUATERNION] = "quaternion", };static const char *const iio_modifier_names[] = {
@@ -76,6 +77,7 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_Z] = "z", [IIO_MOD_LIGHT_BOTH] = "both", [IIO_MOD_LIGHT_IR] = "ir", + [IIO_MOD_R] = "r", };/* relies on pairs of these shared then separate */
drivers/staging/iio/kfifo_buf.c +18 -3
@@ -3,6 +3,7 @@#include <linux/module.h> #include <linux/device.h> #include <linux/workqueue.h> +#include <linux/sched.h> #include <linux/kfifo.h> #include <linux/mutex.h>
@@ -36,6 +37,7 @@ static int iio_request_update_kfifo(struct iio_buffer *r)kfifo_free (&buf->kf); ret =__iio_allocate_kfifo (buf, buf->buffer.bytes_per_datum, buf->buffer.length); + r->stufftoread = false; error_ret:return ret; }
@@ -95,9 +97,16 @@ static int iio_store_to_kfifo(struct iio_buffer *r, {int ret;struct iio_kfifo *kf =iio_to_kfifo (r); - ret =kfifo_in (&kf->kf, data, r->bytes_per_datum); -if (ret != r->bytes_per_datum) -return -EBUSY ; +if (kfifo_avail (&kf->kf) >= r->bytes_per_datum) { + ret =kfifo_in (&kf->kf, data, r->bytes_per_datum); +if (ret != r->bytes_per_datum) +return -EBUSY ; + }else { +return -ENOMEM ; + } + r->stufftoread = true; +wake_up_interruptible (&r->pollq); +return 0 ; }
@@ -113,6 +122,12 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r, n =rounddown (n, r->bytes_per_datum); ret =kfifo_to_user (&kf->kf, buf, n, &copied); +if (kfifo_is_empty (&kf->kf)) + r->stufftoread = false; +/* verify it is still empty to avoid race */ +if (!kfifo_is_empty (&kf->kf)) + r->stufftoread = true; +return copied; }
drivers/staging/iio/types.h +2 -0
@@ -27,6 +27,7 @@ enum iio_chan_type {IIO_ANGL ,IIO_TIMESTAMP ,IIO_CAPACITANCE , + IIO_QUATERNION, }; enum iio_modifier {
@@ -44,6 +45,7 @@ enum iio_modifier {IIO_MOD_X_OR_Y_OR_Z ,IIO_MOD_LIGHT_BOTH ,IIO_MOD_LIGHT_IR , + IIO_MOD_R, };#define IIO_VAL_INT 1
Signature · 1 line
1.7.0.4