From: H Hartley Sweeten Date: Fri, 24 Oct 2014 17:26:05 +0000 (-0700) Subject: staging: comedi: addi_apci_1564: remove private data 'mode_select_register' X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7885b070b83ce5c8fb42bf65047e7dd6388d7b20;p=linux-beck.git staging: comedi: addi_apci_1564: remove private data 'mode_select_register' This driver currently passes the timer channel as the data[5] element to the timer (*insn_config) function. This is stored in the private data and use in the timer (*insn_read) and (*insn_write) functions to read/write the timer. This is just wrong, comedi passes the channel number in the insn->chanspec. Use that instead and remove the private data member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 45f977236162..ad9949c39eae 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -75,6 +75,7 @@ static int apci1564_timer_config(struct comedi_device *dev, unsigned int *data) { struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int ul_Command1 = 0; devpriv->tsk_current = current; @@ -115,19 +116,18 @@ static int apci1564_timer_config(struct comedi_device *dev, outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); } else if (data[0] == ADDIDATA_COUNTER) { devpriv->timer_select_mode = ADDIDATA_COUNTER; - devpriv->mode_select_register = data[5]; /* First Stop The Counter */ ul_Command1 = inl(dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; /* Stop The Timer */ outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); /* Set the reload value */ outl(data[3], dev->iobase + - APCI1564_COUNTER_RELOAD_REG(data[5] - 1)); + APCI1564_COUNTER_RELOAD_REG(chan)); /* Set the mode : */ /* - Disable the hardware */ @@ -141,17 +141,17 @@ static int apci1564_timer_config(struct comedi_device *dev, (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | (unsigned int) ((unsigned int) data[4] << 16UL); outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); /* Enable or Disable Interrupt */ ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1); outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); /* Set the Up/Down selection */ ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18); outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); } else { dev_err(dev->class_dev, "Invalid subdevice.\n"); } @@ -170,6 +170,7 @@ static int apci1564_timer_write(struct comedi_device *dev, unsigned int *data) { struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int ul_Command1 = 0; if (devpriv->timer_select_mode == ADDIDATA_TIMER) { @@ -189,7 +190,7 @@ static int apci1564_timer_write(struct comedi_device *dev, } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { ul_Command1 = inl(dev->iobase + - APCI1564_COUNTER_CTRL_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); if (data[1] == 1) { /* Start the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; @@ -202,7 +203,7 @@ static int apci1564_timer_write(struct comedi_device *dev, ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; } outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); } else { dev_err(dev->class_dev, "Invalid subdevice.\n"); } @@ -218,6 +219,7 @@ static int apci1564_timer_read(struct comedi_device *dev, unsigned int *data) { struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int ul_Command1 = 0; if (devpriv->timer_select_mode == ADDIDATA_TIMER) { @@ -230,10 +232,10 @@ static int apci1564_timer_read(struct comedi_device *dev, /* Read the Counter Actual Value. */ data[0] = inl(dev->iobase + - APCI1564_COUNTER_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_REG(chan)); ul_Command1 = inl(dev->iobase + - APCI1564_COUNTER_STATUS_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_STATUS_REG(chan)); /* Get the software trigger status */ data[1] = (unsigned char) ((ul_Command1 >> 1) & 1); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index b95da410a8e3..c328230b85ec 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -37,7 +37,6 @@ struct apci1564_private { unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ unsigned char timer_select_mode; - unsigned char mode_select_register; struct task_struct *tsk_current; };