usb_master: Store maximum packet size for bulk endpoints

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Use endpoint size for bulk transfer size

Do not hardcode the packet size to 64 bytes, but instead use the value from
the endpoint descriptor.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Create buffer for storing leftover data

The device will send data in chunks of the endpoint size until it finishes
sending the entire range given in set_address(). When we are requested to
read less than that, we need to store the excess data until the next read.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Invalidate read buffer on set_address calls

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Empty read buffer before reading new data from chip

For every readn() call, data which exists in the read buffer must be placed
before any new data from the chip.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Keep track of range after a set_address() call

Knowing the address range is needed in order to know how much data to
expect from the USB device.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Return when no async transfers is to be used

The asynchronous transfer loop is only concerned with transfers of endpoint
sized packets. When there is less than a packet worth of data to transfer,
return immediately.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Update address range on successful bulk read

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Return an error on out of range reads

When we are requested to read more data than what was specified in
set_address(), return immediately with an error.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Print the address range which is being read

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
usb_master: Handle leftover transfers on bulk read

Handle readn() requests for which the last transfer is not a multiple of
the endpoint size. The last transfer usually requires buffering, and is
handled separately from the other transfers.

This change allows the qiprog's test_alignment to complete succesfully.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>