usb: device: Add transfer cancel helper
Add usb_cancel_transfers() helper to cancel all ongoing transfers. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
54000fb886
commit
bf76b2acc3
2 changed files with 23 additions and 0 deletions
|
@ -418,6 +418,11 @@ int usb_transfer_sync(u8_t ep, u8_t *data, size_t dlen, unsigned int flags);
|
||||||
*/
|
*/
|
||||||
void usb_cancel_transfer(u8_t ep);
|
void usb_cancel_transfer(u8_t ep);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Cancel all ongoing transfers
|
||||||
|
*/
|
||||||
|
void usb_cancel_transfers(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check that transfer is ongoing for the endpoint
|
* @brief Check that transfer is ongoing for the endpoint
|
||||||
*
|
*
|
||||||
|
|
|
@ -1419,6 +1419,24 @@ done:
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usb_cancel_transfers(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ARRAY_SIZE(usb_dev.transfer); i++) {
|
||||||
|
struct usb_transfer_data *trans = &usb_dev.transfer[i];
|
||||||
|
unsigned int key;
|
||||||
|
|
||||||
|
key = irq_lock();
|
||||||
|
|
||||||
|
if (trans->status == -EBUSY) {
|
||||||
|
trans->status = -ECANCELED;
|
||||||
|
k_work_submit(&trans->work);
|
||||||
|
LOG_DBG("Cancel transfer");
|
||||||
|
}
|
||||||
|
|
||||||
|
irq_unlock(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct usb_transfer_sync_priv {
|
struct usb_transfer_sync_priv {
|
||||||
int tsize;
|
int tsize;
|
||||||
struct k_sem sem;
|
struct k_sem sem;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue