Changeset f7a55f9 in mainline for uspace/drv/bus/usb/usbmast/mast.c


Ignore:
Timestamp:
2011-07-05T10:43:21Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5e2aa83, bee37cf
Parents:
b5085a7
Message:

Implement Read and Request Sense commands for USB mass storage. In bulk-only
transport fix case when less data is returned by padding + residue. Add note
for case when less data is returned by stalling the pipe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmast/mast.c

    rb5085a7 rf7a55f9  
    9292            str_error(rc));
    9393        if (rc != EOK) {
     94                /*
     95                 * XXX If the pipe is stalled, we should clear it
     96                 * and read CSW.
     97                 */
    9498                return rc;
    9599        }
     
    103107            str_error(rc));
    104108        if (rc != EOK) {
    105                 return rc;
    106         }
     109                MASTLOG("rc != EOK\n");
     110                return rc;
     111        }
     112
    107113        if (csw_size != sizeof(csw)) {
     114                MASTLOG("csw_size != sizeof(csw)\n");
    108115                return ERANGE;
    109116        }
    110117
    111118        if (csw.dCSWTag != tag) {
     119                MASTLOG("csw.dCSWTag != tag\n");
    112120                return EBADCHECKSUM;
    113121        }
     
    117125         */
    118126        if (csw.dCSWStatus != 0) {
     127                MASTLOG("csw.dCSWStatus != 0\n");
    119128                // FIXME: better error code
    120129                // FIXME: distinguish 0x01 and 0x02
     
    124133        size_t residue = (size_t) uint32_usb2host(csw.dCSWDataResidue);
    125134        if (residue > in_buffer_size) {
     135                MASTLOG("residue > in_buffer_size\n");
    126136                return ERANGE;
    127137        }
    128         if (act_size != in_buffer_size - residue) {
    129                 return ERANGE;
    130         }
     138
     139        /*
     140         * When the device has less data to send than requested, it can
     141         * either stall the pipe or send garbage and indicate that via
     142         * the residue field in CSW. That means in_buffer_size - residue
     143         * is the authoritative size of data received.
     144         */
     145
    131146        if (received_size != NULL) {
    132147                *received_size = in_buffer_size - residue;
Note: See TracChangeset for help on using the changeset viewer.