aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@cam.ac.uk>2011-05-18 09:42:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-19 19:15:01 -0400
commit383f650f6cf739b256eb24c4a1d397d883de56ff (patch)
tree01a2d36189c848ed378708ac1a8e258faa9b0306 /drivers
parentd1ab8552cda68dd100cf113cba7bc37e653ad886 (diff)
staging:iio:addac:adt7316 replace abuse of buffer events.
Currently squashed the fault condition from external temperature sensor - lots of other issues to be fixed with this driver which obeys almost no elements of the abi. V2: removed a couple of usused variables that sparse found. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/iio/addac/adt7316.c82
1 files changed, 52 insertions, 30 deletions
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
index 24dd2d2866c9..b71994ee8845 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -462,7 +462,7 @@ static ssize_t adt7316_show_all_ad_channels(struct device *dev,
462 462
463 if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) 463 if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
464 return sprintf(buf, "0 - VDD\n1 - Internal Temperature\n" 464 return sprintf(buf, "0 - VDD\n1 - Internal Temperature\n"
465 "2 - External Temperature or AIN2\n" 465 "2 - External Temperature or AIN1\n"
466 "3 - AIN2\n4 - AIN3\n5 - AIN4\n"); 466 "3 - AIN2\n4 - AIN3\n5 - AIN4\n");
467 else 467 else
468 return sprintf(buf, "0 - VDD\n1 - Internal Temperature\n" 468 return sprintf(buf, "0 - VDD\n1 - Internal Temperature\n"
@@ -1762,49 +1762,71 @@ static const struct attribute_group adt7516_attribute_group = {
1762 .attrs = adt7516_attributes, 1762 .attrs = adt7516_attributes,
1763}; 1763};
1764 1764
1765
1766/*
1767 * temperature bound events
1768 */
1769
1770#define IIO_EVENT_CODE_ADT7316_IN_TEMP_HIGH IIO_BUFFER_EVENT_CODE(0)
1771#define IIO_EVENT_CODE_ADT7316_IN_TEMP_LOW IIO_BUFFER_EVENT_CODE(1)
1772#define IIO_EVENT_CODE_ADT7316_EX_TEMP_HIGH IIO_BUFFER_EVENT_CODE(2)
1773#define IIO_EVENT_CODE_ADT7316_EX_TEMP_LOW IIO_BUFFER_EVENT_CODE(3)
1774#define IIO_EVENT_CODE_ADT7316_EX_TEMP_FAULT IIO_BUFFER_EVENT_CODE(4)
1775#define IIO_EVENT_CODE_ADT7516_AIN1 IIO_BUFFER_EVENT_CODE(5)
1776#define IIO_EVENT_CODE_ADT7516_AIN2 IIO_BUFFER_EVENT_CODE(6)
1777#define IIO_EVENT_CODE_ADT7516_AIN3 IIO_BUFFER_EVENT_CODE(7)
1778#define IIO_EVENT_CODE_ADT7516_AIN4 IIO_BUFFER_EVENT_CODE(8)
1779#define IIO_EVENT_CODE_ADT7316_VDD IIO_BUFFER_EVENT_CODE(9)
1780
1781static irqreturn_t adt7316_event_handler(int irq, void *private) 1765static irqreturn_t adt7316_event_handler(int irq, void *private)
1782{ 1766{
1783 struct iio_dev *indio_dev = private; 1767 struct iio_dev *indio_dev = private;
1784 struct adt7316_chip_info *chip = iio_dev_get_devdata(indio_dev); 1768 struct adt7316_chip_info *chip = iio_dev_get_devdata(indio_dev);
1785 u8 stat1, stat2; 1769 u8 stat1, stat2;
1786 int i, ret, count; 1770 int ret;
1771 s64 time;
1787 1772
1788 ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT1, &stat1); 1773 ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT1, &stat1);
1789 if (!ret) { 1774 if (!ret) {
1790 if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) 1775 if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX)
1791 count = 8; 1776 stat1 &= 0x1F;
1792 else
1793 count = 5;
1794 1777
1795 for (i = 0; i < count; i++) { 1778 time = iio_get_time_ns();
1796 if (stat1 & (1 << i)) 1779 if (stat1 & (1 << 0))
1797 iio_push_event(chip->indio_dev, 0, 1780 iio_push_event(chip->indio_dev, 0,
1798 IIO_EVENT_CODE_ADT7316_IN_TEMP_HIGH + i, 1781 IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
1799 iio_get_time_ns()); 1782 IIO_EV_TYPE_THRESH,
1783 IIO_EV_DIR_RISING),
1784 time);
1785 if (stat1 & (1 << 1))
1786 iio_push_event(chip->indio_dev, 0,
1787 IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
1788 IIO_EV_TYPE_THRESH,
1789 IIO_EV_DIR_FALLING),
1790 time);
1791 if (stat1 & (1 << 2))
1792 iio_push_event(chip->indio_dev, 0,
1793 IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
1794 IIO_EV_TYPE_THRESH,
1795 IIO_EV_DIR_RISING),
1796 time);
1797 if (stat1 & (1 << 3))
1798 iio_push_event(chip->indio_dev, 0,
1799 IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
1800 IIO_EV_TYPE_THRESH,
1801 IIO_EV_DIR_FALLING),
1802 time);
1803 if (stat1 & (1 << 5))
1804 iio_push_event(chip->indio_dev, 0,
1805 IIO_UNMOD_EVENT_CODE(IIO_IN, 1,
1806 IIO_EV_TYPE_THRESH,
1807 IIO_EV_DIR_EITHER),
1808 time);
1809 if (stat1 & (1 << 6))
1810 iio_push_event(chip->indio_dev, 0,
1811 IIO_UNMOD_EVENT_CODE(IIO_IN, 2,
1812 IIO_EV_TYPE_THRESH,
1813 IIO_EV_DIR_EITHER),
1814 time);
1815 if (stat1 & (1 << 7))
1816 iio_push_event(chip->indio_dev, 0,
1817 IIO_UNMOD_EVENT_CODE(IIO_IN, 3,
1818 IIO_EV_TYPE_THRESH,
1819 IIO_EV_DIR_EITHER),
1820 time);
1800 } 1821 }
1801 }
1802
1803 ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT2, &stat2); 1822 ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT2, &stat2);
1804 if (!ret) { 1823 if (!ret) {
1805 if (stat2 & ADT7316_INT_MASK2_VDD) 1824 if (stat2 & ADT7316_INT_MASK2_VDD)
1806 iio_push_event(chip->indio_dev, 0, 1825 iio_push_event(chip->indio_dev, 0,
1807 IIO_EVENT_CODE_ADT7316_VDD, 1826 IIO_UNMOD_EVENT_CODE(IIO_IN,
1827 0,
1828 IIO_EV_TYPE_THRESH,
1829 IIO_EV_DIR_RISING),
1808 iio_get_time_ns()); 1830 iio_get_time_ns());
1809 } 1831 }
1810 1832