Commit f3fb0011 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

iio:staging:accelerometers move towards the new abi

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ff7723e2
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include "../sysfs.h" #include "../sysfs.h"
/* Accelerometer types of attribute */ /* Accelerometer types of attribute */
#define IIO_DEV_ATTR_ACCEL_X_OFFSET(_mode, _show, _store, _addr) \ #define IIO_DEV_ATTR_ACCEL_X_OFFSET(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(accel_x_offset, _mode, _show, _store, _addr) IIO_DEVICE_ATTR(accel_x_offset, _mode, _show, _store, _addr)
...@@ -22,13 +21,13 @@ ...@@ -22,13 +21,13 @@
IIO_DEVICE_ATTR(accel_z_gain, _mode, _show, _store, _addr) IIO_DEVICE_ATTR(accel_z_gain, _mode, _show, _store, _addr)
#define IIO_DEV_ATTR_ACCEL_X(_show, _addr) \ #define IIO_DEV_ATTR_ACCEL_X(_show, _addr) \
IIO_DEVICE_ATTR(accel_x, S_IRUGO, _show, NULL, _addr) IIO_DEVICE_ATTR(accel_x_raw, S_IRUGO, _show, NULL, _addr)
#define IIO_DEV_ATTR_ACCEL_Y(_show, _addr) \ #define IIO_DEV_ATTR_ACCEL_Y(_show, _addr) \
IIO_DEVICE_ATTR(accel_y, S_IRUGO, _show, NULL, _addr) IIO_DEVICE_ATTR(accel_y_raw, S_IRUGO, _show, NULL, _addr)
#define IIO_DEV_ATTR_ACCEL_Z(_show, _addr) \ #define IIO_DEV_ATTR_ACCEL_Z(_show, _addr) \
IIO_DEVICE_ATTR(accel_z, S_IRUGO, _show, NULL, _addr) IIO_DEVICE_ATTR(accel_z_raw, S_IRUGO, _show, NULL, _addr)
/* Thresholds are somewhat chip dependent - may need quite a few defs here */ /* Thresholds are somewhat chip dependent - may need quite a few defs here */
/* For unified thresholds (shared across all directions */ /* For unified thresholds (shared across all directions */
...@@ -61,7 +60,6 @@ ...@@ -61,7 +60,6 @@
#define IIO_DEV_ATTR_ACCEL_THRESH_Z(_mode, _show, _store, _addr) \ #define IIO_DEV_ATTR_ACCEL_THRESH_Z(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(thresh_accel_z, _mode, _show, _store, _addr) IIO_DEVICE_ATTR(thresh_accel_z, _mode, _show, _store, _addr)
/** /**
* IIO_EVENT_ATTR_ACCEL_X_HIGH: threshold event, x acceleration * IIO_EVENT_ATTR_ACCEL_X_HIGH: threshold event, x acceleration
* @_show: read x acceleration high threshold * @_show: read x acceleration high threshold
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h>
#include "../iio.h" #include "../iio.h"
#include "../sysfs.h" #include "../sysfs.h"
...@@ -51,8 +52,10 @@ ...@@ -51,8 +52,10 @@
#define KXSD9_READ(a) (0x80 | (a)) #define KXSD9_READ(a) (0x80 | (a))
#define KXSD9_WRITE(a) (a) #define KXSD9_WRITE(a) (a)
#define IIO_DEV_ATTR_ACCEL_SET_RANGE(_mode, _show, _store) \ #define KXSD9_SCALE_2G "0.011978"
IIO_DEVICE_ATTR(accel_range, _mode, _show, _store, 0) #define KXSD9_SCALE_4G "0.023927"
#define KXSD9_SCALE_6G "0.035934"
#define KXSD9_SCALE_8G "0.047853"
#define KXSD9_STATE_RX_SIZE 2 #define KXSD9_STATE_RX_SIZE 2
#define KXSD9_STATE_TX_SIZE 4 #define KXSD9_STATE_TX_SIZE 4
...@@ -73,7 +76,7 @@ struct kxsd9_state { ...@@ -73,7 +76,7 @@ struct kxsd9_state {
}; };
/* This may want to move to mili g to allow for non integer ranges */ /* This may want to move to mili g to allow for non integer ranges */
static ssize_t kxsd9_read_accel_range(struct device *dev, static ssize_t kxsd9_read_scale(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -101,16 +104,16 @@ static ssize_t kxsd9_read_accel_range(struct device *dev, ...@@ -101,16 +104,16 @@ static ssize_t kxsd9_read_accel_range(struct device *dev,
switch (st->rx[1] & KXSD9_FS_MASK) { switch (st->rx[1] & KXSD9_FS_MASK) {
case KXSD9_FS_8: case KXSD9_FS_8:
len += sprintf(buf, "8\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_8G);
break; break;
case KXSD9_FS_6: case KXSD9_FS_6:
len += sprintf(buf, "6\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_6G);
break; break;
case KXSD9_FS_4: case KXSD9_FS_4:
len += sprintf(buf, "4\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_4G);
break; break;
case KXSD9_FS_2: case KXSD9_FS_2:
len += sprintf(buf, "2\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_2G);
break; break;
} }
...@@ -119,12 +122,12 @@ static ssize_t kxsd9_read_accel_range(struct device *dev, ...@@ -119,12 +122,12 @@ static ssize_t kxsd9_read_accel_range(struct device *dev,
return ret ? ret : len; return ret ? ret : len;
} }
static ssize_t kxsd9_write_accel_range(struct device *dev, static ssize_t kxsd9_write_scale(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
long readin;
struct spi_message msg; struct spi_message msg;
int ret; int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev);
...@@ -145,25 +148,25 @@ static ssize_t kxsd9_write_accel_range(struct device *dev, ...@@ -145,25 +148,25 @@ static ssize_t kxsd9_write_accel_range(struct device *dev,
}, },
}; };
ret = strict_strtol(buf, 10, &readin); if (!strncmp(buf, KXSD9_SCALE_8G,
if (ret) strlen(buf) < strlen(KXSD9_SCALE_8G)
return ret; ? strlen(buf) : strlen(KXSD9_SCALE_8G)))
switch (readin) {
case 8:
val = KXSD9_FS_8; val = KXSD9_FS_8;
break; else if (!strncmp(buf, KXSD9_SCALE_6G,
case 6: strlen(buf) < strlen(KXSD9_SCALE_6G)
? strlen(buf) : strlen(KXSD9_SCALE_6G)))
val = KXSD9_FS_6; val = KXSD9_FS_6;
break; else if (!strncmp(buf, KXSD9_SCALE_4G,
case 4: strlen(buf) < strlen(KXSD9_SCALE_4G)
? strlen(buf) : strlen(KXSD9_SCALE_4G)))
val = KXSD9_FS_4; val = KXSD9_FS_4;
break; else if (!strncmp(buf, KXSD9_SCALE_2G,
case 2: strlen(buf) < strlen(KXSD9_SCALE_2G)
? strlen(buf) : strlen(KXSD9_SCALE_2G)))
val = KXSD9_FS_2; val = KXSD9_FS_2;
break; else
default:
return -EINVAL; return -EINVAL;
}
mutex_lock(&st->buf_lock); mutex_lock(&st->buf_lock);
st->tx[0] = KXSD9_READ(KXSD9_REG_CTRL_C); st->tx[0] = KXSD9_READ(KXSD9_REG_CTRL_C);
st->tx[1] = 0; st->tx[1] = 0;
...@@ -182,6 +185,7 @@ static ssize_t kxsd9_write_accel_range(struct device *dev, ...@@ -182,6 +185,7 @@ static ssize_t kxsd9_write_accel_range(struct device *dev,
mutex_unlock(&st->buf_lock); mutex_unlock(&st->buf_lock);
return ret ? ret : len; return ret ? ret : len;
} }
static ssize_t kxsd9_read_accel(struct device *dev, static ssize_t kxsd9_read_accel(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -227,17 +231,27 @@ static ssize_t kxsd9_read_accel(struct device *dev, ...@@ -227,17 +231,27 @@ static ssize_t kxsd9_read_accel(struct device *dev,
static IIO_DEV_ATTR_ACCEL_X(kxsd9_read_accel, KXSD9_REG_X); static IIO_DEV_ATTR_ACCEL_X(kxsd9_read_accel, KXSD9_REG_X);
static IIO_DEV_ATTR_ACCEL_Y(kxsd9_read_accel, KXSD9_REG_Y); static IIO_DEV_ATTR_ACCEL_Y(kxsd9_read_accel, KXSD9_REG_Y);
static IIO_DEV_ATTR_ACCEL_Z(kxsd9_read_accel, KXSD9_REG_Z); static IIO_DEV_ATTR_ACCEL_Z(kxsd9_read_accel, KXSD9_REG_Z);
static IIO_DEV_ATTR_ADC(0, kxsd9_read_accel, KXSD9_REG_AUX); static IIO_DEV_ATTR_IN_RAW(0, kxsd9_read_accel, KXSD9_REG_AUX);
static IIO_DEV_ATTR_ACCEL_SET_RANGE(S_IRUGO | S_IWUSR,
kxsd9_read_accel_range, static IIO_DEVICE_ATTR(accel_scale,
kxsd9_write_accel_range); S_IRUGO | S_IWUSR,
kxsd9_read_scale,
kxsd9_write_scale,
0);
static IIO_CONST_ATTR(accel_scale_available,
KXSD9_SCALE_2G " "
KXSD9_SCALE_4G " "
KXSD9_SCALE_6G " "
KXSD9_SCALE_8G);
static struct attribute *kxsd9_attributes[] = { static struct attribute *kxsd9_attributes[] = {
&iio_dev_attr_accel_x.dev_attr.attr, &iio_dev_attr_accel_x_raw.dev_attr.attr,
&iio_dev_attr_accel_y.dev_attr.attr, &iio_dev_attr_accel_y_raw.dev_attr.attr,
&iio_dev_attr_accel_z.dev_attr.attr, &iio_dev_attr_accel_z_raw.dev_attr.attr,
&iio_dev_attr_adc_0.dev_attr.attr, &iio_dev_attr_in0_raw.dev_attr.attr,
&iio_dev_attr_accel_range.dev_attr.attr, &iio_dev_attr_accel_scale.dev_attr.attr,
&iio_const_attr_accel_scale_available.dev_attr.attr,
NULL, NULL,
}; };
......
...@@ -179,10 +179,6 @@ int lis3l02dq_spi_read_reg_8(struct device *dev, ...@@ -179,10 +179,6 @@ int lis3l02dq_spi_read_reg_8(struct device *dev,
int lis3l02dq_spi_write_reg_8(struct device *dev, int lis3l02dq_spi_write_reg_8(struct device *dev,
u8 reg_address, u8 reg_address,
u8 *val); u8 *val);
#define LIS3L02DQ_SCAN_ACC_X 0
#define LIS3L02DQ_SCAN_ACC_Y 1
#define LIS3L02DQ_SCAN_ACC_Z 2
#ifdef CONFIG_IIO_RING_BUFFER #ifdef CONFIG_IIO_RING_BUFFER
/* At the moment triggers are only used for ring buffer /* At the moment triggers are only used for ring buffer
......
...@@ -458,41 +458,39 @@ static int lis3l02dq_initial_setup(struct lis3l02dq_state *st) ...@@ -458,41 +458,39 @@ static int lis3l02dq_initial_setup(struct lis3l02dq_state *st)
return ret; return ret;
} }
static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO, #define LIS3L02DQ_SIGNED_ATTR(name, reg) \
lis3l02dq_read_signed, IIO_DEVICE_ATTR(name, \
lis3l02dq_write_signed, S_IWUSR | S_IRUGO, \
lis3l02dq_read_signed, \
lis3l02dq_write_signed, \
reg);
#define LIS3L02DQ_UNSIGNED_ATTR(name, reg) \
IIO_DEVICE_ATTR(name, \
S_IWUSR | S_IRUGO, \
lis3l02dq_read_unsigned, \
lis3l02dq_write_unsigned, \
reg);
static LIS3L02DQ_SIGNED_ATTR(accel_x_calibbias,
LIS3L02DQ_REG_OFFSET_X_ADDR); LIS3L02DQ_REG_OFFSET_X_ADDR);
static LIS3L02DQ_SIGNED_ATTR(accel_y_calibbias,
static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
lis3l02dq_read_signed,
lis3l02dq_write_signed,
LIS3L02DQ_REG_OFFSET_Y_ADDR); LIS3L02DQ_REG_OFFSET_Y_ADDR);
static LIS3L02DQ_SIGNED_ATTR(accel_z_calibbias,
static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO,
lis3l02dq_read_signed,
lis3l02dq_write_signed,
LIS3L02DQ_REG_OFFSET_Z_ADDR); LIS3L02DQ_REG_OFFSET_Z_ADDR);
static IIO_DEV_ATTR_ACCEL_X_GAIN(S_IWUSR | S_IRUGO, static LIS3L02DQ_UNSIGNED_ATTR(accel_x_calibscale,
lis3l02dq_read_unsigned,
lis3l02dq_write_unsigned,
LIS3L02DQ_REG_GAIN_X_ADDR); LIS3L02DQ_REG_GAIN_X_ADDR);
static LIS3L02DQ_UNSIGNED_ATTR(accel_y_calibscale,
static IIO_DEV_ATTR_ACCEL_Y_GAIN(S_IWUSR | S_IRUGO,
lis3l02dq_read_unsigned,
lis3l02dq_write_unsigned,
LIS3L02DQ_REG_GAIN_Y_ADDR); LIS3L02DQ_REG_GAIN_Y_ADDR);
static LIS3L02DQ_UNSIGNED_ATTR(accel_z_calibscale,
static IIO_DEV_ATTR_ACCEL_Z_GAIN(S_IWUSR | S_IRUGO,
lis3l02dq_read_unsigned,
lis3l02dq_write_unsigned,
LIS3L02DQ_REG_GAIN_Z_ADDR); LIS3L02DQ_REG_GAIN_Z_ADDR);
static IIO_DEV_ATTR_ACCEL_THRESH(S_IWUSR | S_IRUGO, static IIO_DEVICE_ATTR(accel_mag_either_rising_value,
S_IWUSR | S_IRUGO,
lis3l02dq_read_16bit_signed, lis3l02dq_read_16bit_signed,
lis3l02dq_write_16bit_signed, lis3l02dq_write_16bit_signed,
LIS3L02DQ_REG_THS_L_ADDR); LIS3L02DQ_REG_THS_L_ADDR);
/* RFC The reading method for these will change depending on whether /* RFC The reading method for these will change depending on whether
* ring buffer capture is in use. Is it worth making these take two * ring buffer capture is in use. Is it worth making these take two
* functions and let the core handle which to call, or leave as in this * functions and let the core handle which to call, or leave as in this
...@@ -512,7 +510,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ...@@ -512,7 +510,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
lis3l02dq_read_frequency, lis3l02dq_read_frequency,
lis3l02dq_write_frequency); lis3l02dq_write_frequency);
static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("280 560 1120 4480"); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("280 560 1120 4480");
static ssize_t lis3l02dq_read_interrupt_config(struct device *dev, static ssize_t lis3l02dq_read_interrupt_config(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
...@@ -522,7 +520,7 @@ static ssize_t lis3l02dq_read_interrupt_config(struct device *dev, ...@@ -522,7 +520,7 @@ static ssize_t lis3l02dq_read_interrupt_config(struct device *dev,
s8 val; s8 val;
struct iio_event_attr *this_attr = to_iio_event_attr(attr); struct iio_event_attr *this_attr = to_iio_event_attr(attr);
ret = lis3l02dq_spi_read_reg_8(dev, ret = lis3l02dq_spi_read_reg_8(dev->parent,
LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
(u8 *)&val); (u8 *)&val);
...@@ -545,7 +543,7 @@ static ssize_t lis3l02dq_write_interrupt_config(struct device *dev, ...@@ -545,7 +543,7 @@ static ssize_t lis3l02dq_write_interrupt_config(struct device *dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
/* read current value */ /* read current value */
ret = lis3l02dq_spi_read_reg_8(dev, ret = lis3l02dq_spi_read_reg_8(dev->parent,
LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
&valold); &valold);
if (ret) if (ret)
...@@ -618,7 +616,7 @@ static int lis3l02dq_thresh_handler_th(struct iio_dev *dev_info, ...@@ -618,7 +616,7 @@ static int lis3l02dq_thresh_handler_th(struct iio_dev *dev_info,
static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s) static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s)
{ {
struct iio_work_cont *wc struct iio_work_cont *wc
= container_of(work_s, struct iio_work_cont, ws_nocheck); = container_of(work_s, struct iio_work_cont, ws);
struct lis3l02dq_state *st = wc->st; struct lis3l02dq_state *st = wc->st;
u8 t; u8 t;
...@@ -668,43 +666,51 @@ static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s) ...@@ -668,43 +666,51 @@ static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s)
/* A shared handler for a number of threshold types */ /* A shared handler for a number of threshold types */
IIO_EVENT_SH(threshold, &lis3l02dq_thresh_handler_th); IIO_EVENT_SH(threshold, &lis3l02dq_thresh_handler_th);
IIO_EVENT_ATTR_ACCEL_X_HIGH_SH(iio_event_threshold, IIO_EVENT_ATTR_SH(accel_x_mag_pos_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config, lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config, lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_HIGH); LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_HIGH);
IIO_EVENT_ATTR_ACCEL_Y_HIGH_SH(iio_event_threshold, IIO_EVENT_ATTR_SH(accel_y_mag_pos_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config, lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config, lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_HIGH); LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_HIGH);
IIO_EVENT_ATTR_ACCEL_Z_HIGH_SH(iio_event_threshold, IIO_EVENT_ATTR_SH(accel_z_mag_pos_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config, lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config, lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_HIGH); LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_HIGH);
IIO_EVENT_ATTR_ACCEL_X_LOW_SH(iio_event_threshold, IIO_EVENT_ATTR_SH(accel_x_mag_neg_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config, lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config, lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_LOW); LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_LOW);
IIO_EVENT_ATTR_ACCEL_Y_LOW_SH(iio_event_threshold, IIO_EVENT_ATTR_SH(accel_y_mag_neg_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config, lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config, lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_LOW); LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_LOW);
IIO_EVENT_ATTR_ACCEL_Z_LOW_SH(iio_event_threshold, IIO_EVENT_ATTR_SH(accel_z_mag_neg_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config, lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config, lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_LOW); LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_LOW);
static struct attribute *lis3l02dq_event_attributes[] = { static struct attribute *lis3l02dq_event_attributes[] = {
&iio_event_attr_accel_x_high.dev_attr.attr, &iio_event_attr_accel_x_mag_pos_rising_en.dev_attr.attr,
&iio_event_attr_accel_y_high.dev_attr.attr, &iio_event_attr_accel_y_mag_pos_rising_en.dev_attr.attr,
&iio_event_attr_accel_z_high.dev_attr.attr, &iio_event_attr_accel_z_mag_pos_rising_en.dev_attr.attr,
&iio_event_attr_accel_x_low.dev_attr.attr, &iio_event_attr_accel_x_mag_neg_rising_en.dev_attr.attr,
&iio_event_attr_accel_y_low.dev_attr.attr, &iio_event_attr_accel_y_mag_neg_rising_en.dev_attr.attr,
&iio_event_attr_accel_z_low.dev_attr.attr, &iio_event_attr_accel_z_mag_neg_rising_en.dev_attr.attr,
&iio_dev_attr_accel_mag_either_rising_value.dev_attr.attr,
NULL NULL
}; };
...@@ -713,20 +719,21 @@ static struct attribute_group lis3l02dq_event_attribute_group = { ...@@ -713,20 +719,21 @@ static struct attribute_group lis3l02dq_event_attribute_group = {
}; };
static IIO_CONST_ATTR(name, "lis3l02dq"); static IIO_CONST_ATTR(name, "lis3l02dq");
static IIO_CONST_ATTR(accel_scale, "0.00958");
static struct attribute *lis3l02dq_attributes[] = { static struct attribute *lis3l02dq_attributes[] = {
&iio_dev_attr_accel_x_offset.dev_attr.attr, &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
&iio_dev_attr_accel_y_offset.dev_attr.attr, &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
&iio_dev_attr_accel_z_offset.dev_attr.attr, &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
&iio_dev_attr_accel_x_gain.dev_attr.attr, &iio_dev_attr_accel_x_calibscale.dev_attr.attr,
&iio_dev_attr_accel_y_gain.dev_attr.attr, &iio_dev_attr_accel_y_calibscale.dev_attr.attr,
&iio_dev_attr_accel_z_gain.dev_attr.attr, &iio_dev_attr_accel_z_calibscale.dev_attr.attr,
&iio_dev_attr_thresh.dev_attr.attr, &iio_const_attr_accel_scale.dev_attr.attr,
&iio_dev_attr_accel_x.dev_attr.attr, &iio_dev_attr_accel_x_raw.dev_attr.attr,
&iio_dev_attr_accel_y.dev_attr.attr, &iio_dev_attr_accel_y_raw.dev_attr.attr,
&iio_dev_attr_accel_z.dev_attr.attr, &iio_dev_attr_accel_z_raw.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_const_attr_available_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_const_attr_name.dev_attr.attr, &iio_const_attr_name.dev_attr.attr,
NULL NULL
}; };
......
...@@ -75,16 +75,16 @@ static int lis3l02dq_scan_el_set_state(struct iio_scan_el *scan_el, ...@@ -75,16 +75,16 @@ static int lis3l02dq_scan_el_set_state(struct iio_scan_el *scan_el,
return ret; return ret;
} }
static IIO_SCAN_EL_C(accel_x, LIS3L02DQ_SCAN_ACC_X, IIO_SIGNED(16), static IIO_SCAN_EL_C(accel_x, 0, IIO_SIGNED(16),
LIS3L02DQ_REG_OUT_X_L_ADDR, LIS3L02DQ_REG_OUT_X_L_ADDR,
&lis3l02dq_scan_el_set_state); &lis3l02dq_scan_el_set_state);
static IIO_SCAN_EL_C(accel_y, LIS3L02DQ_SCAN_ACC_Y, IIO_SIGNED(16), static IIO_SCAN_EL_C(accel_y, 1, IIO_SIGNED(16),
LIS3L02DQ_REG_OUT_Y_L_ADDR, LIS3L02DQ_REG_OUT_Y_L_ADDR,
&lis3l02dq_scan_el_set_state); &lis3l02dq_scan_el_set_state);
static IIO_SCAN_EL_C(accel_z, LIS3L02DQ_SCAN_ACC_Z, IIO_SIGNED(16), static IIO_SCAN_EL_C(accel_z, 2, IIO_SIGNED(16),
LIS3L02DQ_REG_OUT_Z_L_ADDR, LIS3L02DQ_REG_OUT_Z_L_ADDR,
&lis3l02dq_scan_el_set_state); &lis3l02dq_scan_el_set_state);
static IIO_SCAN_EL_TIMESTAMP; static IIO_SCAN_EL_TIMESTAMP(3);
static struct attribute *lis3l02dq_scan_el_attrs[] = { static struct attribute *lis3l02dq_scan_el_attrs[] = {
&iio_scan_el_accel_x.dev_attr.attr, &iio_scan_el_accel_x.dev_attr.attr,
......
...@@ -187,6 +187,7 @@ struct sca3000_state { ...@@ -187,6 +187,7 @@ struct sca3000_state {
/** /**
* struct sca3000_chip_info - model dependant parameters * struct sca3000_chip_info - model dependant parameters
* @name: model identification * @name: model identification
* @scale: string containing floating point scale factor
* @temp_output: some devices have temperature sensors. * @temp_output: some devices have temperature sensors.
* @measurement_mode_freq: normal mode sampling frequency * @measurement_mode_freq: normal mode sampling frequency
* @option_mode_1: first optional mode. Not all models have one * @option_mode_1: first optional mode. Not all models have one
...@@ -199,6 +200,7 @@ struct sca3000_state { ...@@ -199,6 +200,7 @@ struct sca3000_state {
**/ **/
struct sca3000_chip_info { struct sca3000_chip_info {
const char *name; const char *name;
const char *scale;
bool temp_output; bool temp_output;
int measurement_mode_freq; int measurement_mode_freq;
int option_mode_1; int option_mode_1;
......
This diff is collapsed.
...@@ -186,11 +186,29 @@ static ssize_t sca3000_store_ring_bpse(struct device *dev, ...@@ -186,11 +186,29 @@ static ssize_t sca3000_store_ring_bpse(struct device *dev,
return ret ? ret : len; return ret ? ret : len;
} }
static IIO_CONST_ATTR(bpse_available, "8 11"); static IIO_SCAN_EL_C(accel_x, 0, 0, 0, 0);
static IIO_SCAN_EL_C(accel_y, 1, 0, 0, 0);
static IIO_DEV_ATTR_BPSE(S_IRUGO | S_IWUSR, static IIO_SCAN_EL_C(accel_z, 2, 0, 0, 0);
static IIO_CONST_ATTR(accel_precision_available, "8 11");
static IIO_DEVICE_ATTR(accel_precision,
S_IRUGO | S_IWUSR,
sca3000_show_ring_bpse, sca3000_show_ring_bpse,
sca3000_store_ring_bpse); sca3000_store_ring_bpse,
0);
static struct attribute *sca3000_scan_el_attrs[] = {
&iio_scan_el_accel_x.dev_attr.attr,
&iio_scan_el_accel_y.dev_attr.attr,
&iio_scan_el_accel_z.dev_attr.attr,
&iio_const_attr_accel_precision_available.dev_attr.attr,
&iio_dev_attr_accel_precision.dev_attr.attr,
NULL
};
static struct attribute_group sca3000_scan_el_group = {
.attrs = sca3000_scan_el_attrs,
.name = "scan_elements",
};
/* /*
* Ring buffer attributes * Ring buffer attributes
...@@ -198,17 +216,15 @@ static IIO_DEV_ATTR_BPSE(S_IRUGO | S_IWUSR, ...@@ -198,17 +216,15 @@ static IIO_DEV_ATTR_BPSE(S_IRUGO | S_IWUSR,
* only apply to the ring buffer. At all times full rate and accuracy * only apply to the ring buffer. At all times full rate and accuracy
* is available via direct reading from registers. * is available via direct reading from registers.
*/ */
static struct attribute *iio_ring_attributes[] = { static struct attribute *sca3000_ring_attributes[] = {
&dev_attr_length.attr, &dev_attr_length.attr,
&dev_attr_bps.attr, &dev_attr_bps.attr,
&dev_attr_ring_enable.attr, &dev_attr_ring_enable.attr,
&iio_dev_attr_bpse.dev_attr.attr,
&iio_const_attr_bpse_available.dev_attr.attr,
NULL, NULL,
}; };
static struct attribute_group sca3000_ring_attr = { static struct attribute_group sca3000_ring_attr = {
.attrs = iio_ring_attributes, .attrs = sca3000_ring_attributes,
}; };
static const struct attribute_group *sca3000_ring_attr_groups[] = { static const struct attribute_group *sca3000_ring_attr_groups[] = {
...@@ -248,6 +264,7 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r) ...@@ -248,6 +264,7 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r)
int sca3000_configure_ring(struct iio_dev *indio_dev) int sca3000_configure_ring(struct iio_dev *indio_dev)
{ {
indio_dev->scan_el_attrs = &sca3000_scan_el_group;
indio_dev->ring = sca3000_rb_allocate(indio_dev); indio_dev->ring = sca3000_rb_allocate(indio_dev);
if (indio_dev->ring == NULL) if (indio_dev->ring == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -248,9 +248,9 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, ...@@ -248,9 +248,9 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
* *
* Odd one out. Handled slightly differently from other scan elements. * Odd one out. Handled slightly differently from other scan elements.
**/ **/
#define IIO_SCAN_EL_TIMESTAMP \ #define IIO_SCAN_EL_TIMESTAMP(number) \
struct iio_scan_el iio_scan_el_timestamp = { \ struct iio_scan_el iio_scan_el_timestamp = { \
.dev_attr = __ATTR(scan_en_timestamp, \ .dev_attr = __ATTR(number##_timestamp_en, \
S_IRUGO | S_IWUSR, \ S_IRUGO | S_IWUSR, \
iio_scan_el_ts_show, \ iio_scan_el_ts_show, \
iio_scan_el_ts_store), \ iio_scan_el_ts_store), \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment