[Armadeus-commitlog] armadeus branch, master, updated. release-3.3-228-g6b1e435
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2011-01-10 08:41:24
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 6b1e43509efefc895681979b7499bf35fa3d7543 (commit)
via 9b86caff4f41a06e6a9350b692c34073e7ecaf76 (commit)
from bb7c62bf01c318b29450250ff8d06a19d7d8a2cf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6b1e43509efefc895681979b7499bf35fa3d7543
Merge: 9b86caff4f41a06e6a9350b692c34073e7ecaf76 bb7c62bf01c318b29450250ff8d06a19d7d8a2cf
Author: Fabien Marteau <fab...@ar...>
Date: Mon Jan 10 09:41:01 2011 +0100
Merge branch 'master' of ssh://armadeus.git.sourceforge.net/gitroot/armadeus/armadeus
commit 9b86caff4f41a06e6a9350b692c34073e7ecaf76
Author: Fabien Marteau <fab...@ar...>
Date: Mon Jan 10 09:40:03 2011 +0100
[LINUX] Updating as5011 drivers according to kernel developper comments
-----------------------------------------------------------------------
Summary of changes:
...us-joystick-adding_as5011_joystick_driver.patch | 647 ++++++++------------
1 files changed, 269 insertions(+), 378 deletions(-)
diff --git a/buildroot/target/device/armadeus/linux/kernel-patches/2.6.36/359-armadeus-joystick-adding_as5011_joystick_driver.patch b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.36/359-armadeus-joystick-adding_as5011_joystick_driver.patch
index 28e6d8a..ac0ae97 100644
--- a/buildroot/target/device/armadeus/linux/kernel-patches/2.6.36/359-armadeus-joystick-adding_as5011_joystick_driver.patch
+++ b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.36/359-armadeus-joystick-adding_as5011_joystick_driver.patch
@@ -5,19 +5,12 @@ Signed-off-by: Fabien Marteau <fab...@ar...>
Index: linux-2.6.36/drivers/input/joystick/as5011.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.36/drivers/input/joystick/as5011.c 2010-12-30 10:12:13.000000000 +0100
-@@ -0,0 +1,418 @@
++++ linux-2.6.36/drivers/input/joystick/as5011.c 2011-01-10 09:36:32.000000000 +0100
+@@ -0,0 +1,368 @@
+/*
-+ * Copyright (c) 2010 Fabien Marteau <fab...@ar...>
-+ *
++ * Copyright (c) 2010, 2011 Fabien Marteau <fab...@ar...>
+ * Sponsored by ARMadeus Systems
-+ */
-+
-+/*
-+ * Driver for Austria Microsystems joysticks AS5011
-+ */
-+
-+/*
++ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
@@ -32,373 +25,334 @@ Index: linux-2.6.36/drivers/input/joystick/as5011.c
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
++ * Driver for Austria Microsystems joysticks AS5011
++ *
+ * TODO:
++ * - Power on the chip when open() and power down when close()
+ * - Manage power mode
+ */
+
-+#include <linux/module.h>
-+#include <linux/init.h>
-+#include <linux/slab.h>
+#include <linux/i2c.h>
-+#include <linux/string.h>
-+#include <linux/list.h>
-+#include <linux/sysfs.h>
-+#include <linux/ctype.h>
-+#include <linux/hwmon-sysfs.h>
-+
-+#include <linux/types.h>
-+#include <linux/errno.h>
-+#include <linux/kernel.h>
-+#include <linux/input.h>
+#include <linux/interrupt.h>
-+#include <linux/mutex.h>
-+
+#include <linux/input.h>
+#include <linux/gpio.h>
-+#include <linux/workqueue.h>
+#include <linux/delay.h>
++#include <linux/input/as5011.h>
++#include <linux/slab.h>
+
-+#include <linux/as5011.h>
+#define DRIVER_DESC "Driver for Austria Microsystems AS5011 joystick"
++#define MODULE_DEVICE_ALIAS "as5011"
+
+MODULE_AUTHOR("Fabien Marteau <fab...@ar...>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
-+#define SIZE_NAME 30
-+#define SIZE_EVENT_PATH 40
++/* registers */
++#define AS5011_CTRL1 0x76
++#define AS5011_CTRL2 0x75
++#define AS5011_XP 0x43
++#define AS5011_XN 0x44
++#define AS5011_YP 0x53
++#define AS5011_YN 0x54
++#define AS5011_X_REG 0x41
++#define AS5011_Y_REG 0x42
++#define AS5011_X_RES_INT 0x51
++#define AS5011_Y_RES_INT 0x52
++
++/* CTRL1 bits */
++#define AS5011_CTRL1_LP_PULSED 0x80
++#define AS5011_CTRL1_LP_ACTIVE 0x40
++#define AS5011_CTRL1_LP_CONTINUE 0x20
++#define AS5011_CTRL1_INT_WUP_EN 0x10
++#define AS5011_CTRL1_INT_ACT_EN 0x08
++#define AS5011_CTRL1_EXT_CLK_EN 0x04
++#define AS5011_CTRL1_SOFT_RST 0x02
++#define AS5011_CTRL1_DATA_VALID 0x01
++
++/* CTRL2 bits */
++#define AS5011_CTRL2_EXT_SAMPLE_EN 0x08
++#define AS5011_CTRL2_RC_BIAS_ON 0x04
++#define AS5011_CTRL2_INV_SPINNING 0x02
++
+#define AS5011_MAX_AXIS 80
+#define AS5011_MIN_AXIS (-80)
+#define AS5011_FUZZ 8
+#define AS5011_FLAT 40
+
-+static int g_num = 1; /* device counter */
++struct as5011_device {
++ struct input_dev *input_dev;
++ struct i2c_client *i2c_client;
++ unsigned int button_gpio;
++ unsigned int button_irq;
++ unsigned int axis_irq;
++};
+
-+static signed char as5011_i2c_read(struct i2c_client *client,
-+ uint8_t aRegAddr);
+static int as5011_i2c_write(struct i2c_client *client,
-+ uint8_t aRegAddr,
-+ uint8_t aValue);
-+
-+/*
-+ * interrupts operations
-+ */
-+
-+static irqreturn_t button_interrupt(int irq, void *dev_id)
++ uint8_t aregaddr,
++ uint8_t avalue)
+{
-+ struct as5011_platform_data *plat_dat =
-+ (struct as5011_platform_data *)dev_id;
-+ int ret;
-+
-+ mutex_lock(&plat_dat->button_lock);
-+ ret = gpio_get_value(plat_dat->button_gpio);
-+ if (ret)
-+ input_report_key(plat_dat->input_dev, BTN_JOYSTICK, 0);
-+ else
-+ input_report_key(plat_dat->input_dev, BTN_JOYSTICK, 1);
-+ input_sync(plat_dat->input_dev);
-+ mutex_unlock(&plat_dat->button_lock);
-+
-+ return IRQ_HANDLED;
++ uint8_t data[2] = { aregaddr, avalue };
++ struct i2c_msg msg = {
++ client->addr, I2C_M_IGNORE_NAK, 2, (uint8_t *)data
++ };
++ int error;
++
++ error = i2c_transfer(client->adapter, &msg, 1);
++ return error < 0 ? error : 0;
+}
+
-+static void as5011_update_axes(struct as5011_platform_data *plat_dat)
++static int as5011_i2c_read(struct i2c_client *client,
++ uint8_t aregaddr, signed char *value)
+{
-+ signed char x, y;
-+
-+ x = as5011_i2c_read(plat_dat->i2c_client, AS5011_X_RES_INT);
-+ y = as5011_i2c_read(plat_dat->i2c_client, AS5011_Y_RES_INT);
-+ input_report_abs(plat_dat->input_dev, ABS_X, x);
-+ input_report_abs(plat_dat->input_dev, ABS_Y, y);
-+ input_sync(plat_dat->input_dev);
++ uint8_t data[2] = { aregaddr };
++ struct i2c_msg msg_set[2] = {
++ { client->addr, I2C_M_REV_DIR_ADDR, 1, (uint8_t *)data },
++ { client->addr, I2C_M_RD | I2C_M_NOSTART, 1, (uint8_t *)data }
++ };
++ int error;
++
++ error = i2c_transfer(client->adapter, msg_set, 2);
++ if (error < 0)
++ return error;
++
++ *value = data[0] & 0x80 ? -1 * (1 + ~data[0]) : data[0];
++ return 0;
+}
+
-+static irqreturn_t as5011_int_interrupt(int irq, void *dev_id)
++static irqreturn_t as5011_button_interrupt(int irq, void *dev_id)
+{
-+ struct as5011_platform_data *plat_dat =
-+ (struct as5011_platform_data *)dev_id;
++ struct as5011_device *as5011 = dev_id;
++ int val = gpio_get_value_cansleep(as5011->button_gpio);
+
-+ mutex_lock(&plat_dat->update_lock);
-+ as5011_update_axes(plat_dat);
-+ mutex_unlock(&plat_dat->update_lock);
++ input_report_key(as5011->input_dev, BTN_JOYSTICK, !val);
++ input_sync(as5011->input_dev);
+
+ return IRQ_HANDLED;
+}
+
-+/*
-+ * I2C bus operation
-+ */
-+
-+static int as5011_i2c_write(struct i2c_client *client,
-+ uint8_t aRegAddr,
-+ uint8_t aValue)
++static irqreturn_t as5011_axis_interrupt(int irq, void *dev_id)
+{
-+ int ret;
-+ uint8_t data[2] = { aRegAddr, aValue };
++ struct as5011_device *as5011 = dev_id;
++ int error;
++ signed char x, y;
+
-+ struct i2c_msg msg = { client->addr,
-+ I2C_M_IGNORE_NAK,
-+ 2,
-+ (uint8_t *)data };
++ error = as5011_i2c_read(as5011->i2c_client, AS5011_X_RES_INT, &x);
++ if (error < 0)
++ goto out;
+
-+ ret = i2c_transfer(client->adapter, &msg, 1);
++ error = as5011_i2c_read(as5011->i2c_client, AS5011_Y_RES_INT, &y);
++ if (error < 0)
++ goto out;
+
-+ if (ret < 0)
-+ return ret;
-+ return 1;
-+}
++ input_report_abs(as5011->input_dev, ABS_X, x);
++ input_report_abs(as5011->input_dev, ABS_Y, y);
++ input_sync(as5011->input_dev);
+
-+static signed char as5011_i2c_read(struct i2c_client *client,
-+ uint8_t aRegAddr)
-+{
-+ int ret;
-+ uint8_t data[2];
-+ struct i2c_msg msg_set[2];
-+ struct i2c_msg msg1 = { client->addr,
-+ I2C_M_REV_DIR_ADDR,
-+ 1,
-+ (uint8_t *)data};
-+ struct i2c_msg msg2 = { client->addr,
-+ I2C_M_RD|I2C_M_NOSTART,
-+ 1,
-+ (uint8_t *)data};
-+
-+ data[0] = aRegAddr;
-+ msg_set[0] = msg1;
-+ msg_set[1] = msg2;
-+ ret = i2c_transfer(client->adapter, msg_set, 2);
-+ if (ret < 0)
-+ return ret;
-+
-+ if (data[0] & 0x80)
-+ return -1*(1+(~data[0]));
-+ else
-+ return data[0];
++out:
++ return IRQ_HANDLED;
+}
+
-+static int __devinit as5011_probe(struct i2c_client *client,
-+ const struct i2c_device_id *id)
++static int __devinit as5011_configure_chip(struct as5011_device *as5011,
++ const struct as5011_platform_data *plat_dat)
+{
-+ struct as5011_platform_data *plat_dat = client->dev.platform_data;
-+ int retval = 0;
-+
-+ plat_dat->num = g_num;
-+ g_num++;
++ struct i2c_client *client = as5011->i2c_client;
++ int error;
++ signed char value;
+
-+ if (!i2c_check_functionality(client->adapter,
-+ I2C_FUNC_PROTOCOL_MANGLING)) {
-+ dev_err(&client->dev,
-+ "i2c bus does not support protocol mangling, as5011 can't work\n");
-+ retval = -ENODEV;
-+ goto err_out;
++ /* chip soft reset */
++ error = as5011_i2c_write(client, AS5011_CTRL1,
++ AS5011_CTRL1_SOFT_RST);
++ if (error < 0) {
++ dev_err(&client->dev, "Soft reset failed\n");
++ return error;
+ }
-+ plat_dat->i2c_client = client;
+
++ mdelay(10);
+
-+ plat_dat->input_dev = input_allocate_device();
-+ if (plat_dat->input_dev == NULL) {
-+ dev_err(&client->dev,
-+ "not enough memory for input devices structure\n");
-+ retval = -ENOMEM;
-+ goto err_out;
++ error = as5011_i2c_write(client, AS5011_CTRL1,
++ AS5011_CTRL1_LP_PULSED |
++ AS5011_CTRL1_LP_ACTIVE |
++ AS5011_CTRL1_INT_ACT_EN);
++ if (error < 0) {
++ dev_err(&client->dev, "Power config failed\n");
++ return error;
+ }
+
-+ plat_dat->input_dev->name = "Austria Microsystem as5011 joystick";
-+ plat_dat->input_dev->uniq = "Austria0";
-+ plat_dat->input_dev->id.bustype = BUS_I2C;
-+ plat_dat->input_dev->phys = NULL;
-+ plat_dat->input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-+ plat_dat->input_dev->keybit[BIT_WORD(BTN_JOYSTICK)] =
-+ BIT_MASK(BTN_JOYSTICK);
-+
-+ input_set_abs_params(plat_dat->input_dev,
-+ ABS_X,
-+ AS5011_MIN_AXIS,
-+ AS5011_MAX_AXIS,
-+ AS5011_FUZZ,
-+ AS5011_FLAT);
-+ input_set_abs_params(plat_dat->input_dev,
-+ ABS_Y,
-+ AS5011_MIN_AXIS,
-+ AS5011_MAX_AXIS,
-+ AS5011_FUZZ,
-+ AS5011_FLAT);
-+
-+ plat_dat->button_irq_name = kmalloc(SIZE_NAME, GFP_KERNEL);
-+ if (plat_dat->button_irq_name == NULL) {
-+ dev_err(&client->dev,
-+ "not enough memory for input devices irq name\n");
-+ retval = -ENOMEM;
-+ goto err_input_free_device;
++ error = as5011_i2c_write(client, AS5011_CTRL2,
++ AS5011_CTRL2_INV_SPINNING);
++ if (error < 0) {
++ dev_err(&client->dev, "Can't invert spinning\n");
++ return error;
+ }
+
-+ scnprintf(plat_dat->button_irq_name,
-+ SIZE_NAME,
-+ "as5011_%d_button",
-+ plat_dat->num);
-+
-+ retval = request_threaded_irq( plat_dat->button_irq,
-+ NULL, button_interrupt,
-+ 0, plat_dat->button_irq_name,
-+ (void *)plat_dat);
-+ if (retval < 0) {
-+ dev_err(&client->dev, "Can't allocate irq %d\n",
-+ plat_dat->button_irq);
-+ retval = -EBUSY;
-+ goto err_free_button_irq_name;
++ /* write threshold */
++ error = as5011_i2c_write(client, AS5011_XP, plat_dat->xp);
++ if (error < 0) {
++ dev_err(&client->dev, "Can't write threshold\n");
++ return error;
+ }
+
-+ if (plat_dat->init_gpio != NULL) {
-+ retval = plat_dat->init_gpio();
-+ if (retval < 0) {
-+ dev_err(&client->dev, "Failed to init gpios\n");
-+ goto err_free_irq_button_interrupt;
-+ }
++ error = as5011_i2c_write(client, AS5011_XN, plat_dat->xn);
++ if (error < 0) {
++ dev_err(&client->dev, "Can't write threshold\n");
++ return error;
+ }
+
-+ /* chip soft reset */
-+ retval = as5011_i2c_write(plat_dat->i2c_client,
-+ AS5011_CTRL1,
-+ AS5011_CTRL1_SOFT_RST);
-+ if (retval < 0) {
-+ dev_err(&plat_dat->i2c_client->dev,
-+ "Soft reset failed\n");
-+ goto err_exit_gpio;
++ error = as5011_i2c_write(client, AS5011_YP, plat_dat->yp);
++ if (error < 0) {
++ dev_err(&client->dev, "Can't write threshold\n");
++ return error;
+ }
+
-+ mdelay(10);
-+
-+ retval = as5011_i2c_write(plat_dat->i2c_client,
-+ AS5011_CTRL1,
-+ AS5011_CTRL1_LP_PULSED |
-+ AS5011_CTRL1_LP_ACTIVE |
-+ AS5011_CTRL1_INT_ACT_EN
-+ );
-+ if (retval < 0) {
-+ dev_err(&plat_dat->i2c_client->dev,
-+ "Power config failed\n");
-+ goto err_exit_gpio;
++ error = as5011_i2c_write(client, AS5011_YN, plat_dat->yn);
++ if (error < 0) {
++ dev_err(&client->dev, "Can't write threshold\n");
++ return error;
+ }
+
-+ retval = as5011_i2c_write(plat_dat->i2c_client,
-+ AS5011_CTRL2,
-+ AS5011_CTRL2_INV_SPINNING);
-+ if (retval < 0) {
-+ dev_err(&plat_dat->i2c_client->dev,
-+ "Can't invert spinning\n");
-+ goto err_exit_gpio;
++ /* to free irq gpio in chip */
++ error = as5011_i2c_read(client, AS5011_X_RES_INT, &value);
++ if (error < 0) {
++ dev_err(&client->dev, "Can't read i2c X resolution value\n");
++ return error;
+ }
+
-+ /* write threshold */
-+ retval = as5011_i2c_write(plat_dat->i2c_client,
-+ AS5011_XP,
-+ plat_dat->Xp);
-+ if (retval < 0) {
-+ dev_err(&plat_dat->i2c_client->dev,
-+ "Can't write threshold\n");
-+ goto err_exit_gpio;
++ return 0;
++}
++
++static int __devinit as5011_probe(struct i2c_client *client,
++ const struct i2c_device_id *id)
++{
++ const struct as5011_platform_data *plat_data;
++ struct as5011_device *as5011;
++ struct input_dev *input_dev;
++ int irq;
++ int error;
++
++ plat_data = client->dev.platform_data;
++ if (!plat_data)
++ return -EINVAL;
++
++ if (!plat_data->axis_irq) {
++ dev_err(&client->dev, "No axis IRQ?\n");
++ return -EINVAL;
+ }
+
-+ retval = as5011_i2c_write(plat_dat->i2c_client,
-+ AS5011_XN,
-+ plat_dat->Xn);
-+ if (retval < 0) {
-+ dev_err(&plat_dat->i2c_client->dev,
-+ "Can't write threshold\n");
-+ goto err_exit_gpio;
++ if (!i2c_check_functionality(client->adapter,
++ I2C_FUNC_PROTOCOL_MANGLING)) {
++ dev_err(&client->dev,
++ "need i2c bus that supports protocol mangling\n");
++ return -ENODEV;
+ }
+
-+ retval = as5011_i2c_write(plat_dat->i2c_client,
-+ AS5011_YP,
-+ plat_dat->Yp);
-+ if (retval < 0) {
-+ dev_err(&plat_dat->i2c_client->dev,
-+ "Can't write threshold\n");
-+ goto err_exit_gpio;
++ as5011 = kmalloc(sizeof(struct as5011_device), GFP_KERNEL);
++ input_dev = input_allocate_device();
++ if (!as5011 || !input_dev) {
++ dev_err(&client->dev,
++ "Can't allocate memory for device structure\n");
++ error = -ENOMEM;
++ goto err_free_mem;
+ }
+
-+ retval = as5011_i2c_write(plat_dat->i2c_client,
-+ AS5011_YN,
-+ plat_dat->Yn);
-+ if (retval < 0) {
-+ dev_err(&plat_dat->i2c_client->dev,
-+ "Can't write threshold\n");
-+ goto err_exit_gpio;
++ as5011->i2c_client = client;
++ as5011->input_dev = input_dev;
++ as5011->button_gpio = plat_data->button_gpio;
++ as5011->axis_irq = plat_data->axis_irq;
++
++ input_dev->name = "Austria Microsystem as5011 joystick";
++ input_dev->id.bustype = BUS_I2C;
++ input_dev->dev.parent = &client->dev;
++
++ __set_bit(EV_KEY, input_dev->evbit);
++ __set_bit(EV_ABS, input_dev->evbit);
++ __set_bit(BTN_JOYSTICK, input_dev->keybit);
++
++ input_set_abs_params(input_dev, ABS_X,
++ AS5011_MIN_AXIS, AS5011_MAX_AXIS, AS5011_FUZZ, AS5011_FLAT);
++ input_set_abs_params(as5011->input_dev, ABS_Y,
++ AS5011_MIN_AXIS, AS5011_MAX_AXIS, AS5011_FUZZ, AS5011_FLAT);
++
++ error = gpio_request(as5011->button_gpio, "AS5011 button");
++ if (error < 0) {
++ dev_err(&client->dev, "Failed to request button gpio\n");
++ goto err_free_mem;
+ }
+
-+ /* request irq */
-+ plat_dat->int_irq_name = kmalloc(SIZE_NAME, GFP_KERNEL);
-+ if (plat_dat->int_irq_name == NULL) {
++ irq = gpio_to_irq(as5011->button_gpio);
++ if (irq < 0) {
+ dev_err(&client->dev,
-+ "not enough memory for input devices int irq name\n");
-+ retval = -ENOMEM;
-+ goto err_exit_gpio;
++ "Failed to get irq number for button gpio\n");
++ goto err_free_button_gpio;
+ }
+
++ as5011->button_irq = irq;
+
-+ /* to free irq gpio in chip*/
-+ as5011_i2c_read(plat_dat->i2c_client, AS5011_X_RES_INT);
-+
-+ /* initialize mutex */
-+ mutex_init(&plat_dat->update_lock);
-+ mutex_init(&plat_dat->button_lock);
++ error = request_threaded_irq(as5011->button_irq,
++ NULL, as5011_button_interrupt,
++ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
++ "as5011_button", as5011);
++ if (error < 0) {
++ dev_err(&client->dev,
++ "Can't allocate button irq %d\n", as5011->button_irq);
++ goto err_free_button_gpio;
++ }
+
-+ scnprintf(plat_dat->int_irq_name,
-+ SIZE_NAME,
-+ "as5011_%d_int",
-+ plat_dat->num);
++ error = as5011_configure_chip(as5011, plat_data);
++ if (error)
++ goto err_free_button_irq;
+
-+ if (request_threaded_irq(plat_dat->int_irq, NULL,
-+ as5011_int_interrupt,
-+ 0, plat_dat->int_irq_name, (void *)plat_dat)) {
-+ dev_err(&client->dev, "Can't allocate int irq %d\n",
-+ plat_dat->int_irq);
-+ retval = -EBUSY;
-+ goto err_free_int_irq_name;
++ error = request_threaded_irq(as5011->axis_irq, NULL,
++ as5011_axis_interrupt,
++ plat_data->axis_irqflags,
++ "as5011_joystick", as5011);
++ if (error) {
++ dev_err(&client->dev,
++ "Can't allocate axis irq %d\n", plat_data->axis_irq);
++ goto err_free_button_irq;
+ }
+
-+ retval = input_register_device(plat_dat->input_dev);
-+ if (retval) {
-+ dev_err(&client->dev, "Failed to register device\n");
-+ goto err_free_irq_int;
++ error = input_register_device(as5011->input_dev);
++ if (error) {
++ dev_err(&client->dev, "Failed to register input device\n");
++ goto err_free_axis_irq;
+ }
+
++ i2c_set_clientdata(client, as5011);
++
+ return 0;
+
-+ /* Error management */
-+err_free_irq_int:
-+ free_irq(plat_dat->int_irq, as5011_int_interrupt);
-+err_free_int_irq_name:
-+ kfree(plat_dat->int_irq_name);
-+err_exit_gpio:
-+ if (plat_dat->exit_gpio != NULL)
-+ plat_dat->exit_gpio();
-+err_free_irq_button_interrupt:
-+ free_irq(plat_dat->button_irq, button_interrupt);
-+err_free_button_irq_name:
-+ kfree(plat_dat->button_irq_name);
-+err_input_free_device:
-+ input_free_device(plat_dat->input_dev);
-+err_out:
-+ return retval;
++err_free_axis_irq:
++ free_irq(as5011->axis_irq, as5011);
++err_free_button_irq:
++ free_irq(as5011->button_irq, as5011);
++err_free_button_gpio:
++ gpio_free(as5011->button_gpio);
++err_free_mem:
++ input_free_device(input_dev);
++ kfree(as5011);
++
++ return error;
+}
-+static int as5011_remove(struct i2c_client *client)
++
++static int __devexit as5011_remove(struct i2c_client *client)
+{
-+ struct as5011_platform_data *plat_dat = client->dev.platform_data;
++ struct as5011_device *as5011 = i2c_get_clientdata(client);
++
++ free_irq(as5011->axis_irq, as5011);
++ free_irq(as5011->button_irq, as5011);
++ gpio_free(as5011->button_gpio);
+
-+ input_unregister_device(plat_dat->input_dev);
-+ free_irq(plat_dat->button_irq, plat_dat);
-+ free_irq(plat_dat->int_irq, plat_dat);
-+ kfree(plat_dat->button_irq_name);
-+ if (plat_dat->exit_gpio != NULL)
-+ plat_dat->exit_gpio();
++ input_unregister_device(as5011->input_dev);
++ kfree(as5011);
+
+ return 0;
+}
++
+static const struct i2c_device_id as5011_id[] = {
-+ { "as5011", 0 },
++ { MODULE_DEVICE_ALIAS, 0 },
+ { }
+};
++MODULE_DEVICE_TABLE(i2c, as5011_id);
+
+static struct i2c_driver as5011_driver = {
+ .driver = {
@@ -409,26 +363,22 @@ Index: linux-2.6.36/drivers/input/joystick/as5011.c
+ .id_table = as5011_id,
+};
+
-+/*
-+ * Module initialization
-+ */
-+
+static int __init as5011_init(void)
+{
+ return i2c_add_driver(&as5011_driver);
+}
++module_init(as5011_init);
+
+static void __exit as5011_exit(void)
+{
+ i2c_del_driver(&as5011_driver);
+}
-+
-+module_init(as5011_init);
+module_exit(as5011_exit);
++
Index: linux-2.6.36/drivers/input/joystick/Kconfig
===================================================================
---- linux-2.6.36.orig/drivers/input/joystick/Kconfig 2010-12-30 09:55:59.000000000 +0100
-+++ linux-2.6.36/drivers/input/joystick/Kconfig 2010-12-30 09:56:09.000000000 +0100
+--- linux-2.6.36.orig/drivers/input/joystick/Kconfig 2010-10-20 22:30:22.000000000 +0200
++++ linux-2.6.36/drivers/input/joystick/Kconfig 2011-01-03 16:58:29.000000000 +0100
@@ -255,6 +255,15 @@
To compile this driver as a module, choose M here: the
module will be called amijoy.
@@ -447,8 +397,8 @@ Index: linux-2.6.36/drivers/input/joystick/Kconfig
select GAMEPORT
Index: linux-2.6.36/drivers/input/joystick/Makefile
===================================================================
---- linux-2.6.36.orig/drivers/input/joystick/Makefile 2010-12-30 09:55:59.000000000 +0100
-+++ linux-2.6.36/drivers/input/joystick/Makefile 2010-12-30 09:56:09.000000000 +0100
+--- linux-2.6.36.orig/drivers/input/joystick/Makefile 2010-10-20 22:30:22.000000000 +0200
++++ linux-2.6.36/drivers/input/joystick/Makefile 2011-01-03 16:58:29.000000000 +0100
@@ -7,6 +7,7 @@
obj-$(CONFIG_JOYSTICK_A3D) += a3d.o
obj-$(CONFIG_JOYSTICK_ADI) += adi.o
@@ -457,84 +407,25 @@ Index: linux-2.6.36/drivers/input/joystick/Makefile
obj-$(CONFIG_JOYSTICK_ANALOG) += analog.o
obj-$(CONFIG_JOYSTICK_COBRA) += cobra.o
obj-$(CONFIG_JOYSTICK_DB9) += db9.o
-Index: linux-2.6.36/include/linux/as5011.h
+Index: linux-2.6.36/include/linux/input/as5011.h
===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.36/include/linux/as5011.h 2010-12-30 09:56:09.000000000 +0100
-@@ -0,0 +1,76 @@
-+#ifndef _AS5011_H
-+#define _AS5011_H
-+
-+/*
-+ * Copyright (c) 2010 Fabien Marteau
-+ *
-+ * 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.
-+ */
-+
-+#include <linux/mutex.h>
-+
-+#define AS5011_MAX_NAME_LENGTH 64
-+#define AS5011_MAX_CNAME_LENGTH 16
-+#define AS5011_MAX_PHYS_LENGTH 64
-+#define AS5011_MAX_LENGTH 64
-+
-+/* registers */
-+#define AS5011_CTRL1 0x76
-+#define AS5011_CTRL2 0x75
-+#define AS5011_XP 0x43
-+#define AS5011_XN 0x44
-+#define AS5011_YP 0x53
-+#define AS5011_YN 0x54
-+#define AS5011_X_REG 0x41
-+#define AS5011_Y_REG 0x42
-+#define AS5011_X_RES_INT 0x51
-+#define AS5011_Y_RES_INT 0x52
-+
-+/* CTRL1 bits */
-+#define AS5011_CTRL1_LP_PULSED 0x80
-+#define AS5011_CTRL1_LP_ACTIVE 0x40
-+#define AS5011_CTRL1_LP_CONTINUE 0x20
-+#define AS5011_CTRL1_INT_WUP_EN 0x10
-+#define AS5011_CTRL1_INT_ACT_EN 0x08
-+#define AS5011_CTRL1_EXT_CLK_EN 0x04
-+#define AS5011_CTRL1_SOFT_RST 0x02
-+#define AS5011_CTRL1_DATA_VALID 0x01
-+
-+/* CTRL2 bits */
-+#define AS5011_CTRL2_EXT_SAMPLE_EN 0x08
-+#define AS5011_CTRL2_RC_BIAS_ON 0x04
-+#define AS5011_CTRL2_INV_SPINNING 0x02
-+
-+
-+struct as5011_platform_data {
-+ /* public */
-+ int button_gpio;
-+ int button_irq;
-+ int int_gpio;
-+ int int_irq;
-+ char Xp, Xn; /* threshold for x axis */
-+ char Yp, Yn; /* threshold for y axis */
-+
-+ int (*init_gpio)(void); /* init interrupts gpios */
-+ void (*exit_gpio)(void);/* exit gpios */
-+
-+ /* private */
-+ int num;
-+ struct input_dev *input_dev;
-+ struct i2c_client *i2c_client;
-+ unsigned char *button_irq_name;
-+ unsigned char *int_irq_name;
-+ char name[AS5011_MAX_NAME_LENGTH];
-+ char cname[AS5011_MAX_CNAME_LENGTH];
-+ char phys[AS5011_MAX_PHYS_LENGTH];
-+ unsigned char data[AS5011_MAX_LENGTH];
-+ char workqueue_name[AS5011_MAX_NAME_LENGTH];
-+ struct workqueue_struct *workqueue;
-+ struct work_struct update_axes_work;
-+ struct mutex update_lock;
-+ struct mutex button_lock;
-+};
-+
-+#endif /* _AS5011_H */
+--- linux-2.6.36.orig/include/linux/input/as5011.h 2011-01-10 09:17:59.000000000 +0100
++++ linux-2.6.36/include/linux/input/as5011.h 2011-01-10 09:18:58.000000000 +0100
+@@ -9,14 +9,10 @@
+ * the Free Software Foundation.
+ */
+
+-#include <linux/mutex.h>
+-
+-#define AS5011_MAX_NAME_LENGTH 64
+-
+ struct as5011_platform_data {
+- int button_gpio;
+- int int_irq; /* irq number */
+- int int_edge;/* irq edge IRQ_TYPE_EDGE_[FALLING,RISING,BOTH] */
++ unsigned int button_gpio;
++ unsigned int axis_irq; /* irq number */
++ unsigned long axis_irqflags;
+ char xp, xn; /* threshold for x axis */
+ char yp, yn; /* threshold for y axis */
+ };
hooks/post-receive
--
armadeus
|