#include "../trigger.h"
#include "adis16201.h"
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *adis16201_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group adis16201_trigger_attr_group = {
- .attrs = adis16201_trigger_attrs,
-};
-
/**
* adis16201_data_rdy_trigger_set_state() set datardy interrupt state
**/
{
int ret;
struct adis16201_state *st = indio_dev->dev_data;
- char *name;
- name = kasprintf(GFP_KERNEL,
- "adis16201-dev%d",
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("adis16201-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
&iio_trigger_generic_data_rdy_poll,
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &adis16201_data_rdy_trigger_set_state;
- st->trig->control_attrs = &adis16201_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct adis16201_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
#include "../trigger.h"
#include "adis16203.h"
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *adis16203_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group adis16203_trigger_attr_group = {
- .attrs = adis16203_trigger_attrs,
-};
-
/**
* adis16203_data_rdy_trigger_set_state() set datardy interrupt state
**/
{
int ret;
struct adis16203_state *st = indio_dev->dev_data;
- char *name;
-
- name = kasprintf(GFP_KERNEL,
- "adis16203-dev%d",
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("adis16203-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &adis16203_data_rdy_trigger_set_state;
- st->trig->control_attrs = &adis16203_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct adis16203_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
#include "../trigger.h"
#include "adis16204.h"
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *adis16204_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group adis16204_trigger_attr_group = {
- .attrs = adis16204_trigger_attrs,
-};
-
/**
* adis16204_data_rdy_trigger_set_state() set datardy interrupt state
**/
{
int ret;
struct adis16204_state *st = indio_dev->dev_data;
- char *name;
-
- name = kasprintf(GFP_KERNEL,
- "adis16204-dev%d",
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("adis16204-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &adis16204_data_rdy_trigger_set_state;
- st->trig->control_attrs = &adis16204_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct adis16204_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
return IRQ_HANDLED;
}
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16209_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group adis16209_trigger_attr_group = {
- .attrs = adis16209_trigger_attrs,
-};
-
/**
* adis16209_data_rdy_trigger_set_state() set datardy interrupt state
**/
{
int ret;
struct adis16209_state *st = indio_dev->dev_data;
- char *name;
-
- name = kasprintf(GFP_KERNEL,
- "adis16209-dev%d",
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("adis16209-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &adis16209_data_rdy_trigger_set_state;
- st->trig->control_attrs = &adis16209_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct adis16209_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
return IRQ_HANDLED;
}
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16240_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group adis16240_trigger_attr_group = {
- .attrs = adis16240_trigger_attrs,
-};
-
/**
* adis16240_data_rdy_trigger_set_state() set datardy interrupt state
**/
{
int ret;
struct adis16240_state *st = indio_dev->dev_data;
- char *name;
- name = kasprintf(GFP_KERNEL, "adis16240-dev%d", indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("adis16240-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &adis16240_data_rdy_trigger_set_state;
- st->trig->control_attrs = &adis16240_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct adis16240_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
return ret;
}
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *lis3l02dq_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group lis3l02dq_trigger_attr_group = {
- .attrs = lis3l02dq_trigger_attrs,
-};
-
/**
* lis3l02dq_trig_try_reen() try renabling irq for data rdy trigger
* @trig: the datardy trigger
struct iio_sw_ring_helper_state *h
= iio_dev_get_devdata(indio_dev);
struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
- char *name;
- name = kasprintf(GFP_KERNEL,
- "lis3l02dq-dev%d",
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("lis3l02dq-dev%d", indio_dev->id);
if (!st->trig) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
st->trig->dev.parent = &st->us->dev;
st->trig->private_data = st;
st->trig->set_trigger_state = &lis3l02dq_data_rdy_trigger_set_state;
st->trig->try_reenable = &lis3l02dq_trig_try_reen;
- st->trig->control_attrs = &lis3l02dq_trigger_attr_group;
ret = iio_trigger_register(st->trig);
if (ret)
goto error_free_trig;
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
iio_trigger_unregister(st->trig);
- kfree(st->trig->name);
iio_free_trigger(st->trig);
}
#include "../trigger.h"
#include "adis16260.h"
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16260_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group adis16260_trigger_attr_group = {
- .attrs = adis16260_trigger_attrs,
-};
-
/**
* adis16260_data_rdy_trigger_set_state() set datardy interrupt state
**/
{
int ret;
struct adis16260_state *st = indio_dev->dev_data;
- char *name;
- name = kasprintf(GFP_KERNEL,
- "%s-dev%d",
- spi_get_device_id(st->us)->name,
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("%s-dev%d",
+ spi_get_device_id(st->us)->name,
+ indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &adis16260_data_rdy_trigger_set_state;
- st->trig->control_attrs = &adis16260_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct adis16260_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
#include "../trigger.h"
#include "adis16400.h"
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16400_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group adis16400_trigger_attr_group = {
- .attrs = adis16400_trigger_attrs,
-};
-
/**
* adis16400_data_rdy_trigger_set_state() set datardy interrupt state
**/
{
int ret;
struct adis16400_state *st = indio_dev->dev_data;
- char *name;
-
- name = kasprintf(GFP_KERNEL,
- "%s-dev%d",
- spi_get_device_id(st->us)->name,
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("%s-dev%d",
+ spi_get_device_id(st->us)->name,
+ indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &adis16400_data_rdy_trigger_set_state;
- st->trig->control_attrs = &adis16400_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct adis16400_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
static LIST_HEAD(iio_trigger_list);
static DEFINE_MUTEX(iio_trigger_list_lock);
+/**
+ * iio_trigger_read_name() - retrieve useful identifying name
+ **/
+static ssize_t iio_trigger_read_name(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct iio_trigger *trig = dev_get_drvdata(dev);
+ return sprintf(buf, "%s\n", trig->name);
+}
+
+static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+
/**
* iio_trigger_register_sysfs() - create a device for this trigger
* @trig_info: the trigger
**/
static int iio_trigger_register_sysfs(struct iio_trigger *trig_info)
{
- int ret = 0;
-
- if (trig_info->control_attrs)
- ret = sysfs_create_group(&trig_info->dev.kobj,
- trig_info->control_attrs);
-
- return ret;
+ return sysfs_add_file_to_group(&trig_info->dev.kobj,
+ &dev_attr_name.attr,
+ NULL);
}
static void iio_trigger_unregister_sysfs(struct iio_trigger *trig_info)
{
- if (trig_info->control_attrs)
- sysfs_remove_group(&trig_info->dev.kobj,
- trig_info->control_attrs);
+ sysfs_remove_file_from_group(&trig_info->dev.kobj,
+ &dev_attr_name.attr,
+ NULL);
}
}
EXPORT_SYMBOL(iio_trigger_notify_done);
-/**
- * iio_trigger_read_name() - retrieve useful identifying name
- **/
-ssize_t iio_trigger_read_name(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_trigger *trig = dev_get_drvdata(dev);
- return sprintf(buf, "%s\n", trig->name);
-}
-EXPORT_SYMBOL(iio_trigger_read_name);
-
/* Trigger Consumer related functions */
/* Complexity in here. With certain triggers (datardy) an acknowledgement
irq_free_descs(trig->subirq_base,
CONFIG_IIO_CONSUMERS_PER_TRIGGER);
}
+ kfree(trig->name);
kfree(trig);
iio_put();
}
trig->subirqs[d->irq - trig->subirq_base].enabled = true;
}
-struct iio_trigger *iio_allocate_trigger_named(const char *name)
+struct iio_trigger *iio_allocate_trigger(const char *fmt, ...)
{
+ va_list vargs;
struct iio_trigger *trig;
trig = kzalloc(sizeof *trig, GFP_KERNEL);
if (trig) {
device_initialize(&trig->dev);
dev_set_drvdata(&trig->dev, (void *)trig);
- if (name) {
- mutex_init(&trig->pool_lock);
- trig->subirq_base
- = irq_alloc_descs(-1, 0,
- CONFIG_IIO_CONSUMERS_PER_TRIGGER,
- 0);
- if (trig->subirq_base < 0) {
- kfree(trig);
- return NULL;
- }
- trig->name = name;
- trig->subirq_chip.name = name;
- trig->subirq_chip.irq_mask = &iio_trig_subirqmask;
- trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask;
- for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
- irq_set_chip(trig->subirq_base + i,
- &trig->subirq_chip);
- irq_set_handler(trig->subirq_base + i,
- &handle_simple_irq);
- irq_modify_status(trig->subirq_base + i,
- IRQ_NOREQUEST | IRQ_NOAUTOEN,
- IRQ_NOPROBE);
- }
+ mutex_init(&trig->pool_lock);
+ trig->subirq_base
+ = irq_alloc_descs(-1, 0,
+ CONFIG_IIO_CONSUMERS_PER_TRIGGER,
+ 0);
+ if (trig->subirq_base < 0) {
+ kfree(trig);
+ return NULL;
+ }
+ va_start(vargs, fmt);
+ trig->name = kvasprintf(GFP_KERNEL, fmt, vargs);
+ va_end(vargs);
+ if (trig->name == NULL) {
+ irq_free_descs(trig->subirq_base,
+ CONFIG_IIO_CONSUMERS_PER_TRIGGER);
+ kfree(trig);
+ return NULL;
+ }
+ trig->subirq_chip.name = trig->name;
+ trig->subirq_chip.irq_mask = &iio_trig_subirqmask;
+ trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask;
+ for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
+ irq_set_chip(trig->subirq_base + i,
+ &trig->subirq_chip);
+ irq_set_handler(trig->subirq_base + i,
+ &handle_simple_irq);
+ irq_modify_status(trig->subirq_base + i,
+ IRQ_NOREQUEST | IRQ_NOAUTOEN,
+ IRQ_NOPROBE);
}
iio_get();
}
return trig;
}
-EXPORT_SYMBOL(iio_allocate_trigger_named);
-
-struct iio_trigger *iio_allocate_trigger(void)
-{
- return iio_allocate_trigger_named(NULL);
-}
EXPORT_SYMBOL(iio_allocate_trigger);
void iio_free_trigger(struct iio_trigger *trig)
{
int ret;
struct ade7758_state *st = indio_dev->dev_data;
- char *name;
- name = kasprintf(GFP_KERNEL,
- "%s-dev%d",
- spi_get_device_id(st->us)->name,
- indio_dev->id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- st->trig = iio_allocate_trigger_named(name);
+ st->trig = iio_allocate_trigger("%s-dev%d",
+ spi_get_device_id(st->us)->name,
+ indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_free_name;
+ goto error_ret;
}
ret = request_irq(st->us->irq,
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
-error_free_name:
- kfree(name);
error_ret:
return ret;
}
struct ade7758_state *state = indio_dev->dev_data;
iio_trigger_unregister(state->trig);
- kfree(state->trig->name);
free_irq(state->us->irq, state->trig);
iio_free_trigger(state->trig);
}
* @private_data: [DRIVER] device specific data
* @list: [INTERN] used in maintenance of global trigger list
* @alloc_list: [DRIVER] used for driver specific trigger list
- * @control_attrs: [DRIVER] sysfs attributes relevant to trigger type
* @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)
+ * @subirq_chip: [INTERN] associate 'virtual' irq chip.
+ * @subirq_base: [INTERN] base number for irqs provided by trigger.
+ * @subirqs: [INTERN] information about the 'child' irqs.
+ * @pool: [INTERN] bitmap of irqs currently in use.
+ * @pool_lock: [INTERN] protection of the irq pool.
**/
struct iio_trigger {
int id;
void *private_data;
struct list_head list;
struct list_head alloc_list;
- const struct attribute_group *control_attrs;
struct module *owner;
int use_count;
get_device(&trig->dev);
};
-/**
- * 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,
- char *buf);
-
-#define IIO_TRIGGER_NAME_ATTR DEVICE_ATTR(name, S_IRUGO, \
- iio_trigger_read_name, \
- NULL);
-
/**
* iio_trigger_register() - register a trigger with the IIO core
* @trig_info: trigger to be registered
* @h: the function that is actually run on trigger
* @thread: threaded interrupt part
* @type: the type of interrupt (basically if oneshot)
+ * @name: name used to identify the trigger consumer.
* @irq: the corresponding irq as allocated from the
* trigger pool
* @timestamp: some devices need a timestamp grabbed as soon
int iio_triggered_ring_postenable(struct iio_dev *indio_dev);
int iio_triggered_ring_predisable(struct iio_dev *indio_dev);
-struct iio_trigger *iio_allocate_trigger(void);
-struct iio_trigger *iio_allocate_trigger_named(const char *name);
+struct iio_trigger *iio_allocate_trigger(const char *fmt, ...)
+ __attribute__((format(printf, 1, 2)));
void iio_free_trigger(struct iio_trigger *trig);
#endif /* _IIO_TRIGGER_H_ */
static DEVICE_ATTR(frequency, S_IRUGO | S_IWUSR, iio_bfin_tmr_frequency_show,
iio_bfin_tmr_frequency_store);
-static IIO_TRIGGER_NAME_ATTR;
static struct attribute *iio_bfin_tmr_trigger_attrs[] = {
&dev_attr_frequency.attr,
- &dev_attr_name.attr,
NULL,
};
.attrs = iio_bfin_tmr_trigger_attrs,
};
+static const struct attribute_group *iio_bfin_tmr_trigger_attr_groups[] = {
+ &iio_bfin_tmr_trigger_attr_group,
+ NULL
+};
+
static irqreturn_t iio_bfin_tmr_trigger_isr(int irq, void *devid)
{
st->timer_num = ret;
st->t = &iio_bfin_timer_code[st->timer_num];
- st->trig = iio_allocate_trigger();
+ st->trig = iio_allocate_trigger("bfintmr%d", st->timer_num);
if (!st->trig) {
ret = -ENOMEM;
goto out1;
}
st->trig->private_data = st;
- st->trig->control_attrs = &iio_bfin_tmr_trigger_attr_group;
st->trig->owner = THIS_MODULE;
- st->trig->name = kasprintf(GFP_KERNEL, "bfintmr%d", st->timer_num);
- if (st->trig->name == NULL) {
- ret = -ENOMEM;
- goto out2;
- }
-
+ st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
ret = iio_trigger_register(st->trig);
if (ret)
- goto out3;
+ goto out2;
ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
0, st->trig->name, st);
return 0;
out4:
iio_trigger_unregister(st->trig);
-out3:
- kfree(st->trig->name);
out2:
iio_put_trigger(st->trig);
out1:
disable_gptimers(st->t->bit);
free_irq(st->irq, st);
iio_trigger_unregister(st->trig);
- kfree(st->trig->name);
iio_put_trigger(st->trig);
kfree(st);
return IRQ_HANDLED;
}
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *iio_gpio_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group iio_gpio_trigger_attr_group = {
- .attrs = iio_gpio_trigger_attrs,
-};
-
static int iio_gpio_trigger_probe(struct platform_device *pdev)
{
struct iio_gpio_trigger_info *trig_info;
for (irq = irq_res->start; irq <= irq_res->end; irq++) {
- trig = iio_allocate_trigger();
+ trig = iio_allocate_trigger("irqtrig%d", irq);
if (!trig) {
ret = -ENOMEM;
goto error_free_completed_registrations;
ret = -ENOMEM;
goto error_put_trigger;
}
- trig->control_attrs = &iio_gpio_trigger_attr_group;
trig->private_data = trig_info;
trig_info->irq = irq;
trig->owner = THIS_MODULE;
- trig->name = kasprintf(GFP_KERNEL, "irqtrig%d", irq);
- if (trig->name == NULL) {
- ret = -ENOMEM;
- goto error_free_trig_info;
- }
ret = request_irq(irq, iio_gpio_trigger_poll,
irqflags, trig->name, trig);
if (ret) {
dev_err(&pdev->dev,
"request IRQ-%d failed", irq);
- goto error_free_name;
+ goto error_free_trig_info;
}
ret = iio_trigger_register(trig);
/* First clean up the partly allocated trigger */
error_release_irq:
free_irq(irq, trig);
-error_free_name:
- kfree(trig->name);
error_free_trig_info:
kfree(trig_info);
error_put_trigger:
alloc_list) {
trig_info = trig->private_data;
free_irq(gpio_to_irq(trig_info->irq), trig);
- kfree(trig->name);
kfree(trig_info);
iio_trigger_unregister(trig);
}
trig_info = trig->private_data;
iio_trigger_unregister(trig);
free_irq(trig_info->irq, trig);
- kfree(trig->name);
kfree(trig_info);
iio_put_trigger(trig);
}
return ret;
}
-static IIO_TRIGGER_NAME_ATTR;
static DEVICE_ATTR(frequency, S_IRUGO | S_IWUSR,
iio_trig_periodic_read_freq,
iio_trig_periodic_write_freq);
static struct attribute *iio_trig_prtc_attrs[] = {
&dev_attr_frequency.attr,
- &dev_attr_name.attr,
NULL,
};
+
static const struct attribute_group iio_trig_prtc_attr_group = {
.attrs = iio_trig_prtc_attrs,
};
+static const struct attribute_group *iio_trig_prtc_attr_groups[] = {
+ &iio_trig_prtc_attr_group,
+ NULL
+};
+
static void iio_prtc_trigger_poll(void *private_data)
{
/* Timestamp is not provided currently */
for (i = 0;; i++) {
if (pdata[i] == NULL)
break;
- trig = iio_allocate_trigger();
+ trig = iio_allocate_trigger("periodic%s", pdata[i]);
if (!trig) {
ret = -ENOMEM;
goto error_free_completed_registrations;
trig->private_data = trig_info;
trig->owner = THIS_MODULE;
trig->set_trigger_state = &iio_trig_periodic_rtc_set_state;
- trig->name = kasprintf(GFP_KERNEL, "periodic%s", pdata[i]);
- if (trig->name == NULL) {
- ret = -ENOMEM;
- goto error_free_trig_info;
- }
-
/* RTC access */
trig_info->rtc
= rtc_class_open(pdata[i]);
if (trig_info->rtc == NULL) {
ret = -EINVAL;
- goto error_free_name;
+ goto error_free_trig_info;
}
trig_info->task.func = iio_prtc_trigger_poll;
trig_info->task.private_data = trig;
ret = rtc_irq_register(trig_info->rtc, &trig_info->task);
if (ret)
goto error_close_rtc;
- trig->control_attrs = &iio_trig_prtc_attr_group;
+ trig->dev.groups = iio_trig_prtc_attr_groups;
ret = iio_trigger_register(trig);
if (ret)
goto error_unregister_rtc_irq;
rtc_irq_unregister(trig_info->rtc, &trig_info->task);
error_close_rtc:
rtc_class_close(trig_info->rtc);
-error_free_name:
- kfree(trig->name);
error_free_trig_info:
kfree(trig_info);
error_put_trigger_and_remove_from_list:
trig_info = trig->private_data;
rtc_irq_unregister(trig_info->rtc, &trig_info->task);
rtc_class_close(trig_info->rtc);
- kfree(trig->name);
kfree(trig_info);
iio_trigger_unregister(trig);
}
trig_info = trig->private_data;
rtc_irq_unregister(trig_info->rtc, &trig_info->task);
rtc_class_close(trig_info->rtc);
- kfree(trig->name);
kfree(trig_info);
iio_trigger_unregister(trig);
}
}
static DEVICE_ATTR(trigger_now, S_IWUSR, NULL, iio_sysfs_trigger_poll);
-static IIO_TRIGGER_NAME_ATTR;
static struct attribute *iio_sysfs_trigger_attrs[] = {
&dev_attr_trigger_now.attr,
- &dev_attr_name.attr,
NULL,
};
.attrs = iio_sysfs_trigger_attrs,
};
+static const struct attribute_group *iio_sysfs_trigger_attr_groups[] = {
+ &iio_sysfs_trigger_attr_group,
+ NULL
+};
+
static int iio_sysfs_trigger_probe(int id)
{
struct iio_sysfs_trig *t;
int ret;
- char *name;
bool foundit = false;
mutex_lock(&iio_syfs_trig_list_mut);
list_for_each_entry(t, &iio_sysfs_trig_list, l)
ret = -EINVAL;
goto out1;
}
-
- name = kasprintf(GFP_KERNEL, "sysfstrig%d", id);
- if (name == NULL) {
- ret = -ENOMEM;
- goto out1;
- }
t = kmalloc(sizeof(*t), GFP_KERNEL);
if (t == NULL) {
ret = -ENOMEM;
- goto free_name;
+ goto out1;
}
t->id = id;
- t->trig = iio_allocate_trigger_named(name);
+ t->trig = iio_allocate_trigger("sysfstrig%d", id);
if (!t->trig) {
ret = -ENOMEM;
goto free_t;
}
- t->trig->control_attrs = &iio_sysfs_trigger_attr_group;
+ t->trig->dev.groups = iio_sysfs_trigger_attr_groups;
t->trig->owner = THIS_MODULE;
t->trig->dev.parent = &iio_sysfs_trig_dev;
iio_put_trigger(t->trig);
free_t:
kfree(t);
-free_name:
- kfree(name);
out1:
mutex_unlock(&iio_syfs_trig_list_mut);
return ret;
}
iio_trigger_unregister(t->trig);
- kfree(t->trig->name);
iio_free_trigger(t->trig);
list_del(&t->l);