Commit 1581a035 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_labpc: fix build when VIRT_TO_BUS is not defined

After merging the final tree, the next-20130424 build (powerpc
allyesconfig) failed like this:

drivers/staging/comedi/drivers/ni_labpc.c: In function 'labpc_ai_cmd':
drivers/staging/comedi/drivers/ni_labpc.c:980:9: error:
    implicit declaration of function 'virt_to_bus'
   [-Werror=implicit-function-declaration]

The virt_to_bus() is only needed for the ISA DMA support in this driver.

On powerpc, CONFIG_COMEDI_NI_LABPC_ISA cannot be enabled due to the
depends on VIRT_TO_BUS but the PCI driver, ni_labpc_pci, can be enabled.
That driver uses the ni_labpc driver for the common support code shared
by the ISA, PCI, and PCMCIA boards.

The ISA specific support, and the optional ISA DMA support, are currently
still in the common ni_labpc driver. The ISA specific code is protected
by #if IS_ENABLED(CONFIG_COMEDI_NI_LABPC_ISA) and the ISA DMA support
is protected by #ifdef CONFIG_ISA_DMA_API. This allows the ISA support
to be enabled on architectures that support VIRT_TO_BUS and optionally
enables ISA DMA support if ISA_DMA_API is enabled.

Unfortunately, the ISA DMA code uses virt_to_bus(). This results in
the build failure for architectures that enable ISA_DMA_API but do not
have VIRT_TO_BUS.

Add a new member to the private data, dma_addr, to hold the phys_addr_t
returned by virt_to_bus() and initialize it in the ISA specific
labpc_attach().

For architectures that enable ISA_DMA_API but not VIRT_TO_BUS, this
will fix the build error. This is also safe for architectures the
enable both options but don't enable COMEDI_NI_LABPC_ISA because the
dma channel (devpriv->dma_chan) is only initialized in the ISA
specific labpc_attach().
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0a438d5b
...@@ -976,8 +976,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -976,8 +976,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* clear flip-flop to make sure 2-byte registers for /* clear flip-flop to make sure 2-byte registers for
* count and address get set correctly */ * count and address get set correctly */
clear_dma_ff(devpriv->dma_chan); clear_dma_ff(devpriv->dma_chan);
set_dma_addr(devpriv->dma_chan, set_dma_addr(devpriv->dma_chan, devpriv->dma_addr);
virt_to_bus(devpriv->dma_buffer));
/* set appropriate size of transfer */ /* set appropriate size of transfer */
devpriv->dma_transfer_size = labpc_suggest_transfer_size(cmd); devpriv->dma_transfer_size = labpc_suggest_transfer_size(cmd);
if (cmd->stop_src == TRIG_COUNT && if (cmd->stop_src == TRIG_COUNT &&
...@@ -1089,7 +1088,7 @@ static void labpc_drain_dma(struct comedi_device *dev) ...@@ -1089,7 +1088,7 @@ static void labpc_drain_dma(struct comedi_device *dev)
devpriv->count -= num_points; devpriv->count -= num_points;
/* set address and count for next transfer */ /* set address and count for next transfer */
set_dma_addr(devpriv->dma_chan, virt_to_bus(devpriv->dma_buffer)); set_dma_addr(devpriv->dma_chan, devpriv->dma_addr);
set_dma_count(devpriv->dma_chan, leftover * sample_size); set_dma_count(devpriv->dma_chan, leftover * sample_size);
release_dma_lock(flags); release_dma_lock(flags);
...@@ -1741,6 +1740,9 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1741,6 +1740,9 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
unsigned long dma_flags; unsigned long dma_flags;
devpriv->dma_chan = dma_chan; devpriv->dma_chan = dma_chan;
devpriv->dma_addr =
virt_to_bus(devpriv->dma_buffer);
dma_flags = claim_dma_lock(); dma_flags = claim_dma_lock();
disable_dma(devpriv->dma_chan); disable_dma(devpriv->dma_chan);
set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); set_dma_mode(devpriv->dma_chan, DMA_MODE_READ);
......
...@@ -82,6 +82,7 @@ struct labpc_private { ...@@ -82,6 +82,7 @@ struct labpc_private {
unsigned int divisor_b1; unsigned int divisor_b1;
unsigned int dma_chan; /* dma channel to use */ unsigned int dma_chan; /* dma channel to use */
u16 *dma_buffer; /* buffer ai will dma into */ u16 *dma_buffer; /* buffer ai will dma into */
phys_addr_t dma_addr;
/* transfer size in bytes for current transfer */ /* transfer size in bytes for current transfer */
unsigned int dma_transfer_size; unsigned int dma_transfer_size;
/* we are using dma/fifo-half-full/etc. */ /* we are using dma/fifo-half-full/etc. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment