summaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/industrialio-trigger.c
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@cam.ac.uk>2011-05-18 14:42:32 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-19 16:15:04 -0700
commit21b185f8d5951ebbf76d61f431fb541dce5113d1 (patch)
treec9337b56b2835849657da639d6ed64bad4a339fe /drivers/staging/iio/industrialio-trigger.c
parente3796e6bbba213ba2aad7212de0bdae2833ac45e (diff)
downloadop-kernel-dev-21b185f8d5951ebbf76d61f431fb541dce5113d1.zip
op-kernel-dev-21b185f8d5951ebbf76d61f431fb541dce5113d1.tar.gz
staging:iio: poll func allocation clean up.
Add a function to neatly deal with allocation of poll functions. Ultimately this allows us to more easily change the implementation. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/industrialio-trigger.c')
-rw-r--r--drivers/staging/iio/industrialio-trigger.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
index e83edac..6159023 100644
--- a/drivers/staging/iio/industrialio-trigger.c
+++ b/drivers/staging/iio/industrialio-trigger.c
@@ -270,6 +270,42 @@ irqreturn_t iio_pollfunc_store_time(int irq, void *p)
}
EXPORT_SYMBOL(iio_pollfunc_store_time);
+struct iio_poll_func
+*iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p),
+ irqreturn_t (*thread)(int irq, void *p),
+ int type,
+ void *private,
+ const char *fmt,
+ ...)
+{
+ va_list vargs;
+ struct iio_poll_func *pf;
+
+ pf = kmalloc(sizeof *pf, GFP_KERNEL);
+ if (pf == NULL)
+ return NULL;
+ va_start(vargs, fmt);
+ pf->name = kvasprintf(GFP_KERNEL, fmt, vargs);
+ va_end(vargs);
+ if (pf->name == NULL) {
+ kfree(pf);
+ return NULL;
+ }
+ pf->h = h;
+ pf->thread = thread;
+ pf->type = type;
+
+ return pf;
+}
+EXPORT_SYMBOL_GPL(iio_alloc_pollfunc);
+
+void iio_dealloc_pollfunc(struct iio_poll_func *pf)
+{
+ kfree(pf->name);
+ kfree(pf);
+}
+EXPORT_SYMBOL_GPL(iio_dealloc_pollfunc);
+
/**
* iio_trigger_read_currrent() - trigger consumer sysfs query which trigger
*
OpenPOWER on IntegriCloud