From: H Hartley Sweeten Date: Mon, 2 May 2016 17:11:41 +0000 (-0700) Subject: staging: comedi: mite: remove mite member 'channel_allocated' X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=48a73aedd7e47140bec5ccab17d4aa8604f76000;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- 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 */