staging: comedi: s626: remove 'allocatedBuf' from private data
This variable is only used to count the number of dma buffers allocated during the attach. If an allocation fails, the attach function exits with -ENOMEM. When this variable is checked later it will always be == 2. Just remove the variable and the check. This allows bringing the code back an indent level in s626_initialize(). Note, coding style issues in this function are not addressed yet. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f996ab29e9
commit
68ad0ae0ea
1 changed files with 181 additions and 192 deletions
|
@ -80,7 +80,6 @@ INSN_CONFIG instructions:
|
||||||
|
|
||||||
struct s626_private {
|
struct s626_private {
|
||||||
void __iomem *base_addr;
|
void __iomem *base_addr;
|
||||||
short allocatedBuf;
|
|
||||||
uint8_t ai_cmd_running; /* ai_cmd is running */
|
uint8_t ai_cmd_running; /* ai_cmd is running */
|
||||||
uint8_t ai_continous; /* continous acquisition */
|
uint8_t ai_continous; /* continous acquisition */
|
||||||
int ai_sample_count; /* number of samples to acquire */
|
int ai_sample_count; /* number of samples to acquire */
|
||||||
|
@ -2443,24 +2442,18 @@ static int s626_allocate_dma_buffers(struct comedi_device *dev)
|
||||||
void *addr;
|
void *addr;
|
||||||
dma_addr_t appdma;
|
dma_addr_t appdma;
|
||||||
|
|
||||||
devpriv->allocatedBuf = 0;
|
|
||||||
|
|
||||||
addr = pci_alloc_consistent(pcidev, DMABUF_SIZE, &appdma);
|
addr = pci_alloc_consistent(pcidev, DMABUF_SIZE, &appdma);
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
devpriv->ANABuf.LogicalBase = addr;
|
devpriv->ANABuf.LogicalBase = addr;
|
||||||
devpriv->ANABuf.PhysicalBase = appdma;
|
devpriv->ANABuf.PhysicalBase = appdma;
|
||||||
|
|
||||||
devpriv->allocatedBuf++;
|
|
||||||
|
|
||||||
addr = pci_alloc_consistent(pcidev, DMABUF_SIZE, &appdma);
|
addr = pci_alloc_consistent(pcidev, DMABUF_SIZE, &appdma);
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
devpriv->RPSBuf.LogicalBase = addr;
|
devpriv->RPSBuf.LogicalBase = addr;
|
||||||
devpriv->RPSBuf.PhysicalBase = appdma;
|
devpriv->RPSBuf.PhysicalBase = appdma;
|
||||||
|
|
||||||
devpriv->allocatedBuf++;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2471,11 +2464,10 @@ static void s626_initialize(struct comedi_device *dev)
|
||||||
/* uint16_t StartVal; */
|
/* uint16_t StartVal; */
|
||||||
/* uint16_t index; */
|
/* uint16_t index; */
|
||||||
/* unsigned int data[16]; */
|
/* unsigned int data[16]; */
|
||||||
int i;
|
|
||||||
|
|
||||||
if (devpriv->allocatedBuf == 2) {
|
|
||||||
dma_addr_t pPhysBuf;
|
dma_addr_t pPhysBuf;
|
||||||
uint16_t chan;
|
uint16_t chan;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
|
||||||
/* enab DEBI and audio pins, enable I2C interface. */
|
/* enab DEBI and audio pins, enable I2C interface. */
|
||||||
MC_ENABLE(P_MC1, MC1_DEBI | MC1_AUDIO | MC1_I2C);
|
MC_ENABLE(P_MC1, MC1_DEBI | MC1_AUDIO | MC1_I2C);
|
||||||
|
@ -2623,8 +2615,7 @@ static void s626_initialize(struct comedi_device *dev)
|
||||||
* single DWORD will be transferred each time a DMA transfer is
|
* single DWORD will be transferred each time a DMA transfer is
|
||||||
* enabled. */
|
* enabled. */
|
||||||
|
|
||||||
pPhysBuf =
|
pPhysBuf = devpriv->ANABuf.PhysicalBase +
|
||||||
devpriv->ANABuf.PhysicalBase +
|
|
||||||
(DAC_WDMABUF_OS * sizeof(uint32_t));
|
(DAC_WDMABUF_OS * sizeof(uint32_t));
|
||||||
|
|
||||||
WR7146(P_BASEA2_OUT, (uint32_t) pPhysBuf); /* Buffer base adrs. */
|
WR7146(P_BASEA2_OUT, (uint32_t) pPhysBuf); /* Buffer base adrs. */
|
||||||
|
@ -2632,8 +2623,8 @@ static void s626_initialize(struct comedi_device *dev)
|
||||||
|
|
||||||
/* Cache Audio2's output DMA buffer logical address. This is
|
/* Cache Audio2's output DMA buffer logical address. This is
|
||||||
* where DAC data is buffered for A2 output DMA transfers. */
|
* where DAC data is buffered for A2 output DMA transfers. */
|
||||||
devpriv->pDacWBuf =
|
devpriv->pDacWBuf = (uint32_t *)devpriv->ANABuf.LogicalBase +
|
||||||
(uint32_t *) devpriv->ANABuf.LogicalBase + DAC_WDMABUF_OS;
|
DAC_WDMABUF_OS;
|
||||||
|
|
||||||
/* Audio2's output channels does not use paging. The protection
|
/* Audio2's output channels does not use paging. The protection
|
||||||
* violation handling bit is set so that the DMAC will
|
* violation handling bit is set so that the DMAC will
|
||||||
|
@ -2717,8 +2708,7 @@ static void s626_initialize(struct comedi_device *dev)
|
||||||
* standard DIO (vs. counter overflow) mode, disable the battery
|
* standard DIO (vs. counter overflow) mode, disable the battery
|
||||||
* charger, and reset the watchdog interval selector to zero.
|
* charger, and reset the watchdog interval selector to zero.
|
||||||
*/
|
*/
|
||||||
WriteMISC2(dev, (uint16_t) (DEBIread(dev,
|
WriteMISC2(dev, (uint16_t)(DEBIread(dev, LP_RDMISC2) &
|
||||||
LP_RDMISC2) &
|
|
||||||
MISC2_BATT_ENABLE));
|
MISC2_BATT_ENABLE));
|
||||||
|
|
||||||
/* Initialize the digital I/O subsystem. */
|
/* Initialize the digital I/O subsystem. */
|
||||||
|
@ -2727,7 +2717,6 @@ static void s626_initialize(struct comedi_device *dev)
|
||||||
/* enable interrupt test */
|
/* enable interrupt test */
|
||||||
/* writel(IRQ_GPIO3 | IRQ_RPS1,devpriv->base_addr+P_IER); */
|
/* writel(IRQ_GPIO3 | IRQ_RPS1,devpriv->base_addr+P_IER); */
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static int s626_attach_pci(struct comedi_device *dev, struct pci_dev *pcidev)
|
static int s626_attach_pci(struct comedi_device *dev, struct pci_dev *pcidev)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue