From: H Hartley Sweeten Date: Sat, 19 Jul 2014 00:01:20 +0000 (-0700) Subject: staging: comedi: pcl816: remove forward declaration X-Git-Tag: v3.17-rc1~123^2~377 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=bb3bd743b8394452f8415be099aa512a5bfeb03a;p=karo-tx-linux.git staging: comedi: pcl816: remove forward declaration Move check_channel_list() to remove the need for the forward declaration. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 7cd54359af64..54732c5cab97 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -130,10 +130,6 @@ struct pcl816_private { unsigned int ai_cmd_canceled:1; }; -static int check_channel_list(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int *chanlist, unsigned int chanlen); - static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters) { struct pcl816_private *devpriv = dev->private; @@ -363,6 +359,62 @@ static irqreturn_t pcl816_interrupt(int irq, void *d) return IRQ_HANDLED; } +static int check_channel_list(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int *chanlist, + unsigned int chanlen) +{ + unsigned int chansegment[16]; + unsigned int i, nowmustbechan, seglen, segpos; + + /* correct channel and range number check itself comedi/range.c */ + if (chanlen < 1) { + dev_err(dev->class_dev, "range/channel list is empty!\n"); + return 0; + } + + if (chanlen > 1) { + /* first channel is every time ok */ + chansegment[0] = chanlist[0]; + for (i = 1, seglen = 1; i < chanlen; i++, seglen++) { + /* we detect loop, this must by finish */ + if (chanlist[0] == chanlist[i]) + break; + nowmustbechan = + (CR_CHAN(chansegment[i - 1]) + 1) % chanlen; + if (nowmustbechan != CR_CHAN(chanlist[i])) { + /* channel list isn't continuous :-( */ + dev_dbg(dev->class_dev, + "channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n", + i, CR_CHAN(chanlist[i]), nowmustbechan, + CR_CHAN(chanlist[0])); + return 0; + } + /* well, this is next correct channel in list */ + chansegment[i] = chanlist[i]; + } + + /* check whole chanlist */ + for (i = 0, segpos = 0; i < chanlen; i++) { + if (chanlist[i] != chansegment[i % seglen]) { + dev_dbg(dev->class_dev, + "bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", + i, CR_CHAN(chansegment[i]), + CR_RANGE(chansegment[i]), + CR_AREF(chansegment[i]), + CR_CHAN(chanlist[i % seglen]), + CR_RANGE(chanlist[i % seglen]), + CR_AREF(chansegment[i % seglen])); + return 0; /* chan/gain list is strange */ + } + } + } else { + seglen = 1; + } + + return seglen; /* we can serve this with MUX logic */ +} + static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -542,62 +594,6 @@ static int pcl816_ai_cancel(struct comedi_device *dev, return 0; } -static int -check_channel_list(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int *chanlist, - unsigned int chanlen) -{ - unsigned int chansegment[16]; - unsigned int i, nowmustbechan, seglen, segpos; - - /* correct channel and range number check itself comedi/range.c */ - if (chanlen < 1) { - dev_err(dev->class_dev, "range/channel list is empty!\n"); - return 0; - } - - if (chanlen > 1) { - /* first channel is every time ok */ - chansegment[0] = chanlist[0]; - for (i = 1, seglen = 1; i < chanlen; i++, seglen++) { - /* we detect loop, this must by finish */ - if (chanlist[0] == chanlist[i]) - break; - nowmustbechan = - (CR_CHAN(chansegment[i - 1]) + 1) % chanlen; - if (nowmustbechan != CR_CHAN(chanlist[i])) { - /* channel list isn't continuous :-( */ - dev_dbg(dev->class_dev, - "channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n", - i, CR_CHAN(chanlist[i]), nowmustbechan, - CR_CHAN(chanlist[0])); - return 0; - } - /* well, this is next correct channel in list */ - chansegment[i] = chanlist[i]; - } - - /* check whole chanlist */ - for (i = 0, segpos = 0; i < chanlen; i++) { - if (chanlist[i] != chansegment[i % seglen]) { - dev_dbg(dev->class_dev, - "bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", - i, CR_CHAN(chansegment[i]), - CR_RANGE(chansegment[i]), - CR_AREF(chansegment[i]), - CR_CHAN(chanlist[i % seglen]), - CR_RANGE(chanlist[i % seglen]), - CR_AREF(chansegment[i % seglen])); - return 0; /* chan/gain list is strange */ - } - } - } else { - seglen = 1; - } - - return seglen; /* we can serve this with MUX logic */ -} - static int pcl816_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn,