[Armadeus-commitlog] armadeus branch, master, updated. release-3.3-356-g81250d1
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2011-02-22 16:52:27
|
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 81250d10b68c6d279dc12153d36661caad232e43 (commit)
from 2157ffdab3d52df1d9be6d3eb76839316f0d24d8 (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 81250d10b68c6d279dc12153d36661caad232e43
Author: Fabien Marteau <fab...@ar...>
Date: Tue Feb 22 17:51:31 2011 +0100
[linux] Adding driver for MCP4912 DAC chip, adding platform data for apf51dev
-----------------------------------------------------------------------
Summary of changes:
.../408-armadeus-add_apf51-dev_baseboard.patch | 25 +-
...-armadeus-BACKPORT_iio_linux-next20110221.patch | 4519 ++++++++++++++++++++
...3-armadeus-adding_mcp4912_dac_chip_driver.patch | 394 ++
3 files changed, 4929 insertions(+), 9 deletions(-)
create mode 100644 buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/422-armadeus-BACKPORT_iio_linux-next20110221.patch
create mode 100644 buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/423-armadeus-adding_mcp4912_dac_chip_driver.patch
diff --git a/buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/408-armadeus-add_apf51-dev_baseboard.patch b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/408-armadeus-add_apf51-dev_baseboard.patch
index dc6a63d..79ab67f 100644
--- a/buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/408-armadeus-add_apf51-dev_baseboard.patch
+++ b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/408-armadeus-add_apf51-dev_baseboard.patch
@@ -4,8 +4,8 @@ Signed-off-by: Julien Boibessot <jul...@ar...>
Index: linux-2.6.38-rc3/arch/arm/mach-mx5/Kconfig
===================================================================
---- linux-2.6.38-rc3.orig/arch/arm/mach-mx5/Kconfig 2011-02-18 10:13:10.000000000 +0100
-+++ linux-2.6.38-rc3/arch/arm/mach-mx5/Kconfig 2011-02-18 10:33:41.000000000 +0100
+--- linux-2.6.38-rc3.orig/arch/arm/mach-mx5/Kconfig 2011-02-22 15:08:04.000000000 +0100
++++ linux-2.6.38-rc3/arch/arm/mach-mx5/Kconfig 2011-02-22 17:49:07.000000000 +0100
@@ -167,12 +167,32 @@
select SOC_IMX51
select IMX_HAVE_PLATFORM_IMX_UART
@@ -43,8 +43,8 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/Kconfig
endif
Index: linux-2.6.38-rc3/arch/arm/mach-mx5/Makefile
===================================================================
---- linux-2.6.38-rc3.orig/arch/arm/mach-mx5/Makefile 2011-02-18 10:13:10.000000000 +0100
-+++ linux-2.6.38-rc3/arch/arm/mach-mx5/Makefile 2011-02-18 10:33:03.000000000 +0100
+--- linux-2.6.38-rc3.orig/arch/arm/mach-mx5/Makefile 2011-02-22 15:08:04.000000000 +0100
++++ linux-2.6.38-rc3/arch/arm/mach-mx5/Makefile 2011-02-22 17:49:07.000000000 +0100
@@ -8,6 +8,7 @@
obj-$(CONFIG_CPU_FREQ_IMX) += cpu_op-mx51.o
@@ -56,8 +56,8 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/Makefile
Index: linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c 2011-02-18 10:13:10.000000000 +0100
-@@ -0,0 +1,431 @@
++++ linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c 2011-02-22 17:25:43.000000000 +0100
+@@ -0,0 +1,438 @@
+ /*
+ * Support for APF51's official development baseboard (APF51Dev)
+ *
@@ -90,6 +90,7 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c
+#include <mach/ssi.h>
+#include <linux/can/platform/mcp251x.h>
+
++#include "../../../drivers/staging/iio/dac/mcp49x2.h"
+#include "devices-imx51.h"
+#include "devices.h"
+
@@ -142,6 +143,7 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c
+ MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK,
+ (_MX51_PAD_CSPI1_SS0__GPIO4_24 | MUX_PAD_CTRL(APF51_GPIO_SPECIAL_PAD_CTRL)),
+ (_MX51_PAD_CSPI1_SS1__GPIO4_25 | MUX_PAD_CTRL(APF51_GPIO_SPECIAL_PAD_CTRL)),
++ (_MX51_PAD_CSPI1_RDY__GPIO4_26 | MUX_PAD_CTRL(APF51_GPIO_SPECIAL_PAD_CTRL)), /* LDAC for mcp4912 */
+
+ (_MX51_PAD_NANDF_D14__GPIO3_26 | MUX_PAD_CTRL(APF51_GPIO_SPECIAL_PAD_CTRL)), /* ADC_SSTRB */
+
@@ -259,6 +261,11 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c
+#define APF51DEV_ECSPI1_SS0 IMX_GPIO_NR(4, 24)
+#define APF51DEV_ECSPI1_SS1 IMX_GPIO_NR(4, 25)
+
++static struct mcp49x2_config mcp4912_dat = {
++ .ldac_pin = IMX_GPIO_NR(4, 26), /* GPIO4-26 */
++ .vref_mv = {3100, 3100},
++};
++
+static struct spi_board_info apf51dev_spi1_board_info[] __initdata = {
+ {
+ .modalias = "as1531",
@@ -274,7 +281,7 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c
+ .bus_num = 0,
+ .chip_select = 1,
+ .mode = SPI_MODE_0,
-+ .platform_data = NULL,
++ .platform_data = &mcp4912_dat,
+ },
+};
+
@@ -303,7 +310,7 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c
+#define APF51DEV_ECSPI2_SS1 IMX_GPIO_NR(3, 28)
+#define APF51DEV_ECSPI2_SS2 IMX_GPIO_NR(3, 27)
+
-+static struct spi_board_info apf51dev_spi2_board_info[] __initdata = {
++static struct spi_board_info apf51dev_spi2_board_info[] = {
+ {
+ .modalias = "mcp2515",
+ .max_speed_hz = 8000000,
@@ -319,7 +326,7 @@ Index: linux-2.6.38-rc3/arch/arm/mach-mx5/apf51dev-baseboard.c
+ .bus_num = 1,
+ .chip_select = 1,
+ .mode = SPI_MODE_0,
-+ .platform_data = NULL,
++ .platform_data = &mcp4912_dat,
+ },
+};
+
diff --git a/buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/422-armadeus-BACKPORT_iio_linux-next20110221.patch b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/422-armadeus-BACKPORT_iio_linux-next20110221.patch
new file mode 100644
index 0000000..7bb31ee
--- /dev/null
+++ b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.38/422-armadeus-BACKPORT_iio_linux-next20110221.patch
@@ -0,0 +1,4519 @@
+Backport all drivers from iio staging directory
+
+Signed-off-by: Fabien Marteau <fab...@ar...>
+Index: linux-2.6.38-rc3/drivers/staging/iio/accel/Kconfig
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/accel/Kconfig 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/accel/Kconfig 2011-02-21 18:29:49.000000000 +0100
+@@ -66,12 +66,33 @@
+ tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver"
+ depends on SPI
+ select IIO_TRIGGER if IIO_RING_BUFFER
+- select IIO_SW_RING if IIO_RING_BUFFER
++ depends on !IIO_RING_BUFFER || IIO_KFIFO_BUF || IIO_SW_RING
+ help
+ Say yes here to build SPI support for the ST microelectronics
+ accelerometer. The driver supplies direct access via sysfs files
+ and an event interface via a character device.
+
++choice
++ prompt "Buffer type"
++ depends on LIS3L02DQ && IIO_RING_BUFFER
++
++config LIS3L02DQ_BUF_KFIFO
++ depends on IIO_KFIFO_BUF
++ bool "Simple FIFO"
++ help
++ Kfifo based FIFO. Does not provide any events so it is up
++ to userspace to ensure it reads often enough that data is not
++ lost.
++
++config LIS3L02DQ_BUF_RING_SW
++ depends on IIO_SW_RING
++ bool "IIO Software Ring"
++ help
++ Original IIO ring buffer implementation. Provides simple
++ buffer events, half full etc.
++
++endchoice
++
+ config SCA3000
+ depends on IIO_RING_BUFFER
+ depends on SPI
+Index: linux-2.6.38-rc3/drivers/staging/iio/accel/lis3l02dq.h
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/accel/lis3l02dq.h 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/accel/lis3l02dq.h 2011-02-21 18:29:49.000000000 +0100
+@@ -196,6 +196,16 @@
+ int lis3l02dq_configure_ring(struct iio_dev *indio_dev);
+ void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev);
+
++#ifdef CONFIG_LIS3L02DQ_BUF_RING_SW
++#define lis3l02dq_free_buf iio_sw_rb_free
++#define lis3l02dq_alloc_buf iio_sw_rb_allocate
++#define lis3l02dq_register_buf_funcs iio_ring_sw_register_funcs
++#endif
++#ifdef CONFIG_LIS3L02DQ_BUF_KFIFO
++#define lis3l02dq_free_buf iio_kfifo_free
++#define lis3l02dq_alloc_buf iio_kfifo_allocate
++#define lis3l02dq_register_buf_funcs iio_kfifo_register_funcs
++#endif
+ #else /* CONFIG_IIO_RING_BUFFER */
+
+ static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
+Index: linux-2.6.38-rc3/drivers/staging/iio/accel/lis3l02dq_ring.c
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/accel/lis3l02dq_ring.c 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/accel/lis3l02dq_ring.c 2011-02-21 18:29:49.000000000 +0100
+@@ -13,6 +13,7 @@
+ #include "../iio.h"
+ #include "../sysfs.h"
+ #include "../ring_sw.h"
++#include "../kfifo_buf.h"
+ #include "accel.h"
+ #include "../trigger.h"
+ #include "lis3l02dq.h"
+@@ -484,7 +485,7 @@
+ void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev)
+ {
+ kfree(indio_dev->pollfunc);
+- iio_sw_rb_free(indio_dev->ring);
++ lis3l02dq_free_buf(indio_dev->ring);
+ }
+
+ int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
+@@ -495,13 +496,13 @@
+ INIT_WORK(&h->work_trigger_to_ring, lis3l02dq_trigger_bh_to_ring);
+ h->get_ring_element = &lis3l02dq_get_ring_element;
+
+- ring = iio_sw_rb_allocate(indio_dev);
++ ring = lis3l02dq_alloc_buf(indio_dev);
+ if (!ring)
+ return -ENOMEM;
+
+ indio_dev->ring = ring;
+ /* Effectively select the ring buffer implementation */
+- iio_ring_sw_register_funcs(&ring->access);
++ lis3l02dq_register_buf_funcs(&ring->access);
+ ring->bpe = 2;
+ ring->scan_el_attrs = &lis3l02dq_scan_el_group;
+ ring->scan_timestamp = true;
+@@ -522,6 +523,6 @@
+ return 0;
+
+ error_iio_sw_rb_free:
+- iio_sw_rb_free(indio_dev->ring);
++ lis3l02dq_free_buf(indio_dev->ring);
+ return ret;
+ }
+Index: linux-2.6.38-rc3/drivers/staging/iio/adc/ad7476_core.c
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/adc/ad7476_core.c 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/adc/ad7476_core.c 2011-02-21 18:29:49.000000000 +0100
+@@ -190,7 +190,7 @@
+ goto error_disable_reg;
+ }
+
+- /* Estabilish that the iio_dev is a child of the i2c device */
++ /* Establish that the iio_dev is a child of the spi device */
+ st->indio_dev->dev.parent = &spi->dev;
+ st->indio_dev->attrs = &ad7476_attribute_group;
+ st->indio_dev->dev_data = (void *)(st);
+Index: linux-2.6.38-rc3/drivers/staging/iio/dac/Kconfig
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/dac/Kconfig 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/dac/Kconfig 2011-02-21 18:29:49.000000000 +0100
+@@ -19,3 +19,13 @@
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad5446.
++
++config MAX517
++ tristate "Maxim MAX517/518/519 DAC driver"
++ depends on I2C && EXPERIMENTAL
++ help
++ If you say yes here you get support for the Maxim chips MAX517,
++ MAX518 and MAX519 (I2C 8-Bit DACs with rail-to-rail outputs).
++
++ This driver can also be built as a module. If so, the module
++ will be called max517.
+Index: linux-2.6.38-rc3/drivers/staging/iio/dac/Makefile
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/dac/Makefile 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/dac/Makefile 2011-02-21 18:29:49.000000000 +0100
+@@ -4,3 +4,4 @@
+
+ obj-$(CONFIG_AD5624R_SPI) += ad5624r_spi.o
+ obj-$(CONFIG_AD5446) += ad5446.o
++obj-$(CONFIG_MAX517) += max517.o
+Index: linux-2.6.38-rc3/drivers/staging/iio/dac/max517.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.38-rc3/drivers/staging/iio/dac/max517.c 2011-02-21 18:29:49.000000000 +0100
+@@ -0,0 +1,298 @@
++/*
++ * max517.c - Support for Maxim MAX517, MAX518 and MAX519
++ *
++ * Copyright (C) 2010, 2011 Roland Stigge <st...@an...>
++ *
++ * 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
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <linux/module.h>
++#include <linux/init.h>
++#include <linux/slab.h>
++#include <linux/jiffies.h>
++#include <linux/i2c.h>
++#include <linux/err.h>
++
++#include "../iio.h"
++#include "dac.h"
++
++#include "max517.h"
++
++#define MAX517_DRV_NAME "max517"
++
++/* Commands */
++#define COMMAND_CHANNEL0 0x00
++#define COMMAND_CHANNEL1 0x01 /* for MAX518 and MAX519 */
++#define COMMAND_PD 0x08 /* Power Down */
++
++enum max517_device_ids {
++ ID_MAX517,
++ ID_MAX518,
++ ID_MAX519,
++};
++
++struct max517_data {
++ struct iio_dev *indio_dev;
++ struct i2c_client *client;
++ unsigned short vref_mv[2];
++};
++
++/*
++ * channel: bit 0: channel 1
++ * bit 1: channel 2
++ * (this way, it's possible to set both channels at once)
++ */
++static ssize_t max517_set_value(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count, int channel)
++{
++ struct iio_dev *dev_info = dev_get_drvdata(dev);
++ struct max517_data *data = iio_dev_get_devdata(dev_info);
++ struct i2c_client *client = data->client;
++ u8 outbuf[4]; /* 1x or 2x command + value */
++ int outbuf_size = 0;
++ int res;
++ long val;
++
++ res = strict_strtol(buf, 10, &val);
++
++ if (res)
++ return res;
++
++ if (val < 0 || val > 255)
++ return -EINVAL;
++
++ if (channel & 1) {
++ outbuf[outbuf_size++] = COMMAND_CHANNEL0;
++ outbuf[outbuf_size++] = val;
++ }
++ if (channel & 2) {
++ outbuf[outbuf_size++] = COMMAND_CHANNEL1;
++ outbuf[outbuf_size++] = val;
++ }
++
++ /*
++ * At this point, there are always 1 or 2 two-byte commands in
++ * outbuf. With 2 commands, the device can set two outputs
++ * simultaneously, latching the values upon the end of the I2C
++ * transfer.
++ */
++
++ res = i2c_master_send(client, outbuf, outbuf_size);
++ if (res < 0)
++ return res;
++
++ return count;
++}
++
++static ssize_t max517_set_value_1(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ return max517_set_value(dev, attr, buf, count, 1);
++}
++static IIO_DEV_ATTR_OUT_RAW(1, max517_set_value_1, 0);
++
++static ssize_t max517_set_value_2(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ return max517_set_value(dev, attr, buf, count, 2);
++}
++static IIO_DEV_ATTR_OUT_RAW(2, max517_set_value_2, 1);
++
++static ssize_t max517_set_value_both(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ return max517_set_value(dev, attr, buf, count, 3);
++}
++static IIO_DEVICE_ATTR_NAMED(out1and2_raw, out1&2_raw, S_IWUSR, NULL,
++ max517_set_value_both, -1);
++
++static ssize_t max517_show_scale(struct device *dev,
++ struct device_attribute *attr,
++ char *buf, int channel)
++{
++ struct iio_dev *dev_info = dev_get_drvdata(dev);
++ struct max517_data *data = iio_dev_get_devdata(dev_info);
++ /* Corresponds to Vref / 2^(bits) */
++ unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8;
++
++ return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
++}
++
++static ssize_t max517_show_scale1(struct device *dev,
++ struct device_attribute *attr,
++ char *buf)
++{
++ return max517_show_scale(dev, attr, buf, 1);
++}
++static IIO_DEVICE_ATTR(out1_scale, S_IRUGO, max517_show_scale1, NULL, 0);
++
++static ssize_t max517_show_scale2(struct device *dev,
++ struct device_attribute *attr,
++ char *buf)
++{
++ return max517_show_scale(dev, attr, buf, 2);
++}
++static IIO_DEVICE_ATTR(out2_scale, S_IRUGO, max517_show_scale2, NULL, 0);
++
++/* On MAX517 variant, we have one output */
++static struct attribute *max517_attributes[] = {
++ &iio_dev_attr_out1_raw.dev_attr.attr,
++ &iio_dev_attr_out1_scale.dev_attr.attr,
++ NULL
++};
++
++static struct attribute_group max517_attribute_group = {
++ .attrs = max517_attributes,
++};
++
++/* On MAX518 and MAX519 variant, we have two outputs */
++static struct attribute *max518_attributes[] = {
++ &iio_dev_attr_out1_raw.dev_attr.attr,
++ &iio_dev_attr_out1_scale.dev_attr.attr,
++ &iio_dev_attr_out2_raw.dev_attr.attr,
++ &iio_dev_attr_out2_scale.dev_attr.attr,
++ &iio_dev_attr_out1and2_raw.dev_attr.attr,
++ NULL
++};
++
++static struct attribute_group max518_attribute_group = {
++ .attrs = max518_attributes,
++};
++
++static int max517_suspend(struct i2c_client *client, pm_message_t mesg)
++{
++ u8 outbuf = COMMAND_PD;
++
++ return i2c_master_send(client, &outbuf, 1);
++}
++
++static int max517_resume(struct i2c_client *client)
++{
++ u8 outbuf = 0;
++
++ return i2c_master_send(client, &outbuf, 1);
++}
++
++static int max517_probe(struct i2c_client *client,
++ const struct i2c_device_id *id)
++{
++ struct max517_data *data;
++ struct max517_platform_data *platform_data = client->dev.platform_data;
++ int err;
++
++ data = kzalloc(sizeof(struct max517_data), GFP_KERNEL);
++ if (!data) {
++ err = -ENOMEM;
++ goto exit;
++ }
++
++ i2c_set_clientdata(client, data);
++
++ data->client = client;
++
++ data->indio_dev = iio_allocate_device();
++ if (data->indio_dev == NULL) {
++ err = -ENOMEM;
++ goto exit_free_data;
++ }
++
++ /* establish that the iio_dev is a child of the i2c device */
++ data->indio_dev->dev.parent = &client->dev;
++
++ /* reduced attribute set for MAX517 */
++ if (id->driver_data == ID_MAX517)
++ data->indio_dev->attrs = &max517_attribute_group;
++ else
++ data->indio_dev->attrs = &max518_attribute_group;
++ data->indio_dev->dev_data = (void *)(data);
++ data->indio_dev->driver_module = THIS_MODULE;
++ data->indio_dev->modes = INDIO_DIRECT_MODE;
++
++ /*
++ * Reference voltage on MAX518 and default is 5V, else take vref_mv
++ * from platform_data
++ */
++ if (id->driver_data == ID_MAX518 || !platform_data) {
++ data->vref_mv[0] = data->vref_mv[1] = 5000; /* mV */
++ } else {
++ data->vref_mv[0] = platform_data->vref_mv[0];
++ data->vref_mv[1] = platform_data->vref_mv[1];
++ }
++
++ err = iio_device_register(data->indio_dev);
++ if (err)
++ goto exit_free_device;
++
++ dev_info(&client->dev, "DAC registered\n");
++
++ return 0;
++
++exit_free_device:
++ iio_free_device(data->indio_dev);
++exit_free_data:
++ kfree(data);
++exit:
++ return err;
++}
++
++static int max517_remove(struct i2c_client *client)
++{
++ struct max517_data *data = i2c_get_clientdata(client);
++
++ iio_free_device(data->indio_dev);
++ kfree(data);
++
++ return 0;
++}
++
++static const struct i2c_device_id max517_id[] = {
++ { "max517", ID_MAX517 },
++ { "max518", ID_MAX518 },
++ { "max519", ID_MAX519 },
++ { }
++};
++MODULE_DEVICE_TABLE(i2c, max517_id);
++
++static struct i2c_driver max517_driver = {
++ .driver = {
++ .name = MAX517_DRV_NAME,
++ },
++ .probe = max517_probe,
++ .remove = max517_remove,
++ .suspend = max517_suspend,
++ .resume = max517_resume,
++ .id_table = max517_id,
++};
++
++static int __init max517_init(void)
++{
++ return i2c_add_driver(&max517_driver);
++}
++
++static void __exit max517_exit(void)
++{
++ i2c_del_driver(&max517_driver);
++}
++
++MODULE_AUTHOR("Roland Stigge <st...@an...>");
++MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC");
++MODULE_LICENSE("GPL");
++
++module_init(max517_init);
++module_exit(max517_exit);
+Index: linux-2.6.38-rc3/drivers/staging/iio/dac/max517.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.38-rc3/drivers/staging/iio/dac/max517.h 2011-02-21 18:29:49.000000000 +0100
+@@ -0,0 +1,19 @@
++/*
++ * MAX517 DAC driver
++ *
++ * Copyright 2011 Roland Stigge <st...@an...>
++ *
++ * Licensed under the GPL-2 or later.
++ */
++#ifndef IIO_DAC_MAX517_H_
++#define IIO_DAC_MAX517_H_
++
++/*
++ * TODO: struct max517_platform_data needs to go into include/linux/iio
++ */
++
++struct max517_platform_data {
++ u16 vref_mv[2];
++};
++
++#endif /* IIO_DAC_MAX517_H_ */
+Index: linux-2.6.38-rc3/drivers/staging/iio/dds/ad9832.c
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/dds/ad9832.c 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/dds/ad9832.c 2011-02-21 18:29:49.000000000 +0100
+@@ -1,228 +1,336 @@
+ /*
+- * Driver for ADI Direct Digital Synthesis ad9832
++ * AD9832 SPI DDS driver
+ *
+- * Copyright (c) 2010 Analog Devices Inc.
+- *
+- * 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.
++ * Copyright 2011 Analog Devices Inc.
+ *
++ * Licensed under the GPL-2.
+ */
+-#include <linux/types.h>
+-#include <linux/mutex.h>
++
+ #include <linux/device.h>
+-#include <linux/spi/spi.h>
++#include <linux/kernel.h>
+ #include <linux/slab.h>
+ #include <linux/sysfs.h>
++#include <linux/spi/spi.h>
++#include <linux/regulator/consumer.h>
++#include <linux/err.h>
++#include <asm/div64.h>
+
+ #include "../iio.h"
+ #include "../sysfs.h"
++#include "dds.h"
+
+-#define DRV_NAME "ad9832"
+-
+-#define value_mask (u16)0xf000
+-#define cmd_shift 12
+-#define add_shift 8
+-#define AD9832_SYNC (1 << 13)
+-#define AD9832_SELSRC (1 << 12)
+-#define AD9832_SLEEP (1 << 13)
+-#define AD9832_RESET (1 << 12)
+-#define AD9832_CLR (1 << 11)
+-
+-#define ADD_FREQ0LL 0x0
+-#define ADD_FREQ0HL 0x1
+-#define ADD_FREQ0LM 0x2
+-#define ADD_FREQ0HM 0x3
+-#define ADD_FREQ1LL 0x4
+-#define ADD_FREQ1HL 0x5
+-#define ADD_FREQ1LM 0x6
+-#define ADD_FREQ1HM 0x7
+-#define ADD_PHASE0L 0x8
+-#define ADD_PHASE0H 0x9
+-#define ADD_PHASE1L 0xa
+-#define ADD_PHASE1H 0xb
+-#define ADD_PHASE2L 0xc
+-#define ADD_PHASE2H 0xd
+-#define ADD_PHASE3L 0xe
+-#define ADD_PHASE3H 0xf
+-
+-#define CMD_PHA8BITSW 0x1
+-#define CMD_PHA16BITSW 0x0
+-#define CMD_FRE8BITSW 0x3
+-#define CMD_FRE16BITSW 0x2
+-#define CMD_SELBITSCTL 0x6
+-
+-struct ad9832_setting {
+- u16 freq0[4];
+- u16 freq1[4];
+- u16 phase0[2];
+- u16 phase1[2];
+- u16 phase2[2];
+- u16 phase3[2];
+-};
++#include "ad9832.h"
+
+-struct ad9832_state {
+- struct mutex lock;
+- struct iio_dev *idev;
+- struct spi_device *sdev;
+-};
++static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
++{
++ unsigned long long freqreg = (u64) fout *
++ (u64) ((u64) 1L << AD9832_FREQ_BITS);
++ do_div(freqreg, mclk);
++ return freqreg;
++}
+
+-static ssize_t ad9832_set_parameter(struct device *dev,
+- struct device_attribute *attr,
+- const char *buf,
+- size_t len)
++static int ad9832_write_frequency(struct ad9832_state *st,
++ unsigned addr, unsigned long fout)
+ {
+- struct spi_message msg;
+- struct spi_transfer xfer;
+- int ret;
+- struct ad9832_setting config;
+- struct iio_dev *idev = dev_get_drvdata(dev);
+- struct ad9832_state *st = idev->dev_data;
+-
+- config.freq0[0] = (CMD_FRE8BITSW << add_shift | ADD_FREQ0LL << add_shift | buf[0]);
+- config.freq0[1] = (CMD_FRE16BITSW << add_shift | ADD_FREQ0HL << add_shift | buf[1]);
+- config.freq0[2] = (CMD_FRE8BITSW << add_shift | ADD_FREQ0LM << add_shift | buf[2]);
+- config.freq0[3] = (CMD_FRE16BITSW << add_shift | ADD_FREQ0HM << add_shift | buf[3]);
+- config.freq1[0] = (CMD_FRE8BITSW << add_shift | ADD_FREQ1LL << add_shift | buf[4]);
+- config.freq1[1] = (CMD_FRE16BITSW << add_shift | ADD_FREQ1HL << add_shift | buf[5]);
+- config.freq1[2] = (CMD_FRE8BITSW << add_shift | ADD_FREQ1LM << add_shift | buf[6]);
+- config.freq1[3] = (CMD_FRE16BITSW << add_shift | ADD_FREQ1HM << add_shift | buf[7]);
+-
+- config.phase0[0] = (CMD_PHA8BITSW << add_shift | ADD_PHASE0L << add_shift | buf[9]);
+- config.phase0[1] = (CMD_PHA16BITSW << add_shift | ADD_PHASE0H << add_shift | buf[10]);
+- config.phase1[0] = (CMD_PHA8BITSW << add_shift | ADD_PHASE1L << add_shift | buf[11]);
+- config.phase1[1] = (CMD_PHA16BITSW << add_shift | ADD_PHASE1H << add_shift | buf[12]);
+- config.phase2[0] = (CMD_PHA8BITSW << add_shift | ADD_PHASE2L << add_shift | buf[13]);
+- config.phase2[1] = (CMD_PHA16BITSW << add_shift | ADD_PHASE2H << add_shift | buf[14]);
+- config.phase3[0] = (CMD_PHA8BITSW << add_shift | ADD_PHASE3L << add_shift | buf[15]);
+- config.phase3[1] = (CMD_PHA16BITSW << add_shift | ADD_PHASE3H << add_shift | buf[16]);
+-
+- xfer.len = 2 * len;
+- xfer.tx_buf = &config;
+- mutex_lock(&st->lock);
+-
+- spi_message_init(&msg);
+- spi_message_add_tail(&xfer, &msg);
+- ret = spi_sync(st->sdev, &msg);
+- if (ret)
+- goto error_ret;
+-error_ret:
+- mutex_unlock(&st->lock);
++ unsigned long regval;
+
+- return ret ? ret : len;
+-}
++ if (fout > (st->mclk / 2))
++ return -EINVAL;
+
+-static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9832_set_parameter, 0);
++ regval = ad9832_calc_freqreg(st->mclk, fout);
+
+-static struct attribute *ad9832_attributes[] = {
+- &iio_dev_attr_dds.dev_attr.attr,
+- NULL,
+-};
++ st->freq_data[0] = cpu_to_be16((AD9832_CMD_FRE8BITSW << CMD_SHIFT) |
++ (addr << ADD_SHIFT) |
++ ((regval >> 24) & 0xFF));
++ st->freq_data[1] = cpu_to_be16((AD9832_CMD_FRE16BITSW << CMD_SHIFT) |
++ ((addr - 1) << ADD_SHIFT) |
++ ((regval >> 16) & 0xFF));
++ st->freq_data[2] = cpu_to_be16((AD9832_CMD_FRE8BITSW << CMD_SHIFT) |
++ ((addr - 2) << ADD_SHIFT) |
++ ((regval >> 8) & 0xFF));
++ st->freq_data[3] = cpu_to_be16((AD9832_CMD_FRE16BITSW << CMD_SHIFT) |
++ ((addr - 3) << ADD_SHIFT) |
++ ((regval >> 0) & 0xFF));
+
+-static const struct attribute_group ad9832_attribute_group = {
+- .name = DRV_NAME,
+- .attrs = ad9832_attributes,
+-};
++ return spi_sync(st->spi, &st->freq_msg);;
++}
+
+-static void ad9832_init(struct ad9832_state *st)
++static int ad9832_write_phase(struct ad9832_state *st,
++ unsigned long addr, unsigned long phase)
+ {
+- struct spi_message msg;
+- struct spi_transfer xfer;
+- int ret;
+- u16 config = 0;
++ if (phase > (1 << AD9832_PHASE_BITS))
++ return -EINVAL;
+
+- config = 0x3 << 14 | AD9832_SLEEP | AD9832_RESET | AD9832_CLR;
++ st->phase_data[0] = cpu_to_be16((AD9832_CMD_PHA8BITSW << CMD_SHIFT) |
++ (addr << ADD_SHIFT) |
++ ((phase >> 8) & 0xFF));
++ st->phase_data[1] = cpu_to_be16((AD9832_CMD_PHA16BITSW << CMD_SHIFT) |
++ ((addr - 1) << ADD_SHIFT) |
++ (phase & 0xFF));
+
+- mutex_lock(&st->lock);
++ return spi_sync(st->spi, &st->phase_msg);
++}
+
+- xfer.len = 2;
+- xfer.tx_buf = &config;
++static ssize_t ad9832_write(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf,
++ size_t len)
++{
++ struct iio_dev *dev_info = dev_get_drvdata(dev);
++ struct ad9832_state *st = dev_info->dev_data;
++ struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
++ int ret;
++ long val;
+
+- spi_message_init(&msg);
+- spi_message_add_tail(&xfer, &msg);
+- ret = spi_sync(st->sdev, &msg);
++ ret = strict_strtoul(buf, 10, &val);
+ if (ret)
+ goto error_ret;
+
+- config = 0x2 << 14 | AD9832_SYNC | AD9832_SELSRC;
+- xfer.len = 2;
+- xfer.tx_buf = &config;
+-
+- spi_message_init(&msg);
+- spi_message_add_tail(&xfer, &msg);
+- ret = spi_sync(st->sdev, &msg);
+- if (ret)
+- goto error_ret;
++ mutex_lock(&dev_info->mlock);
++ switch (this_attr->address) {
++ case AD9832_FREQ0HM:
++ case AD9832_FREQ1HM:
++ ret = ad9832_write_frequency(st, this_attr->address, val);
++ break;
++ case AD9832_PHASE0H:
++ case AD9832_PHASE1H:
++ case AD9832_PHASE2H:
++ case AD9832_PHASE3H:
++ ret = ad9832_write_phase(st, this_attr->address, val);
++ break;
++ case AD9832_PINCTRL_EN:
++ if (val)
++ st->ctrl_ss &= ~AD9832_SELSRC;
++ else
++ st->ctrl_ss |= AD9832_SELSRC;
++ st->data = cpu_to_be16((AD9832_CMD_SYNCSELSRC << CMD_SHIFT) |
++ st->ctrl_ss);
++ ret = spi_sync(st->spi, &st->msg);
++ break;
++ case AD9832_FREQ_SYM:
++ if (val == 1)
++ st->ctrl_fp |= AD9832_FREQ;
++ else if (val == 0)
++ st->ctrl_fp &= ~AD9832_FREQ;
++ else {
++ ret = -EINVAL;
++ break;
++ }
++ st->data = cpu_to_be16((AD9832_CMD_FPSELECT << CMD_SHIFT) |
++ st->ctrl_fp);
++ ret = spi_sync(st->spi, &st->msg);
++ break;
++ case AD9832_PHASE_SYM:
++ if (val < 0 || val > 3) {
++ ret = -EINVAL;
++ break;
++ }
++
++ st->ctrl_fp &= ~AD9832_PHASE(3);
++ st->ctrl_fp |= AD9832_PHASE(val);
++
++ st->data = cpu_to_be16((AD9832_CMD_FPSELECT << CMD_SHIFT) |
++ st->ctrl_fp);
++ ret = spi_sync(st->spi, &st->msg);
++ break;
++ case AD9832_OUTPUT_EN:
++ if (val)
++ st->ctrl_src &= ~(AD9832_RESET | AD9832_SLEEP |
++ AD9832_CLR);
++ else
++ st->ctrl_src |= AD9832_RESET;
++
++ st->data = cpu_to_be16((AD9832_CMD_SLEEPRESCLR << CMD_SHIFT) |
++ st->ctrl_src);
++ ret = spi_sync(st->spi, &st->msg);
++ break;
++ default:
++ ret = -ENODEV;
++ }
++ mutex_unlock(&dev_info->mlock);
+
+- config = CMD_SELBITSCTL << cmd_shift;
+- xfer.len = 2;
+- xfer.tx_buf = &config;
+-
+- spi_message_init(&msg);
+- spi_message_add_tail(&xfer, &msg);
+- ret = spi_sync(st->sdev, &msg);
+- if (ret)
+- goto error_ret;
++error_ret:
++ return ret ? ret : len;
++}
+
+- config = 0x3 << 14;
++static ssize_t ad9832_show_name(struct device *dev,
++ struct device_attribute *attr,
++ char *buf)
++{
++ struct iio_dev *dev_info = dev_get_drvdata(dev);
++ struct ad9832_state *st = iio_dev_get_devdata(dev_info);
+
+- xfer.len = 2;
+- xfer.tx_buf = &config;
++ return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
++}
++static IIO_DEVICE_ATTR(name, S_IRUGO, ad9832_show_name, NULL, 0);
+
+- spi_message_init(&msg);
+- spi_message_add_tail(&xfer, &msg);
+- ret = spi_sync(st->sdev, &msg);
+- if (ret)
+- goto error_ret;
+-error_ret:
+- mutex_unlock(&st->lock);
++/**
++ * see dds.h for further information
++ */
+
++static IIO_DEV_ATTR_FREQ(0, 0, S_IWUSR, NULL, ad9832_write, AD9832_FREQ0HM);
++static IIO_DEV_ATTR_FREQ(0, 1, S_IWUSR, NULL, ad9832_write, AD9832_FREQ1HM);
++static IIO_DEV_ATTR_FREQSYMBOL(0, S_IWUSR, NULL, ad9832_write, AD9832_FREQ_SYM);
++static IIO_CONST_ATTR_FREQ_SCALE(0, "1"); /* 1Hz */
++
++static IIO_DEV_ATTR_PHASE(0, 0, S_IWUSR, NULL, ad9832_write, AD9832_PHASE0H);
++static IIO_DEV_ATTR_PHASE(0, 1, S_IWUSR, NULL, ad9832_write, AD9832_PHASE1H);
++static IIO_DEV_ATTR_PHASE(0, 2, S_IWUSR, NULL, ad9832_write, AD9832_PHASE2H);
++static IIO_DEV_ATTR_PHASE(0, 3, S_IWUSR, NULL, ad9832_write, AD9832_PHASE3H);
++static IIO_DEV_ATTR_PHASESYMBOL(0, S_IWUSR, NULL,
++ ad9832_write, AD9832_PHASE_SYM);
++static IIO_CONST_ATTR_PHASE_SCALE(0, "0.0015339808"); /* 2PI/2^12 rad*/
++
++static IIO_DEV_ATTR_PINCONTROL_EN(0, S_IWUSR, NULL,
++ ad9832_write, AD9832_PINCTRL_EN);
++static IIO_DEV_ATTR_OUT_ENABLE(0, S_IWUSR, NULL,
++ ad9832_write, AD9832_OUTPUT_EN);
+
++static struct attribute *ad9832_attributes[] = {
++ &iio_dev_attr_dds0_freq0.dev_attr.attr,
++ &iio_dev_attr_dds0_freq1.dev_attr.attr,
++ &iio_const_attr_dds0_freq_scale.dev_attr.attr,
++ &iio_dev_attr_dds0_phase0.dev_attr.attr,
++ &iio_dev_attr_dds0_phase1.dev_attr.attr,
++ &iio_dev_attr_dds0_phase2.dev_attr.attr,
++ &iio_dev_attr_dds0_phase3.dev_attr.attr,
++ &iio_const_attr_dds0_phase_scale.dev_attr.attr,
++ &iio_dev_attr_dds0_pincontrol_en.dev_attr.attr,
++ &iio_dev_attr_dds0_freqsymbol.dev_attr.attr,
++ &iio_dev_attr_dds0_phasesymbol.dev_attr.attr,
++ &iio_dev_attr_dds0_out_enable.dev_attr.attr,
++ &iio_dev_attr_name.dev_attr.attr,
++ NULL,
++};
+
+-}
++static const struct attribute_group ad9832_attribute_group = {
++ .attrs = ad9832_attributes,
++};
+
+ static int __devinit ad9832_probe(struct spi_device *spi)
+ {
++ struct ad9832_platform_data *pdata = spi->dev.platform_data;
+ struct ad9832_state *st;
+- int ret = 0;
++ int ret;
++
++ if (!pdata) {
++ dev_dbg(&spi->dev, "no platform data?\n");
++ return -ENODEV;
++ }
+
+ st = kzalloc(sizeof(*st), GFP_KERNEL);
+ if (st == NULL) {
+ ret = -ENOMEM;
+ goto error_ret;
+ }
+- spi_set_drvdata(spi, st);
+
+- mutex_init(&st->lock);
+- st->sdev = spi;
++ st->reg = regulator_get(&spi->dev, "vcc");
++ if (!IS_ERR(st->reg)) {
++ ret = regulator_enable(st->reg);
++ if (ret)
++ goto error_put_reg;
++ }
+
+- st->idev = iio_allocate_device();
+- if (st->idev == NULL) {
++ st->mclk = pdata->mclk;
++
++ spi_set_drvdata(spi, st);
++ st->spi = spi;
++
++ st->indio_dev = iio_allocate_device();
++ if (st->indio_dev == NULL) {
+ ret = -ENOMEM;
+- goto error_free_st;
++ goto error_disable_reg;
+ }
+- st->idev->dev.parent = &spi->dev;
+- st->idev->num_interrupt_lines = 0;
+- st->idev->event_attrs = NULL;
+-
+- st->idev->attrs = &ad9832_attribute_group;
+- st->idev->dev_data = (void *)(st);
+- st->idev->driver_module = THIS_MODULE;
+- st->idev->modes = INDIO_DIRECT_MODE;
+
+- ret = iio_device_register(st->idev);
++ st->indio_dev->dev.parent = &spi->dev;
++ st->indio_dev->attrs = &ad9832_attribute_group;
++ st->indio_dev->dev_data = (void *) st;
++ st->indio_dev->driver_module = THIS_MODULE;
++ st->indio_dev->modes = INDIO_DIRECT_MODE;
++
++ /* Setup default messages */
++
++ st->xfer.tx_buf = &st->data;
++ st->xfer.len = 2;
++
++ spi_message_init(&st->msg);
++ spi_message_add_tail(&st->xfer, &st->msg);
++
++ st->freq_xfer[0].tx_buf = &st->freq_data[0];
++ st->freq_xfer[0].len = 2;
++ st->freq_xfer[0].cs_change = 1;
++ st->freq_xfer[1].tx_buf = &st->freq_data[1];
++ st->freq_xfer[1].len = 2;
++ st->freq_xfer[1].cs_change = 1;
++ st->freq_xfer[2].tx_buf = &st->freq_data[2];
++ st->freq_xfer[2].len = 2;
++ st->freq_xfer[2].cs_change = 1;
++ st->freq_xfer[3].tx_buf = &st->freq_data[3];
++ st->freq_xfer[3].len = 2;
++
++ spi_message_init(&st->freq_msg);
++ spi_message_add_tail(&st->freq_xfer[0], &st->freq_msg);
++ spi_message_add_tail(&st->freq_xfer[1], &st->freq_msg);
++ spi_message_add_tail(&st->freq_xfer[2], &st->freq_msg);
++ spi_message_add_tail(&st->freq_xfer[3], &st->freq_msg);
++
++ st->phase_xfer[0].tx_buf = &st->phase_data[0];
++ st->phase_xfer[0].len = 2;
++ st->phase_xfer[0].cs_change = 1;
++ st->phase_xfer[1].tx_buf = &st->phase_data[1];
++ st->phase_xfer[1].len = 2;
++
++ spi_message_init(&st->phase_msg);
++ spi_message_add_tail(&st->phase_xfer[0], &st->phase_msg);
++ spi_message_add_tail(&st->phase_xfer[1], &st->phase_msg);
++
++ st->ctrl_src = AD9832_SLEEP | AD9832_RESET | AD9832_CLR;
++ st->data = cpu_to_be16((AD9832_CMD_SLEEPRESCLR << CMD_SHIFT) |
++ st->ctrl_src);
++ ret = spi_sync(st->spi, &st->msg);
++ if (ret) {
++ dev_err(&spi->dev, "device init failed\n");
++ goto error_free_device;
++ }
++
++ ret = ad9832_write_frequency(st, AD9832_FREQ0HM, pdata->freq0);
++ if (ret)
++ goto error_free_device;
++
++ ret = ad9832_write_frequency(st, AD9832_FREQ1HM, pdata->freq1);
++ if (ret)
++ goto error_free_device;
++
++ ret = ad9832_write_phase(st, AD9832_PHASE0H, pdata->phase0);
++ if (ret)
++ goto error_free_device;
++
++ ret = ad9832_write_phase(st, AD9832_PHASE1H, pdata->phase1);
++ if (ret)
++ goto error_free_device;
++
++ ret = ad9832_write_phase(st, AD9832_PHASE2H, pdata->phase2);
+ if (ret)
+- goto error_free_dev;
+- spi->max_speed_hz = 2000000;
+- spi->mode = SPI_MODE_3;
+- spi->bits_per_word = 16;
+- spi_setup(spi);
+- ad9832_init(st);
++ goto error_free_device;
++
++ ret = ad9832_write_phase(st, AD9832_PHASE3H, pdata->phase3);
++ if (ret)
++ goto error_free_device;
++
++ ret = iio_device_register(st->indio_dev);
++ if (ret)
++ goto error_free_device;
++
+ return 0;
+
+-error_free_dev:
+- iio_free_device(st->idev);
+-error_free_st:
++error_free_device:
++ iio_free_device(st->indio_dev);
++error_disable_reg:
++ if (!IS_ERR(st->reg))
++ regulator_disable(st->reg);
++error_put_reg:
++ if (!IS_ERR(st->reg))
++ regulator_put(st->reg);
+ kfree(st);
+ error_ret:
+ return ret;
+@@ -232,33 +340,45 @@
+ {
+ struct ad9832_state *st = spi_get_drvdata(spi);
+
+- iio_device_unregister(st->idev);
++ iio_device_unregister(st->indio_dev);
++ if (!IS_ERR(st->reg)) {
++ regulator_disable(st->reg);
++ regulator_put(st->reg);
++ }
+ kfree(st);
+-
+ return 0;
+ }
+
++static const struct spi_device_id ad9832_id[] = {
++ {"ad9832", 0},
++ {"ad9835", 0},
++ {}
++};
++
+ static struct spi_driver ad9832_driver = {
+ .driver = {
+- .name = DRV_NAME,
+- .owner = THIS_MODULE,
++ .name = "ad9832",
++ .bus = &spi_bus_type,
++ .owner = THIS_MODULE,
+ },
+- .probe = ad9832_probe,
+- .remove = __devexit_p(ad9832_remove),
++ .probe = ad9832_probe,
++ .remove = __devexit_p(ad9832_remove),
++ .id_table = ad9832_id,
+ };
+
+-static __init int ad9832_spi_init(void)
++static int __init ad9832_init(void)
+ {
+ return spi_register_driver(&ad9832_driver);
+ }
+-module_init(ad9832_spi_init);
++module_init(ad9832_init);
+
+-static __exit void ad9832_spi_exit(void)
++static void __exit ad9832_exit(void)
+ {
+ spi_unregister_driver(&ad9832_driver);
+ }
+-module_exit(ad9832_spi_exit);
++module_exit(ad9832_exit);
+
+-MODULE_AUTHOR("Cliff Cai");
+-MODULE_DESCRIPTION("Analog Devices ad9832 driver");
++MODULE_AUTHOR("Michael Hennerich <hen...@bl...>");
++MODULE_DESCRIPTION("Analog Devices AD9832/AD9835 DDS");
+ MODULE_LICENSE("GPL v2");
++MODULE_ALIAS("spi:ad9832");
+Index: linux-2.6.38-rc3/drivers/staging/iio/dds/ad9832.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.38-rc3/drivers/staging/iio/dds/ad9832.h 2011-02-21 18:29:49.000000000 +0100
+@@ -0,0 +1,128 @@
++/*
++ * AD9832 SPI DDS driver
++ *
++ * Copyright 2011 Analog Devices Inc.
++ *
++ * Licensed under the GPL-2 or later.
++ */
++#ifndef IIO_DDS_AD9832_H_
++#define IIO_DDS_AD9832_H_
++
++/* Registers */
++
++#define AD9832_FREQ0LL 0x0
++#define AD9832_FREQ0HL 0x1
++#define AD9832_FREQ0LM 0x2
++#define AD9832_FREQ0HM 0x3
++#define AD9832_FREQ1LL 0x4
++#define AD9832_FREQ1HL 0x5
++#define AD9832_FREQ1LM 0x6
++#define AD9832_FREQ1HM 0x7
++#define AD9832_PHASE0L 0x8
++#define AD9832_PHASE0H 0x9
++#define AD9832_PHASE1L 0xA
++#define AD9832_PHASE1H 0xB
++#define AD9832_PHASE2L 0xC
++#define AD9832_PHASE2H 0xD
++#define AD9832_PHASE3L 0xE
++#define AD9832_PHASE3H 0xF
++
++#define AD9832_PHASE_SYM 0x10
++#define AD9832_FREQ_SYM 0x11
++#define AD9832_PINCTRL_EN 0x12
++#define AD9832_OUTPUT_EN 0x13
++
++/* Command Control Bits */
++
++#define AD9832_CMD_PHA8BITSW 0x1
++#define AD9832_CMD_PHA16BITSW 0x0
++#define AD9832_CMD_FRE8BITSW 0x3
++#define AD9832_CMD_FRE16BITSW 0x2
++#define AD9832_CMD_FPSELECT 0x6
++#define AD9832_CMD_SYNCSELSRC 0x8
++#define AD9832_CMD_SLEEPRESCLR 0xC
++
++#define AD9832_FREQ (1 << 11)
++#define AD9832_PHASE(x) (((x) & 3) << 9)
++#define AD9832_SYNC (1 << 13)
++#define AD9832_SELSRC (1 << 12)
++#define AD9832_SLEEP (1 << 13)
++#define AD9832_RESET (1 << 12)
++#define AD9832_CLR (1 << 11)
++#define CMD_SHIFT 12
++#define ADD_SHIFT 8
++#define AD9832_FREQ_BITS 32
++#define AD9832_PHASE_BITS 12
++#define RES_MASK(bits) ((1 << (bits)) - 1)
++
++/**
++ * struct ad9832_state - driver instance specific data
++ * @indio_dev: the industrial I/O device
++ * @spi: spi_device
++ * @reg: supply regulator
++ * @mclk: external master clock
++ * @ctrl_fp: cached frequency/phase control word
++ * @ctrl_ss: cached sync/selsrc control word
++ * @ctrl_src: cached sleep/reset/clr word
++ * @xfer: default spi transfer
++ * @msg: default spi message
++ * @freq_xfer: tuning word spi transfer
++ * @freq_msg: tuning word spi message
++ * @phase_xfer: tuning word spi transfer
++ * @phase_msg: tuning word spi message
++ * @data: spi transmit buffer
++ * @phase_data: tuning word spi transmit buffer
++ * @freq_data: tuning word spi transmit buffer
++ */
++
++struct ad9832_state {
++ struct iio_dev *indio_dev;
++ struct spi_device *spi;
++ struct regulator *reg;
++ unsigned long mclk;
++ unsigned short ctrl_fp;
++ unsigned short ctrl_ss;
++ unsigned short ctrl_src;
++ struct spi_transfer xfer;
++ struct spi_message msg;
++ struct spi_transfer freq_xfer[4];
++ struct spi_message freq_msg;
++ struct spi_transfer phase_xfer[2];
++ struct spi_message phase_msg;
++ /*
++ * DMA (thus cache coherency maintenance) requires the
++ * transfer buffers to live in their own cache lines.
++ */
++ union {
++ unsigned short freq_data[4]____cacheline_aligned;
++ unsigned short phase_data[2];
++ unsigned short data;
++ };
++};
++
++/*
++ * TODO: struct ad9832_platform_data needs to go into include/linux/iio
++ */
++
++/**
++ * struct ad9832_platform_data - platform specific information
++ * @mclk: master clock in Hz
++ * @freq0: power up freq0 tuning word in Hz
++ * @freq1: power up freq1 tuning word in Hz
++ * @phase0: power up phase0 value [0..4095] correlates with 0..2PI
++ * @phase1: power up phase1 value [0..4095] correlates with 0..2PI
++ * @phase2: power up phase2 value [0..4095] correlates with 0..2PI
++ * @phase3: power up phase3 value [0..4095] correlates with 0..2PI
++ */
++
++struct ad9832_platform_data {
++ unsigned long mclk;
++ unsigned long freq0;
++ unsigned long freq1;
++ unsigned short phase0;
++ unsigned short phase1;
++ unsigned short phase2;
++ unsigned short phase3;
++};
++
++#endif /* IIO_DDS_AD9832_H_ */
+Index: linux-2.6.38-rc3/drivers/staging/iio/dds/Kconfig
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/dds/Kconfig 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/dds/Kconfig 2011-02-21 18:29:49.000000000 +0100
+@@ -15,7 +15,10 @@
+ depends on SPI
+ help
+ Say yes here to build support for Analog Devices DDS chip
+- ad9832 and ad9835, provides direct access via sysfs.
++ AD9832 and AD9835, provides direct access via sysfs.
++
++ To compile this driver as a module, choose M here: the
++ module will be called ad9832.
+
+ config AD9834
+ tristate "Analog Devices ad9833/4/ driver"
+Index: linux-2.6.38-rc3/drivers/staging/iio/Documentation/dac/max517
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.38-rc3/drivers/staging/iio/Documentation/dac/max517 2011-02-21 18:29:49.000000000 +0100
+@@ -0,0 +1,41 @@
++Kernel driver max517
++====================
++
++Supported chips:
++ * Maxim MAX517, MAX518, MAX519
++ Prefix: 'max517'
++ Datasheet: Publicly available at the Maxim website
++ http://www.maxim-ic.com/
++
++Author:
++ Roland Stigge <st...@an...>
++
++Description
++-----------
++
++The Maxim MAX517/518/519 is an 8-bit DAC on the I2C bus. The following table
++shows the different feature sets of the variants MAX517, MAX518 and MAX519:
++
++Feature MAX517 MAX518 MAX519
++--------------------------------------------------------------------------
++One output channel X
++Two output channels X X
++Simultaneous output updates X X
++Supply voltage as reference X
++Separate reference input X
++Reference input for each DAC X
++
++Via the iio sysfs interface, there are three attributes available: out1_raw,
++out2_raw and out12_raw. With out1_raw and out2_raw, the current output values
++(0..255) of the DACs can be written to the device. out12_raw can be used to set
++both output channel values simultaneously.
++
++With MAX517, only out1_raw is available.
++
++Via out1_scale (and where appropriate, out2_scale), the current scaling factor
++in mV can be read.
++
++When the operating system goes to a power down state, the Power Down function
++of the chip is activated, reducing the supply current to 4uA.
++
++On power-up, the device is in 0V-output state.
+Index: linux-2.6.38-rc3/drivers/staging/iio/Documentation/generic_buffer.c
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/Documentation/generic_buffer.c 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/Documentation/generic_buffer.c 2011-02-21 18:29:49.000000000 +0100
+@@ -26,11 +26,9 @@
+ #include <sys/stat.h>
+ #include <sys/dir.h>
+ #include <linux/types.h>
++#include <string.h>
+ #include "iio_utils.h"
+
+-const int buf_len = 128;
+-const int num_loops = 2;
+-
+ /**
+ * size_from_channelarray() - calculate the storage size of a scan
+ * @channels: the channel info array
+@@ -118,6 +116,11 @@
+
+ int main(int argc, char **argv)
+ {
++ unsigned long num_loops = 2;
++ unsigned long timedelay = 1000000;
++ unsigned long buf_len = 128;
++
++
+ int ret, c, i, j, toread;
+
+ FILE *fp_ev;
+@@ -134,10 +137,12 @@
+ int dev_num, trig_num;
+ char *buffer_access, *buffer_event;
+ int scan_size;
++ int noevents = 0;
++ char *dummy;
+
+ struct iio_channel_info *infoarray;
+
+- while ((c = getopt(argc, argv, "t:n:")) != -1) {
++ while ((c = getopt(argc, argv, "l:w:c:et:n:")) != -1) {
+ switch (c) {
+ case 'n':
+ device_name = optarg;
+@@ -146,6 +151,18 @@
+ trigger_name = optarg;
+ datardytrigger = 0;
+ break;
++ case 'e':
++ noevents = 1;
++ break;
++ case 'c':
++ num_loops = strtoul(optarg, &dummy, 10);
++ break;
++ case 'w':
++ timedelay = strtoul(optarg, &dummy, 10);
++ break;
++ case 'l':
++ buf_len = strtoul(optarg, &dummy, 10);
++ break;
+ case '?':
+ return -1;
+ }
+@@ -260,22 +277,30 @@
+
+ /* Wait for events 10 times */
+ for (j = 0; j < num_loops; j++) {
+- read_size = fread(&dat, 1, sizeof(struct iio_event_data),
+- fp_ev);
+- switch (dat.id) {
+- case IIO_EVENT_CODE_RING_100_FULL:
+- toread = buf_len;
+- break;
+- case IIO_EVENT_CODE_RING_75_FULL:
+- toread = buf_len*3/4;
+- break;
+- case IIO_EVENT_CODE_RING_50_FULL:
+- toread = buf_len/2;
+- break;
+- default:
+- printf("Unexpecteded event code\n");
+- continue;
++ if (!noevents) {
++ read_size = fread(&dat,
++ 1,
++ sizeof(struct iio_event_data),
++ fp_ev);
++ switch (dat.id) {
++ case IIO_EVENT_CODE_RING_100_FULL:
++ toread = buf_len;
++ break;
++ case IIO_EVENT_CODE_RING_75_FULL:
++ toread = buf_len*3/4;
++ break;
++ case IIO_EVENT_CODE_RING_50_FULL:
++ toread = buf_len/2;
++ break;
++ default:
++ printf("Unexpecteded event code\n");
++ continue;
++ }
++ } else {
++ usleep(timedelay);
++ toread = 64;
+ }
++
+ read_size = read(fp,
+ data,
+ toread*scan_size);
+Index: linux-2.6.38-rc3/drivers/staging/iio/Documentation/iio_utils.h
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/Documentation/iio_utils.h 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/Documentation/iio_utils.h 2011-02-21 18:29:49.000000000 +0100
+@@ -398,7 +398,7 @@
+ return 0;
+
+ error_cleanup_array:
+- for (i = count - 1; i >= 0; i++)
++ for (i = count - 1; i >= 0; i--)
+ free((*ci_array)[i].name);
+ free(*ci_array);
+ error_close_dir:
+Index: linux-2.6.38-rc3/drivers/staging/iio/Documentation/sysfs-bus-iio
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/Documentation/sysfs-bus-iio 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/Documentation/sysfs-bus-iio 2011-02-21 18:29:49.000000000 +0100
+@@ -168,6 +168,7 @@
+ What: /sys/bus/iio/devices/deviceX/inY_scale
+ What: /sys/bus/iio/devices/deviceX/inY_supply_scale
+ What: /sys/bus/iio/devices/deviceX/in_scale
++What: /sys/bus/iio/devices/deviceX/outY_scale
+ What: /sys/bus/iio/devices/deviceX/accel_scale
+ What: /sys/bus/iio/devices/deviceX/accel_peak_scale
+ What: /sys/bus/iio/devices/deviceX/gyro_scale
+@@ -222,6 +223,23 @@
+ If a discrete set of scale values are available, they
+ are listed in this attribute.
+
++What: /sys/bus/iio/devices/deviceX/outY_raw
++KernelVersion: 2.6.37
++Contact: lin...@vg...
++Description:
++ Raw (unscaled, no bias etc.) output voltage for
++ channel Y. The number must always be specified and
++ unique if the output corresponds to a single channel.
++
++What: /sys/bus/iio/devices/deviceX/outY&Z_raw
++KernelVersion: 2.6.37
++Contact: lin...@vg...
++Description:
++ Raw (unscaled, no bias etc.) output voltage for an aggregate of
++ channel Y, channel Z, etc. This interface is available in cases
++ where a single output sets the value for multiple channels
++ simultaneously.
++
+ What: /sys/bus/iio/devices/deviceX/deviceX:eventY
+ KernelVersion: 2.6.35
+ Contact: lin...@vg...
+Index: linux-2.6.38-rc3/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.38-rc3/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs 2011-02-21 18:29:49.000000000 +0100
+@@ -0,0 +1,11 @@
++What: /sys/bus/iio/devices/triggerX/trigger_now
++KernelVersion: 2.6.38
++Contact: lin...@vg...
++Description:
++ This file is provided by the iio-trig-sysfs stand-alone trigger
++ driver. Writing this file with any value triggers an event
++ driven driver, associated with this trigger, to capture data
++ into an in kernel buffer. This approach can be valuable during
++ automated testing or in situations, where other trigger methods
++ are not applicable. For example no RTC or spare GPIOs.
++ X is the IIO index of the trigger.
+Index: linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16060_core.c
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/gyro/adis16060_core.c 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16060_core.c 2011-02-21 18:29:49.000000000 +0100
+@@ -25,11 +25,9 @@
+
+ #include "adis16060.h"
+
+-#define DRIVER_NAME "adis16060"
++static struct adis16060_state *adis16060_st;
+
+-struct adis16060_state *adis16060_st;
+-
+-int adis16060_spi_write(struct device *dev,
++static int adis16060_spi_write(struct device *dev,
+ u8 val)
+ {
+ int ret;
+@@ -47,7 +45,7 @@
+ return ret;
+ }
+
+-int adis16060_spi_read(struct device *dev,
++static int adis16060_spi_read(struct device *dev,
+ u16 *val)
+ {
+ int ret;
+@@ -58,12 +56,15 @@
+
+ ret = spi_read(st->us_r, st->rx, 3);
+
+- /* The internal successive approximation ADC begins the conversion process
+- * on the falling edge of MSEL1 and starts to place data MSB first on the
+- * DOUT line at the 6th falling edge of SCLK
++ /* The internal successive approximation ADC begins the
++ * conversion process on the falling edge of MSEL1 and
++ * starts to place data MSB first on the DOUT line at
++ * the 6th falling edge of SCLK
+ */
+ if (ret == 0)
+- *val = ((st->rx[0] & 0x3) << 12) | (st->rx[1] << 4) | ((st->rx[2] >> 4) & 0xF);
++ *val = ((st->rx[0] & 0x3) << 12) |
++ (st->rx[1] << 4) |
++ ((st->rx[2] >> 4) & 0xF);
+ mutex_unlock(&st->buf_lock);
+
+ return ret;
+@@ -74,7 +75,7 @@
+ char *buf)
+ {
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+- u16 val;
++ u16 val = 0;
+ ssize_t ret;
+
+ /* Take the iio_dev status lock */
+@@ -174,45 +175,14 @@
+ st->indio_dev->driver_module = THIS_MODULE;
+ st->indio_dev->modes = INDIO_DIRECT_MODE;
+
+- ret = adis16060_configure_ring(st->indio_dev);
+- if (ret)
+- goto error_free_dev;
+-
+ ret = iio_device_register(st->indio_dev);
+ if (ret)
+- goto error_unreg_ring_funcs;
++ goto error_free_dev;
+ regdone = 1;
+
+- ret = adis16060_initialize_ring(st->indio_dev->ring);
+- if (ret) {
+- printk(KERN_ERR "failed to initialize the ring\n");
+- goto error_unreg_ring_funcs;
+- }
+-
+- if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
+- ret = iio_register_interrupt_line(spi->irq,
+- st->indio_dev,
+- 0,
+- IRQF_TRIGGER_RISING,
+- "adis16060");
+- if (ret)
+- goto error_uninitialize_ring;
+-
+- ret = adis16060_probe_trigger(st->indio_dev);
+- if (ret)
+- goto error_unregister_line;
+- }
+-
+ adis16060_st = st;
+ return 0;
+
+-error_unregister_line:
+- if (st->indio_dev->modes & INDIO_RING_TRIGGERED)
+- iio_unregister_interrupt_line(st->indio_dev, 0);
+-error_uninitialize_ring:
+- adis16060_uninitialize_ring(st->indio_dev->ring);
+-error_unreg_ring_funcs:
+- adis16060_unconfigure_ring(st->indio_dev);
+ error_free_dev:
+ if (regdone)
+ iio_device_unregister(st->indio_dev);
+@@ -236,12 +206,9 @@
+
+ flush_scheduled_work();
+
+- adis16060_remove_trigger(indio_dev);
+ if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
+ iio_unregister_interrupt_line(indio_dev, 0);
+
+- adis16060_uninitialize_ring(indio_dev->ring);
+- adis16060_unconfigure_ring(indio_dev);
+ iio_device_unregister(indio_dev);
+ kfree(st->tx);
+ kfree(st->rx);
+@@ -315,5 +282,5 @@
+ module_exit(adis16060_exit);
+
+ MODULE_AUTHOR("Barry Song <21...@gm...>");
+-MODULE_DESCRIPTION("Analog Devices ADIS16060 Yaw Rate Gyroscope with SPI driver");
++MODULE_DESCRIPTION("Analog Devices ADIS16060 Yaw Rate Gyroscope Driver");
+ MODULE_LICENSE("GPL v2");
+Index: linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16060.h
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/gyro/adis16060.h 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16060.h 2011-02-21 18:29:49.000000000 +0100
+@@ -14,11 +14,7 @@
+ /**
+ * struct adis16060_state - device instance specific data
+ * @us_w: actual spi_device to write data
+- * @work_trigger_to_ring: bh for triggered event handling
+- * @inter: used to check if new interrupt has been triggered
+- * @last_timestamp: passing timestamp from th to bh of interrupt handler
+ * @indio_dev: industrial I/O device structure
+- * @trig: data ready trigger registered with iio
+ * @tx: transmit buffer
+ * @rx: recieve buffer
+ * @buf_lock: mutex to protect tx and rx
+@@ -26,76 +22,10 @@
+ struct adis16060_state {
+ struct spi_device *us_w;
+ struct spi_device *us_r;
+- struct work_struct work_trigger_to_ring;
+- s64 last_timestamp;
+ struct iio_dev *indio_dev;
+- struct iio_trigger *trig;
+ u8 *tx;
+ u8 *rx;
+ struct mutex buf_lock;
+ };
+
+-#if defined(CONFIG_IIO_RING_BUFFER) && defined(THIS_HAS_RING_BUFFER_SUPPORT)
+-/* At the moment triggers are only used for ring buffer
+- * filling. This may change!
+- */
+-
+-enum adis16060_scan {
+- ADIS16060_SCAN_GYRO,
+- ADIS16060_SCAN_TEMP,
+- ADIS16060_SCAN_ADC_1,
+- ADIS16060_SCAN_ADC_2,
+-};
+-
+-void adis16060_remove_trigger(struct iio_dev *indio_dev);
+-int adis16060_probe_trigger(struct iio_dev *indio_dev);
+-
+-ssize_t adis16060_read_data_from_ring(struct device *dev,
+- struct device_attribute *attr,
+- char *buf);
+-
+-
+-int adis16060_configure_ring(struct iio_dev *indio_dev);
+-void adis16060_unconfigure_ring(struct iio_dev *indio_dev);
+-
+-int adis16060_initialize_ring(struct iio_ring_buffer *ring);
+-void adis16060_uninitialize_ring(struct iio_ring_buffer *ring);
+-#else /* CONFIG_IIO_RING_BUFFER */
+-
+-static inline void adis16060_remove_trigger(struct iio_dev *indio_dev)
+-{
+-}
+-
+-static inline int adis16060_probe_trigger(struct iio_dev *indio_dev)
+-{
+- return 0;
+-}
+-
+-static inline ssize_t
+-adis16060_read_data_from_ring(struct device *dev,
+- struct device_attribute *attr,
+- char *buf)
+-{
+- return 0;
+-}
+-
+-static int adis16060_configure_ring(struct iio_dev *indio_dev)
+-{
+- return 0;
+-}
+-
+-static inline void adis16060_unconfigure_ring(struct iio_dev *indio_dev)
+-{
+-}
+-
+-static inline int adis16060_initialize_ring(struct iio_ring_buffer *ring)
+-{
+- return 0;
+-}
+-
+-static inline void adis16060_uninitialize_ring(struct iio_ring_buffer *ring)
+-{
+-}
+-
+-#endif /* CONFIG_IIO_RING_BUFFER */
+ #endif /* SPI_ADIS16060_H_ */
+Index: linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16080_core.c
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/gyro/adis16080_core.c 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16080_core.c 2011-02-21 18:29:49.000000000 +0100
+@@ -25,11 +25,7 @@
+
+ #include "adis16080.h"
+
+-#define DRIVER_NAME "adis16080"
+-
+-struct adis16080_state *adis16080_st;
+-
+-int adis16080_spi_write(struct device *dev,
++static int adis16080_spi_write(struct device *dev,
+ u16 val)
+ {
+ int ret;
+@@ -46,7 +42,7 @@
+ return ret;
+ }
+
+-int adis16080_spi_read(struct device *dev,
++static int adis16080_spi_read(struct device *dev,
+ u16 *val)
+ {
+ int ret;
+@@ -69,7 +65,7 @@
+ char *buf)
+ {
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+- u16 val;
++ u16 val = 0;
+ ssize_t ret;
+
+ /* Take the iio_dev status lock */
+@@ -169,45 +165,13 @@
+ st->indio_dev->driver_module = THIS_MODULE;
+ st->indio_dev->modes = INDIO_DIRECT_MODE;
+
+- ret = adis16080_configure_ring(st->indio_dev);
+- if (ret)
+- goto error_free_dev;
+-
+ ret = iio_device_register(st->indio_dev);
+ if (ret)
+- goto error_unreg_ring_funcs;
++ goto error_free_dev;
+ regdone = 1;
+
+- ret = adis16080_initialize_ring(st->indio_dev->ring);
+- if (ret) {
+- printk(KERN_ERR "failed to initialize the ring\n");
+- goto error_unreg_ring_funcs;
+- }
+-
+- if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
+- ret = iio_register_interrupt_line(spi->irq,
+- st->indio_dev,
+- 0,
+- IRQF_TRIGGER_RISING,
+- "adis16080");
+- if (ret)
+- goto error_uninitialize_ring;
+-
+- ret = adis16080_probe_trigger(st->indio_dev);
+- if (ret)
+- goto error_unregister_line;
+- }
+-
+- adis16080_st = st;
+ return 0;
+
+-error_unregister_line:
+- if (st->indio_dev->modes & INDIO_RING_TRIGGERED)
+- iio_unregister_interrupt_line(st->indio_dev, 0);
+-error_uninitialize_ring:
+- adis16080_uninitialize_ring(st->indio_dev->ring);
+-error_unreg_ring_funcs:
+- adis16080_unconfigure_ring(st->indio_dev);
+ error_free_dev:
+ if (regdone)
+ iio_device_unregister(st->indio_dev);
+@@ -229,14 +193,6 @@
+ struct adis16080_state *st = spi_get_drvdata(spi);
+ struct iio_dev *indio_dev = st->indio_dev;
+
+- flush_scheduled_work();
+-
+- adis16080_remove_trigger(indio_dev);
+- if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
+- iio_unregister_interrupt_line(indio_dev, 0);
+-
+- adis16080_uninitialize_ring(indio_dev->ring);
+- adis16080_unconfigure_ring(indio_dev);
+ iio_device_unregister(indio_dev);
+ kfree(st->tx);
+ kfree(st->rx);
+@@ -267,5 +223,5 @@
+ module_exit(adis16080_exit);
+
+ MODULE_AUTHOR("Barry Song <21...@gm...>");
+-MODULE_DESCRIPTION("Analog Devices ADIS16080/100 Yaw Rate Gyroscope with SPI driver");
++MODULE_DESCRIPTION("Analog Devices ADIS16080/100 Yaw Rate Gyroscope Driver");
+ MODULE_LICENSE("GPL v2");
+Index: linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16080.h
+===================================================================
+--- linux-2.6.38-rc3.orig/drivers/staging/iio/gyro/adis16080.h 2011-02-01 04:05:49.000000000 +0100
++++ linux-2.6.38-rc3/drivers/staging/iio/gyro/adis16080.h 2011-02-21 18:29:49.000000000 +0100
+@@ -1,14 +1,19 @@
+ #ifndef SPI_ADIS16080_H_
+ #define SPI_ADIS16080_H_
+
+-#define ADIS16080_DIN_CODE 4 /* Output data format setting. 0: Twos complement. 1: Offset binary. */
++/* Output data format setting. 0: Twos complement. 1: Offset binary. */
++#define ADIS16080_DIN_CODE 4
+ #define ADIS16080_DIN_GYRO (0 << 10) /* Gyroscope output */
+ #define ADIS16080_DIN_TEMP (1 << 10) /* Temperature output */
+ #define ADIS16080_DIN_AIN1 (2 << 10)
+ #define ADIS16080_DIN_AIN2 (3 << 10)
+-#define ADIS16080_DIN_WRITE (1 << 15) /* 1: Write contents on DIN to con...
[truncated message content] |