Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 249781
b: refs/heads/master
c: db9afe2
h: refs/heads/master
i:
  249779: 6a2a054
v: v3
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed May 19, 2011
1 parent c258d91 commit 30c361c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 724cf92ddc0209d7b7358525a450d0238c784410
refs/heads/master: db9afe2fc0c59f84bc1950b9b78767bbcdc80f13
62 changes: 15 additions & 47 deletions trunk/drivers/staging/iio/adc/ad7816.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

#include <linux/interrupt.h>
#include <linux/gpio.h>
#include <linux/workqueue.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/list.h>
#include <linux/spi/spi.h>
#include <linux/rtc.h>

#include "../iio.h"
#include "../sysfs.h"
Expand Down Expand Up @@ -47,8 +45,6 @@ struct ad7816_chip_info {
const char *name;
struct spi_device *spi_dev;
struct iio_dev *indio_dev;
struct work_struct thresh_work;
s64 last_timestamp;
u16 rdwr_pin;
u16 convert_pin;
u16 busy_pin;
Expand Down Expand Up @@ -266,33 +262,14 @@ static const struct attribute_group ad7816_attribute_group = {

#define IIO_EVENT_CODE_AD7816_OTI IIO_BUFFER_EVENT_CODE(0)

static void ad7816_interrupt_bh(struct work_struct *work_s)
static irqreturn_t ad7816_event_handler(int irq, void *private)
{
struct ad7816_chip_info *chip =
container_of(work_s, struct ad7816_chip_info, thresh_work);

enable_irq(chip->spi_dev->irq);

iio_push_event(chip->indio_dev, 0,
IIO_EVENT_CODE_AD7816_OTI,
chip->last_timestamp);
}

static int ad7816_interrupt(struct iio_dev *dev_info,
int index,
s64 timestamp,
int no_test)
{
struct ad7816_chip_info *chip = dev_info->dev_data;

chip->last_timestamp = timestamp;
schedule_work(&chip->thresh_work);

return 0;
iio_push_event(private, 0,
IIO_EVENT_CODE_AD7816_OTI,
iio_get_time_ns());
return IRQ_HANDLED;
}

IIO_EVENT_SH(ad7816, &ad7816_interrupt);

static ssize_t ad7816_show_oti(struct device *dev,
struct device_attribute *attr,
char *buf)
Expand Down Expand Up @@ -352,11 +329,11 @@ static inline ssize_t ad7816_set_oti(struct device *dev,
return len;
}

IIO_EVENT_ATTR_SH(oti, iio_event_ad7816,
ad7816_show_oti, ad7816_set_oti, 0);
static IIO_DEVICE_ATTR(oti, S_IRUGO | S_IWUSR,
ad7816_show_oti, ad7816_set_oti, 0);

static struct attribute *ad7816_event_attributes[] = {
&iio_event_attr_oti.dev_attr.attr,
&iio_dev_attr_oti.dev_attr.attr,
NULL,
};

Expand Down Expand Up @@ -438,23 +415,14 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)

if (spi_dev->irq) {
/* Only low trigger is supported in ad7816/7/8 */
ret = iio_register_interrupt_line(spi_dev->irq,
chip->indio_dev,
0,
IRQF_TRIGGER_LOW,
chip->name);
ret = request_threaded_irq(spi_dev->irq,
NULL,
&ad7816_event_handler,
IRQF_TRIGGER_LOW,
chip->name,
chip->indio_dev);
if (ret)
goto error_unreg_dev;

/*
* The event handler list element refer to iio_event_ad7816.
* All event attributes bind to the same event handler.
* So, only register event handler once.
*/
iio_add_event_to_list(&iio_event_ad7816,
&chip->indio_dev->interrupts[0]->ev_list);

INIT_WORK(&chip->thresh_work, ad7816_interrupt_bh);
}

dev_info(&spi_dev->dev, "%s temperature sensor and ADC registered.\n",
Expand Down Expand Up @@ -485,7 +453,7 @@ static int __devexit ad7816_remove(struct spi_device *spi_dev)

dev_set_drvdata(&spi_dev->dev, NULL);
if (spi_dev->irq)
iio_unregister_interrupt_line(indio_dev, 0);
free_irq(spi_dev->irq, indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(chip->indio_dev);
gpio_free(chip->busy_pin);
Expand Down

0 comments on commit 30c361c

Please sign in to comment.