Re: [PATCH] staging: comedi: ni_labpc: fix build when VIRT_TO_BUS is not defined

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 24 Apr 2013 11:26:14 -0700 H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxxxxxxxxxxx>
> Reported-by: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
> Cc: Ian Abbott <abbotti@xxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/staging/comedi/drivers/ni_labpc.c | 8 +++++---
>  drivers/staging/comedi/drivers/ni_labpc.h | 1 +
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
> index 3d978f3..77a7bb6 100644
> --- a/drivers/staging/comedi/drivers/ni_labpc.c
> +++ b/drivers/staging/comedi/drivers/ni_labpc.c
> @@ -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);
> diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h
> index 615f16f..4b691f5 100644
> --- a/drivers/staging/comedi/drivers/ni_labpc.h
> +++ b/drivers/staging/comedi/drivers/ni_labpc.h
> @@ -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. */

I applied this patch as fix patch after the staging tree today and it
seems to compile fine.

-- 
Cheers,
Stephen Rothwell                    sfr@xxxxxxxxxxxxxxxx

Attachment: pgpd2aOs14_pR.pgp
Description: PGP signature

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux