staging: comedi: mite: use prefered form for passing a struct size
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 2 May 2016 17:11:43 +0000 (10:11 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 May 2016 21:11:15 +0000 (14:11 -0700)
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@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/mite.c

index 8b0f875972f56c85a3cc6af24cef55011547a1ab..650c6039df3986a2cee2da5299c1433d65877786 100644 (file)
@@ -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);