diff options
Diffstat (limited to 'drivers/staging/iio/trigger')
-rw-r--r-- | drivers/staging/iio/trigger/Kconfig | 17 | ||||
-rw-r--r-- | drivers/staging/iio/trigger/Makefile | 2 | ||||
-rw-r--r-- | drivers/staging/iio/trigger/iio-trig-gpio.c | 167 | ||||
-rw-r--r-- | drivers/staging/iio/trigger/iio-trig-sysfs.c | 227 |
4 files changed, 0 insertions, 413 deletions
diff --git a/drivers/staging/iio/trigger/Kconfig b/drivers/staging/iio/trigger/Kconfig index 1a051da..2fd18c6 100644 --- a/drivers/staging/iio/trigger/Kconfig +++ b/drivers/staging/iio/trigger/Kconfig @@ -12,23 +12,6 @@ config IIO_PERIODIC_RTC_TRIGGER Provides support for using periodic capable real time clocks as IIO triggers. -config IIO_GPIO_TRIGGER - tristate "GPIO trigger" - depends on GPIOLIB - help - Provides support for using GPIO pins as IIO triggers. - -config IIO_SYSFS_TRIGGER - tristate "SYSFS trigger" - depends on SYSFS - select IRQ_WORK - help - Provides support for using SYSFS entry as IIO triggers. - If unsure, say N (but it's safe to say "Y"). - - To compile this driver as a module, choose M here: the - module will be called iio-trig-sysfs. - config IIO_BFIN_TMR_TRIGGER tristate "Blackfin TIMER trigger" depends on BLACKFIN diff --git a/drivers/staging/iio/trigger/Makefile b/drivers/staging/iio/trigger/Makefile index b088b57..238481b 100644 --- a/drivers/staging/iio/trigger/Makefile +++ b/drivers/staging/iio/trigger/Makefile @@ -3,6 +3,4 @@ # obj-$(CONFIG_IIO_PERIODIC_RTC_TRIGGER) += iio-trig-periodic-rtc.o -obj-$(CONFIG_IIO_GPIO_TRIGGER) += iio-trig-gpio.o -obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o obj-$(CONFIG_IIO_BFIN_TMR_TRIGGER) += iio-trig-bfin-timer.o diff --git a/drivers/staging/iio/trigger/iio-trig-gpio.c b/drivers/staging/iio/trigger/iio-trig-gpio.c deleted file mode 100644 index 7c593d1..0000000 --- a/drivers/staging/iio/trigger/iio-trig-gpio.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Industrial I/O - gpio based trigger support - * - * Copyright (c) 2008 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Currently this is more of a functioning proof of concept than a full - * fledged trigger driver. - * - * TODO: - * - * Add board config elements to allow specification of startup settings. - */ - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/interrupt.h> -#include <linux/gpio.h> -#include <linux/slab.h> - -#include <linux/iio/iio.h> -#include <linux/iio/trigger.h> - -static LIST_HEAD(iio_gpio_trigger_list); -static DEFINE_MUTEX(iio_gpio_trigger_list_lock); - -struct iio_gpio_trigger_info { - struct mutex in_use; - unsigned int irq; -}; -/* - * Need to reference count these triggers and only enable gpio interrupts - * as appropriate. - */ - -/* So what functionality do we want in here?... */ -/* set high / low as interrupt type? */ - -static irqreturn_t iio_gpio_trigger_poll(int irq, void *private) -{ - /* Timestamp not currently provided */ - iio_trigger_poll(private, 0); - return IRQ_HANDLED; -} - -static const struct iio_trigger_ops iio_gpio_trigger_ops = { - .owner = THIS_MODULE, -}; - -static int iio_gpio_trigger_probe(struct platform_device *pdev) -{ - struct iio_gpio_trigger_info *trig_info; - struct iio_trigger *trig, *trig2; - unsigned long irqflags; - struct resource *irq_res; - int irq, ret = 0, irq_res_cnt = 0; - - do { - irq_res = platform_get_resource(pdev, - IORESOURCE_IRQ, irq_res_cnt); - - if (irq_res == NULL) { - if (irq_res_cnt == 0) - dev_err(&pdev->dev, "No GPIO IRQs specified"); - break; - } - irqflags = (irq_res->flags & IRQF_TRIGGER_MASK) | IRQF_SHARED; - - for (irq = irq_res->start; irq <= irq_res->end; irq++) { - - trig = iio_trigger_alloc("irqtrig%d", irq); - if (!trig) { - ret = -ENOMEM; - goto error_free_completed_registrations; - } - - trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL); - if (!trig_info) { - ret = -ENOMEM; - goto error_put_trigger; - } - iio_trigger_set_drvdata(trig, trig_info); - trig_info->irq = irq; - trig->ops = &iio_gpio_trigger_ops; - 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_trig_info; - } - - ret = iio_trigger_register(trig); - if (ret) - goto error_release_irq; - - list_add_tail(&trig->alloc_list, - &iio_gpio_trigger_list); - } - - irq_res_cnt++; - } while (irq_res != NULL); - - - return 0; - -/* First clean up the partly allocated trigger */ -error_release_irq: - free_irq(irq, trig); -error_free_trig_info: - kfree(trig_info); -error_put_trigger: - iio_trigger_put(trig); -error_free_completed_registrations: - /* The rest should have been added to the iio_gpio_trigger_list */ - list_for_each_entry_safe(trig, - trig2, - &iio_gpio_trigger_list, - alloc_list) { - trig_info = iio_trigger_get_drvdata(trig); - free_irq(gpio_to_irq(trig_info->irq), trig); - kfree(trig_info); - iio_trigger_unregister(trig); - } - - return ret; -} - -static int iio_gpio_trigger_remove(struct platform_device *pdev) -{ - struct iio_trigger *trig, *trig2; - struct iio_gpio_trigger_info *trig_info; - - mutex_lock(&iio_gpio_trigger_list_lock); - list_for_each_entry_safe(trig, - trig2, - &iio_gpio_trigger_list, - alloc_list) { - trig_info = iio_trigger_get_drvdata(trig); - iio_trigger_unregister(trig); - free_irq(trig_info->irq, trig); - kfree(trig_info); - iio_trigger_put(trig); - } - mutex_unlock(&iio_gpio_trigger_list_lock); - - return 0; -} - -static struct platform_driver iio_gpio_trigger_driver = { - .probe = iio_gpio_trigger_probe, - .remove = iio_gpio_trigger_remove, - .driver = { - .name = "iio_gpio_trigger", - .owner = THIS_MODULE, - }, -}; - -module_platform_driver(iio_gpio_trigger_driver); - -MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>"); -MODULE_DESCRIPTION("Example gpio trigger for the iio subsystem"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/trigger/iio-trig-sysfs.c b/drivers/staging/iio/trigger/iio-trig-sysfs.c deleted file mode 100644 index b727bde..0000000 --- a/drivers/staging/iio/trigger/iio-trig-sysfs.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2011 Analog Devices Inc. - * - * Licensed under the GPL-2. - * - */ - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/slab.h> -#include <linux/list.h> -#include <linux/irq_work.h> - -#include <linux/iio/iio.h> -#include <linux/iio/trigger.h> - -struct iio_sysfs_trig { - struct iio_trigger *trig; - struct irq_work work; - int id; - struct list_head l; -}; - -static LIST_HEAD(iio_sysfs_trig_list); -static DEFINE_MUTEX(iio_syfs_trig_list_mut); - -static int iio_sysfs_trigger_probe(int id); -static ssize_t iio_sysfs_trig_add(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - int ret; - unsigned long input; - - ret = strict_strtoul(buf, 10, &input); - if (ret) - return ret; - ret = iio_sysfs_trigger_probe(input); - if (ret) - return ret; - return len; -} -static DEVICE_ATTR(add_trigger, S_IWUSR, NULL, &iio_sysfs_trig_add); - -static int iio_sysfs_trigger_remove(int id); -static ssize_t iio_sysfs_trig_remove(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - int ret; - unsigned long input; - - ret = strict_strtoul(buf, 10, &input); - if (ret) - return ret; - ret = iio_sysfs_trigger_remove(input); - if (ret) - return ret; - return len; -} - -static DEVICE_ATTR(remove_trigger, S_IWUSR, NULL, &iio_sysfs_trig_remove); - -static struct attribute *iio_sysfs_trig_attrs[] = { - &dev_attr_add_trigger.attr, - &dev_attr_remove_trigger.attr, - NULL, -}; - -static const struct attribute_group iio_sysfs_trig_group = { - .attrs = iio_sysfs_trig_attrs, -}; - -static const struct attribute_group *iio_sysfs_trig_groups[] = { - &iio_sysfs_trig_group, - NULL -}; - - -/* Nothing to actually do upon release */ -static void iio_trigger_sysfs_release(struct device *dev) -{ -} - -static struct device iio_sysfs_trig_dev = { - .bus = &iio_bus_type, - .groups = iio_sysfs_trig_groups, - .release = &iio_trigger_sysfs_release, -}; - -static void iio_sysfs_trigger_work(struct irq_work *work) -{ - struct iio_sysfs_trig *trig = container_of(work, struct iio_sysfs_trig, - work); - - iio_trigger_poll(trig->trig, 0); -} - -static ssize_t iio_sysfs_trigger_poll(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct iio_trigger *trig = to_iio_trigger(dev); - struct iio_sysfs_trig *sysfs_trig = iio_trigger_get_drvdata(trig); - - irq_work_queue(&sysfs_trig->work); - - return count; -} - -static DEVICE_ATTR(trigger_now, S_IWUSR, NULL, iio_sysfs_trigger_poll); - -static struct attribute *iio_sysfs_trigger_attrs[] = { - &dev_attr_trigger_now.attr, - NULL, -}; - -static const struct attribute_group iio_sysfs_trigger_attr_group = { - .attrs = iio_sysfs_trigger_attrs, -}; - -static const struct attribute_group *iio_sysfs_trigger_attr_groups[] = { - &iio_sysfs_trigger_attr_group, - NULL -}; - -static const struct iio_trigger_ops iio_sysfs_trigger_ops = { - .owner = THIS_MODULE, -}; - -static int iio_sysfs_trigger_probe(int id) -{ - struct iio_sysfs_trig *t; - int ret; - bool foundit = false; - mutex_lock(&iio_syfs_trig_list_mut); - list_for_each_entry(t, &iio_sysfs_trig_list, l) - if (id == t->id) { - foundit = true; - break; - } - if (foundit) { - ret = -EINVAL; - goto out1; - } - t = kmalloc(sizeof(*t), GFP_KERNEL); - if (t == NULL) { - ret = -ENOMEM; - goto out1; - } - t->id = id; - t->trig = iio_trigger_alloc("sysfstrig%d", id); - if (!t->trig) { - ret = -ENOMEM; - goto free_t; - } - - t->trig->dev.groups = iio_sysfs_trigger_attr_groups; - t->trig->ops = &iio_sysfs_trigger_ops; - t->trig->dev.parent = &iio_sysfs_trig_dev; - iio_trigger_set_drvdata(t->trig, t); - - init_irq_work(&t->work, iio_sysfs_trigger_work); - - ret = iio_trigger_register(t->trig); - if (ret) - goto out2; - list_add(&t->l, &iio_sysfs_trig_list); - __module_get(THIS_MODULE); - mutex_unlock(&iio_syfs_trig_list_mut); - return 0; - -out2: - iio_trigger_put(t->trig); -free_t: - kfree(t); -out1: - mutex_unlock(&iio_syfs_trig_list_mut); - return ret; -} - -static int iio_sysfs_trigger_remove(int id) -{ - bool foundit = false; - struct iio_sysfs_trig *t; - mutex_lock(&iio_syfs_trig_list_mut); - list_for_each_entry(t, &iio_sysfs_trig_list, l) - if (id == t->id) { - foundit = true; - break; - } - if (!foundit) { - mutex_unlock(&iio_syfs_trig_list_mut); - return -EINVAL; - } - - iio_trigger_unregister(t->trig); - iio_trigger_free(t->trig); - - list_del(&t->l); - kfree(t); - module_put(THIS_MODULE); - mutex_unlock(&iio_syfs_trig_list_mut); - return 0; -} - - -static int __init iio_sysfs_trig_init(void) -{ - device_initialize(&iio_sysfs_trig_dev); - dev_set_name(&iio_sysfs_trig_dev, "iio_sysfs_trigger"); - return device_add(&iio_sysfs_trig_dev); -} -module_init(iio_sysfs_trig_init); - -static void __exit iio_sysfs_trig_exit(void) -{ - device_unregister(&iio_sysfs_trig_dev); -} -module_exit(iio_sysfs_trig_exit); - -MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); -MODULE_DESCRIPTION("Sysfs based trigger for the iio subsystem"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:iio-trig-sysfs"); |