summaryrefslogtreecommitdiff
path: root/drivers/staging/iio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r--drivers/staging/iio/Documentation/device.txt4
-rw-r--r--drivers/staging/iio/Documentation/overview.txt9
-rw-r--r--drivers/staging/iio/Kconfig10
-rw-r--r--drivers/staging/iio/accel/Kconfig2
-rw-r--r--drivers/staging/iio/accel/accel.h6
-rw-r--r--drivers/staging/iio/accel/sca3000.h4
-rw-r--r--drivers/staging/iio/accel/sca3000_core.c2
-rw-r--r--drivers/staging/iio/adc/Kconfig10
-rw-r--r--drivers/staging/iio/adc/Makefile2
-rw-r--r--drivers/staging/iio/adc/max1363.h6
-rw-r--r--drivers/staging/iio/chrdev.h4
-rw-r--r--drivers/staging/iio/iio.h36
-rw-r--r--drivers/staging/iio/light/Kconfig18
-rw-r--r--drivers/staging/iio/light/Makefile2
-rw-r--r--drivers/staging/iio/light/tsl2561.c272
-rw-r--r--drivers/staging/iio/light/tsl2563.c773
-rw-r--r--drivers/staging/iio/light/tsl2563.h9
-rw-r--r--drivers/staging/iio/ring_generic.h73
-rw-r--r--drivers/staging/iio/ring_sw.h69
-rw-r--r--drivers/staging/iio/sysfs.h114
-rw-r--r--drivers/staging/iio/trigger.h35
-rw-r--r--drivers/staging/iio/trigger/Kconfig6
-rw-r--r--drivers/staging/iio/trigger_consumer.h8
23 files changed, 1058 insertions, 416 deletions
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt
index 6916cd33335..69d9570f29f 100644
--- a/drivers/staging/iio/Documentation/device.txt
+++ b/drivers/staging/iio/Documentation/device.txt
@@ -10,7 +10,7 @@ First allocate one using:
struct iio_dev *indio_dev = iio_allocate_device();
-The fill in the following.
+Then fill in the following:
indio_dev->dev.parent
the struct device associated with the underlying hardware.
@@ -45,5 +45,5 @@ allocated prior to registering the device with the iio-core, but must
be registered afterwards (otherwise the whole parentage of devices
gets confused)
-On remove iio_device_unregister(indio_dev) will remove the device from
+On remove, iio_device_unregister(indio_dev) will remove the device from
the core, and iio_free_device will clean up.
diff --git a/drivers/staging/iio/Documentation/overview.txt b/drivers/staging/iio/Documentation/overview.txt
index 64584ad4024..e39dfc1705a 100644
--- a/drivers/staging/iio/Documentation/overview.txt
+++ b/drivers/staging/iio/Documentation/overview.txt
@@ -24,11 +24,12 @@ hwmon with simple polled access to device channels via sysfs.
* Event chrdevs. These are similar to input in that they provide a
route to user space for hardware triggered events. Such events include
threshold detectors, free-fall detectors and more complex action
-detection. They events themselves are currently very simple with
+detection. The events themselves are currently very simple with
merely an event code and a timestamp. Any data associated with the
-event must be accessed via polling. Note a given device may have one
-or more event channel. These events are turned on or off (if possible)
-via sysfs interfaces.
+event must be accessed via polling.
+
+Note: A given device may have one or more event channel. These events are
+turned on or off (if possible) via sysfs interfaces.
* Hardware ring buffer support. Some recent sensors have included
fifo / ring buffers on the sensor chip. These greatly reduce the load
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index 4586650d65c..ace99f6d116 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -8,7 +8,7 @@ menuconfig IIO
---help---
The industrial I/O subsystem provides a unified framework for
drivers for many different types of embedded sensors using a
- number of different physical interfaces (i2c, spi etc). See
+ number of different physical interfaces (i2c, spi, etc). See
Documentation/industrialio for more information.
if IIO
@@ -23,10 +23,10 @@ if IIO_RING_BUFFER
config IIO_SW_RING
tristate "Industrial I/O lock free software ring"
help
- example software ring buffer implementation. The design aim
- of this particular realization was to minize write locking
- with the intention that some devices would be able to write
- in interrupt context.
+ Example software ring buffer implementation. The design aim
+ of this particular realization was to minimize write locking
+ with the intention that some devices would be able to write
+ in interrupt context.
endif # IIO_RINGBUFFER
diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig
index fef3da48276..3d3c3339dbc 100644
--- a/drivers/staging/iio/accel/Kconfig
+++ b/drivers/staging/iio/accel/Kconfig
@@ -13,6 +13,8 @@ config KXSD9
config LIS3L02DQ
tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver"
depends on SPI
+ select IIO_TRIGGER if IIO_RING_BUFFER
+ select IIO_SW_RING if IIO_RING_BUFFER
help
Say yes here to build SPI support for the ST microelectronics
accelerometer. The driver supplies direct access via sysfs files
diff --git a/drivers/staging/iio/accel/accel.h b/drivers/staging/iio/accel/accel.h
index 811fa0527a4..d7fc7f98348 100644
--- a/drivers/staging/iio/accel/accel.h
+++ b/drivers/staging/iio/accel/accel.h
@@ -31,13 +31,13 @@
IIO_DEVICE_ATTR(accel_z, S_IRUGO, _show, NULL, _addr)
/* Thresholds are somewhat chip dependent - may need quite a few defs here */
-/* For unified thesholds (shared across all directions */
+/* For unified thresholds (shared across all directions */
/**
* IIO_DEV_ATTR_ACCEL_THRESH: unified threshold
* @_mode: read/write
* @_show: read detector threshold value
- * @_store: write detector theshold value
+ * @_store: write detector threshold value
* @_addr: driver specific data, typically a register address
*
* This one is for cases where as single threshold covers all directions
@@ -48,7 +48,7 @@
/**
* IIO_DEV_ATTR_ACCEL_THRESH_X: independant direction threshold, x axis
* @_mode: readable / writable
- * @_show: read x axis detector theshold value
+ * @_show: read x axis detector threshold value
* @_store: write x axis detector threshold value
* @_addr: device driver dependant, typically a register address
**/
diff --git a/drivers/staging/iio/accel/sca3000.h b/drivers/staging/iio/accel/sca3000.h
index 29e11da0957..da7d3cb5ae7 100644
--- a/drivers/staging/iio/accel/sca3000.h
+++ b/drivers/staging/iio/accel/sca3000.h
@@ -74,7 +74,7 @@
#define SCA3000_MEAS_MODE_OP_2 0x02
/* In motion detection mode the accelerations are band pass filtered
- * (aprox 1 - 25Hz) and then a programmable theshold used to trigger
+ * (aprox 1 - 25Hz) and then a programmable threshold used to trigger
* and interrupt.
*/
#define SCA3000_MEAS_MODE_MOT_DET 0x03
@@ -139,7 +139,7 @@
/* Values of mulipexed registers (write to ctrl_data after select) */
#define SCA3000_REG_ADDR_CTRL_DATA 0x22
-/* Measurment modes available on some sca3000 series chips. Code assumes others
+/* Measurement modes available on some sca3000 series chips. Code assumes others
* may become available in the future.
*
* Bypass - Bypass the low-pass filter in the signal channel so as to increase
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index e27e3b7d100..cedcaa2b3d1 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -720,7 +720,7 @@ error_ret:
static IIO_DEV_ATTR_TEMP(sca3000_read_temp);
/**
- * sca3000_show_thresh() sysfs query of a theshold
+ * sca3000_show_thresh() sysfs query of a threshold
**/
static ssize_t sca3000_show_thresh(struct device *dev,
struct device_attribute *attr,
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig
index b8c2858585f..3989c0ca0e0 100644
--- a/drivers/staging/iio/adc/Kconfig
+++ b/drivers/staging/iio/adc/Kconfig
@@ -6,8 +6,18 @@ comment "Analog to digital convertors"
config MAX1363
tristate "MAXIM max1363 ADC driver"
depends on I2C
+ select IIO_TRIGGER if IIO_RING_BUFFER
help
Say yes here to build support for many MAXIM i2c analog to digital
convertors (ADC). (max1361, max1362, max1363, max1364, max1136,
max1136, max1137, max1138, max1139, max1236, max1237, max11238,
max1239) Provides direct access via sysfs.
+
+config MAX1363_RING_BUFFER
+ bool "MAXIM max1363: use ring buffer"
+ depends on MAX1363
+ select IIO_RING_BUFFER
+ select IIO_SW_RING
+ help
+ Say yes here to include ring buffer support in the MAX1363
+ ADC driver.
diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
index 0c2b6f39e8c..08cee5c22b9 100644
--- a/drivers/staging/iio/adc/Makefile
+++ b/drivers/staging/iio/adc/Makefile
@@ -3,6 +3,6 @@
#
max1363-y := max1363_core.o
-max1363-$(CONFIG_IIO_RING_BUFFER) += max1363_ring.o
+max1363-$(CONFIG_MAX1363_RING_BUFFER) += max1363_ring.o
obj-$(CONFIG_MAX1363) += max1363.o
diff --git a/drivers/staging/iio/adc/max1363.h b/drivers/staging/iio/adc/max1363.h
index 8aca81f14d0..c112fbef270 100644
--- a/drivers/staging/iio/adc/max1363.h
+++ b/drivers/staging/iio/adc/max1363.h
@@ -228,7 +228,7 @@ struct max1363_state {
struct iio_trigger *trig;
struct regulator *reg;
};
-#ifdef CONFIG_IIO_RING_BUFFER
+#ifdef CONFIG_MAX1363_RING_BUFFER
ssize_t max1363_scan_from_ring(struct device *dev,
struct device_attribute *attr,
@@ -239,7 +239,7 @@ void max1363_ring_cleanup(struct iio_dev *indio_dev);
int max1363_initialize_ring(struct iio_ring_buffer *ring);
void max1363_uninitialize_ring(struct iio_ring_buffer *ring);
-#else /* CONFIG_IIO_RING_BUFFER */
+#else /* CONFIG_MAX1363_RING_BUFFER */
static inline void max1363_uninitialize_ring(struct iio_ring_buffer *ring)
{
@@ -265,5 +265,5 @@ max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
};
static inline void max1363_ring_cleanup(struct iio_dev *indio_dev) {};
-#endif /* CONFIG_IIO_RING_BUFFER */
+#endif /* CONFIG_MAX1363_RING_BUFFER */
#endif /* _MAX1363_H_ */
diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h
index 8bc64bf0845..f42bafb3a89 100644
--- a/drivers/staging/iio/chrdev.h
+++ b/drivers/staging/iio/chrdev.h
@@ -75,10 +75,12 @@ struct iio_shared_ev_pointer {
* @current_events: number of events in detected list
* @id: indentifier to allow the event interface to know which
* physical line it corresponds to
+ * @attr: this chrdev's minor number sysfs attribute
* @owner: ensure the driver module owns the file, not iio
* @private: driver specific data
* @_name: used internally to store the sysfs name for minor id
* attribute
+ * @_attrname: the event interface's attribute name
*/
struct iio_event_interface {
struct device dev;
@@ -105,7 +107,7 @@ struct iio_event_interface {
* @handler: event handler function - called on event if this
* event_handler is enabled.
*
- * Each device has one list of these per interrupt line
+ * Each device has one list of these per interrupt line.
**/
struct iio_event_handler_list {
struct list_head list;
diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
index 25ccb809221..71dbfe12b57 100644
--- a/drivers/staging/iio/iio.h
+++ b/drivers/staging/iio/iio.h
@@ -166,7 +166,7 @@ static inline int iio_scan_mask_clear(struct iio_dev *dev_info, int bit)
* @bit: which number scan element is this
**/
static inline int iio_scan_mask_count_to_right(struct iio_dev *dev_info,
-int bit)
+ int bit)
{
int count = 0;
int mask = (1 << bit);
@@ -239,7 +239,7 @@ void iio_unregister_interrupt_line(struct iio_dev *dev_info,
* @dev_info: IIO device structure
* @ev_line: Which event line (hardware interrupt)
* @ev_code: What event
- * @timestamp: When the event occured
+ * @timestamp: When the event occurred
**/
int iio_push_event(struct iio_dev *dev_info,
int ev_line,
@@ -248,11 +248,11 @@ int iio_push_event(struct iio_dev *dev_info,
/**
* struct iio_work_cont - container for when singleton handler case matters
- * @ws: [DEVICE]work_struct when not only possible event
- * @ws_nocheck: [DEVICE]work_struct when only possible event
- * @address: [DEVICE]associated register address
- * @mask: [DEVICE]associated mask for identifying event source
- * @st: [DEVICE]device specific state information
+ * @ws: [DEVICE] work_struct when not only possible event
+ * @ws_nocheck: [DEVICE] work_struct when only possible event
+ * @address: [DEVICE] associated register address
+ * @mask: [DEVICE] associated mask for identifying event source
+ * @st: [DEVICE] device specific state information
**/
struct iio_work_cont {
struct work_struct ws;
@@ -273,9 +273,9 @@ struct iio_work_cont {
* @cont: the work container
* @_checkfunc: function called when there are multiple possible int sources
* @_nocheckfunc: function for when there is only one int source
- * @_add: driver dependant, typically a register address
- * @_mask: driver dependant, typically a bit mask for a register
- * @_st: driver dependant, typically pointer to a device state structure
+ * @_add: driver dependent, typically a register address
+ * @_mask: driver dependent, typically a bit mask for a register
+ * @_st: driver dependent, typically pointer to a device state structure
**/
static inline void
iio_init_work_cont(struct iio_work_cont *cont,
@@ -290,7 +290,7 @@ iio_init_work_cont(struct iio_work_cont *cont,
cont->st = _st;
}
/**
- * __iio_push_event() tries to add an event to the list associated with a chrdev
+ * __iio_push_event() - tries to add an event to the list associated with a chrdev
* @ev_int: the event interface to which we are pushing the event
* @ev_code: the outgoing event code
* @timestamp: timestamp of the event
@@ -302,8 +302,8 @@ int __iio_push_event(struct iio_event_interface *ev_int,
struct iio_shared_ev_pointer*
shared_pointer_p);
/**
- * __iio_change_event() change an event code in case of event escallation
- * @ev: the evnet to be changed
+ * __iio_change_event() - change an event code in case of event escalation
+ * @ev: the event to be changed
* @ev_code: new event code
* @timestamp: new timestamp
**/
@@ -312,7 +312,7 @@ void __iio_change_event(struct iio_detected_event_list *ev,
s64 timestamp);
/**
- * iio_setup_ev_int() Configure an event interface (chrdev)
+ * iio_setup_ev_int() - configure an event interface (chrdev)
* @name: name used for resulting sysfs directory etc.
* @ev_int: interface we are configuring
* @owner: module that is responsible for registering this ev_int
@@ -343,7 +343,7 @@ extern dev_t iio_devt;
extern struct class iio_class;
/**
- * iio_put_device() - reference counted deallocated of struct device
+ * iio_put_device() - reference counted deallocation of struct device
* @dev: the iio_device containing the device
**/
static inline void iio_put_device(struct iio_dev *dev)
@@ -353,7 +353,7 @@ static inline void iio_put_device(struct iio_dev *dev)
};
/**
- * to_iio_dev() - get iio_dev for which we have have the struct device
+ * to_iio_dev() - get iio_dev for which we have the struct device
* @d: the struct device
**/
static inline struct iio_dev *to_iio_dev(struct device *d)
@@ -377,6 +377,7 @@ struct iio_dev *iio_allocate_device(void);
/**
* iio_free_device() - free an iio_dev from a driver
+ * @dev: the iio_dev associated with the device
**/
void iio_free_device(struct iio_dev *dev);
@@ -395,7 +396,8 @@ int iio_device_get_chrdev_minor(void);
void iio_device_free_chrdev_minor(int val);
/**
- * iio_ring_enabled() helper function to test if any form of ring enabled
+ * iio_ring_enabled() - helper function to test if any form of ring is enabled
+ * @dev_info: IIO device info structure for device
**/
static inline bool iio_ring_enabled(struct iio_dev *dev_info)
{
diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
index 12af0c46fe2..80cb6e590fb 100644
--- a/drivers/staging/iio/light/Kconfig
+++ b/drivers/staging/iio/light/Kconfig
@@ -3,11 +3,13 @@
#
comment "Light sensors"
-config TSL2561
- tristate "TAOS TSL2561 light-to-digital convertor"
- depends on I2C
- help
- Say yes bere to build support for the TAOS light to digital
- convertor. This chip has two light sensors. One is broadband
- including infrared whilst the other measures only infrared.
- Provides direct access via sysfs.
+config SENSORS_TSL2563
+ tristate "TAOS TSL256[0-3] ambient light sensor"
+ depends on I2C
+ help
+ If you say yes here you get support for the Taos TSL2560,
+ TSL2561, TSL2562 and TSL2563 ambient light sensors.
+
+ This driver can also be built as a module. If so, the module
+ will be called tsl2563.
+
diff --git a/drivers/staging/iio/light/Makefile b/drivers/staging/iio/light/Makefile
index ccff1516760..30f3300e2a6 100644
--- a/drivers/staging/iio/light/Makefile
+++ b/drivers/staging/iio/light/Makefile
@@ -2,4 +2,4 @@
# Makefile for industrial I/O Light sensors
#
-obj-$(CONFIG_TSL2561) += tsl2561.o
+obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o
diff --git a/drivers/staging/iio/light/tsl2561.c b/drivers/staging/iio/light/tsl2561.c
deleted file mode 100644
index fc2107f4c04..00000000000
--- a/drivers/staging/iio/light/tsl2561.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * tsl2561.c - Linux kernel modules for light to digital convertor
- *
- * Copyright (C) 2008-2009 Jonathan Cameron <jic23@cam.ac.uk>
- *
- * 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.
- *
- * Some portions based upon the tsl2550 driver.
- *
- * This driver could probably be adapted easily to talk to the tsl2560 (smbus)
- *
- * Needs some work to support the events this can generate.
- * Todo: Implement interrupt handling. Currently a hardware bug means
- * this isn't available on my test board.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/i2c.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "light.h"
-
-#define TSL2561_CONTROL_REGISTER 0x00
-#define TSL2561_TIMING_REGISTER 0x01
-#define TSL2561_THRESHLOW_LOW_REGISTER 0x02
-#define TSL2561_THRESHLOW_HIGH_REGISTER 0x03
-#define TSL2561_THRESHHIGH_LOW_REGISTER 0x04
-#define TSL2561_THRESHHIGH_HIGH_REGISTER 0x05
-#define TSL2561_INT_CONTROL_REGISTER 0x06
-
-#define TSL2561_INT_REG_INT_OFF 0x00
-#define TSL2561_INT_REG_INT_LEVEL 0x08
-#define TSL2561_INT_REG_INT_SMBUS 0x10
-#define TSL2561_INT_REG_INT_TEST 0x18
-
-#define TSL2561_ID_REGISTER 0x0A
-
-#define TSL2561_DATA_0_LOW 0x0C
-#define TSL2561_DATA_1_LOW 0x0E
-
-/* Control Register Values */
-#define TSL2561_CONT_REG_PWR_ON 0x03
-#define TSL2561_CONT_REG_PWR_OFF 0x00
-
-/**
- * struct tsl2561_state - device specific state
- * @indio_dev: the industrialio I/O info structure
- * @client: i2c client
- * @command_buf: single command buffer used for all operations
- * @command_buf_lock: ensure unique access to command_buf
- */
-struct tsl2561_state {
- struct iio_dev *indio_dev;
- struct i2c_client *client;
- struct tsl2561_command *command_buf;
- struct mutex command_buf_lock;
-};
-
-/**
- * struct tsl2561_command - command byte for smbus
- * @address: register address
- * @block: is this a block r/w
- * @word: is this a word r/w
- * @clear: set to 1 to clear pending interrupt
- * @cmd: select the command register - always 1.
- */
-struct tsl2561_command {
- unsigned int address:4;
- unsigned int block:1;
- unsigned int word:1;
- unsigned int clear:1;
- unsigned int cmd:1;
-};
-
-static inline void tsl2561_init_command_buf(struct tsl2561_command *buf)
-{
- buf->address = 0;
- buf->block = 0;
- buf->word = 0;
- buf->clear = 0;
- buf->cmd = 1;
-}
-
-static ssize_t tsl2561_read_val(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret = 0, data;
- ssize_t len = 0;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct tsl2561_state *st = indio_dev->dev_data;
-
- mutex_lock(&st->command_buf_lock);
- st->command_buf->cmd = 1;
- st->command_buf->word = 1;
- st->command_buf->address = this_attr->address;
-
- data = i2c_smbus_read_word_data(st->client, *(char *)(st->command_buf));
- if (data < 0) {
- ret = data;
- goto error_ret;
- }
- len = sprintf(buf, "%u\n", data);
-
-error_ret:
- mutex_unlock(&st->command_buf_lock);
-
- return ret ? ret : len;
-}
-
-static IIO_DEV_ATTR_LIGHT_INFRARED(0, tsl2561_read_val, TSL2561_DATA_0_LOW);
-static IIO_DEV_ATTR_LIGHT_BROAD(0, tsl2561_read_val, TSL2561_DATA_1_LOW);
-
-static struct attribute *tsl2561_attributes[] = {
- &iio_dev_attr_light_infrared0.dev_attr.attr,
- &iio_dev_attr_light_broadspectrum0.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group tsl2561_attribute_group = {
- .attrs = tsl2561_attributes,
-};
-
-static int tsl2561_initialize(struct tsl2561_state *st)
-{
- int err;
-
- mutex_lock(&st->command_buf_lock);
- st->command_buf->word = 0;
- st->command_buf->block = 0;
- st->command_buf->address = TSL2561_CONTROL_REGISTER;
- err = i2c_smbus_write_byte_data(st->client, *(char *)(st->command_buf),
- TSL2561_CONT_REG_PWR_ON);
- if (err)
- goto error_ret;
-
- st->command_buf->address = TSL2561_INT_CONTROL_REGISTER;
- err = i2c_smbus_write_byte_data(st->client, *(char *)(st->command_buf),
- TSL2561_INT_REG_INT_TEST);
-
-error_ret:
- mutex_unlock(&st->command_buf_lock);
-
- return err;
-}
-
-static int tsl2561_powerdown(struct i2c_client *client)
-{
- int err;
- struct tsl2561_command Command = {
- .cmd = 1,
- .clear = 0,
- .word = 0,
- .block = 0,
- .address = TSL2561_CONTROL_REGISTER,
- };
-
- err = i2c_smbus_write_byte_data(client, *(char *)(&Command),
- TSL2561_CONT_REG_PWR_OFF);
- return (err < 0) ? err : 0;
-}
-static int __devinit tsl2561_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
-{
- int ret = 0, regdone = 0;
- struct tsl2561_state *st = kzalloc(sizeof(*st), GFP_KERNEL);
-
- if (st == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- i2c_set_clientdata(client, st);
- st->client = client;
- mutex_init(&st->command_buf_lock);
-
- st->command_buf = kmalloc(sizeof(*st->command_buf), GFP_KERNEL);
- if (st->command_buf == NULL) {
- ret = -ENOMEM;
- goto error_free_state;
- }
- tsl2561_init_command_buf(st->command_buf);
-
- st->indio_dev = iio_allocate_device();
- if (st->indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_free_command_buf;
- }
- st->indio_dev->attrs = &tsl2561_attribute_group;
- st->indio_dev->dev.parent = &client->dev;
- st->indio_dev->dev_data = (void *)(st);
- st->indio_dev->driver_module = THIS_MODULE;
- st->indio_dev->modes = INDIO_DIRECT_MODE;
- ret = iio_device_register(st->indio_dev);
- if (ret)
- goto error_free_iiodev;
- regdone = 1;
- /* Intialize the chip */
- ret = tsl2561_initialize(st);
- if (ret)
- goto error_unregister_iiodev;
-
- return 0;
-error_unregister_iiodev:
-error_free_iiodev:
- if (regdone)
- iio_device_unregister(st->indio_dev);
- else
- iio_free_device(st->indio_dev);
-error_free_command_buf:
- kfree(st->command_buf);
-error_free_state:
- kfree(st);
-error_ret:
- return ret;
-
-}
-
-static int __devexit tsl2561_remove(struct i2c_client *client)
-{
- struct tsl2561_state *st = i2c_get_clientdata(client);
-
- iio_device_unregister(st->indio_dev);
- kfree(st);
-
- return tsl2561_powerdown(client);
-}
-
-static const struct i2c_device_id tsl2561_id[] = {
- { "tsl2561", 0 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, tsl2561_id);
-
-
-static struct i2c_driver tsl2561_driver = {
- .driver = {
- .name = "tsl2561",
- },
- .probe = tsl2561_probe,
- .remove = __devexit_p(tsl2561_remove),
- .id_table = tsl2561_id,
-};
-
-static __init int tsl2561_init(void)
-{
- return i2c_add_driver(&tsl2561_driver);
-}
-module_init(tsl2561_init);
-
-static __exit void tsl2561_exit(void)
-{
- i2c_del_driver(&tsl2561_driver);
-}
-module_exit(tsl2561_exit);
-
-MODULE_AUTHOR("Jonathan Cameron <jic23@cam.ac.uk>");
-MODULE_DESCRIPTION("TSL2561 light sensor driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c
new file mode 100644
index 00000000000..78b9432c810
--- /dev/null
+++ b/drivers/staging/iio/light/tsl2563.c
@@ -0,0 +1,773 @@
+/*
+ * drivers/i2c/chips/tsl2563.c
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Written by Timo O. Karjalainen <timo.o.karjalainen@nokia.com>
+ * Contact: Amit Kucheria <amit.kucheria@verdurent.com>
+ *
+ * Converted to IIO driver
+ * Amit Kucheria <amit.kucheria@verdurent.com>
+ *
+ * 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.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
+
+#include "../iio.h"
+#include "tsl2563.h"
+
+/* Use this many bits for fraction part. */
+#define ADC_FRAC_BITS (14)
+
+/* Given number of 1/10000's in ADC_FRAC_BITS precision. */
+#define FRAC10K(f) (((f) * (1L << (ADC_FRAC_BITS))) / (10000))
+
+/* Bits used for fraction in calibration coefficients.*/
+#define CALIB_FRAC_BITS (10)
+/* 0.5 in CALIB_FRAC_BITS precision */
+#define CALIB_FRAC_HALF (1 << (CALIB_FRAC_BITS - 1))
+/* Make a fraction from a number n that was multiplied with b. */
+#define CALIB_FRAC(n, b) (((n) << CALIB_FRAC_BITS) / (b))
+/* Decimal 10^(digits in sysfs presentation) */
+#define CALIB_BASE_SYSFS (1000)
+
+#define TSL2563_CMD (0x80)
+#define TSL2563_CLEARINT (0x40)
+
+#define TSL2563_REG_CTRL (0x00)
+#define TSL2563_REG_TIMING (0x01)
+#define TSL2563_REG_LOWLOW (0x02) /* data0 low threshold, 2 bytes */
+#define TSL2563_REG_LOWHIGH (0x03)
+#define TSL2563_REG_HIGHLOW (0x04) /* data0 high threshold, 2 bytes */
+#define TSL2563_REG_HIGHHIGH (0x05)
+#define TSL2563_REG_INT (0x06)
+#define TSL2563_REG_ID (0x0a)
+#define TSL2563_REG_DATA0LOW (0x0c) /* broadband sensor value, 2 bytes */
+#define TSL2563_REG_DATA0HIGH (0x0d)
+#define TSL2563_REG_DATA1LOW (0x0e) /* infrared sensor value, 2 bytes */
+#define TSL2563_REG_DATA1HIGH (0x0f)
+
+#define TSL2563_CMD_POWER_ON (0x03)
+#define TSL2563_CMD_POWER_OFF (0x00)
+#define TSL2563_CTRL_POWER_MASK (0x03)
+
+#define TSL2563_TIMING_13MS (0x00)
+#define TSL2563_TIMING_100MS (0x01)
+#define TSL2563_TIMING_400MS (0x02)
+#define TSL2563_TIMING_MASK (0x03)
+#define TSL2563_TIMING_GAIN16 (0x10)
+#define TSL2563_TIMING_GAIN1 (0x00)
+
+#define TSL2563_INT_DISBLED (0x00)
+#define TSL2563_INT_LEVEL (0x10)
+#define TSL2563_INT_PERSIST(n) ((n) & 0x0F)
+
+struct tsl2563_gainlevel_coeff {
+ u8 gaintime;
+ u16 min;
+ u16 max;
+};
+
+static struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] = {
+ {
+ .gaintime = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN16,
+ .min = 0,
+ .max = 65534,
+ }, {
+ .gaintime = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN1,
+ .min = 2048,
+ .max = 65534,
+ }, {
+ .gaintime = TSL2563_TIMING_100MS | TSL2563_TIMING_GAIN1,
+ .min = 4095,
+ .max = 37177,
+ }, {
+ .gaintime = TSL2563_TIMING_13MS | TSL2563_TIMING_GAIN1,
+ .min = 3000,
+ .max = 65535,
+ },
+};
+
+struct tsl2563_chip {
+ struct mutex lock;
+ struct i2c_client *client;
+ struct iio_dev *indio_dev;
+ struct delayed_work poweroff_work;
+
+ /* Remember state for suspend and resume functions */
+ pm_message_t state;
+
+ struct tsl2563_gainlevel_coeff *gainlevel;
+
+ /* Thresholds are in lux */
+ u16 low_thres;
+ u16 high_thres;
+ u8 intr;
+
+ /* Calibration coefficients */
+ u32 calib0;
+ u32 calib1;
+ int cover_comp_gain;
+
+ /* Cache current values, to be returned while suspended */
+ u32 data0;
+ u32 data1;
+};
+
+static int tsl2563_write(struct i2c_client *client, u8 reg, u8 value)
+{
+ int ret;
+ u8 buf[2];
+
+ buf[0] = TSL2563_CMD | reg;
+ buf[1] = value;
+
+ ret = i2c_master_send(client, buf, sizeof(buf));
+ return (ret == sizeof(buf)) ? 0 : ret;
+}
+
+static int tsl2563_read(struct i2c_client *client, u8 reg, void *buf, int len)
+{
+ int ret;
+ u8 cmd = TSL2563_CMD | reg;
+
+ ret = i2c_master_send(client, &cmd, sizeof(cmd));
+ if (ret != sizeof(cmd))
+ return ret;
+
+ return i2c_master_recv(client, buf, len);
+}
+
+static int tsl2563_set_power(struct tsl2563_chip *chip, int on)
+{
+ struct i2c_client *client = chip->client;
+ u8 cmd;
+
+ cmd = on ? TSL2563_CMD_POWER_ON : TSL2563_CMD_POWER_OFF;
+ return tsl2563_write(client, TSL2563_REG_CTRL, cmd);
+}
+
+/*
+ * Return value is 0 for off, 1 for on, or a negative error
+ * code if reading failed.
+ */
+static int tsl2563_get_power(struct tsl2563_chip *chip)
+{
+ struct i2c_client *client = chip->client;
+ int ret;
+ u8 val;
+
+ ret = tsl2563_read(client, TSL2563_REG_CTRL, &val, sizeof(val));
+ if (ret != sizeof(val))
+ return ret;
+
+ return (val & TSL2563_CTRL_POWER_MASK) == TSL2563_CMD_POWER_ON;
+}
+
+static int tsl2563_configure(struct tsl2563_chip *chip)
+{
+ struct i2c_client *client = chip->client;
+ int ret;
+
+ ret = tsl2563_write(client, TSL2563_REG_TIMING,
+ chip->gainlevel->gaintime);
+ if (ret)
+ goto out;
+
+ ret = tsl2563_write(client, TSL2563_REG_INT, chip->intr);
+
+out:
+ return ret;
+}
+
+static void tsl2563_poweroff_work(struct work_struct *work)
+{
+ struct tsl2563_chip *chip =
+ container_of(work, struct tsl2563_chip, poweroff_work.work);
+ tsl2563_set_power(chip, 0);
+}
+
+static int tsl2563_detect(struct tsl2563_chip *chip)
+{
+ int ret;
+
+ ret = tsl2563_set_power(chip, 1);
+ if (ret)
+ return ret;
+
+ ret = tsl2563_get_power(chip);
+ if (ret < 0)
+ return ret;
+
+ return ret ? 0 : -ENODEV;
+}
+
+static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id)
+{
+ struct i2c_client *client = chip->client;
+ int ret;
+
+ ret = tsl2563_read(client, TSL2563_REG_ID, id, sizeof(*id));
+ if (ret != sizeof(*id))
+ return ret;
+
+ return 0;
+}
+
+/*
+ * "Normalized" ADC value is one obtained with 400ms of integration time and
+ * 16x gain. This function returns the number of bits of shift needed to
+ * convert between normalized values and HW values obtained using given
+ * timing and gain settings.
+ */
+static int adc_shiftbits(u8 timing)
+{
+ int shift = 0;
+
+ switch (timing & TSL2563_TIMING_MASK) {
+ case TSL2563_TIMING_13MS:
+ shift += 5;
+ break;
+ case TSL2563_TIMING_100MS:
+ shift += 2;
+ break;
+ case TSL2563_TIMING_400MS:
+ /* no-op */
+ break;
+ }
+
+ if (!(timing & TSL2563_TIMING_GAIN16))
+ shift += 4;
+
+ return shift;
+}
+
+/* Convert a HW ADC value to normalized scale. */
+static u32 normalize_adc(u16 adc, u8 timing)
+{
+ return adc << adc_shiftbits(timing);
+}
+
+static void tsl2563_wait_adc(struct tsl2563_chip *chip)
+{
+ unsigned int delay;
+
+ switch (chip->gainlevel->gaintime & TSL2563_TIMING_MASK) {
+ case TSL2563_TIMING_13MS:
+ delay = 14;
+ break;
+ case TSL2563_TIMING_100MS:
+ delay = 101;
+ break;
+ default:
+ delay = 402;
+ }
+ /*
+ * TODO: Make sure that we wait at least required delay but why we
+ * have to extend it one tick more?
+ */
+ schedule_timeout_interruptible(msecs_to_jiffies(delay) + 2);
+}
+
+static int tsl2563_adjust_gainlevel(struct tsl2563_chip *chip, u16 adc)
+{
+ struct i2c_client *client = chip->client;
+
+ if (adc > chip->gainlevel->max || adc < chip->gainlevel->min) {
+
+ (adc > chip->gainlevel->max) ?
+ chip->gainlevel++ : chip->gainlevel--;
+
+ tsl2563_write(client, TSL2563_REG_TIMING,
+ chip->gainlevel->gaintime);
+
+ tsl2563_wait_adc(chip);
+ tsl2563_wait_adc(chip);
+
+ return 1;
+ } else
+ return 0;
+}
+
+static int tsl2563_get_adc(struct tsl2563_chip *chip)
+{
+ struct i2c_client *client = chip->client;
+ u8 buf0[2], buf1[2];
+ u16 adc0, adc1;
+ int retry = 1;
+ int ret = 0;
+
+ if (chip->state.event != PM_EVENT_ON)
+ goto out;
+
+ cancel_delayed_work(&chip->poweroff_work);
+
+ if (!tsl2563_get_power(chip)) {
+ ret = tsl2563_set_power(chip, 1);
+ if (ret)
+ goto out;
+ ret = tsl2563_configure(chip);
+ if (ret)
+ goto out;
+ tsl2563_wait_adc(chip);
+ }
+
+ while (retry) {
+ ret = tsl2563_read(client,
+ TSL2563_REG_DATA0LOW | TSL2563_CLEARINT,
+ buf0, sizeof(buf0));
+ if (ret != sizeof(buf0))
+ goto out;
+
+ ret = tsl2563_read(client, TSL2563_REG_DATA1LOW,
+ buf1, sizeof(buf1));
+ if (ret != sizeof(buf1))
+ goto out;
+
+ adc0 = (buf0[1] << 8) + buf0[0];
+ adc1 = (buf1[1] << 8) + buf1[0];
+
+ retry = tsl2563_adjust_gainlevel(chip, adc0);
+ }
+
+ chip->data0 = normalize_adc(adc0, chip->gainlevel->gaintime);
+ chip->data1 = normalize_adc(adc1, chip->gainlevel->gaintime);
+
+ schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
+
+ ret = 0;
+out:
+ return ret;
+}
+
+static inline int calib_to_sysfs(u32 calib)
+{
+ return (int) (((calib * CALIB_BASE_SYSFS) +
+ CALIB_FRAC_HALF) >> CALIB_FRAC_BITS);
+}
+
+static inline u32 calib_from_sysfs(int value)
+{
+ return (((u32) value) << CALIB_FRAC_BITS) / CALIB_BASE_SYSFS;
+}
+
+/*
+ * Conversions between lux and ADC values.
+ *
+ * The basic formula is lux = c0 * adc0 - c1 * adc1, where c0 and c1 are
+ * appropriate constants. Different constants are needed for different
+ * kinds of light, determined by the ratio adc1/adc0 (basically the ratio
+ * of the intensities in infrared and visible wavelengths). lux_table below
+ * lists the upper threshold of the adc1/adc0 ratio and the corresponding
+ * constants.
+ */
+
+struct tsl2563_lux_coeff {
+ unsigned long ch_ratio;
+ unsigned long ch0_coeff;
+ unsigned long ch1_coeff;
+};
+
+static const struct tsl2563_lux_coeff lux_table[] = {
+ {
+ .ch_ratio = FRAC10K(1300),
+ .ch0_coeff = FRAC10K(315),
+ .ch1_coeff = FRAC10K(262),
+ }, {
+ .ch_ratio = FRAC10K(2600),
+ .ch0_coeff = FRAC10K(337),
+ .ch1_coeff = FRAC10K(430),
+ }, {
+ .ch_ratio = FRAC10K(3900),
+ .ch0_coeff = FRAC10K(363),
+ .ch1_coeff = FRAC10K(529),
+ }, {
+ .ch_ratio = FRAC10K(5200),
+ .ch0_coeff = FRAC10K(392),
+ .ch1_coeff = FRAC10K(605),
+ }, {
+ .ch_ratio = FRAC10K(6500),
+ .ch0_coeff = FRAC10K(229),
+ .ch1_coeff = FRAC10K(291),
+ }, {
+ .ch_ratio = FRAC10K(8000),
+ .ch0_coeff = FRAC10K(157),
+ .ch1_coeff = FRAC10K(180),
+ }, {
+ .ch_ratio = FRAC10K(13000),
+ .ch0_coeff = FRAC10K(34),
+ .ch1_coeff = FRAC10K(26),
+ }, {
+ .ch_ratio = ULONG_MAX,
+ .ch0_coeff = 0,
+ .ch1_coeff = 0,
+ },
+};
+
+/*
+ * Convert normalized, scaled ADC values to lux.
+ */
+static unsigned int adc_to_lux(u32 adc0, u32 adc1)
+{
+ const struct tsl2563_lux_coeff *lp = lux_table;
+ unsigned long ratio, lux, ch0 = adc0, ch1 = adc1;
+
+ ratio = ch0 ? ((ch1 << ADC_FRAC_BITS) / ch0) : ULONG_MAX;
+
+ while (lp->ch_ratio < ratio)
+ lp++;
+
+ lux = ch0 * lp->ch0_coeff - ch1 * lp->ch1_coeff;
+
+ return (unsigned int) (lux >> ADC_FRAC_BITS);
+}
+
+/*--------------------------------------------------------------*/
+/* Sysfs interface */
+/*--------------------------------------------------------------*/
+
+static ssize_t tsl2563_adc0_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2563_chip *chip = indio_dev->dev_data;
+ int ret;
+
+ mutex_lock(&chip->lock);
+
+ ret = tsl2563_get_adc(chip);
+ if (ret)
+ goto out;
+
+ ret = snprintf(buf, PAGE_SIZE, "%d\n", chip->data0);
+out:
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static ssize_t tsl2563_adc1_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2563_chip *chip = indio_dev->dev_data;
+ int ret;
+
+ mutex_lock(&chip->lock);
+
+ ret = tsl2563_get_adc(chip);
+ if (ret)
+ goto out;
+
+ ret = snprintf(buf, PAGE_SIZE, "%d\n", chip->data1);
+out:
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+/* Apply calibration coefficient to ADC count. */
+static u32 calib_adc(u32 adc, u32 calib)
+{
+ unsigned long scaled = adc;
+
+ scaled *= calib;
+ scaled >>= CALIB_FRAC_BITS;
+
+ return (u32) scaled;
+}
+
+static ssize_t tsl2563_lux_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2563_chip *chip = indio_dev->dev_data;
+ u32 calib0, calib1;
+ int ret;
+
+ mutex_lock(&chip->lock);
+
+ ret = tsl2563_get_adc(chip);
+ if (ret)
+ goto out;
+
+ calib0 = calib_adc(chip->data0, chip->calib0) * chip->cover_comp_gain;
+ calib1 = calib_adc(chip->data1, chip->calib1) * chip->cover_comp_gain;
+
+ ret = snprintf(buf, PAGE_SIZE, "%d\n", adc_to_lux(calib0, calib1));
+
+out:
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static ssize_t format_calib(char *buf, int len, u32 calib)
+{
+ return snprintf(buf, PAGE_SIZE, "%d\n", calib_to_sysfs(calib));
+}
+
+static ssize_t tsl2563_calib0_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2563_chip *chip = indio_dev->dev_data;
+ int ret;
+
+ mutex_lock(&chip->lock);
+ ret = format_calib(buf, PAGE_SIZE, chip->calib0);
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static ssize_t tsl2563_calib1_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2563_chip *chip = indio_dev->dev_data;
+ int ret;
+
+ mutex_lock(&chip->lock);
+ ret = format_calib(buf, PAGE_SIZE, chip->calib1);
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static int do_calib_store(struct device *dev, const char *buf, size_t len,
+ int ch)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2563_chip *chip = indio_dev->dev_data;
+ int value;
+ u32 calib;
+
+ if (1 != sscanf(buf, "%d", &value))
+ return -EINVAL;
+
+ calib = calib_from_sysfs(value);
+
+ if (ch)
+ chip->calib1 = calib;
+ else
+ chip->calib0 = calib;
+
+ return len;
+}
+
+static ssize_t tsl2563_calib0_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ return do_calib_store(dev, buf, len, 0);
+}
+
+static ssize_t tsl2563_calib1_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ return do_calib_store(dev, buf, len, 1);
+}
+
+/* AmitXXXX: Convert to IIO_DEV_ATTR_LIGHT* as in tsl2561
+ * once I understand what they mean */
+static DEVICE_ATTR(adc0, S_IRUGO, tsl2563_adc0_show, NULL);
+static DEVICE_ATTR(adc1, S_IRUGO, tsl2563_adc1_show, NULL);
+static DEVICE_ATTR(lux, S_IRUGO, tsl2563_lux_show, NULL);
+static DEVICE_ATTR(calib0, S_IRUGO | S_IWUSR,
+ tsl2563_calib0_show, tsl2563_calib0_store);
+static DEVICE_ATTR(calib1, S_IRUGO | S_IWUSR,
+ tsl2563_calib1_show, tsl2563_calib1_store);
+
+static struct attribute *tsl2563_attributes[] = {
+ &dev_attr_adc0.attr,
+ &dev_attr_adc1.attr,
+ &dev_attr_lux.attr,
+ &dev_attr_calib0.attr,
+ &dev_attr_calib1.attr,
+ NULL
+};
+
+static const struct attribute_group tsl2563_group = {
+ .attrs = tsl2563_attributes,
+};
+
+/*--------------------------------------------------------------*/
+/* Probe, Attach, Remove */
+/*--------------------------------------------------------------*/
+static struct i2c_driver tsl2563_i2c_driver;
+
+static int __devinit tsl2563_probe(struct i2c_client *client,
+ const struct i2c_device_id *device_id)
+{
+ struct tsl2563_chip *chip;
+ struct tsl2563_platform_data *pdata = client->dev.platform_data;
+ int err = 0;
+ int ret;
+ u8 id;
+
+ chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+ if (!chip)
+ return -ENOMEM;
+
+ i2c_set_clientdata(client, chip);
+ chip->client = client;
+
+ err = tsl2563_detect(chip);
+ if (err) {
+ dev_err(&client->dev, "device not found, error %d \n", -err);
+ goto fail1;
+ }
+
+ err = tsl2563_read_id(chip, &id);
+ if (err)
+ goto fail1;
+
+ mutex_init(&chip->lock);
+
+ /* Default values used until userspace says otherwise */
+ chip->low_thres = 0x0;
+ chip->high_thres = 0xffff;
+ chip->gainlevel = tsl2563_gainlevel_table;
+ chip->intr = TSL2563_INT_PERSIST(4);
+ chip->calib0 = calib_from_sysfs(CALIB_BASE_SYSFS);
+ chip->calib1 = calib_from_sysfs(CALIB_BASE_SYSFS);
+
+ if (pdata)
+ chip->cover_comp_gain = pdata->cover_comp_gain;
+ else
+ chip->cover_comp_gain = 1;
+
+ dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f);
+
+ chip->indio_dev = iio_allocate_device();
+ if (!chip->indio_dev)
+ goto fail1;
+ chip->indio_dev->attrs = &tsl2563_group;
+ chip->indio_dev->dev.parent = &client->dev;
+ chip->indio_dev->dev_data = (void *)(chip);
+ chip->indio_dev->driver_module = THIS_MODULE;
+ chip->indio_dev->modes = INDIO_DIRECT_MODE;
+ ret = iio_device_register(chip->indio_dev);
+ if (ret)
+ goto fail1;
+
+ err = tsl2563_configure(chip);
+ if (err)
+ goto fail2;
+
+ INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work);
+ schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
+
+ return 0;
+fail2:
+ iio_device_unregister(chip->indio_dev);
+fail1:
+ kfree(chip);
+ return err;
+}
+
+static int tsl2563_remove(struct i2c_client *client)
+{
+ struct tsl2563_chip *chip = i2c_get_clientdata(client);
+
+ iio_device_unregister(chip->indio_dev);
+
+ kfree(chip);
+ return 0;
+}
+
+static int tsl2563_suspend(struct i2c_client *client, pm_message_t state)
+{
+ struct tsl2563_chip *chip = i2c_get_clientdata(client);
+ int ret;
+
+ mutex_lock(&chip->lock);
+
+ ret = tsl2563_set_power(chip, 0);
+ if (ret)
+ goto out;
+
+ chip->state = state;
+
+out:
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static int tsl2563_resume(struct i2c_client *client)
+{
+ struct tsl2563_chip *chip = i2c_get_clientdata(client);
+ int ret;
+
+ mutex_lock(&chip->lock);
+
+ ret = tsl2563_set_power(chip, 1);
+ if (ret)
+ goto out;
+
+ ret = tsl2563_configure(chip);
+ if (ret)
+ goto out;
+
+ chip->state.event = PM_EVENT_ON;
+
+out:
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static const struct i2c_device_id tsl2563_id[] = {
+ { "tsl2560", 0 },
+ { "tsl2561", 1 },
+ { "tsl2562", 2 },
+ { "tsl2563", 3 },
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, tsl2563_id);
+
+static struct i2c_driver tsl2563_i2c_driver = {
+ .driver = {
+ .name = "tsl2563",
+ },
+ .suspend = tsl2563_suspend,
+ .resume = tsl2563_resume,
+ .probe = tsl2563_probe,
+ .remove = __devexit_p(tsl2563_remove),
+ .id_table = tsl2563_id,
+};
+
+static int __init tsl2563_init(void)
+{
+ return i2c_add_driver(&tsl2563_i2c_driver);
+}
+
+static void __exit tsl2563_exit(void)
+{
+ i2c_del_driver(&tsl2563_i2c_driver);
+}
+
+MODULE_AUTHOR("Nokia Corporation");
+MODULE_DESCRIPTION("tsl2563 light sensor driver");
+MODULE_LICENSE("GPL");
+
+module_init(tsl2563_init);
+module_exit(tsl2563_exit);
diff --git a/drivers/staging/iio/light/tsl2563.h b/drivers/staging/iio/light/tsl2563.h
new file mode 100644
index 00000000000..b97368bd7ff
--- /dev/null
+++ b/drivers/staging/iio/light/tsl2563.h
@@ -0,0 +1,9 @@
+#ifndef __LINUX_TSL2563_H
+#define __LINUX_TSL2563_H
+
+struct tsl2563_platform_data {
+ int cover_comp_gain;
+};
+
+#endif /* __LINUX_TSL2563_H */
+
diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h
index d9261897f33..93b91b28a02 100644
--- a/drivers/staging/iio/ring_generic.h
+++ b/drivers/staging/iio/ring_generic.h
@@ -25,9 +25,12 @@ int iio_push_ring_event(struct iio_ring_buffer *ring_buf,
int event_code,
s64 timestamp);
/**
- * iio_push_or_escallate_ring_event() - escallate or add as appropriate
+ * iio_push_or_escallate_ring_event() - escalate or add as appropriate
+ * @ring_buf: ring buffer that is the event source
+ * @event_code: event indentification code
+ * @timestamp: time of event
*
- * Typical usecase is to escallate a 50% ring full to 75% full if noone has yet
+ * Typical usecase is to escalate a 50% ring full to 75% full if noone has yet
* read the first event. Clearly the 50% full is no longer of interest in
* typical use case.
**/
@@ -37,10 +40,6 @@ int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf,
/**
* struct iio_ring_access_funcs - access functions for ring buffers.
- * @create: perform allocation
- * @init: get ring buffer ready for use
- * @_exit: reverse steps in init
- * @_free: deallocate ring buffer
* @mark_in_use: reference counting, typically to prevent module removal
* @unmark_in_use: reduce reference count when no longer using ring buffer
* @store_to: actually store stuff to the ring buffer
@@ -60,7 +59,7 @@ int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf,
*
* The purpose of this structure is to make the ring buffer element
* modular as event for a given driver, different usecases may require
- * different ring designs (space efficiency vs speed for example.
+ * different ring designs (space efficiency vs speed for example).
*
* It is worth noting that a given ring implementation may only support a small
* proportion of these functions. The core code 'should' cope fine with any of
@@ -91,23 +90,25 @@ struct iio_ring_access_funcs {
/**
* struct iio_ring_buffer - general ring buffer structure
- * @length: [DEVICE]number of datums in ring
- * @bpd: [DEVICE]size of individual datum including timestamp
- * @loopcount: [INTERN]number of times the ring has looped
- * @access_minor_name: [INTERN]store of name of the access chrdev minor number
- * sysfs attribute
- * @access_handler: [INTERN]chrdev access handling
- * @event_minor_name: [INTERN]store of name of the event chrdev minor number
- * sysfs attribute
- * @ev_int: [INTERN]chrdev interface for the event chrdev
- * @shared_ev_pointer: [INTERN]the shared event pointer to allow escalation of
+ * @dev: ring buffer device struct
+ * @access_dev: system device struct for the chrdev
+ * @indio_dev: industrial I/O device structure
+ * @owner: module that owns the ring buffer (for ref counting)
+ * @id: unique id number
+ * @access_id: device id number
+ * @length: [DEVICE] number of datums in ring
+ * @bpd: [DEVICE] size of individual datum including timestamp
+ * @loopcount: [INTERN] number of times the ring has looped
+ * @access_handler: [INTERN] chrdev access handling
+ * @ev_int: [INTERN] chrdev interface for the event chrdev
+ * @shared_ev_pointer: [INTERN] the shared event pointer to allow escalation of
* events
- * @ring_access: [DRIVER]ring access functions associated with the
+ * @access: [DRIVER] ring access functions associated with the
* implementation.
- * @ring_prenable: [DRIVER] function to run prior to marking ring enabled
- * @ring_postenable: [DRIVER] function to run after marking ring enabled
- * @ring_predisable: [DRIVER] function to run prior to marking ring disabled
- * @ring_postdisable: [DRIVER] function to run after marking ring disabled
+ * @preenable: [DRIVER] function to run prior to marking ring enabled
+ * @postenable: [DRIVER] function to run after marking ring enabled
+ * @predisable: [DRIVER] function to run prior to marking ring disabled
+ * @postdisable: [DRIVER] function to run after marking ring disabled
**/
struct iio_ring_buffer {
struct device dev;
@@ -133,7 +134,10 @@ void iio_ring_buffer_init(struct iio_ring_buffer *ring,
struct iio_dev *dev_info);
/**
- * __iio_init_ring_buffer() - initialize common elements of ring buffers.
+ * __iio_init_ring_buffer() - initialize common elements of ring buffers
+ * @ring: ring buffer that is the event source
+ * @bytes_per_datum: size of individual datum including timestamp
+ * @length: number of datums in ring
**/
static inline void __iio_init_ring_buffer(struct iio_ring_buffer *ring,
int bytes_per_datum, int length)
@@ -171,7 +175,11 @@ struct iio_scan_el {
container_of(_dev_attr, struct iio_scan_el, dev_attr);
/**
- * iio_scan_el_store() - sysfs scan element selection interface.
+ * iio_scan_el_store() - sysfs scan element selection interface
+ * @dev: the target device
+ * @attr: the device attribute that is being processed
+ * @buf: input from userspace
+ * @len: length of input
*
* A generic function used to enable various scan elements. In some
* devices explicit read commands for each channel mean this is merely
@@ -184,12 +192,15 @@ ssize_t iio_scan_el_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t len);
/**
* iio_scal_el_show() - sysfs interface to query whether a scan element is
- * is enabled or not.
+ * is enabled or not
+ * @dev: the target device
+ * @attr: the device attribute that is being processed
+ * @buf: output buffer
**/
ssize_t iio_scan_el_show(struct device *dev, struct device_attribute *attr,
char *buf);
/**
- * IIO_SCAN_EL: - declare and initialize a scan element without control func
+ * IIO_SCAN_EL - declare and initialize a scan element without control func
* @_name: identifying name. Resulting struct is iio_scan_el_##_name,
* sysfs element, scan_en_##_name.
* @_number: unique id number for the scan element.
@@ -214,8 +225,14 @@ ssize_t iio_scan_el_ts_store(struct device *dev, struct device_attribute *attr,
ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
char *buf);
/**
- * IIO_SCAN_EL_C: - declare and initialize a scan element with a control func
+ * IIO_SCAN_EL_C - declare and initialize a scan element with a control func
*
+ * @_name: identifying name. Resulting struct is iio_scan_el_##_name,
+ * sysfs element, scan_en_##_name.
+ * @_number: unique id number for the scan element.
+ * @_bits: number of bits in the scan element result (used in mixed bit
+ * length devices).
+ * @_label: indentification variable used by drivers. Often a reg address.
* @_controlfunc: function used to notify hardware of whether state changes
**/
#define IIO_SCAN_EL_C(_name, _number, _bits, _label, _controlfunc) \
@@ -230,7 +247,7 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
.set_state = _controlfunc, \
}
/**
- * IIO_SCAN_EL_TIMESTAMP: - declare a special scan element for timestamps
+ * IIO_SCAN_EL_TIMESTAMP - declare a special scan element for timestamps
*
* Odd one out. Handled slightly differently from other scan elements.
**/
diff --git a/drivers/staging/iio/ring_sw.h b/drivers/staging/iio/ring_sw.h
index ae70ee0538f..fd677f00836 100644
--- a/drivers/staging/iio/ring_sw.h
+++ b/drivers/staging/iio/ring_sw.h
@@ -29,59 +29,71 @@
* driver requests - some may support multiple options */
-#include <linux/autoconf.h>
#include "iio.h"
#include "ring_generic.h"
#if defined CONFIG_IIO_SW_RING || defined CONFIG_IIO_SW_RING_MODULE
/**
- * iio_create_sw_rb() software ring buffer allocation
+ * iio_create_sw_rb() - software ring buffer allocation
* @r: pointer to ring buffer pointer
**/
int iio_create_sw_rb(struct iio_ring_buffer **r);
/**
- * iio_init_sw_rb() initialize the software ring buffer
+ * iio_init_sw_rb() - initialize the software ring buffer
* @r: pointer to a software ring buffer created by an
- * iio_create_sw_rb call.
+ * iio_create_sw_rb call
+ * @indio_dev: industrial I/O device structure
**/
int iio_init_sw_rb(struct iio_ring_buffer *r, struct iio_dev *indio_dev);
+
/**
- * iio_exit_sw_rb() reverse what was done in iio_init_sw_rb
+ * iio_exit_sw_rb() - reverse what was done in iio_init_sw_rb
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
void iio_exit_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_free_sw_rb() free memory occupied by the core ring buffer struct
+ * iio_free_sw_rb() - free memory occupied by the core ring buffer struct
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
void iio_free_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_mark_sw_rb_in_use() reference counting to prevent incorrect chances
+ * iio_mark_sw_rb_in_use() - reference counting to prevent incorrect chances
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
void iio_mark_sw_rb_in_use(struct iio_ring_buffer *r);
/**
- * iio_unmark_sw_rb_in_use() notify the ring buffer that we don't care anymore
+ * iio_unmark_sw_rb_in_use() - notify the ring buffer that we don't care anymore
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
void iio_unmark_sw_rb_in_use(struct iio_ring_buffer *r);
/**
- * iio_read_last_from_sw_rb() attempt to read the last stored datum from the rb
+ * iio_read_last_from_sw_rb() - attempt to read the last stored datum from the rb
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
+ * @data: where to store the last datum
**/
int iio_read_last_from_sw_rb(struct iio_ring_buffer *r, u8 *data);
/**
- * iio_store_to_sw_rb() store a new datum to the ring buffer
- * @rb: pointer to ring buffer instance
- * @data: the datum to be stored including timestamp if relevant.
- * @timestamp: timestamp which will be attached to buffer events if relevant.
+ * iio_store_to_sw_rb() - store a new datum to the ring buffer
+ * @r: pointer to ring buffer instance
+ * @data: the datum to be stored including timestamp if relevant
+ * @timestamp: timestamp which will be attached to buffer events if relevant
**/
int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp);
/**
- * iio_rip_sw_rb() attempt to read data from the ring buffer
+ * iio_rip_sw_rb() - attempt to read data from the ring buffer
* @r: ring buffer instance
* @count: number of datum's to try and read
* @data: where the data will be stored.
@@ -94,38 +106,53 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r,
int *dead_offset);
/**
- * iio_request_update_sw_rb() update params if update needed
+ * iio_request_update_sw_rb() - update params if update needed
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
int iio_request_update_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_mark_update_needed_sw_rb() tell the ring buffer it needs a param update
+ * iio_mark_update_needed_sw_rb() - tell the ring buffer it needs a param update
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
int iio_mark_update_needed_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_get_bpd_sw_rb() get the datum size in bytes
+ * iio_get_bpd_sw_rb() - get the datum size in bytes
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
int iio_get_bpd_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_set_bpd_sw_rb() set the datum size in bytes
+ * iio_set_bpd_sw_rb() - set the datum size in bytes
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
+ * @bpd: bytes per datum value
**/
int iio_set_bpd_sw_rb(struct iio_ring_buffer *r, size_t bpd);
/**
- * iio_get_length_sw_rb() get how many datums the rb may contain
+ * iio_get_length_sw_rb() - get how many datums the rb may contain
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
**/
int iio_get_length_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_set_length_sw_rb() set how many datums the rb may contain
+ * iio_set_length_sw_rb() - set how many datums the rb may contain
+ * @r: pointer to a software ring buffer created by an
+ * iio_create_sw_rb call
+ * @length: max number of data items for the ring buffer
**/
int iio_set_length_sw_rb(struct iio_ring_buffer *r, int length);
/**
- * iio_ring_sw_register_funcs() helper function to set up rb access
+ * iio_ring_sw_register_funcs() - helper function to set up rb access
+ * @ra: pointer to @iio_ring_access_funcs
**/
static inline void iio_ring_sw_register_funcs(struct iio_ring_access_funcs *ra)
{
diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h
index bfe4055c0ed..e501e1338e1 100644
--- a/drivers/staging/iio/sysfs.h
+++ b/drivers/staging/iio/sysfs.h
@@ -15,7 +15,7 @@
#include "iio.h"
/**
- * struct iio_event_attribute - event control attribute
+ * struct iio_event_attr - event control attribute
* @dev_attr: underlying device attribute
* @mask: mask for the event when detecting
* @listel: list header to allow addition to list of event handlers
@@ -54,6 +54,7 @@ __init_iio_chrdev_minor_attr(struct iio_chrdev_minor_attr *minor_attr,
* struct iio_dev_attr - iio specific device attribute
* @dev_attr: underlying device attribute
* @address: associated register address
+ * @val2: secondary attribute value
*/
struct iio_dev_attr {
struct device_attribute dev_attr;
@@ -71,6 +72,8 @@ ssize_t iio_read_const_attr(struct device *dev,
/**
* struct iio_const_attr - constant device specific attribute
* often used for things like available modes
+ * @string: attribute string
+ * @dev_attr: underlying device attribute
*/
struct iio_const_attr {
const char *string;
@@ -80,7 +83,7 @@ struct iio_const_attr {
#define to_iio_const_attr(_dev_attr) \
container_of(_dev_attr, struct iio_const_attr, dev_attr)
-/* Some attributes will be hard coded (device dependant) and not require an
+/* Some attributes will be hard coded (device dependent) and not require an
address, in these cases pass a negative */
#define IIO_ATTR(_name, _mode, _show, _store, _addr) \
{ .dev_attr = __ATTR(_name, _mode, _show, _store), \
@@ -108,102 +111,130 @@ struct iio_const_attr {
/* Generic attributes of onetype or another */
/**
- * IIO_DEV_ATTR_REG: revision number for the device
+ * IIO_DEV_ATTR_REV - revision number for the device
+ * @_show: output method for the attribute
*
* Very much device dependent.
**/
#define IIO_DEV_ATTR_REV(_show) \
IIO_DEVICE_ATTR(revision, S_IRUGO, _show, NULL, 0)
+
/**
- * IIO_DEV_ATTR_NAME: chip type dependant identifier
+ * IIO_DEV_ATTR_NAME - chip type dependent identifier
+ * @_show: output method for the attribute
**/
#define IIO_DEV_ATTR_NAME(_show) \
IIO_DEVICE_ATTR(name, S_IRUGO, _show, NULL, 0)
/**
- * IIO_DEV_ATTR_SAMP_FREQ: sets any internal clock frequency
+ * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
+ * @_mode: sysfs file mode/permissions
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
**/
#define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) \
IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0)
/**
- * IIO_DEV_ATTR_AVAIL_SAMP_FREQ: list available sampling frequencies.
+ * IIO_DEV_ATTR_AVAIL_SAMP_FREQ - list available sampling frequencies
+ * @_show: output method for the attribute
*
- * May be mode dependant on some devices
+ * May be mode dependent on some devices
**/
#define IIO_DEV_ATTR_AVAIL_SAMP_FREQ(_show) \
IIO_DEVICE_ATTR(available_sampling_frequency, S_IRUGO, _show, NULL, 0)
/**
- * IIO_DEV_ATTR_CONST_AVAIL_SAMP_FREQ: list available sampling frequencies.
+ * IIO_CONST_ATTR_AVAIL_SAMP_FREQ - list available sampling frequencies
+ * @_string: frequency string for the attribute
*
* Constant version
**/
#define IIO_CONST_ATTR_AVAIL_SAMP_FREQ(_string) \
IIO_CONST_ATTR(available_sampling_frequency, _string)
+
/**
- * IIO_DEV_ATTR_SCAN_MODE: select a scan mode
+ * IIO_DEV_ATTR_SCAN_MODE - select a scan mode
+ * @_mode: sysfs file mode/permissions
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
*
* This is used when only certain combinations of inputs may be read in one
* scan.
**/
#define IIO_DEV_ATTR_SCAN_MODE(_mode, _show, _store) \
IIO_DEVICE_ATTR(scan_mode, _mode, _show, _store, 0)
+
/**
- * IIO_DEV_ATTR_AVAIL_SCAN_MODES: list available scan modes
+ * IIO_DEV_ATTR_AVAIL_SCAN_MODES - list available scan modes
+ * @_show: output method for the attribute
**/
#define IIO_DEV_ATTR_AVAIL_SCAN_MODES(_show) \
IIO_DEVICE_ATTR(available_scan_modes, S_IRUGO, _show, NULL, 0)
/**
- * IIO_DEV_ATTR_SCAN: result of scan of multiple channels
+ * IIO_DEV_ATTR_SCAN - result of scan of multiple channels
+ * @_show: output method for the attribute
**/
#define IIO_DEV_ATTR_SCAN(_show) \
IIO_DEVICE_ATTR(scan, S_IRUGO, _show, NULL, 0);
/**
- * IIO_DEV_ATTR_INPUT: direct read of a single input channel
+ * IIO_DEV_ATTR_INPUT - direct read of a single input channel
+ * @_number: input channel number
+ * @_show: output method for the attribute
**/
#define IIO_DEV_ATTR_INPUT(_number, _show) \
IIO_DEVICE_ATTR(in##_number, S_IRUGO, _show, NULL, _number)
-
/**
- * IIO_DEV_ATTR_SW_RING_ENABLE: enable software ring buffer
+ * IIO_DEV_ATTR_SW_RING_ENABLE - enable software ring buffer
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
*
- * Success may be dependant on attachment of trigger previously
+ * Success may be dependent on attachment of trigger previously.
**/
#define IIO_DEV_ATTR_SW_RING_ENABLE(_show, _store) \
IIO_DEVICE_ATTR(sw_ring_enable, S_IRUGO | S_IWUSR, _show, _store, 0)
/**
- * IIO_DEV_ATTR_HW_RING_ENABLE: enable hardware ring buffer
+ * IIO_DEV_ATTR_HW_RING_ENABLE - enable hardware ring buffer
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
*
- * This is a different attribute from the software one as one can invision
+ * This is a different attribute from the software one as one can envision
* schemes where a combination of the two may be used.
**/
#define IIO_DEV_ATTR_HW_RING_ENABLE(_show, _store) \
IIO_DEVICE_ATTR(hw_ring_enable, S_IRUGO | S_IWUSR, _show, _store, 0)
/**
- * IIO_DEV_ATTR_BPSE: set number of bits per scan element
+ * IIO_DEV_ATTR_BPSE - set number of bits per scan element
+ * @_mode: sysfs file mode/permissions
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
**/
#define IIO_DEV_ATTR_BPSE(_mode, _show, _store) \
IIO_DEVICE_ATTR(bpse, _mode, _show, _store, 0)
/**
- * IIO_DEV_ATTR_BPSE_AVAILABLE: no of bits per scan element supported
+ * IIO_DEV_ATTR_BPSE_AVAILABLE - number of bits per scan element supported
+ * @_show: output method for the attribute
**/
#define IIO_DEV_ATTR_BPSE_AVAILABLE(_show) \
IIO_DEVICE_ATTR(bpse_available, S_IRUGO, _show, NULL, 0)
/**
- * IIO_DEV_ATTR_TEMP: many sensors have auxiliary temperature sensors
+ * IIO_DEV_ATTR_TEMP - many sensors have auxiliary temperature sensors
+ * @_show: output method for the attribute
**/
#define IIO_DEV_ATTR_TEMP(_show) \
IIO_DEVICE_ATTR(temp, S_IRUGO, _show, NULL, 0)
+
/**
- * IIO_EVENT_SH: generic shared event handler
+ * IIO_EVENT_SH - generic shared event handler
+ * @_name: event name
+ * @_handler: handler function to be called
*
* This is used in cases where more than one event may result from a single
* handler. Often the case that some alarm register must be read and multiple
@@ -221,8 +252,14 @@ struct iio_const_attr {
.prev = &iio_event_##_name.list, \
}, \
};
+
/**
- * IIO_EVENT_ATTR_SH: generic shared event attribute
+ * IIO_EVENT_ATTR_SH - generic shared event attribute
+ * @_name: event name
+ * @_ev_list: event handler list
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
+ * @_mask: mask used when detecting the event
*
* An attribute with an associated IIO_EVENT_SH
**/
@@ -235,7 +272,12 @@ struct iio_const_attr {
.listel = &_ev_list };
/**
- * IIO_EVENT_ATTR: non shared event attribute
+ * IIO_EVENT_ATTR - non-shared event attribute
+ * @_name: event name
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
+ * @_mask: mask used when detecting the event
+ * @_handler: handler function to be called
**/
#define IIO_EVENT_ATTR(_name, _show, _store, _mask, _handler) \
static struct iio_event_handler_list \
@@ -251,10 +293,14 @@ struct iio_const_attr {
.listel = &iio_event_##_name }; \
/**
- * IIO_EVENT_ATTR_DATA_RDY: event driven by data ready signal
+ * IIO_EVENT_ATTR_DATA_RDY - event driven by data ready signal
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
+ * @_mask: mask used when detecting the event
+ * @_handler: handler function to be called
*
* Not typically implemented in devices where full triggering support
- * has been implemented
+ * has been implemented.
**/
#define IIO_EVENT_ATTR_DATA_RDY(_show, _store, _mask, _handler) \
IIO_EVENT_ATTR(data_rdy, _show, _store, _mask, _handler)
@@ -269,19 +315,31 @@ struct iio_const_attr {
#define IIO_EVENT_CODE_DEVICE_SPECIFIC 1000
/**
- * IIO_EVENT_ATTR_RING_50_FULL: ring buffer event to indicate 50% full
+ * IIO_EVENT_ATTR_RING_50_FULL - ring buffer event to indicate 50% full
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
+ * @_mask: mask used when detecting the event
+ * @_handler: handler function to be called
**/
#define IIO_EVENT_ATTR_RING_50_FULL(_show, _store, _mask, _handler) \
IIO_EVENT_ATTR(ring_50_full, _show, _store, _mask, _handler)
/**
- * IIO_EVENT_ATTR_RING_50_FULL_SH: shared ring event to indicate 50% full
+ * IIO_EVENT_ATTR_RING_50_FULL_SH - shared ring event to indicate 50% full
+ * @_evlist: event handler list
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
+ * @_mask: mask used when detecting the event
**/
#define IIO_EVENT_ATTR_RING_50_FULL_SH(_evlist, _show, _store, _mask) \
IIO_EVENT_ATTR_SH(ring_50_full, _evlist, _show, _store, _mask)
/**
- * IIO_EVENT_ATTR_RING_75_FULL_SH: shared ring event to indicate 75% full
+ * IIO_EVENT_ATTR_RING_75_FULL_SH - shared ring event to indicate 75% full
+ * @_evlist: event handler list
+ * @_show: output method for the attribute
+ * @_store: input method for the attribute
+ * @_mask: mask used when detecting the event
**/
#define IIO_EVENT_ATTR_RING_75_FULL_SH(_evlist, _show, _store, _mask) \
IIO_EVENT_ATTR_SH(ring_75_full, _evlist, _show, _store, _mask)
diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h
index 8284098c958..784e7b6fac1 100644
--- a/drivers/staging/iio/trigger.h
+++ b/drivers/staging/iio/trigger.h
@@ -19,16 +19,18 @@
* @id: [INTERN] unique id number
* @name: [DRIVER] unique name
* @dev: [DRIVER] associated device (if relevant)
- * @sysfs_dev: [INTERN] sysfs relevant device
* @private_data: [DRIVER] device specific data
* @list: [INTERN] used in maintenance of global trigger list
* @alloc_list: [DRIVER] used for driver specific trigger list
- * @poll_func_list_lock:[INTERN] protection of the polling function list
+ * @pollfunc_list_lock: [INTERN] protection of the polling function list
* @pollfunc_list: [INTERN] list of functions to run on trigger.
* @control_attrs: [DRIVER] sysfs attributes relevant to trigger type
- * @set_trigger_state: [DRIVER] switch on/off the trigger on demand
* @timestamp: [INTERN] timestamp usesd by some trigs (e.g. datardy)
* @owner: [DRIVER] used to monitor usage count of the trigger.
+ * @use_count: use count for the trigger
+ * @set_trigger_state: [DRIVER] switch on/off the trigger on demand
+ * @try_reenable: function to reenable the trigger when the
+ * use count is zero (may be NULL)
**/
struct iio_trigger {
int id;
@@ -68,6 +70,9 @@ static inline void iio_get_trigger(struct iio_trigger *trig)
/**
* iio_trigger_read_name() - sysfs access function to get the trigger name
+ * @dev: the system device
+ * @attr: device attributes for the device
+ * @buf: output buffer to store the trigger name
**/
ssize_t iio_trigger_read_name(struct device *dev,
struct device_attribute *attr,
@@ -79,6 +84,8 @@ ssize_t iio_trigger_read_name(struct device *dev,
/**
* iio_trigger_find_by_name() - search global trigger list
+ * @name: trigger name to search for
+ * @len: trigger name string length to compare
**/
struct iio_trigger *iio_trigger_find_by_name(const char *name, size_t len);
@@ -90,32 +97,35 @@ int iio_trigger_register(struct iio_trigger *trig_info);
/**
* iio_trigger_unregister() - unregister a trigger from the core
+ * @trig_info: trigger to be unregistered
**/
void iio_trigger_unregister(struct iio_trigger *trig_info);
/**
* iio_trigger_attach_poll_func() - add a function pair to be run on trigger
* @trig: trigger to which the function pair are being added
- * @pf: poll function pair
+ * @pf: poll function pair
**/
int iio_trigger_attach_poll_func(struct iio_trigger *trig,
struct iio_poll_func *pf);
/**
* iio_trigger_dettach_poll_func() - remove function pair from those to be
- * run on trigger.
- * @trig: trigger from which the function is being removed.
+ * run on trigger
+ * @trig: trigger from which the function is being removed
* @pf: poll function pair
**/
int iio_trigger_dettach_poll_func(struct iio_trigger *trig,
struct iio_poll_func *pf);
/**
- * iio_trigger_poll() - called on a trigger occuring
+ * iio_trigger_poll() - called on a trigger occurring
+ * @trig: trigger which occurred
+ *
* Typically called in relevant hardware interrupt handler.
**/
-void iio_trigger_poll(struct iio_trigger *);
-void iio_trigger_notify_done(struct iio_trigger *);
+void iio_trigger_poll(struct iio_trigger *trig);
+void iio_trigger_notify_done(struct iio_trigger *trig);
/**
* struct iio_poll_func - poll function pair
@@ -127,11 +137,10 @@ void iio_trigger_notify_done(struct iio_trigger *);
* control on sensor supporting it.
* @poll_func_main: function in here is run after all immediates.
* Reading from sensor etc typically involves
- * scheduling
- * from here.
+ * scheduling from here.
*
- * The two stage approach used here only important when multiple sensors are
- * being triggered by a single trigger. This really comes into it's own with
+ * The two stage approach used here is only important when multiple sensors are
+ * being triggered by a single trigger. This really comes into its own with
* simultaneous sampling devices where a simple latch command can be used to
* make the device store the values on all inputs.
**/
diff --git a/drivers/staging/iio/trigger/Kconfig b/drivers/staging/iio/trigger/Kconfig
index fdd9301271a..d842a584a3a 100644
--- a/drivers/staging/iio/trigger/Kconfig
+++ b/drivers/staging/iio/trigger/Kconfig
@@ -9,13 +9,13 @@ config IIO_PERIODIC_RTC_TRIGGER
tristate "Periodic RTC triggers"
depends on RTC_CLASS
help
- Provides support for using periodic capable real time
- clocks as IIO triggers.
+ Provides support for using periodic capable real time
+ clocks as IIO triggers.
config IIO_GPIO_TRIGGER
tristate "GPIO trigger"
depends on GENERIC_GPIO
help
- Provides support for using GPIO pins as IIO triggers.
+ Provides support for using GPIO pins as IIO triggers.
endif # IIO_TRIGGER
diff --git a/drivers/staging/iio/trigger_consumer.h b/drivers/staging/iio/trigger_consumer.h
index 4c7f527dc79..a02d70b0d24 100644
--- a/drivers/staging/iio/trigger_consumer.h
+++ b/drivers/staging/iio/trigger_consumer.h
@@ -10,12 +10,13 @@
#ifdef CONFIG_IIO_TRIGGER
/**
- * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers.
+ * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
* @dev_info: iio_dev associated with the device that will consume the trigger
**/
int iio_device_register_trigger_consumer(struct iio_dev *dev_info);
+
/**
- * iio_device_unregister_trigger_consumer() - reverse the registration process.
+ * iio_device_unregister_trigger_consumer() - reverse the registration process
* @dev_info: iio_dev associated with the device that consumed the trigger
**/
int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info);
@@ -23,13 +24,14 @@ int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info);
#else
/**
- * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers.
+ * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
* @dev_info: iio_dev associated with the device that will consume the trigger
**/
int iio_device_register_trigger_consumer(struct iio_dev *dev_info)
{
return 0;
};
+
/**
* iio_device_unregister_trigger_consumer() - reverse the registration process
* @dev_info: iio_dev associated with the device that consumed the trigger