From d29f73db791098179af90e6a5b1df41f941b32cd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:08:38 +0100 Subject: staging:iio:triggers introduce iio_trigger_ops to take const bits out of iio_trig_structure. Right now this results in increased code, but I still think it is worth doing to avoid replication across instances of drivers etc and move as much stuff as possible to constant. Ops structure is optional for the occasional driver that uses none of it (currently only the ad7793). Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 90ca2df..513a7a0 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -206,8 +206,8 @@ EXPORT_SYMBOL(iio_trigger_poll_chained); void iio_trigger_notify_done(struct iio_trigger *trig) { trig->use_count--; - if (trig->use_count == 0 && trig->try_reenable) - if (trig->try_reenable(trig)) { + if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable) + if (trig->ops->try_reenable(trig)) { /* Missed and interrupt so launch new poll now */ iio_trigger_poll(trig, 0); } @@ -234,8 +234,8 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, ret = request_threaded_irq(pf->irq, pf->h, pf->thread, pf->type, pf->name, pf); - if (trig->set_trigger_state && notinuse) - ret = trig->set_trigger_state(trig, true); + if (trig->ops && trig->ops->set_trigger_state && notinuse) + ret = trig->ops->set_trigger_state(trig, true); return ret; } @@ -249,8 +249,8 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, = (bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1); - if (trig->set_trigger_state && no_other_users) { - ret = trig->set_trigger_state(trig, false); + if (trig->ops && trig->ops->set_trigger_state && no_other_users) { + ret = trig->ops->set_trigger_state(trig, false); if (ret) goto error_ret; } @@ -358,8 +358,8 @@ static ssize_t iio_trigger_write_current(struct device *dev, return ret; } - if (trig && trig->validate_device) { - ret = trig->validate_device(trig, dev_info); + if (trig && trig->ops && trig->ops->validate_device) { + ret = trig->ops->validate_device(trig, dev_info); if (ret) return ret; } -- cgit v1.1 From df9c1c42c26f9a516dd44c956cff301741a0884e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Aug 2011 17:56:03 +0100 Subject: staging:iio: Introduce iio_core.h and move all core only stuff out of iio.h. Also get rid of a few function defs where they are only now in one core file anyway. Whilst here add mask = 0 to get rid of warning. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 513a7a0..ebacfda 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -18,6 +18,7 @@ #include "iio.h" #include "trigger.h" +#include "iio_core.h" #include "trigger_consumer.h" /* RFC - Question of approach -- cgit v1.1 From 5f9c035cae18be30b70efc88c3c88b34283db62f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:33 +0100 Subject: staging:iio:triggers. Add a reference get to the core for triggers. This is to do with dynamically allocated triggers and the need to ensure the underlying structures don't go away when a consumer is using them. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index ebacfda..89a9934 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -8,7 +8,6 @@ */ #include -#include #include #include #include @@ -478,6 +477,7 @@ struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) IRQ_NOPROBE); } iio_get(); + get_device(&trig->dev); } return trig; } @@ -501,6 +501,9 @@ EXPORT_SYMBOL(iio_device_register_trigger_consumer); int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) { + /* Clean up and associated but not attached triggers references */ + if (dev_info->trig) + iio_put_trigger(dev_info->trig); sysfs_remove_group(&dev_info->dev.kobj, &iio_trigger_consumer_attr_group); return 0; -- cgit v1.1 From e65bc6ac6fa54959ac0b3712b0f35bbf073c073e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:36 +0100 Subject: staging:iio:pollfunc: Make explicit that private data is always pointer to a struct iio_dev. This is always true, so lets make it explicit. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 89a9934..ccfd558 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -274,7 +274,7 @@ 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, + struct iio_dev *indio_dev, const char *fmt, ...) { @@ -294,7 +294,7 @@ struct iio_poll_func pf->h = h; pf->thread = thread; pf->type = type; - pf->private_data = private; + pf->indio_dev = indio_dev; return pf; } -- cgit v1.1 From f60c4a02aa05817f00408ecefdf221f44781e08a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:37 +0100 Subject: staging:iio: prevent removal of module connected to trigger. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index ccfd558..7012f8c 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -230,6 +230,8 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, bool notinuse = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); + /* Prevent the module being removed whilst attached to a trigger */ + __module_get(pf->indio_dev->info->driver_module); pf->irq = iio_trigger_get_irq(trig); ret = request_threaded_irq(pf->irq, pf->h, pf->thread, pf->type, pf->name, @@ -256,6 +258,7 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, } iio_trigger_put_irq(trig, pf->irq); free_irq(pf->irq, pf); + module_put(pf->indio_dev->info->driver_module); error_ret: return ret; -- cgit v1.1 From 6aea1c364cde5b28b551844b7b8925f523310a18 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:38 +0100 Subject: staging:iio:rename trigger_consumer.h to indicate it is core only. Need this out the way to create a trigger_consumer.h that actually is for trigger consumers. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 7012f8c..8fafeb8 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -18,7 +18,7 @@ #include "iio.h" #include "trigger.h" #include "iio_core.h" -#include "trigger_consumer.h" +#include "iio_core_trigger.h" /* RFC - Question of approach * Make the common case (single sensor single trigger) -- cgit v1.1 From 3f72395ee595a2a2fe1ed01c006c4f0cce313512 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:39 +0100 Subject: staging:iio: spit trigger.h into provider and consumer parts. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 8fafeb8..1013442 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -19,6 +19,7 @@ #include "trigger.h" #include "iio_core.h" #include "iio_core_trigger.h" +#include "trigger_consumer.h" /* RFC - Question of approach * Make the common case (single sensor single trigger) -- cgit v1.1 From cb6c89a094df3823a1797b880e5dfda2fbfcd584 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:40 +0100 Subject: staging:iio:trigger core. Trivial code cleanups. Stop exporting functions only intended for core usage. Return void from function which can never return anything other than 0. Trivial stype cleanups. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 1013442..72ea106 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -174,13 +174,12 @@ static struct iio_trigger *iio_trigger_find_by_name(const char *name, void iio_trigger_poll(struct iio_trigger *trig, s64 time) { int i; - if (!trig->use_count) { + if (!trig->use_count) for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) if (trig->subirqs[i].enabled) { trig->use_count++; generic_handle_irq(trig->subirq_base + i); } - } } EXPORT_SYMBOL(iio_trigger_poll); @@ -322,12 +321,10 @@ static ssize_t iio_trigger_read_current(struct device *dev, char *buf) { struct iio_dev *dev_info = dev_get_drvdata(dev); - int len = 0; + if (dev_info->trig) - len = sprintf(buf, - "%s\n", - dev_info->trig->name); - return len; + return sprintf(buf, "%s\n", dev_info->trig->name); + return 0; } /** @@ -496,23 +493,18 @@ EXPORT_SYMBOL(iio_free_trigger); int iio_device_register_trigger_consumer(struct iio_dev *dev_info) { - int ret; - ret = sysfs_create_group(&dev_info->dev.kobj, - &iio_trigger_consumer_attr_group); - return ret; + return sysfs_create_group(&dev_info->dev.kobj, + &iio_trigger_consumer_attr_group); } -EXPORT_SYMBOL(iio_device_register_trigger_consumer); -int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) +void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) { /* Clean up and associated but not attached triggers references */ if (dev_info->trig) iio_put_trigger(dev_info->trig); sysfs_remove_group(&dev_info->dev.kobj, &iio_trigger_consumer_attr_group); - return 0; } -EXPORT_SYMBOL(iio_device_unregister_trigger_consumer); int iio_triggered_ring_postenable(struct iio_dev *indio_dev) { -- cgit v1.1 From 208b813c04ef7e628783cc62eeb1a140ae25bd19 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 24 Aug 2011 17:28:41 +0100 Subject: staging:iio:trigger push functions that don't need to be generaly available down into the core. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 72ea106..f1ece86 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -215,6 +215,26 @@ void iio_trigger_notify_done(struct iio_trigger *trig) EXPORT_SYMBOL(iio_trigger_notify_done); /* Trigger Consumer related functions */ +static int iio_trigger_get_irq(struct iio_trigger *trig) +{ + int ret; + mutex_lock(&trig->pool_lock); + ret = bitmap_find_free_region(trig->pool, + CONFIG_IIO_CONSUMERS_PER_TRIGGER, + ilog2(1)); + mutex_unlock(&trig->pool_lock); + if (ret >= 0) + ret += trig->subirq_base; + + return ret; +} + +static void iio_trigger_put_irq(struct iio_trigger *trig, int irq) +{ + mutex_lock(&trig->pool_lock); + clear_bit(irq - trig->subirq_base, trig->pool); + mutex_unlock(&trig->pool_lock); +} /* Complexity in here. With certain triggers (datardy) an acknowledgement * may be needed if the pollfuncs do not include the data read for the @@ -223,8 +243,8 @@ EXPORT_SYMBOL(iio_trigger_notify_done); * the relevant function is in there may be the best option. */ /* Worth protecting against double additions?*/ -int iio_trigger_attach_poll_func(struct iio_trigger *trig, - struct iio_poll_func *pf) +static int iio_trigger_attach_poll_func(struct iio_trigger *trig, + struct iio_poll_func *pf) { int ret = 0; bool notinuse @@ -241,10 +261,9 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, return ret; } -EXPORT_SYMBOL(iio_trigger_attach_poll_func); -int iio_trigger_dettach_poll_func(struct iio_trigger *trig, - struct iio_poll_func *pf) +static int iio_trigger_dettach_poll_func(struct iio_trigger *trig, + struct iio_poll_func *pf) { int ret = 0; bool no_other_users @@ -263,7 +282,6 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig, error_ret: return ret; } -EXPORT_SYMBOL(iio_trigger_dettach_poll_func); irqreturn_t iio_pollfunc_store_time(int irq, void *p) { -- cgit v1.1 From 47c24fdd4253a2c8d730b978a186923b1af5e879 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:07 +0100 Subject: staging:iio: use ida_simple_get and ida_simple_remove + merge ids Use new simple ida allocation functions to remove some boilerplate code. Also, now we only have one chdev per device we don't need to maintain a separate ida for minor numbers. Just use the devices id. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 48 +++++------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index f1ece86..b99d14e 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -32,8 +32,7 @@ * Any other suggestions? */ -static DEFINE_IDR(iio_trigger_idr); -static DEFINE_SPINLOCK(iio_trigger_idr_lock); +static DEFINE_IDA(iio_trigger_ida); /* Single list of all available triggers */ static LIST_HEAD(iio_trigger_list); @@ -72,48 +71,15 @@ static void iio_trigger_unregister_sysfs(struct iio_trigger *trig_info) NULL); } - -/** - * iio_trigger_register_id() - get a unique id for this trigger - * @trig_info: the trigger - **/ -static int iio_trigger_register_id(struct iio_trigger *trig_info) -{ - int ret = 0; - -idr_again: - if (unlikely(idr_pre_get(&iio_trigger_idr, GFP_KERNEL) == 0)) - return -ENOMEM; - - spin_lock(&iio_trigger_idr_lock); - ret = idr_get_new(&iio_trigger_idr, NULL, &trig_info->id); - spin_unlock(&iio_trigger_idr_lock); - if (unlikely(ret == -EAGAIN)) - goto idr_again; - else if (likely(!ret)) - trig_info->id = trig_info->id & MAX_ID_MASK; - - return ret; -} - -/** - * iio_trigger_unregister_id() - free up unique id for use by another trigger - * @trig_info: the trigger - **/ -static void iio_trigger_unregister_id(struct iio_trigger *trig_info) -{ - spin_lock(&iio_trigger_idr_lock); - idr_remove(&iio_trigger_idr, trig_info->id); - spin_unlock(&iio_trigger_idr_lock); -} - int iio_trigger_register(struct iio_trigger *trig_info) { int ret; - ret = iio_trigger_register_id(trig_info); - if (ret) + trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); + if (trig_info->id < 0) { + ret = trig_info->id; goto error_ret; + } /* Set the name used for the sysfs directory etc */ dev_set_name(&trig_info->dev, "trigger%ld", (unsigned long) trig_info->id); @@ -136,7 +102,7 @@ int iio_trigger_register(struct iio_trigger *trig_info) error_device_del: device_del(&trig_info->dev); error_unregister_id: - iio_trigger_unregister_id(trig_info); + ida_simple_remove(&iio_trigger_ida, trig_info->id); error_ret: return ret; } @@ -149,7 +115,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info) mutex_unlock(&iio_trigger_list_lock); iio_trigger_unregister_sysfs(trig_info); - iio_trigger_unregister_id(trig_info); + ida_simple_remove(&iio_trigger_ida, trig_info->id); /* Possible issue in here */ device_unregister(&trig_info->dev); } -- cgit v1.1 From 9019309c2f32a4479c88047532552bdeea38585a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 30 Aug 2011 12:41:08 +0100 Subject: staging:iio: remove defunct iio_put and iio_get. All iio dependent modules statically depend on industrialio so these aren't needed. Not sure why they originally existed, but they aren't now. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index b99d14e..3e60406 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -394,7 +394,6 @@ static void iio_trig_release(struct device *device) } kfree(trig->name); kfree(trig); - iio_put(); } static struct device_type iio_trig_type = { @@ -461,7 +460,6 @@ struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE); } - iio_get(); get_device(&trig->dev); } return trig; -- cgit v1.1 From 26d25ae3f0d8ffe350aacc75b71198d6b35bd1f4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:40 +0100 Subject: staging:iio: rework of attribute registration. This set also includes quite a number of bug fixes of particularly remove functions. Necessary due to issue pointed out in Bart Van Assche's patch: docs/driver-model: Document device.groups V2: Rebase due to patch reordering. V3: Pull various error fixes and cleanups out into their own patches. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 3e60406..a66dcf7 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -475,8 +475,10 @@ EXPORT_SYMBOL(iio_free_trigger); int iio_device_register_trigger_consumer(struct iio_dev *dev_info) { - return sysfs_create_group(&dev_info->dev.kobj, - &iio_trigger_consumer_attr_group); + dev_info->groups[dev_info->groupcounter++] = + &iio_trigger_consumer_attr_group; + + return 0; } void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) @@ -484,8 +486,6 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) /* Clean up and associated but not attached triggers references */ if (dev_info->trig) iio_put_trigger(dev_info->trig); - sysfs_remove_group(&dev_info->dev.kobj, - &iio_trigger_consumer_attr_group); } int iio_triggered_ring_postenable(struct iio_dev *indio_dev) -- cgit v1.1 From 3b99fb7656a73d483b00fd4777646c00db16b040 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:53 +0100 Subject: staging:iio: treewide rename iio_triggered_ring_* to iio_triggered_buffer_* Not always a ring so naming is missleading. Also, kfifo_buf is probably first buffer to take out of staging and it definitely isn't a ring. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index a66dcf7..00d0e0c 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -488,20 +488,20 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) iio_put_trigger(dev_info->trig); } -int iio_triggered_ring_postenable(struct iio_dev *indio_dev) +int iio_triggered_buffer_postenable(struct iio_dev *indio_dev) { return indio_dev->trig ? iio_trigger_attach_poll_func(indio_dev->trig, indio_dev->pollfunc) : 0; } -EXPORT_SYMBOL(iio_triggered_ring_postenable); +EXPORT_SYMBOL(iio_triggered_buffer_postenable); -int iio_triggered_ring_predisable(struct iio_dev *indio_dev) +int iio_triggered_buffer_predisable(struct iio_dev *indio_dev) { return indio_dev->trig ? iio_trigger_dettach_poll_func(indio_dev->trig, indio_dev->pollfunc) : 0; } -EXPORT_SYMBOL(iio_triggered_ring_predisable); +EXPORT_SYMBOL(iio_triggered_buffer_predisable); -- cgit v1.1 From ec3afa40c648ed17eb2a83a4b7249deab3631f61 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 21 Sep 2011 11:15:54 +0100 Subject: staging:iio: tree wide IIO_RING_TRIGGERED -> IIO_BUFFER_TRIGGERED also, IIO_RING_HARDWARE_BUFFER -> IIO_BUFFER_HARDWARE These aren't always rings so the naming should not imply that. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 00d0e0c..3926649 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -329,7 +329,7 @@ static ssize_t iio_trigger_write_current(struct device *dev, int ret; mutex_lock(&dev_info->mlock); - if (dev_info->currentmode == INDIO_RING_TRIGGERED) { + if (dev_info->currentmode == INDIO_BUFFER_TRIGGERED) { mutex_unlock(&dev_info->mlock); return -EBUSY; } -- cgit v1.1 From f8c6f4e9a40d47ce86a641eb20fb7c5a59f06ff0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Thu, 6 Oct 2011 17:14:35 +0100 Subject: staging:iio:core:naming: dev_info to indio_dev for consistency We had a random missmatch of these two. Lets pick the most common and get rid of the other. This patch covers the core. Others will clean up the drivers. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/industrialio-trigger.c | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers/staging/iio/industrialio-trigger.c') diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 3926649..2c626e0 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -304,10 +304,10 @@ static ssize_t iio_trigger_read_current(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); + struct iio_dev *indio_dev = dev_get_drvdata(dev); - if (dev_info->trig) - return sprintf(buf, "%s\n", dev_info->trig->name); + if (indio_dev->trig) + return sprintf(buf, "%s\n", indio_dev->trig->name); return 0; } @@ -323,38 +323,38 @@ static ssize_t iio_trigger_write_current(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct iio_trigger *oldtrig = dev_info->trig; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_trigger *oldtrig = indio_dev->trig; struct iio_trigger *trig; int ret; - mutex_lock(&dev_info->mlock); - if (dev_info->currentmode == INDIO_BUFFER_TRIGGERED) { - mutex_unlock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); + if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { + mutex_unlock(&indio_dev->mlock); return -EBUSY; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); trig = iio_trigger_find_by_name(buf, len); - if (trig && dev_info->info->validate_trigger) { - ret = dev_info->info->validate_trigger(dev_info, trig); + if (trig && indio_dev->info->validate_trigger) { + ret = indio_dev->info->validate_trigger(indio_dev, trig); if (ret) return ret; } if (trig && trig->ops && trig->ops->validate_device) { - ret = trig->ops->validate_device(trig, dev_info); + ret = trig->ops->validate_device(trig, indio_dev); if (ret) return ret; } - dev_info->trig = trig; + indio_dev->trig = trig; - if (oldtrig && dev_info->trig != oldtrig) + if (oldtrig && indio_dev->trig != oldtrig) iio_put_trigger(oldtrig); - if (dev_info->trig) - iio_get_trigger(dev_info->trig); + if (indio_dev->trig) + iio_get_trigger(indio_dev->trig); return len; } @@ -473,19 +473,19 @@ void iio_free_trigger(struct iio_trigger *trig) } EXPORT_SYMBOL(iio_free_trigger); -int iio_device_register_trigger_consumer(struct iio_dev *dev_info) +int iio_device_register_trigger_consumer(struct iio_dev *indio_dev) { - dev_info->groups[dev_info->groupcounter++] = + indio_dev->groups[indio_dev->groupcounter++] = &iio_trigger_consumer_attr_group; return 0; } -void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info) +void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev) { /* Clean up and associated but not attached triggers references */ - if (dev_info->trig) - iio_put_trigger(dev_info->trig); + if (indio_dev->trig) + iio_put_trigger(indio_dev->trig); } int iio_triggered_buffer_postenable(struct iio_dev *indio_dev) -- cgit v1.1