[PATCH 452/961] staging: iio: ak8975: add platform data.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tony SIM <chinyeow.sim.xt@xxxxxxxxxxx>

As some of the platform not support irq_to_gpio, we pass gpio port
by platform data.

Signed-off-by: Tony SIM <chinyeow.sim.xt@xxxxxxxxxxx>
Signed-off-by: Andrew Chew <achew@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
 drivers/staging/iio/magnetometer/ak8975.c |    8 +++++++-
 include/linux/input/ak8975.h              |   20 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)
 create mode 100644 include/linux/input/ak8975.h

diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c
index 420f206..80c0f41 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -29,6 +29,7 @@
 #include <linux/delay.h>
 
 #include <linux/gpio.h>
+#include <linux/input/ak8975.h>
 
 #include "../iio.h"
 #include "magnet.h"
@@ -435,6 +436,7 @@ static int ak8975_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
 	struct ak8975_data *data;
+	struct ak8975_platform_data *pdata;
 	int err;
 
 	/* Allocate our device context. */
@@ -452,7 +454,11 @@ static int ak8975_probe(struct i2c_client *client,
 
 	/* Grab and set up the supplied GPIO. */
 	data->eoc_irq = client->irq;
-	data->eoc_gpio = irq_to_gpio(client->irq);
+	pdata = client->dev.platform_data;
+	if (pdata)
+		data->eoc_gpio = pdata->gpio;
+	else
+		data->eoc_gpio = irq_to_gpio(client->irq);
 
 	if (!data->eoc_gpio) {
 		dev_err(&client->dev, "failed, no valid GPIO\n");
diff --git a/include/linux/input/ak8975.h b/include/linux/input/ak8975.h
new file mode 100644
index 0000000..25d41eb
--- /dev/null
+++ b/include/linux/input/ak8975.h
@@ -0,0 +1,20 @@
+/*
+ * ak8975 platform support
+ *
+ * Copyright (C) 2010 Renesas Solutions Corp.
+ *
+ * Author: Tony SIM <chinyeow.sim.xt@xxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _AK8975_H
+#define _AK8975_H
+
+struct ak8975_platform_data {
+	int gpio;
+};
+
+#endif
-- 
1.7.4.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux