[PATCH 09/11] bus: mhi: host: Get total descriptor count
Sivareddy Surasani <[email protected]>
| Newsgroups | dev.linux.lists.mhi,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Vivek Pernamitta <[email protected]> Introduce a new API to retrieve the length of a transfer ring. This API allows clients to query the ring length. Signed-off-by: Vivek Pernamitta <[email protected]> Signed-off-by: Sivareddy Surasani <[email protected]> --- drivers/bus/mhi/host/main.c | 11 +++++++++++ include/linux/mhi.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 9772fb13400c..6be15297829d 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -345,6 +345,17 @@ int mhi_get_free_desc_count(struct mhi_device *mhi_dev, } EXPORT_SYMBOL_GPL(mhi_get_free_desc_count); +int mhi_get_total_descriptors(struct mhi_device *mhi_dev, + enum dma_data_direction dir) +{ + struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? + mhi_dev->ul_chan : mhi_dev->dl_chan; + struct mhi_ring *tre_ring = &mhi_chan->tre_ring; + + return tre_ring->elements; +} +EXPORT_SYMBOL(mhi_get_total_descriptors); + void mhi_notify(struct mhi_device *mhi_dev, enum mhi_callback cb_reason) { struct mhi_driver *mhi_drv; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 66fd83bed306..013bc2d82196 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -620,6 +620,15 @@ void mhi_notify(struct mhi_device *mhi_dev, enum mhi_callback cb_reason); int mhi_get_free_desc_count(struct mhi_device *mhi_dev, enum dma_data_direction dir); +/** + * mhi_get_total_descriptors - Get total transfer ring length + * Get # of TD available to queue buffers + * @mhi_dev: Device associated with the channels + * @dir: Direction of the channel + */ +int mhi_get_total_descriptors(struct mhi_device *mhi_dev, + enum dma_data_direction dir); + /** * mhi_prepare_for_power_up - Do pre-initialization before power up. * This is optional, call this before power up if -- 2.34.1