staging: comedi: ni_labpc: fix build when VIRT_TO_BUS is not defined
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 24 Apr 2013 18:26:14 +0000 (11:26 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 May 2013 21:36:28 +0000 (17:36 -0400)
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_labpc.h

index 3d978f34d212b4c9f925ad928496403f8039c40f..77a7bb63258034ae0dd2b88bd692a0b6da9fe317 100644 (file)
@@ -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
                 * count and address get set correctly */
                clear_dma_ff(devpriv->dma_chan);
-               set_dma_addr(devpriv->dma_chan,
-                            virt_to_bus(devpriv->dma_buffer));
+               set_dma_addr(devpriv->dma_chan, devpriv->dma_addr);
                /*  set appropriate size of transfer */
                devpriv->dma_transfer_size = labpc_suggest_transfer_size(cmd);
                if (cmd->stop_src == TRIG_COUNT &&
@@ -1089,7 +1088,7 @@ static void labpc_drain_dma(struct comedi_device *dev)
                devpriv->count -= num_points;
 
        /*  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);
        release_dma_lock(flags);
 
@@ -1741,6 +1740,9 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                                unsigned long dma_flags;
 
                                devpriv->dma_chan = dma_chan;
+                               devpriv->dma_addr =
+                                       virt_to_bus(devpriv->dma_buffer);
+
                                dma_flags = claim_dma_lock();
                                disable_dma(devpriv->dma_chan);
                                set_dma_mode(devpriv->dma_chan, DMA_MODE_READ);
index 615f16f271c0a8078a1a6a22339393ffdeddf2ed..4b691f5a9965098cd6edebb5be04d940ea65af19 100644 (file)
@@ -82,6 +82,7 @@ struct labpc_private {
        unsigned int divisor_b1;
        unsigned int dma_chan;  /*  dma channel to use */
        u16 *dma_buffer;        /*  buffer ai will dma into */
+       phys_addr_t dma_addr;
        /* transfer size in bytes for current transfer */
        unsigned int dma_transfer_size;
        /* we are using dma/fifo-half-full/etc. */