[PATCH 15/37] staging: comedi: ni_labpc_isadma: tidy up labpc_init_dma_chan()

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

 



DMA support is optional for the labpc driver. The return value from
labpc_init_dma_chan() is not even checked by the caller.

Change the return type to void and tidy up the function a bit.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_labpc_isadma.c | 22 ++++++++--------------
 drivers/staging/comedi/drivers/ni_labpc_isadma.h |  7 +++----
 2 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c
index b7217a7..829c4e4 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c
@@ -163,28 +163,24 @@ void labpc_handle_dma_status(struct comedi_device *dev)
 }
 EXPORT_SYMBOL_GPL(labpc_handle_dma_status);
 
-int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan)
+void labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan)
 {
 	struct labpc_private *devpriv = dev->private;
 	struct labpc_dma_desc *dma = &devpriv->dma_desc;
-	void *dma_buffer;
 	unsigned long dma_flags;
-	int ret;
 
 	if (dma_chan != 1 && dma_chan != 3)
-		return -EINVAL;
+		return;
 
-	dma_buffer = kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA);
-	if (!dma_buffer)
-		return -ENOMEM;
+	if (request_dma(dma_chan, dev->board_name))
+		return;
 
-	ret = request_dma(dma_chan, dev->board_name);
-	if (ret) {
-		kfree(dma_buffer);
-		return ret;
+	dma->virt_addr = kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA);
+	if (!dma->virt_addr) {
+		free_dma(dma_chan);
+		return;
 	}
 
-	dma->virt_addr = dma_buffer;
 	dma->chan = dma_chan;
 	dma->hw_addr = virt_to_bus(dma->virt_addr);
 
@@ -192,8 +188,6 @@ int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan)
 	disable_dma(dma->chan);
 	set_dma_mode(dma->chan, DMA_MODE_READ);
 	release_dma_lock(dma_flags);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(labpc_init_dma_chan);
 
diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h
index 2582f22..8f062f7 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h
+++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h
@@ -16,7 +16,7 @@ static inline bool labpc_have_dma_chan(struct comedi_device *dev)
 	return (bool)devpriv->dma_desc.chan;
 }
 
-int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan);
+void labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan);
 void labpc_free_dma_chan(struct comedi_device *dev);
 void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s);
 void labpc_drain_dma(struct comedi_device *dev);
@@ -29,10 +29,9 @@ static inline bool labpc_have_dma_chan(struct comedi_device *dev)
 	return false;
 }
 
-static inline int labpc_init_dma_chan(struct comedi_device *dev,
-				      unsigned int dma_chan)
+static inline void labpc_init_dma_chan(struct comedi_device *dev,
+				       unsigned int dma_chan)
 {
-	return -ENOTSUPP;
 }
 
 static inline void labpc_free_dma_chan(struct comedi_device *dev)
-- 
2.0.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-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