Re: [PATCH 10/19] staging: comedi: mite: use prefered form for passing a struct size

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

 



On 02/05/16 18:11, H Hartley Sweeten wrote:
Add a local variable to mite_buf_change() so that the prefered
form of passing a struct size, sizeof(*p), can be used.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
  drivers/staging/comedi/drivers/mite.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index 8b0f875..650c603 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -473,6 +473,7 @@ int mite_buf_change(struct mite_ring *ring,
  		    struct comedi_subdevice *s)
  {
  	struct comedi_async *async = s->async;
+	struct mite_dma_desc *descs;
  	unsigned int n_links;

  	mite_free_dma_descs(ring);
@@ -482,15 +483,15 @@ int mite_buf_change(struct mite_ring *ring,

  	n_links = async->prealloc_bufsz >> PAGE_SHIFT;

-	ring->descs =
-	    dma_alloc_coherent(ring->hw_dev,
-			       n_links * sizeof(struct mite_dma_desc),
-			       &ring->dma_addr, GFP_KERNEL);
-	if (!ring->descs) {
+	descs = dma_alloc_coherent(ring->hw_dev,
+				   n_links * sizeof(*descs),
+				   &ring->dma_addr, GFP_KERNEL);
+	if (!descs) {
  		dev_err(s->device->class_dev,
  			"mite: ring buffer allocation failed\n");
  		return -ENOMEM;
  	}
+	ring->descs = descs;
  	ring->n_links = n_links;

  	return mite_init_ring_descriptors(ring, s, n_links << PAGE_SHIFT);


It doesn't matter, but you could have just used `sizeof(*ring->descs)` instead of defining a new variable.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
_______________________________________________
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