diff options
author | H Hartley Sweeten | 2016-05-02 19:11:41 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2016-05-03 23:11:15 +0200 |
commit | 48a73aedd7e47140bec5ccab17d4aa8604f76000 (patch) | |
tree | 33803187f8f4de9199a3101f9046f886263dba15 /drivers/staging/comedi | |
parent | staging: comedi: mite: rename mite member 'mite_io_addr' (diff) | |
download | kernel-qcow2-linux-48a73aedd7e47140bec5ccab17d4aa8604f76000.tar.gz kernel-qcow2-linux-48a73aedd7e47140bec5ccab17d4aa8604f76000.tar.xz kernel-qcow2-linux-48a73aedd7e47140bec5ccab17d4aa8604f76000.zip |
staging: comedi: mite: remove mite member 'channel_allocated'
An allocated mite_channel will have its 'ring' member initialized
to point to the mite_ring that will be used for DMA. A non-allocated
mite_channel will have a 'ring' member set to NULL, either by a
channel release or due to the initial kzalloc of the 'mite' struct.
Refactor the code to use the mite_chan->ring to detect in a channel
is allocated and remove the unnecessary member.
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/comedi')
-rw-r--r-- | drivers/staging/comedi/drivers/mite.c | 17 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/mite.h | 1 |
2 files changed, 8 insertions, 10 deletions
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 9a74e37bb2f7..14b5345a9357 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -392,9 +392,9 @@ struct mite_channel *mite_request_channel_in_range(struct mite *mite, unsigned int min_channel, unsigned int max_channel) { - int i; + struct mite_channel *mite_chan = NULL; unsigned long flags; - struct mite_channel *channel = NULL; + int i; /* * spin lock so mite_release_channel can be called safely @@ -402,15 +402,15 @@ struct mite_channel *mite_request_channel_in_range(struct mite *mite, */ spin_lock_irqsave(&mite->lock, flags); for (i = min_channel; i <= max_channel; ++i) { - if (mite->channel_allocated[i] == 0) { - mite->channel_allocated[i] = 1; - channel = &mite->channels[i]; - channel->ring = ring; + mite_chan = &mite->channels[i]; + if (!mite_chan->ring) { + mite_chan->ring = ring; break; } + mite_chan = NULL; } spin_unlock_irqrestore(&mite->lock, flags); - return channel; + return mite_chan; } EXPORT_SYMBOL_GPL(mite_request_channel_in_range); @@ -421,7 +421,7 @@ void mite_release_channel(struct mite_channel *mite_chan) /* spin lock to prevent races with mite_request_channel */ spin_lock_irqsave(&mite->lock, flags); - if (mite->channel_allocated[mite_chan->channel]) { + if (mite_chan->ring) { mite_dma_disarm(mite_chan); mite_dma_reset(mite_chan); /* @@ -433,7 +433,6 @@ void mite_release_channel(struct mite_channel *mite_chan) CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE, mite->mmio + MITE_CHCR(mite_chan->channel)); - mite->channel_allocated[mite_chan->channel] = 0; mite_chan->ring = NULL; mmiowb(); } diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index d1d97eca5fe9..2d97ad4f6d43 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -54,7 +54,6 @@ struct mite { struct pci_dev *pcidev; void __iomem *mmio; struct mite_channel channels[MAX_MITE_DMA_CHANNELS]; - short channel_allocated[MAX_MITE_DMA_CHANNELS]; int num_channels; unsigned int fifo_size; /* protects mite_channel from being released by the driver */ |