Fix for USB - fix issues that were introduced in 18780d5 #150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request checklist
Note: these are not necessarily requirements
Pull Request description
(mass_driver.c) Fix glitches related to USB support that were introduced with commit 18780d5 on June 8th.
By the USB 1.1 specification, section 9.4.10: Devices that only support a default setting for the specified interface may return a STALL.
If that happens, we shall clear the halt state of the interface's pipes and continue, as with Linux.
As the code for making reads in blocks was removed, the loop only iterates once.
That is wrong, as reading from a 4096-byte device (for example) could require the loop to iterate twice if the last LBA is not aligned with the device's physical LBAs.
At the 2nd iteration, nsectors would have been 1, when it should then read a complete sector and copy the first half of it with memcpy.
The other commit is something I added in case sceCdInit() is called from a high-priority thread... but may be just more for correctness in the end: