Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fe11ffe authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: pcl812: remove VIRT_TO_BUS dependancy



Use dma_{alloc,free}_coherent() to allocate and free the DMA buffers.
This removes the dependancy on VIRT_TO_BUS.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d8332a68
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ config COMEDI_PCL730

config COMEDI_PCL812
	tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216"
	depends on VIRT_TO_BUS && ISA_DMA_API
	depends on ISA_DMA_API
	---help---
	  Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink
	  ACL-8112DG/HG/PG, ACL-8113, ACL-8216, ICP DAS A-821PGH/PGL/PGL-NDA,
+9 −11
Original line number Diff line number Diff line
@@ -507,8 +507,8 @@ static const struct pcl812_board boardtypes[] = {
};

struct pcl812_dma_desc {
	unsigned long virt_addr;	/* virtual address of DMA buffer */
	unsigned int hw_addr;	/* hardware (bus) address of DMA buffer */
	void *virt_addr;	/* virtual address of DMA buffer */
	dma_addr_t hw_addr;	/* hardware (bus) address of DMA buffer */
	unsigned int size;	/* transfer size (in bytes) */
};

@@ -518,7 +518,6 @@ struct pcl812_private {
	unsigned int last_ai_chanspec;
	unsigned char mode_reg_int;	/*  there is stored INT number for some card */
	unsigned int ai_poll_ptr;	/*  how many sampes transfer poll */
	unsigned int dmapages;
	unsigned int hwdmasize;
	struct pcl812_dma_desc dma_desc[2];
	int cur_dma;
@@ -905,7 +904,7 @@ static void pcl812_handle_dma(struct comedi_device *dev,
	bufptr = devpriv->ai_poll_ptr;
	devpriv->ai_poll_ptr = 0;

	transfer_from_dma_buf(dev, s, (void *)dma->virt_addr, bufptr, nsamples);
	transfer_from_dma_buf(dev, s, dma->virt_addr, bufptr, nsamples);
}

static irqreturn_t pcl812_interrupt(int irq, void *d)
@@ -964,7 +963,7 @@ static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
		return 0;
	}

	transfer_from_dma_buf(dev, s, (void *)dma->virt_addr,
	transfer_from_dma_buf(dev, s, dma->virt_addr,
			      devpriv->ai_poll_ptr, top2);

	devpriv->ai_poll_ptr = top1;	/*  new buffer position */
@@ -1203,17 +1202,15 @@ static int pcl812_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
		return 0;
	devpriv->dma = dma_chan;

	devpriv->dmapages = 1;	/* we want 8KB */
	devpriv->hwdmasize = (1 << devpriv->dmapages) * PAGE_SIZE;
	devpriv->hwdmasize = PAGE_SIZE * 2;	/* we want 8KB */

	for (i = 0; i < 2; i++) {
		dma = &devpriv->dma_desc[i];

		dma->virt_addr =  __get_dma_pages(GFP_KERNEL, devpriv->dmapages);
		dma->virt_addr = dma_alloc_coherent(NULL, devpriv->hwdmasize,
						    &dma->hw_addr, GFP_KERNEL);
		if (!dma->virt_addr)
			return -ENOMEM;

		dma->hw_addr = virt_to_bus((void *)dma->virt_addr);
	}
	return 0;
}
@@ -1230,7 +1227,8 @@ static void pcl812_free_dma(struct comedi_device *dev)
	for (i = 0; i < 2; i++) {
		dma = &devpriv->dma_desc[i];
		if (dma->virt_addr)
			free_pages(dma->virt_addr, devpriv->dmapages);
			dma_free_coherent(NULL, devpriv->hwdmasize,
					  dma->virt_addr, dma->hw_addr);
	}
	if (devpriv->dma)
		free_dma(devpriv->dma);