aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/Documentation
diff options
context:
space:
mode:
authorJames Morris <james.l.morris@oracle.com>2012-08-17 20:42:30 +1000
committerJames Morris <james.l.morris@oracle.com>2012-08-17 20:42:30 +1000
commit51b743fe87d7fb3dba7a2ff4a1fe23bb65dc2245 (patch)
treef8b8f601713a3ecb264eb9f145636343d9350520 /drivers/staging/iio/Documentation
parentptrace: mark __ptrace_may_access() static (diff)
parentLinux 3.6-rc2 (diff)
downloadlinux-dev-51b743fe87d7fb3dba7a2ff4a1fe23bb65dc2245.tar.xz
linux-dev-51b743fe87d7fb3dba7a2ff4a1fe23bb65dc2245.zip
Merge tag 'v3.6-rc2' into next
Linux 3.6-rc2 Resync with Linus.
Diffstat (limited to 'drivers/staging/iio/Documentation')
-rw-r--r--drivers/staging/iio/Documentation/device.txt12
-rw-r--r--drivers/staging/iio/Documentation/generic_buffer.c71
-rw-r--r--drivers/staging/iio/Documentation/iio_event_monitor.c14
-rw-r--r--drivers/staging/iio/Documentation/iio_utils.h33
-rw-r--r--[-rwxr-xr-x]drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl25830
-rw-r--r--[-rwxr-xr-x]drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x0
-rw-r--r--drivers/staging/iio/Documentation/overview.txt2
-rw-r--r--drivers/staging/iio/Documentation/ring.txt4
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio-light25
9 files changed, 106 insertions, 55 deletions
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt
index 0338c7cd0a8b..ea08d6213373 100644
--- a/drivers/staging/iio/Documentation/device.txt
+++ b/drivers/staging/iio/Documentation/device.txt
@@ -12,7 +12,7 @@ struct iio_dev *indio_dev = iio_device_alloc(sizeof(struct chip_state));
where chip_state is a structure of local state data for this instance of
the chip.
-That data can be accessed using iio_priv(struct iio_dev *)
+That data can be accessed using iio_priv(struct iio_dev *).
Then fill in the following:
@@ -29,8 +29,6 @@ Then fill in the following:
* info->driver_module:
Set to THIS_MODULE. Used to ensure correct ownership
of various resources allocate by the core.
- * info->num_interrupt_lines:
- Number of event triggering hardware lines the device has.
* info->event_attrs:
Attributes used to enable / disable hardware events.
* info->attrs:
@@ -41,7 +39,7 @@ Then fill in the following:
and for associate parameters such as offsets and scales.
* info->write_raw:
Raw value writing function. Used for writable device values such
- as DAC values and caliboffset.
+ as DAC values and calibbias.
* info->read_event_config:
Typically only set if there are some interrupt lines. This
is used to read if an on sensor event detector is enabled.
@@ -64,8 +62,8 @@ Then fill in the following:
Poll function related elements. This controls what occurs when a trigger
to which this device is attached sends an event.
- indio_dev->channels:
- Specification of device channels. Most attributes etc are built
- form this spec.
+ Specification of device channels. Most attributes etc. are built
+ from this spec.
- indio_dev->num_channels:
How many channels are there?
@@ -78,4 +76,4 @@ be registered afterwards (otherwise the whole parentage of devices
gets confused)
On remove, iio_device_unregister(indio_dev) will remove the device from
-the core, and iio_device_free will clean up.
+the core, and iio_device_free(indio_dev) will clean up.
diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c
index bf553356fdad..827e92de8e30 100644
--- a/drivers/staging/iio/Documentation/generic_buffer.c
+++ b/drivers/staging/iio/Documentation/generic_buffer.c
@@ -18,6 +18,8 @@
*
*/
+#define _GNU_SOURCE
+
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
@@ -29,12 +31,14 @@
#include <string.h>
#include <poll.h>
#include <endian.h>
+#include <getopt.h>
+#include <inttypes.h>
#include "iio_utils.h"
/**
* size_from_channelarray() - calculate the storage size of a scan
- * @channels: the channel info array
- * @num_channels: size of the channel info array
+ * @channels: the channel info array
+ * @num_channels: number of channels
*
* Has the side effect of filling the channels[i].location values used
* in processing the buffer output.
@@ -58,22 +62,22 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
void print2byte(int input, struct iio_channel_info *info)
{
/* First swap if incorrect endian */
-
if (info->be)
input = be16toh((uint16_t)input);
else
input = le16toh((uint16_t)input);
- /* shift before conversion to avoid sign extension
- of left aligned data */
+ /*
+ * Shift before conversion to avoid sign extension
+ * of left aligned data
+ */
input = input >> info->shift;
if (info->is_signed) {
int16_t val = input;
val &= (1 << info->bits_used) - 1;
val = (int16_t)(val << (16 - info->bits_used)) >>
(16 - info->bits_used);
- printf("%05f ", val,
- (float)(val + info->offset)*info->scale);
+ printf("%05f ", ((float)val + info->offset)*info->scale);
} else {
uint16_t val = input;
val &= (1 << info->bits_used) - 1;
@@ -83,39 +87,39 @@ void print2byte(int input, struct iio_channel_info *info)
/**
* process_scan() - print out the values in SI units
* @data: pointer to the start of the scan
- * @infoarray: information about the channels. Note
+ * @channels: information about the channels. Note
* size_from_channelarray must have been called first to fill the
* location offsets.
- * @num_channels: the number of active channels
+ * @num_channels: number of channels
**/
void process_scan(char *data,
- struct iio_channel_info *infoarray,
+ struct iio_channel_info *channels,
int num_channels)
{
int k;
for (k = 0; k < num_channels; k++)
- switch (infoarray[k].bytes) {
+ switch (channels[k].bytes) {
/* only a few cases implemented so far */
case 2:
- print2byte(*(uint16_t *)(data + infoarray[k].location),
- &infoarray[k]);
+ print2byte(*(uint16_t *)(data + channels[k].location),
+ &channels[k]);
break;
case 8:
- if (infoarray[k].is_signed) {
+ if (channels[k].is_signed) {
int64_t val = *(int64_t *)
(data +
- infoarray[k].location);
- if ((val >> infoarray[k].bits_used) & 1)
- val = (val & infoarray[k].mask) |
- ~infoarray[k].mask;
+ channels[k].location);
+ if ((val >> channels[k].bits_used) & 1)
+ val = (val & channels[k].mask) |
+ ~channels[k].mask;
/* special case for timestamp */
- if (infoarray[k].scale == 1.0f &&
- infoarray[k].offset == 0.0f)
- printf(" %lld", val);
+ if (channels[k].scale == 1.0f &&
+ channels[k].offset == 0.0f)
+ printf("%" PRId64 " ", val);
else
printf("%05f ", ((float)val +
- infoarray[k].offset)*
- infoarray[k].scale);
+ channels[k].offset)*
+ channels[k].scale);
}
break;
default:
@@ -130,10 +134,7 @@ int main(int argc, char **argv)
unsigned long timedelay = 1000000;
unsigned long buf_len = 128;
-
int ret, c, i, j, toread;
-
- FILE *fp_ev;
int fp;
int num_channels;
@@ -149,7 +150,7 @@ int main(int argc, char **argv)
int noevents = 0;
char *dummy;
- struct iio_channel_info *infoarray;
+ struct iio_channel_info *channels;
while ((c = getopt(argc, argv, "l:w:c:et:n:")) != -1) {
switch (c) {
@@ -192,7 +193,7 @@ int main(int argc, char **argv)
asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num);
if (trigger_name == NULL) {
/*
- * Build the trigger name. If it is device associated it's
+ * Build the trigger name. If it is device associated its
* name is <device_name>_dev[n] where n matches the device
* number found above
*/
@@ -217,7 +218,7 @@ int main(int argc, char **argv)
* Parse the files in scan_elements to identify what channels are
* present
*/
- ret = build_channel_array(dev_dir_name, &infoarray, &num_channels);
+ ret = build_channel_array(dev_dir_name, &channels, &num_channels);
if (ret) {
printf("Problem reading scan element information\n");
printf("diag %s\n", dev_dir_name);
@@ -236,7 +237,7 @@ int main(int argc, char **argv)
goto error_free_triggername;
}
printf("%s %s\n", dev_dir_name, trigger_name);
- /* Set the device trigger to be the data rdy trigger found above */
+ /* Set the device trigger to be the data ready trigger found above */
ret = write_sysfs_string_and_verify("trigger/current_trigger",
dev_dir_name,
trigger_name);
@@ -254,7 +255,7 @@ int main(int argc, char **argv)
ret = write_sysfs_int("enable", buf_dir_name, 1);
if (ret < 0)
goto error_free_buf_dir_name;
- scan_size = size_from_channelarray(infoarray, num_channels);
+ scan_size = size_from_channelarray(channels, num_channels);
data = malloc(scan_size*buf_len);
if (!data) {
ret = -ENOMEM;
@@ -269,7 +270,7 @@ int main(int argc, char **argv)
/* Attempt to open non blocking the access dev */
fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
- if (fp == -1) { /*If it isn't there make the node */
+ if (fp == -1) { /* If it isn't there make the node */
printf("Failed to open %s\n", buffer_access);
ret = -errno;
goto error_free_buffer_access;
@@ -300,16 +301,16 @@ int main(int argc, char **argv)
}
for (i = 0; i < read_size/scan_size; i++)
process_scan(data + scan_size*i,
- infoarray,
+ channels,
num_channels);
}
- /* Stop the ring buffer */
+ /* Stop the buffer */
ret = write_sysfs_int("enable", buf_dir_name, 0);
if (ret < 0)
goto error_close_buffer_access;
- /* Disconnect from the trigger - just write a dummy name.*/
+ /* Disconnect the trigger - just write a dummy name. */
write_sysfs_string("trigger/current_trigger",
dev_dir_name, "NULL");
diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c
index 22275845fb12..3a9b00087403 100644
--- a/drivers/staging/iio/Documentation/iio_event_monitor.c
+++ b/drivers/staging/iio/Documentation/iio_event_monitor.c
@@ -45,6 +45,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_ANGL] = "angl",
[IIO_TIMESTAMP] = "timestamp",
[IIO_CAPACITANCE] = "capacitance",
+ [IIO_ALTVOLTAGE] = "altvoltage",
};
static const char * const iio_ev_type_text[] = {
@@ -67,6 +68,12 @@ static const char * const iio_modifier_names[] = {
[IIO_MOD_Z] = "z",
[IIO_MOD_LIGHT_BOTH] = "both",
[IIO_MOD_LIGHT_IR] = "ir",
+ [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
+ [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
+ [IIO_MOD_LIGHT_CLEAR] = "clear",
+ [IIO_MOD_LIGHT_RED] = "red",
+ [IIO_MOD_LIGHT_GREEN] = "green",
+ [IIO_MOD_LIGHT_BLUE] = "blue",
};
static bool event_is_known(struct iio_event_data *event)
@@ -92,6 +99,7 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_ANGL:
case IIO_TIMESTAMP:
case IIO_CAPACITANCE:
+ case IIO_ALTVOLTAGE:
break;
default:
return false;
@@ -104,6 +112,12 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_MOD_Z:
case IIO_MOD_LIGHT_BOTH:
case IIO_MOD_LIGHT_IR:
+ case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
+ case IIO_MOD_SUM_SQUARED_X_Y_Z:
+ case IIO_MOD_LIGHT_CLEAR:
+ case IIO_MOD_LIGHT_RED:
+ case IIO_MOD_LIGHT_GREEN:
+ case IIO_MOD_LIGHT_BLUE:
break;
default:
return false;
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index 6f3a392297ec..cf32ae099cd6 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -7,14 +7,15 @@
* the Free Software Foundation.
*/
-/* Made up value to limit allocation sizes */
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdint.h>
#include <dirent.h>
+#include <errno.h>
+/* Made up value to limit allocation sizes */
#define IIO_MAX_NAME_LENGTH 30
#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
@@ -27,7 +28,7 @@ const char *iio_dir = "/sys/bus/iio/devices/";
* @full_name: the full channel name
* @generic_name: the output generic channel name
**/
-static int iioutils_break_up_name(const char *full_name,
+inline int iioutils_break_up_name(const char *full_name,
char **generic_name)
{
char *current;
@@ -157,7 +158,8 @@ inline int iioutils_get_type(unsigned *is_signed,
&padint, shift);
if (ret < 0) {
printf("failed to pass scan type description\n");
- return ret;
+ ret = -errno;
+ goto error_close_sysfsfp;
}
*be = (endianchar == 'b');
*bytes = padint / 8;
@@ -173,7 +175,11 @@ inline int iioutils_get_type(unsigned *is_signed,
free(filename);
filename = 0;
+ sysfsfp = 0;
}
+error_close_sysfsfp:
+ if (sysfsfp)
+ fclose(sysfsfp);
error_free_filename:
if (filename)
free(filename);
@@ -280,7 +286,7 @@ inline int build_channel_array(const char *device_dir,
{
DIR *dp;
FILE *sysfsfp;
- int count, temp, i;
+ int count, i;
struct iio_channel_info *current;
int ret;
const struct dirent *ent;
@@ -447,7 +453,7 @@ inline int find_type_by_name(const char *name, const char *type)
dp = opendir(iio_dir);
if (dp == NULL) {
- printf("No industrialio devices available");
+ printf("No industrialio devices available\n");
return -ENODEV;
}
@@ -467,23 +473,30 @@ inline int find_type_by_name(const char *name, const char *type)
+ strlen(type)
+ numstrlen
+ 6);
- if (filename == NULL)
+ if (filename == NULL) {
+ closedir(dp);
return -ENOMEM;
+ }
sprintf(filename, "%s%s%d/name",
iio_dir,
type,
number);
nameFile = fopen(filename, "r");
- if (!nameFile)
+ if (!nameFile) {
+ free(filename);
continue;
+ }
free(filename);
fscanf(nameFile, "%s", thisname);
- if (strcmp(name, thisname) == 0)
- return number;
fclose(nameFile);
+ if (strcmp(name, thisname) == 0) {
+ closedir(dp);
+ return number;
+ }
}
}
}
+ closedir(dp);
return -ENODEV;
}
@@ -512,6 +525,7 @@ inline int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
goto error_free;
}
fscanf(sysfsfp, "%d", &test);
+ fclose(sysfsfp);
if (test != val) {
printf("Possible failure in int write %d to %s%s\n",
val,
@@ -561,6 +575,7 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify)
goto error_free;
}
fscanf(sysfsfp, "%s", temp);
+ fclose(sysfsfp);
if (strcmp(temp, val) != 0) {
printf("Possible failure in string write of %s "
"Should be %s "
diff --git a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
index 470f7ad9c073..470f7ad9c073 100755..100644
--- a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
+++ b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
diff --git a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x
index b2798b258bf7..b2798b258bf7 100755..100644
--- a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x
+++ b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x
diff --git a/drivers/staging/iio/Documentation/overview.txt b/drivers/staging/iio/Documentation/overview.txt
index afc39ecde9ca..43f92b06bc3e 100644
--- a/drivers/staging/iio/Documentation/overview.txt
+++ b/drivers/staging/iio/Documentation/overview.txt
@@ -8,7 +8,7 @@ actual devices combine some ADCs with digital to analog converters
The aim is to fill the gap between the somewhat similar hwmon and
input subsystems. Hwmon is very much directed at low sample rate
sensors used in applications such as fan speed control and temperature
-measurement. Input is, as it's name suggests focused on input
+measurement. Input is, as its name suggests focused on input
devices. In some cases there is considerable overlap between these and
IIO.
diff --git a/drivers/staging/iio/Documentation/ring.txt b/drivers/staging/iio/Documentation/ring.txt
index e33807761cd7..e1da43381d0e 100644
--- a/drivers/staging/iio/Documentation/ring.txt
+++ b/drivers/staging/iio/Documentation/ring.txt
@@ -15,8 +15,8 @@ struct iio_ring_buffer contains a struct iio_ring_setup_ops *setup_ops
which in turn contains the 4 function pointers
(preenable, postenable, predisable and postdisable).
These are used to perform device specific steps on either side
-of the core changing it's current mode to indicate that the buffer
-is enabled or disabled (along with enabling triggering etc as appropriate).
+of the core changing its current mode to indicate that the buffer
+is enabled or disabled (along with enabling triggering etc. as appropriate).
Also in struct iio_ring_buffer is a struct iio_ring_access_funcs.
The function pointers within here are used to allow the core to handle
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-light b/drivers/staging/iio/Documentation/sysfs-bus-iio-light
index 715c74dcb53a..17e5c9c515d4 100644
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio-light
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-light
@@ -34,7 +34,7 @@ Description:
it comes back in SI units, it should also include _input else it
should include _raw to signify it is not in SI units.
-What: /sys/.../device[n]/proximity_on_chip_ambient_infrared_supression
+What: /sys/.../device[n]/proximity_on_chip_ambient_infrared_suppression
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
@@ -82,3 +82,26 @@ Contact: linux-iio@vger.kernel.org
Description:
This property gets/sets the table of coefficients
used in calculating illuminance in lux.
+
+What: /sys/bus/iio/devices/device[n]/in_intensity_clear[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_intensity_red[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_intensity_green[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_intensity_blue[_input|_raw]
+KernelVersion: 3.6.0
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property is supported by sensors that have a RGBC
+ sensing mode. This value should be the output from a reading
+ and if expressed in SI units, should include _input. If this
+ value is not in SI units (irradiance, uW/mm^2), then it should
+ include _raw.
+
+What: /sys/bus/iio/devices/device[n]/in_cct0[_input|_raw]
+KernelVersion: 3.6.0
+Contact: linux-iio@vger.kernel.org
+Description:
+ This should return the correlated color temperature from the
+ light sensor. If it comes back in SI units, it should also
+ include _input else it should include _raw to signify it is not
+ in SI units.
+