Skip to content

Commit

Permalink
bus: mhi: Add mhi_queue_is_full function
Browse files Browse the repository at this point in the history
This function can be used by client driver to determine whether it's
possible to queue new elements in a channel ring.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1604424234-24446-1-git-send-email-loic.poulain@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Loic Poulain authored and Jakub Kicinski committed Nov 6, 2020
1 parent 5aee948 commit d8c4a22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/bus/mhi/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,17 @@ int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
}
EXPORT_SYMBOL_GPL(mhi_queue_buf);

bool mhi_queue_is_full(struct mhi_device *mhi_dev, enum dma_data_direction dir)
{
struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
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 mhi_is_ring_full(mhi_cntrl, tre_ring);
}
EXPORT_SYMBOL_GPL(mhi_queue_is_full);

int mhi_send_cmd(struct mhi_controller *mhi_cntrl,
struct mhi_chan *mhi_chan,
enum mhi_cmd_type cmd)
Expand Down
7 changes: 7 additions & 0 deletions include/linux/mhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,4 +737,11 @@ int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
struct sk_buff *skb, size_t len, enum mhi_flags mflags);

/**
* mhi_queue_is_full - Determine whether queueing new elements is possible
* @mhi_dev: Device associated with the channels
* @dir: DMA direction for the channel
*/
bool mhi_queue_is_full(struct mhi_device *mhi_dev, enum dma_data_direction dir);

#endif /* _MHI_H_ */

0 comments on commit d8c4a22

Please sign in to comment.