From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: jic23@kernel.org
Cc: linux-iio@vger.kernel.org, linux-acpi@vger.kernel.org,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [Patch v1 4/4] iio: imu: inv_mpu6050: ACPI enumeration
Date: Wed, 19 Mar 2014 09:56:43 -0700 [thread overview]
Message-ID: <1395248203-17027-4-git-send-email-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <1395248203-17027-1-git-send-email-srinivas.pandruvada@linux.intel.com>
Added changes so that the module can be enumerated via ACPI.
Also if there is no platform data available, it will use a default
orientation data.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 31 ++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 200163d..2b3f24d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -24,8 +24,16 @@
#include <linux/kfifo.h>
#include <linux/spinlock.h>
#include <linux/iio/iio.h>
+#include <linux/acpi.h>
#include "inv_mpu_iio.h"
+/* Define some default platform data, if not supplied */
+static struct inv_mpu6050_platform_data inv_def_platform_data = {
+ .orientation = {-1, 0, 0,
+ 0, 1, 0,
+ 0, 0, -1 }
+};
+
/*
* this is the gyro scale translated from dynamic range plus/minus
* {250, 500, 1000, 2000} to rad/s
@@ -706,6 +714,7 @@ static int inv_mpu_probe(struct i2c_client *client,
struct inv_mpu6050_state *st;
struct iio_dev *indio_dev;
int result;
+ char *name;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_I2C_BLOCK))
@@ -717,7 +726,10 @@ static int inv_mpu_probe(struct i2c_client *client,
st = iio_priv(indio_dev);
st->client = client;
- st->plat_data = *(struct inv_mpu6050_platform_data
+ if (!dev_get_platdata(&client->dev))
+ st->plat_data = inv_def_platform_data;
+ else
+ st->plat_data = *(struct inv_mpu6050_platform_data
*)dev_get_platdata(&client->dev);
/* power is turned on inside check chip type*/
result = inv_check_and_setup_chip(st, id);
@@ -733,7 +745,14 @@ static int inv_mpu_probe(struct i2c_client *client,
i2c_set_clientdata(client, indio_dev);
indio_dev->dev.parent = &client->dev;
- indio_dev->name = id->name;
+
+ /* id will be NULL when enumerated via ACPI */
+ if (id)
+ name = (char *)id->name;
+ else
+ name = (char *)dev_name(&client->dev);
+
+ indio_dev->name = name;
indio_dev->channels = inv_mpu_channels;
indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
@@ -815,12 +834,20 @@ static const struct i2c_device_id inv_mpu_id[] = {
MODULE_DEVICE_TABLE(i2c, inv_mpu_id);
+static const struct acpi_device_id inv_acpi_match[] = {
+ {"INVN6050", INV_MPU6050},
+ {"INVN6500", INV_MPU6500},
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, inv_acpi_match);
+
static struct i2c_driver inv_mpu_driver = {
.probe = inv_mpu_probe,
.remove = inv_mpu_remove,
.id_table = inv_mpu_id,
.driver = {
.owner = THIS_MODULE,
+ .acpi_match_table = ACPI_PTR(inv_acpi_match),
.name = "inv-mpu6050",
.pm = INV_MPU6050_PMOPS,
},
--
1.7.11.7
next prev parent reply other threads:[~2014-03-19 16:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-19 16:56 [Patch v1 1/4] iio: imu: inv_mpu6050: Add compatibity with MPU6500 Srinivas Pandruvada
2014-03-19 16:56 ` [Patch v1 3/4] iio: imu: Enable checking of presence of device Srinivas Pandruvada
[not found] ` <1395248203-17027-3-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-29 10:52 ` Jonathan Cameron
2014-03-19 16:56 ` Srinivas Pandruvada [this message]
[not found] ` <1395248203-17027-4-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-29 10:59 ` [Patch v1 4/4] iio: imu: inv_mpu6050: ACPI enumeration Jonathan Cameron
[not found] ` <1395248203-17027-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-19 16:56 ` [Patch v1 2/4] iio: imu: inv_mpu6050: Enable default bypass mode Srinivas Pandruvada
[not found] ` <1395248203-17027-2-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-29 10:49 ` Jonathan Cameron
2014-03-29 10:46 ` [Patch v1 1/4] iio: imu: inv_mpu6050: Add compatibity with MPU6500 Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395248203-17027-4-git-send-email-srinivas.pandruvada@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=jic23@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox