Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 268167
b: refs/heads/master
c: 330c6c5
h: refs/heads/master
i:
  268165: 60ab407
  268163: f4e6136
  268159: b1258fa
v: v3
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Sep 6, 2011
1 parent 09732e4 commit 8734094
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 99 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 32b5eecab0f2d6f66f2e237e161d58d5916f8b13
refs/heads/master: 330c6c57e6284a755d7e8a031b3c917571ee6dc3
8 changes: 4 additions & 4 deletions trunk/drivers/staging/iio/accel/lis3l02dq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ static u8 lis3l02dq_axis_map[3][3] = {
};

static int lis3l02dq_read_thresh(struct iio_dev *indio_dev,
int e,
u64 e,
int *val)
{
return lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val);
}

static int lis3l02dq_write_thresh(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int val)
{
u16 value = val;
Expand Down Expand Up @@ -534,7 +534,7 @@ static struct iio_chan_spec lis3l02dq_channels[] = {


static ssize_t lis3l02dq_read_event_config(struct iio_dev *indio_dev,
int event_code)
u64 event_code)
{

u8 val;
Expand Down Expand Up @@ -586,7 +586,7 @@ int lis3l02dq_disable_all_events(struct iio_dev *indio_dev)
}

static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int state)
{
int ret = 0;
Expand Down
10 changes: 5 additions & 5 deletions trunk/drivers/staging/iio/accel/sca3000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ static IIO_CONST_ATTR_TEMP_OFFSET("-214.6");
* sca3000_read_thresh() - query of a threshold
**/
static int sca3000_read_thresh(struct iio_dev *indio_dev,
int e,
u64 e,
int *val)
{
int ret, i;
Expand Down Expand Up @@ -723,8 +723,8 @@ static int sca3000_read_thresh(struct iio_dev *indio_dev,
* sca3000_write_thresh() control of threshold
**/
static int sca3000_write_thresh(struct iio_dev *indio_dev,
int e,
int val)
u64 e,
int val)
{
struct sca3000_state *st = iio_priv(indio_dev);
int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
Expand Down Expand Up @@ -858,7 +858,7 @@ static irqreturn_t sca3000_event_handler(int irq, void *private)
* sca3000_read_event_config() what events are enabled
**/
static int sca3000_read_event_config(struct iio_dev *indio_dev,
int e)
u64 e)
{
struct sca3000_state *st = iio_priv(indio_dev);
int ret;
Expand Down Expand Up @@ -961,7 +961,7 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
* this mode is disabled. Currently normal mode is assumed.
**/
static int sca3000_write_event_config(struct iio_dev *indio_dev,
int e,
u64 e,
int state)
{
struct sca3000_state *st = iio_priv(indio_dev);
Expand Down
10 changes: 5 additions & 5 deletions trunk/drivers/staging/iio/adc/max1363_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static IIO_CONST_ATTR(sampling_frequency_available,
"133000 665000 33300 16600 8300 4200 2000 1000");

static int max1363_read_thresh(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int *val)
{
struct max1363_state *st = iio_priv(indio_dev);
Expand All @@ -565,7 +565,7 @@ static int max1363_read_thresh(struct iio_dev *indio_dev,
}

static int max1363_write_thresh(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int val)
{
struct max1363_state *st = iio_priv(indio_dev);
Expand Down Expand Up @@ -593,7 +593,7 @@ static int max1363_write_thresh(struct iio_dev *indio_dev,
return 0;
}

static const int max1363_event_codes[] = {
static const u64 max1363_event_codes[] = {
IIO_UNMOD_EVENT_CODE(IIO_IN, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
Expand Down Expand Up @@ -624,7 +624,7 @@ static irqreturn_t max1363_event_handler(int irq, void *private)
}

static int max1363_read_event_config(struct iio_dev *indio_dev,
int event_code)
u64 event_code)
{
struct max1363_state *st = iio_priv(indio_dev);

Expand Down Expand Up @@ -776,7 +776,7 @@ static inline int __max1363_check_event_mask(int thismask, int checkmask)
}

static int max1363_write_event_config(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int state)
{
int ret = 0;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/staging/iio/chrdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* the interrupt handler)
*/
struct iio_event_data {
int id;
u64 id;
s64 timestamp;
};

Expand Down
39 changes: 21 additions & 18 deletions trunk/drivers/staging/iio/iio.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@ enum iio_chan_type {
#define IIO_IN IIO_VOLTAGE
#define IIO_IN_DIFF IIO_VOLTAGE_DIFF

#define IIO_MOD_X 0
#define IIO_MOD_LIGHT_BOTH 0
#define IIO_MOD_Y 1
#define IIO_MOD_LIGHT_IR 1
#define IIO_MOD_Z 2
#define IIO_MOD_X_AND_Y 3
#define IIO_MOD_X_ANX_Z 4
#define IIO_MOD_Y_AND_Z 5
#define IIO_MOD_X_AND_Y_AND_Z 6
#define IIO_MOD_X_OR_Y 7
#define IIO_MOD_X_OR_Z 8
#define IIO_MOD_Y_OR_Z 9
#define IIO_MOD_X_OR_Y_OR_Z 10
enum iio_modifier {
IIO_NO_MOD,
IIO_MOD_X,
IIO_MOD_Y,
IIO_MOD_Z,
IIO_MOD_X_AND_Y,
IIO_MOD_X_ANX_Z,
IIO_MOD_Y_AND_Z,
IIO_MOD_X_AND_Y_AND_Z,
IIO_MOD_X_OR_Y,
IIO_MOD_X_OR_Z,
IIO_MOD_Y_OR_Z,
IIO_MOD_X_OR_Y_OR_Z,
IIO_MOD_LIGHT_BOTH,
IIO_MOD_LIGHT_IR,
};

/* Could add the raw attributes as well - allowing buffer only devices */
enum iio_chan_info_enum {
Expand Down Expand Up @@ -243,17 +246,17 @@ struct iio_info {
long mask);

int (*read_event_config)(struct iio_dev *indio_dev,
int event_code);
u64 event_code);

int (*write_event_config)(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int state);

int (*read_event_value)(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int *val);
int (*write_event_value)(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int val);
int (*validate_trigger)(struct iio_dev *indio_dev,
struct iio_trigger *trig);
Expand Down Expand Up @@ -328,7 +331,7 @@ void iio_device_unregister(struct iio_dev *dev_info);
* @ev_code: What event
* @timestamp: When the event occurred
**/
int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp);
int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp);

extern struct bus_type iio_bus_type;

Expand Down
59 changes: 16 additions & 43 deletions trunk/drivers/staging/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,12 @@ static const char * const iio_chan_type_name_spec_complex[] = {
[IIO_VOLTAGE_DIFF] = "voltage%d-voltage%d",
};

static const char * const iio_modifier_names_light[] = {
[IIO_MOD_LIGHT_BOTH] = "both",
[IIO_MOD_LIGHT_IR] = "ir",
};

static const char * const iio_modifier_names_axial[] = {
static const char * const iio_modifier_names[] = {
[IIO_MOD_X] = "x",
[IIO_MOD_Y] = "y",
[IIO_MOD_Z] = "z",
[IIO_MOD_LIGHT_BOTH] = "both",
[IIO_MOD_LIGHT_IR] = "ir",
};

/* relies on pairs of these shared then separate */
Expand Down Expand Up @@ -124,7 +121,7 @@ struct iio_event_interface {
unsigned long flags;
};

int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp)
int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp)
{
struct iio_event_interface *ev_int = dev_info->event_interface;
struct iio_detected_event_list *ev;
Expand Down Expand Up @@ -409,32 +406,14 @@ static int __iio_build_postfix(struct iio_chan_spec const *chan,
if (generic || (!chan->modified && !chan->extend_name)) {
all_post = kasprintf(GFP_KERNEL, "%s", postfix);
} else if (chan->modified) {
const char *intermediate;
switch (chan->type) {
case IIO_INTENSITY:
intermediate
= iio_modifier_names_light[chan->channel2];
break;
case IIO_ACCEL:
case IIO_GYRO:
case IIO_MAGN:
case IIO_INCLI:
case IIO_ROT:
case IIO_ANGL:
intermediate
= iio_modifier_names_axial[chan->channel2];
break;
default:
return -EINVAL;
}
if (chan->extend_name)
all_post = kasprintf(GFP_KERNEL, "%s_%s_%s",
intermediate,
iio_modifier_names[chan->channel2],
chan->extend_name,
postfix);
else
all_post = kasprintf(GFP_KERNEL, "%s_%s",
intermediate,
iio_modifier_names[chan->channel2],
postfix);
} else
all_post = kasprintf(GFP_KERNEL, "%s_%s", chan->extend_name,
Expand Down Expand Up @@ -824,28 +803,22 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
ret = -ENOMEM;
goto error_ret;
}
switch (chan->type) {
/* Switch this to a table at some point */
case IIO_VOLTAGE:
mask = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel,
i/IIO_EV_TYPE_MAX,
i%IIO_EV_TYPE_MAX);
break;
case IIO_ACCEL:
if (chan->modified)
mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel,
i/IIO_EV_TYPE_MAX,
i%IIO_EV_TYPE_MAX);
break;
case IIO_VOLTAGE_DIFF:
mask = IIO_MOD_EVENT_CODE(chan->type, chan->channel,
else if (chan->type == IIO_VOLTAGE_DIFF)
mask = IIO_MOD_EVENT_CODE(chan->type,
chan->channel,
chan->channel2,
i/IIO_EV_TYPE_MAX,
i%IIO_EV_TYPE_MAX);
break;
default:
printk(KERN_INFO "currently unhandled type of event\n");
continue;
}
else
mask = IIO_UNMOD_EVENT_CODE(chan->type,
chan->channel,
i/IIO_EV_TYPE_MAX,
i%IIO_EV_TYPE_MAX);

ret = __iio_add_chan_devattr(postfix,
"events",
chan,
Expand Down
12 changes: 6 additions & 6 deletions trunk/drivers/staging/iio/light/tsl2563.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ static const struct iio_chan_spec tsl2563_channels[] = {
};

static int tsl2563_read_thresh(struct iio_dev *indio_dev,
int event_code,
int *val)
u64 event_code,
int *val)
{
struct tsl2563_chip *chip = iio_priv(indio_dev);

Expand All @@ -569,7 +569,7 @@ static int tsl2563_read_thresh(struct iio_dev *indio_dev,
}

static ssize_t tsl2563_write_thresh(struct iio_dev *indio_dev,
int event_code,
u64 event_code,
int val)
{
struct tsl2563_chip *chip = iio_priv(indio_dev);
Expand Down Expand Up @@ -617,8 +617,8 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private)
}

static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
int event_code,
int state)
u64 event_code,
int state)
{
struct tsl2563_chip *chip = iio_priv(indio_dev);
int ret = 0;
Expand Down Expand Up @@ -659,7 +659,7 @@ static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
}

static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev,
int event_code)
u64 event_code)
{
struct tsl2563_chip *chip = iio_priv(indio_dev);
int ret;
Expand Down
36 changes: 20 additions & 16 deletions trunk/drivers/staging/iio/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,36 +114,40 @@ struct iio_const_attr {
#define IIO_CONST_ATTR_TEMP_SCALE(_string) \
IIO_CONST_ATTR(temp_scale, _string)

#define IIO_EV_TYPE_THRESH 0
#define IIO_EV_TYPE_MAG 1
#define IIO_EV_TYPE_ROC 2
enum iio_event_type {
IIO_EV_TYPE_THRESH,
IIO_EV_TYPE_MAG,
IIO_EV_TYPE_ROC,
};

enum iio_event_direction {
IIO_EV_DIR_EITHER,
IIO_EV_DIR_RISING,
IIO_EV_DIR_FALLING,
};

#define IIO_EV_DIR_EITHER 0
#define IIO_EV_DIR_RISING 1
#define IIO_EV_DIR_FALLING 2
#define IIO_EVENT_CODE(chan_type, modifier, direction, \
type, chan, chan1, chan2) \
(((u64)type << 56) | ((u64)direction << 48) | ((u64)modifier << 40) | \
((u64)chan_type << 32) | (chan2 << 16) | chan1 | chan)

#define IIO_EV_TYPE_MAX 8
#define IIO_EV_BIT(type, direction) \
(1 << (type*IIO_EV_TYPE_MAX + direction))

#define IIO_EVENT_CODE(channelclass, orient_bit, number, \
modifier, type, direction) \
(channelclass | (orient_bit << 8) | ((number) << 9) | \
((modifier) << 13) | ((type) << 16) | ((direction) << 24))

#define IIO_MOD_EVENT_CODE(channelclass, number, modifier, \
type, direction) \
IIO_EVENT_CODE(channelclass, 1, number, modifier, type, direction)
IIO_EVENT_CODE(channelclass, modifier, direction, type, number, 0, 0)

#define IIO_UNMOD_EVENT_CODE(channelclass, number, type, direction) \
IIO_EVENT_CODE(channelclass, 0, number, 0, type, direction)
IIO_EVENT_CODE(channelclass, 0, direction, type, number, 0, 0)

#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 24) & 0xf)
#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xFF)

/* Event code number extraction depends on which type of event we have.
* Perhaps review this function in the future*/
#define IIO_EVENT_CODE_EXTRACT_NUM(mask) ((mask >> 9) & 0x0f)
#define IIO_EVENT_CODE_EXTRACT_NUM(mask) (mask & 0xFFFF)

#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 13) & 0x7)
#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)

#endif /* _INDUSTRIAL_IO_SYSFS_H_ */

0 comments on commit 8734094

Please sign in to comment.