diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-06-20 22:26:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-22 23:05:02 -0400 |
commit | 6baffbc2a4a11d78325f338a5e4731207ab9ca7d (patch) | |
tree | 67708125c650ba19129ed084435da00b15ee08d8 /drivers | |
parent | 954147296993e1c369f8e1d68d488724e7040dea (diff) |
staging: comedi: s626: remove forward declarations 5
Move the irq set/reset/clear and ns_to_timer helper functions
up to remove the need for the forward declarations.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/drivers/s626.c | 224 |
1 files changed, 109 insertions, 115 deletions
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 3cdb29323ca3..cc18bf06a243 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c | |||
@@ -207,12 +207,6 @@ static struct dio_private *dio_private_word[]={ | |||
207 | #define devpriv ((struct s626_private *)dev->private) | 207 | #define devpriv ((struct s626_private *)dev->private) |
208 | #define diopriv ((struct dio_private *)s->private) | 208 | #define diopriv ((struct dio_private *)s->private) |
209 | 209 | ||
210 | static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan); | ||
211 | static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int gruop, | ||
212 | unsigned int mask); | ||
213 | static int s626_dio_clear_irq(struct comedi_device *dev); | ||
214 | static int s626_ns_to_timer(int *nanosec, int round_mode); | ||
215 | |||
216 | /* COUNTER OBJECT ------------------------------------------------ */ | 210 | /* COUNTER OBJECT ------------------------------------------------ */ |
217 | struct enc_private { | 211 | struct enc_private { |
218 | /* Pointers to functions that differ for A and B counters: */ | 212 | /* Pointers to functions that differ for A and B counters: */ |
@@ -803,6 +797,87 @@ static unsigned int s626_ai_reg_to_uint(int data) | |||
803 | /* return 0; */ | 797 | /* return 0; */ |
804 | /* } */ | 798 | /* } */ |
805 | 799 | ||
800 | static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan) | ||
801 | { | ||
802 | unsigned int group; | ||
803 | unsigned int bitmask; | ||
804 | unsigned int status; | ||
805 | |||
806 | /* select dio bank */ | ||
807 | group = chan / 16; | ||
808 | bitmask = 1 << (chan - (16 * group)); | ||
809 | DEBUG("s626_dio_set_irq: enable interrupt on dio channel %d group %d\n", | ||
810 | chan - (16 * group), group); | ||
811 | |||
812 | /* set channel to capture positive edge */ | ||
813 | status = DEBIread(dev, | ||
814 | ((struct dio_private *)(dev->subdevices + 2 + | ||
815 | group)->private)->RDEdgSel); | ||
816 | DEBIwrite(dev, | ||
817 | ((struct dio_private *)(dev->subdevices + 2 + | ||
818 | group)->private)->WREdgSel, | ||
819 | bitmask | status); | ||
820 | |||
821 | /* enable interrupt on selected channel */ | ||
822 | status = DEBIread(dev, | ||
823 | ((struct dio_private *)(dev->subdevices + 2 + | ||
824 | group)->private)->RDIntSel); | ||
825 | DEBIwrite(dev, | ||
826 | ((struct dio_private *)(dev->subdevices + 2 + | ||
827 | group)->private)->WRIntSel, | ||
828 | bitmask | status); | ||
829 | |||
830 | /* enable edge capture write command */ | ||
831 | DEBIwrite(dev, LP_MISC1, MISC1_EDCAP); | ||
832 | |||
833 | /* enable edge capture on selected channel */ | ||
834 | status = DEBIread(dev, | ||
835 | ((struct dio_private *)(dev->subdevices + 2 + | ||
836 | group)->private)->RDCapSel); | ||
837 | DEBIwrite(dev, | ||
838 | ((struct dio_private *)(dev->subdevices + 2 + | ||
839 | group)->private)->WRCapSel, | ||
840 | bitmask | status); | ||
841 | |||
842 | return 0; | ||
843 | } | ||
844 | |||
845 | static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int group, | ||
846 | unsigned int mask) | ||
847 | { | ||
848 | DEBUG | ||
849 | ("s626_dio_reset_irq: disable interrupt on dio channel %d group %d\n", | ||
850 | mask, group); | ||
851 | |||
852 | /* disable edge capture write command */ | ||
853 | DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP); | ||
854 | |||
855 | /* enable edge capture on selected channel */ | ||
856 | DEBIwrite(dev, | ||
857 | ((struct dio_private *)(dev->subdevices + 2 + | ||
858 | group)->private)->WRCapSel, mask); | ||
859 | |||
860 | return 0; | ||
861 | } | ||
862 | |||
863 | static int s626_dio_clear_irq(struct comedi_device *dev) | ||
864 | { | ||
865 | unsigned int group; | ||
866 | |||
867 | /* disable edge capture write command */ | ||
868 | DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP); | ||
869 | |||
870 | for (group = 0; group < S626_DIO_BANKS; group++) { | ||
871 | /* clear pending events and interrupt */ | ||
872 | DEBIwrite(dev, | ||
873 | ((struct dio_private *)(dev->subdevices + 2 + | ||
874 | group)->private)->WRCapSel, | ||
875 | 0xffff); | ||
876 | } | ||
877 | |||
878 | return 0; | ||
879 | } | ||
880 | |||
806 | static irqreturn_t s626_irq_handler(int irq, void *d) | 881 | static irqreturn_t s626_irq_handler(int irq, void *d) |
807 | { | 882 | { |
808 | struct comedi_device *dev = d; | 883 | struct comedi_device *dev = d; |
@@ -1500,6 +1575,34 @@ static int s626_ai_inttrig(struct comedi_device *dev, | |||
1500 | return 1; | 1575 | return 1; |
1501 | } | 1576 | } |
1502 | 1577 | ||
1578 | /* This function doesn't require a particular form, this is just what | ||
1579 | * happens to be used in some of the drivers. It should convert ns | ||
1580 | * nanoseconds to a counter value suitable for programming the device. | ||
1581 | * Also, it should adjust ns so that it cooresponds to the actual time | ||
1582 | * that the device will use. */ | ||
1583 | static int s626_ns_to_timer(int *nanosec, int round_mode) | ||
1584 | { | ||
1585 | int divider, base; | ||
1586 | |||
1587 | base = 500; /* 2MHz internal clock */ | ||
1588 | |||
1589 | switch (round_mode) { | ||
1590 | case TRIG_ROUND_NEAREST: | ||
1591 | default: | ||
1592 | divider = (*nanosec + base / 2) / base; | ||
1593 | break; | ||
1594 | case TRIG_ROUND_DOWN: | ||
1595 | divider = (*nanosec) / base; | ||
1596 | break; | ||
1597 | case TRIG_ROUND_UP: | ||
1598 | divider = (*nanosec + base - 1) / base; | ||
1599 | break; | ||
1600 | } | ||
1601 | |||
1602 | *nanosec = base * divider; | ||
1603 | return divider - 1; | ||
1604 | } | ||
1605 | |||
1503 | /* TO COMPLETE */ | 1606 | /* TO COMPLETE */ |
1504 | static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) | 1607 | static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) |
1505 | { | 1608 | { |
@@ -1832,34 +1935,6 @@ static int s626_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) | |||
1832 | return 0; | 1935 | return 0; |
1833 | } | 1936 | } |
1834 | 1937 | ||
1835 | /* This function doesn't require a particular form, this is just what | ||
1836 | * happens to be used in some of the drivers. It should convert ns | ||
1837 | * nanoseconds to a counter value suitable for programming the device. | ||
1838 | * Also, it should adjust ns so that it cooresponds to the actual time | ||
1839 | * that the device will use. */ | ||
1840 | static int s626_ns_to_timer(int *nanosec, int round_mode) | ||
1841 | { | ||
1842 | int divider, base; | ||
1843 | |||
1844 | base = 500; /* 2MHz internal clock */ | ||
1845 | |||
1846 | switch (round_mode) { | ||
1847 | case TRIG_ROUND_NEAREST: | ||
1848 | default: | ||
1849 | divider = (*nanosec + base / 2) / base; | ||
1850 | break; | ||
1851 | case TRIG_ROUND_DOWN: | ||
1852 | divider = (*nanosec) / base; | ||
1853 | break; | ||
1854 | case TRIG_ROUND_UP: | ||
1855 | divider = (*nanosec + base - 1) / base; | ||
1856 | break; | ||
1857 | } | ||
1858 | |||
1859 | *nanosec = base * divider; | ||
1860 | return divider - 1; | ||
1861 | } | ||
1862 | |||
1863 | static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, | 1938 | static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, |
1864 | struct comedi_insn *insn, unsigned int *data) | 1939 | struct comedi_insn *insn, unsigned int *data) |
1865 | { | 1940 | { |
@@ -1980,87 +2055,6 @@ static int s626_dio_insn_config(struct comedi_device *dev, | |||
1980 | return 1; | 2055 | return 1; |
1981 | } | 2056 | } |
1982 | 2057 | ||
1983 | static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan) | ||
1984 | { | ||
1985 | unsigned int group; | ||
1986 | unsigned int bitmask; | ||
1987 | unsigned int status; | ||
1988 | |||
1989 | /* select dio bank */ | ||
1990 | group = chan / 16; | ||
1991 | bitmask = 1 << (chan - (16 * group)); | ||
1992 | DEBUG("s626_dio_set_irq: enable interrupt on dio channel %d group %d\n", | ||
1993 | chan - (16 * group), group); | ||
1994 | |||
1995 | /* set channel to capture positive edge */ | ||
1996 | status = DEBIread(dev, | ||
1997 | ((struct dio_private *)(dev->subdevices + 2 + | ||
1998 | group)->private)->RDEdgSel); | ||
1999 | DEBIwrite(dev, | ||
2000 | ((struct dio_private *)(dev->subdevices + 2 + | ||
2001 | group)->private)->WREdgSel, | ||
2002 | bitmask | status); | ||
2003 | |||
2004 | /* enable interrupt on selected channel */ | ||
2005 | status = DEBIread(dev, | ||
2006 | ((struct dio_private *)(dev->subdevices + 2 + | ||
2007 | group)->private)->RDIntSel); | ||
2008 | DEBIwrite(dev, | ||
2009 | ((struct dio_private *)(dev->subdevices + 2 + | ||
2010 | group)->private)->WRIntSel, | ||
2011 | bitmask | status); | ||
2012 | |||
2013 | /* enable edge capture write command */ | ||
2014 | DEBIwrite(dev, LP_MISC1, MISC1_EDCAP); | ||
2015 | |||
2016 | /* enable edge capture on selected channel */ | ||
2017 | status = DEBIread(dev, | ||
2018 | ((struct dio_private *)(dev->subdevices + 2 + | ||
2019 | group)->private)->RDCapSel); | ||
2020 | DEBIwrite(dev, | ||
2021 | ((struct dio_private *)(dev->subdevices + 2 + | ||
2022 | group)->private)->WRCapSel, | ||
2023 | bitmask | status); | ||
2024 | |||
2025 | return 0; | ||
2026 | } | ||
2027 | |||
2028 | static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int group, | ||
2029 | unsigned int mask) | ||
2030 | { | ||
2031 | DEBUG | ||
2032 | ("s626_dio_reset_irq: disable interrupt on dio channel %d group %d\n", | ||
2033 | mask, group); | ||
2034 | |||
2035 | /* disable edge capture write command */ | ||
2036 | DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP); | ||
2037 | |||
2038 | /* enable edge capture on selected channel */ | ||
2039 | DEBIwrite(dev, | ||
2040 | ((struct dio_private *)(dev->subdevices + 2 + | ||
2041 | group)->private)->WRCapSel, mask); | ||
2042 | |||
2043 | return 0; | ||
2044 | } | ||
2045 | |||
2046 | static int s626_dio_clear_irq(struct comedi_device *dev) | ||
2047 | { | ||
2048 | unsigned int group; | ||
2049 | |||
2050 | /* disable edge capture write command */ | ||
2051 | DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP); | ||
2052 | |||
2053 | for (group = 0; group < S626_DIO_BANKS; group++) { | ||
2054 | /* clear pending events and interrupt */ | ||
2055 | DEBIwrite(dev, | ||
2056 | ((struct dio_private *)(dev->subdevices + 2 + | ||
2057 | group)->private)->WRCapSel, | ||
2058 | 0xffff); | ||
2059 | } | ||
2060 | |||
2061 | return 0; | ||
2062 | } | ||
2063 | |||
2064 | /* Now this function initializes the value of the counter (data[0]) | 2058 | /* Now this function initializes the value of the counter (data[0]) |
2065 | and set the subdevice. To complete with trigger and interrupt | 2059 | and set the subdevice. To complete with trigger and interrupt |
2066 | configuration */ | 2060 | configuration */ |