I was doing a little digging on my last topic about USB not working properly, and I found this code where the Mutex unlock comes before Mutex lock around a do_while loop. Is this correct?
Unlocks on line 248 and lock on 262
No worries. Found the answer
Tell us and we can close the thread as solved.![]()
In the function static status_t usb_disk_attach(device_node *node, usb_device newDevice, void **cookie), which gets called to load a new disk_device, the device mutex is locked. Then further in the function call stack while checking the usb_drive for health (I suppose), we arrive at usb_disk_transfer_data. Here it unlocks the mutex to interact with the device->lock (which is a semaphore), and locks it again while exiting. And lastly the mutex is unlocked again while exiting usb_disk_attach.
4 Likes
