&t);
if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_HIGH)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_Z,
timestamp);
if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_LOW)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_Z,
timestamp);
if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_HIGH)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_Y,
timestamp);
if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_LOW)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_Y,
timestamp);
if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_HIGH)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_X,
timestamp);
if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_LOW)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_X,
};
static const struct iio_info lis3l02dq_info = {
- .num_interrupt_lines = 1,
.read_raw = &lis3l02dq_read_raw,
.write_raw = &lis3l02dq_write_raw,
.read_event_value = &lis3l02dq_read_thresh,
sca3000_ring_int_process(val, indio_dev->ring);
if (val & SCA3000_INT_STATUS_FREE_FALL)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_X_AND_Y_AND_Z,
last_timestamp);
if (val & SCA3000_INT_STATUS_Y_TRIGGER)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_Y,
last_timestamp);
if (val & SCA3000_INT_STATUS_X_TRIGGER)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_X,
last_timestamp);
if (val & SCA3000_INT_STATUS_Z_TRIGGER)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL,
0,
IIO_MOD_Z,
static const struct iio_info sca3000_info = {
.attrs = &sca3000_attribute_group,
.read_raw = &sca3000_read_raw,
- .num_interrupt_lines = 1,
.event_attrs = &sca3000_event_attribute_group,
.read_event_value = &sca3000_read_thresh,
.write_event_value = &sca3000_write_thresh,
ad7150_i2c_read(chip, AD7150_STATUS, &int_status, 1);
- if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1))
- iio_push_event(indio_dev, 0,
+ if ((int_status & AD7150_STATUS_OUT1) &&
+ !(chip->old_state & AD7150_STATUS_OUT1))
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
timestamp);
- else if ((!(int_status & AD7150_STATUS_OUT1)) && (chip->old_state & AD7150_STATUS_OUT1))
- iio_push_event(indio_dev, 0,
+ else if ((!(int_status & AD7150_STATUS_OUT1)) &&
+ (chip->old_state & AD7150_STATUS_OUT1))
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
timestamp);
- if ((int_status & AD7150_STATUS_OUT2) && !(chip->old_state & AD7150_STATUS_OUT2))
- iio_push_event(indio_dev, 0,
+ if ((int_status & AD7150_STATUS_OUT2) &&
+ !(chip->old_state & AD7150_STATUS_OUT2))
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN,
1,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
timestamp);
- else if ((!(int_status & AD7150_STATUS_OUT2)) && (chip->old_state & AD7150_STATUS_OUT2))
- iio_push_event(indio_dev, 0,
+ else if ((!(int_status & AD7150_STATUS_OUT2)) &&
+ (chip->old_state & AD7150_STATUS_OUT2))
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN,
1,
IIO_EV_TYPE_THRESH,
static const struct iio_info ad7150_info = {
.attrs = &ad7150_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &ad7150_event_attribute_group,
.driver_module = THIS_MODULE,
};
if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
if (((channels[i] >> 11) & 0xFFF) >=
st->cell_threshhigh)
- iio_push_event(dev_info, 0,
+ iio_push_event(dev_info,
IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF,
0,
IIO_EV_TYPE_THRESH,
iio_get_time_ns());
else if (((channels[i] >> 11) & 0xFFF) <=
st->cell_threshlow)
- iio_push_event(dev_info, 0,
+ iio_push_event(dev_info,
IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF,
0,
IIO_EV_TYPE_THRESH,
iio_get_time_ns());
} else {
if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
- iio_push_event(dev_info, 0,
+ iio_push_event(dev_info,
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
0,
IIO_EV_TYPE_THRESH,
iio_get_time_ns());
else if (((channels[i] >> 11) & 0xFFF) <=
st->aux_threshlow)
- iio_push_event(dev_info, 0,
+ iio_push_event(dev_info,
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
0,
IIO_EV_TYPE_THRESH,
static const struct iio_info ad7280_info = {
.read_raw = &ad7280_read_raw,
- .num_interrupt_lines = 1,
.event_attrs = &ad7280_event_attrs_group,
.attrs = &ad7280_attrs_group,
.driver_module = THIS_MODULE,
ad7291_i2c_write(chip, AD7291_COMMAND, command);
if (t_status & (1 << 0))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
timestamp);
if (t_status & (1 << 1))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
timestamp);
if (t_status & (1 << 2))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
timestamp);
if (t_status & (1 << 3))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
0,
IIO_EV_TYPE_THRESH,
for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) {
if (v_status & (1 << i))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN,
i/2,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
timestamp);
if (v_status & (1 << (i + 1)))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN,
i/2,
IIO_EV_TYPE_THRESH,
static const struct iio_info ad7291_info = {
.attrs = &ad7291_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &ad7291_event_attribute_group,
};
ad774x_i2c_read(chip, AD774X_STATUS, &int_status, 1);
if (int_status & AD774X_STATUS_RDYCAP)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_EVENT_CODE_CAP_RDY,
iio_get_time_ns());
if (int_status & AD774X_STATUS_RDYVT)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_EVENT_CODE_VT_RDY,
iio_get_time_ns());
static const struct iio_info ad774x_info = {
.attrs = &ad774x_event_attribute_group,
.event_attrs = &ad774x_event_attribute_group,
- .num_interrupt_lines = 1,
.driver_module = THIS_MODULE,
};
/*
static irqreturn_t ad7816_event_handler(int irq, void *private)
{
- iio_push_event(private, 0,
- IIO_EVENT_CODE_AD7816_OTI,
- iio_get_time_ns());
+ iio_push_event(private, IIO_EVENT_CODE_AD7816_OTI, iio_get_time_ns());
return IRQ_HANDLED;
}
static const struct iio_info ad7816_info = {
.attrs = &ad7816_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &ad7816_event_attribute_group,
.driver_module = THIS_MODULE,
};
for (i = 0; i < 8; i++) {
if (status & (1 << i))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
i & 0x1 ?
IIO_UNMOD_EVENT_CODE(IIO_IN,
(i >> 1),
static const struct iio_info ad7992_info = {
.read_raw = &ad799x_read_raw,
- .num_interrupt_lines = 1,
.event_attrs = &ad7992_event_attrs_group,
.driver_module = THIS_MODULE,
};
static const struct iio_info ad7993_4_7_8_info = {
.read_raw = &ad799x_read_raw,
- .num_interrupt_lines = 1,
.event_attrs = &ad7993_4_7_8_event_attrs_group,
.driver_module = THIS_MODULE,
};
return ret;
if (status & ADT7310_STAT_T_HIGH)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
timestamp);
if (status & ADT7310_STAT_T_LOW)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
timestamp);
if (status & ADT7310_STAT_T_CRIT)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
static const struct iio_info adt7310_info = {
.attrs = &adt7310_attribute_group,
- .num_interrupt_lines = ADT7310_IRQS,
.event_attrs = adt7310_event_attribute_group,
.driver_module = THIS_MODULE,
};
return IRQ_HANDLED;
if (status & ADT7410_STAT_T_HIGH)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
timestamp);
if (status & ADT7410_STAT_T_LOW)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
timestamp);
if (status & ADT7410_STAT_T_CRIT)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
static const struct iio_info adt7410_info = {
.attrs = &adt7410_attribute_group,
- .num_interrupt_lines = ADT7410_IRQS,
.event_attrs = adt7410_event_attribute_group,
.driver_module = THIS_MODULE,
};
static irqreturn_t adt75_event_handler(int irq, void *private)
{
- iio_push_event(private, 0,
+ iio_push_event(private,
IIO_EVENT_CODE_ADT75_OTI,
iio_get_time_ns());
static const struct iio_info adt75_info = {
.attrs = &adt75_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &adt75_event_attribute_group,
.driver_module = THIS_MODULE,
};
i2c_master_recv(st->client, &rx, 1);
mask = rx;
for_each_set_bit(loc, &mask, 8)
- iio_push_event(indio_dev, 0, max1363_event_codes[loc],
- timestamp);
+ iio_push_event(indio_dev, max1363_event_codes[loc], timestamp);
i2c_master_send(st->client, tx, 2);
return IRQ_HANDLED;
.write_event_config = &max1363_write_event_config,
.read_raw = &max1363_read_raw,
.driver_module = THIS_MODULE,
- .num_interrupt_lines = 1,
.event_attrs = &max1363_event_attribute_group,
};
time = iio_get_time_ns();
if (stat1 & (1 << 0))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
time);
if (stat1 & (1 << 1))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
time);
if (stat1 & (1 << 2))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
time);
if (stat1 & (1 << 3))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
time);
if (stat1 & (1 << 5))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN, 1,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_EITHER),
time);
if (stat1 & (1 << 6))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN, 2,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_EITHER),
time);
if (stat1 & (1 << 7))
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN, 3,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_EITHER),
ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT2, &stat2);
if (!ret) {
if (stat2 & ADT7316_INT_MASK2_VDD)
- iio_push_event(indio_dev, 0,
+ iio_push_event(indio_dev,
IIO_UNMOD_EVENT_CODE(IIO_IN,
0,
IIO_EV_TYPE_THRESH,
static const struct iio_info adt7316_info = {
.attrs = &adt7316_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &adt7316_event_attribute_group,
.driver_module = THIS_MODULE,
};
static const struct iio_info adt7516_info = {
.attrs = &adt7516_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &adt7516_event_attribute_group,
.driver_module = THIS_MODULE,
};
static irqreturn_t ad5504_event_handler(int irq, void *private)
{
- iio_push_event(private, 0,
+ iio_push_event(private,
IIO_UNMOD_EVENT_CODE(IIO_TEMP,
0,
IIO_EV_TYPE_THRESH,
static const struct iio_info ad5504_info = {
.attrs = &ad5504_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &ad5504_ev_attribute_group,
.driver_module = THIS_MODULE,
};
static const struct iio_info ad5501_info = {
.attrs = &ad5501_attribute_group,
- .num_interrupt_lines = 1,
.event_attrs = &ad5504_ev_attribute_group,
.driver_module = THIS_MODULE,
};
* struct iio_info - constant information about device
* @driver_module: module structure used to ensure correct
* ownership of chrdevs etc
- * @num_interrupt_lines:number of physical interrupt lines from device
* @event_attrs: event control attributes
* @attrs: general purpose device attributes
* @read_raw: function to request a value from the device.
**/
struct iio_info {
struct module *driver_module;
- int num_interrupt_lines;
struct attribute_group *event_attrs;
const struct attribute_group *attrs;
* @currentmode: [DRIVER] current operating mode
* @dev: [DRIVER] device structure, should be assigned a parent
* and owner
- * @event_interfaces: [INTERN] event chrdevs associated with interrupt lines
+ * @event_interface: [INTERN] event chrdevs associated with interrupt lines
* @ring: [DRIVER] any ring buffer present
* @mlock: [INTERN] lock used to prevent simultaneous device state
* changes
int currentmode;
struct device dev;
- struct iio_event_interface *event_interfaces;
+ struct iio_event_interface *event_interface;
struct iio_ring_buffer *ring;
struct mutex mlock;
* @ev_code: What event
* @timestamp: When the event occurred
**/
-int iio_push_event(struct iio_dev *dev_info,
- int ev_line,
- int ev_code,
- s64 timestamp);
+int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp);
extern struct bus_type iio_bus_type;
unsigned long flags;
};
-int iio_push_event(struct iio_dev *dev_info,
- int ev_line,
- int ev_code,
- s64 timestamp)
+int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp)
{
- struct iio_event_interface *ev_int
- = &dev_info->event_interfaces[ev_line];
+ struct iio_event_interface *ev_int = dev_info->event_interface;
struct iio_detected_event_list *ev;
int ret = 0;
static int iio_event_getfd(struct iio_dev *indio_dev)
{
- if (indio_dev->event_interfaces == NULL)
+ if (indio_dev->event_interface == NULL)
return -ENODEV;
- mutex_lock(&indio_dev->event_interfaces->event_list_lock);
+ mutex_lock(&indio_dev->event_interface->event_list_lock);
if (test_and_set_bit(IIO_BUSY_BIT_POS,
- &indio_dev->event_interfaces->flags)) {
- mutex_unlock(&indio_dev->event_interfaces->event_list_lock);
+ &indio_dev->event_interface->flags)) {
+ mutex_unlock(&indio_dev->event_interface->event_list_lock);
return -EBUSY;
}
- mutex_unlock(&indio_dev->event_interfaces->event_list_lock);
+ mutex_unlock(&indio_dev->event_interface->event_list_lock);
return anon_inode_getfd("iio:event",
&iio_event_chrdev_fileops,
- &indio_dev->event_interfaces[0], O_RDONLY);
+ indio_dev->event_interface, O_RDONLY);
}
static void iio_setup_ev_int(struct iio_event_interface *ev_int)
&iio_ev_state_show,
iio_ev_state_store,
mask,
- /*HACK. - limits us to one
- event interface - fix by
- extending the bitmask - but
- how far*/
0,
&dev_info->dev,
- &dev_info->event_interfaces[0].
+ &dev_info->event_interface->
dev_attr_list);
kfree(postfix);
if (ret)
mask,
0,
&dev_info->dev,
- &dev_info->event_interfaces[0]
- .dev_attr_list);
+ &dev_info->event_interface->
+ dev_attr_list);
kfree(postfix);
if (ret)
goto error_ret;
return ret;
}
-static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info,
- int i)
+static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info)
{
struct iio_dev_attr *p, *n;
list_for_each_entry_safe(p, n,
- &dev_info->event_interfaces[i].
+ &dev_info->event_interface->
dev_attr_list, l) {
sysfs_remove_file_from_group(&dev_info->dev.kobj,
&p->dev_attr.attr,
}
}
-static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info, int i)
+static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info)
{
int j;
int ret;
- INIT_LIST_HEAD(&dev_info->event_interfaces[i].dev_attr_list);
+ INIT_LIST_HEAD(&dev_info->event_interface->dev_attr_list);
/* Dynically created from the channels array */
- if (dev_info->channels) {
- for (j = 0; j < dev_info->num_channels; j++) {
- ret = iio_device_add_event_sysfs(dev_info,
- &dev_info
- ->channels[j]);
- if (ret)
- goto error_clear_attrs;
- }
+ for (j = 0; j < dev_info->num_channels; j++) {
+
+ ret = iio_device_add_event_sysfs(dev_info,
+ &dev_info->channels[j]);
+ if (ret)
+ goto error_clear_attrs;
}
return 0;
error_clear_attrs:
- __iio_remove_event_config_attrs(dev_info, i);
+ __iio_remove_event_config_attrs(dev_info);
return ret;
}
.attrs = iio_events_dummy_attrs
};
+static bool iio_check_for_dynamic_events(struct iio_dev *dev_info)
+{
+ int j;
+ for (j = 0; j < dev_info->num_channels; j++)
+ if (dev_info->channels[j].event_mask != 0)
+ return true;
+ return false;
+}
+
static int iio_device_register_eventset(struct iio_dev *dev_info)
{
- int ret = 0, i, j;
+ int ret = 0;
- if (dev_info->info->num_interrupt_lines == 0)
+ if (!(dev_info->info->event_attrs ||
+ iio_check_for_dynamic_events(dev_info)))
return 0;
- dev_info->event_interfaces =
- kzalloc(sizeof(struct iio_event_interface)
- *dev_info->info->num_interrupt_lines,
- GFP_KERNEL);
- if (dev_info->event_interfaces == NULL) {
+ dev_info->event_interface =
+ kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL);
+ if (dev_info->event_interface == NULL) {
ret = -ENOMEM;
goto error_ret;
}
- for (i = 0; i < dev_info->info->num_interrupt_lines; i++) {
- iio_setup_ev_int(&dev_info->event_interfaces[i]);
- if (dev_info->info->event_attrs != NULL)
- ret = sysfs_create_group(&dev_info->dev.kobj,
- &dev_info->info
- ->event_attrs[i]);
- else
- ret = sysfs_create_group(&dev_info->dev.kobj,
- &iio_events_dummy_group);
- if (ret) {
- dev_err(&dev_info->dev,
- "Failed to register sysfs for event attrs");
- goto error_free_setup_event_lines;
- }
- ret = __iio_add_event_config_attrs(dev_info, i);
+ iio_setup_ev_int(dev_info->event_interface);
+ if (dev_info->info->event_attrs != NULL)
+ ret = sysfs_create_group(&dev_info->dev.kobj,
+ dev_info->info->event_attrs);
+ else
+ ret = sysfs_create_group(&dev_info->dev.kobj,
+ &iio_events_dummy_group);
+ if (ret) {
+ dev_err(&dev_info->dev,
+ "Failed to register sysfs for event attrs");
+ goto error_free_setup_event_lines;
+ }
+ if (dev_info->channels) {
+ ret = __iio_add_event_config_attrs(dev_info);
if (ret) {
if (dev_info->info->event_attrs != NULL)
sysfs_remove_group(&dev_info->dev.kobj,
- &dev_info->info
- ->event_attrs[i]);
+ dev_info->info
+ ->event_attrs);
else
sysfs_remove_group(&dev_info->dev.kobj,
&iio_events_dummy_group);
return 0;
error_free_setup_event_lines:
- for (j = 0; j < i; j++) {
- __iio_remove_event_config_attrs(dev_info, j);
- if (dev_info->info->event_attrs != NULL) {
- sysfs_remove_group(&dev_info->dev.kobj,
- &dev_info->info->event_attrs[j]);
- sysfs_remove_group(&dev_info->dev.kobj,
- &iio_events_dummy_group);
- }
- }
- kfree(dev_info->event_interfaces);
+ __iio_remove_event_config_attrs(dev_info);
+ if (dev_info->info->event_attrs != NULL)
+ sysfs_remove_group(&dev_info->dev.kobj,
+ dev_info->info->event_attrs);
+ else
+ sysfs_remove_group(&dev_info->dev.kobj,
+ &iio_events_dummy_group);
+ kfree(dev_info->event_interface);
error_ret:
return ret;
static void iio_device_unregister_eventset(struct iio_dev *dev_info)
{
- int i;
-
- if (dev_info->info->num_interrupt_lines == 0)
+ if (dev_info->event_interface == NULL)
return;
- for (i = 0; i < dev_info->info->num_interrupt_lines; i++) {
- __iio_remove_event_config_attrs(dev_info, i);
- if (dev_info->info->event_attrs != NULL)
- sysfs_remove_group(&dev_info->dev.kobj,
- &dev_info->info->event_attrs[i]);
- else
- sysfs_remove_group(&dev_info->dev.kobj,
- &iio_events_dummy_group);
- }
- kfree(dev_info->event_interfaces);
+ __iio_remove_event_config_attrs(dev_info);
+ if (dev_info->info->event_attrs != NULL)
+ sysfs_remove_group(&dev_info->dev.kobj,
+ dev_info->info->event_attrs);
+ else
+ sysfs_remove_group(&dev_info->dev.kobj,
+ &iio_events_dummy_group);
+ kfree(dev_info->event_interface);
}
static void iio_dev_release(struct device *device)
struct iio_dev *dev_info = private;
struct tsl2563_chip *chip = iio_priv(dev_info);
- iio_push_event(dev_info, 0,
+ iio_push_event(dev_info,
IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
0,
IIO_EV_TYPE_THRESH,
static const struct iio_info tsl2563_info = {
.driver_module = THIS_MODULE,
- .num_interrupt_lines = 1,
.read_raw = &tsl2563_read_raw,
.write_raw = &tsl2563_write_raw,
.read_event_value = &tsl2563_read_thresh,