diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2016-05-02 10:11:39 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-05-03 14:11:15 -0700 |
commit | 3303410d04f28fa70d19adc9de2ae15a0909aff5 (patch) | |
tree | beaa674aa41d0d1b88978739688aee6e161fec5c /drivers/staging | |
parent | b0af848ca3d4f1f234828ea92feb08667ff8c81e (diff) | |
download | linux-3303410d04f28fa70d19adc9de2ae15a0909aff5.tar.gz linux-3303410d04f28fa70d19adc9de2ae15a0909aff5.tar.bz2 linux-3303410d04f28fa70d19adc9de2ae15a0909aff5.zip |
staging: comedi: mite: tidy up mite_init_ring_descriptors()
Use a local variable for the mite_dma_desc pointer to help clarify
this function.
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>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/drivers/mite.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index c21d9fa0de27..058ea5e454b7 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -516,6 +516,7 @@ int mite_init_ring_descriptors(struct mite_ring *ring, unsigned int nbytes) { struct comedi_async *async = s->async; + struct mite_dma_desc *desc = NULL; unsigned int n_full_links = nbytes >> PAGE_SHIFT; unsigned int remainder = nbytes % PAGE_SIZE; int i; @@ -531,26 +532,23 @@ int mite_init_ring_descriptors(struct mite_ring *ring, /* We set the descriptors for all full links. */ for (i = 0; i < n_full_links; ++i) { - ring->descs[i].count = cpu_to_le32(PAGE_SIZE); - ring->descs[i].addr = - cpu_to_le32(async->buf_map->page_list[i].dma_addr); - ring->descs[i].next = - cpu_to_le32(ring->dma_addr + - (i + 1) * sizeof(struct mite_dma_desc)); + desc = &ring->descs[i]; + desc->count = cpu_to_le32(PAGE_SIZE); + desc->addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); + desc->next = cpu_to_le32(ring->dma_addr + + (i + 1) * sizeof(*desc)); } /* the last link is either a remainder or was a full link. */ if (remainder > 0) { + desc = &ring->descs[i]; /* set the lesser count for the remainder link */ - ring->descs[i].count = cpu_to_le32(remainder); - ring->descs[i].addr = - cpu_to_le32(async->buf_map->page_list[i].dma_addr); - /* increment i so that assignment below refs last link */ - ++i; + desc->count = cpu_to_le32(remainder); + desc->addr = cpu_to_le32(async->buf_map->page_list[i].dma_addr); } /* Assign the last link->next to point back to the head of the list. */ - ring->descs[i - 1].next = cpu_to_le32(ring->dma_addr); + desc->next = cpu_to_le32(ring->dma_addr); /* * barrier is meant to insure that all the writes to the dma descriptors |