Changeset 70c12d6 in mainline for uspace/drv/usbmast/mast.c


Ignore:
Timestamp:
2011-05-11T19:20:06Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cf002dbf
Parents:
19387b61
Message:

Fix inquiry of USB mass storage

The problem was bad endianness in SCSI command descriptor block
(damn, why we need different endianness at all?).

File:
1 edited

Legend:

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

    r19387b61 r70c12d6  
    4040#include <str_error.h>
    4141#include <usb/debug.h>
     42#include <usb/request.h>
    4243
    4344bool usb_mast_verbose = true;
     
    6364 * @return Error code.
    6465 */
    65 int usb_massstor_data_in(usb_pipe_t *bulk_in_pipe, usb_pipe_t *bulk_out_pipe,
     66int usb_massstor_data_in(usb_device_t *dev,
     67    size_t bulk_in_pipe_index, size_t bulk_out_pipe_index,
    6668    uint32_t tag, uint8_t lun, void *cmd, size_t cmd_size,
    6769    void *in_buffer, size_t in_buffer_size, size_t *received_size)
     
    6971        int rc;
    7072        size_t act_size;
     73        usb_pipe_t *bulk_in_pipe = dev->pipes[bulk_in_pipe_index].pipe;
     74        usb_pipe_t *bulk_out_pipe = dev->pipes[bulk_out_pipe_index].pipe;
    7175
    7276        /* Prepare CBW - command block wrapper */
     
    135139}
    136140
     141int usb_massstor_reset(usb_device_t *dev)
     142{
     143        return usb_control_request_set(&dev->ctrl_pipe,
     144            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
     145            0xFF, 0, dev->interface_no, NULL, 0);
     146}
     147
     148void usb_massstor_reset_recovery(usb_device_t *dev,
     149    size_t bulk_in_idx, size_t bulk_out_idx)
     150{
     151        /* We would ignore errors here because if this fails
     152         * we are doomed anyway and any following transaction would fail.
     153         */
     154        usb_massstor_reset(dev);
     155        usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_in_idx].pipe);
     156        usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_out_idx].pipe);
     157}
     158
     159int usb_massstor_get_max_lun(usb_device_t *dev)
     160{
     161        uint8_t max_lun;
     162        size_t data_recv_len;
     163        int rc = usb_control_request_get(&dev->ctrl_pipe,
     164            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
     165            0xFE, 0, dev->interface_no, &max_lun, 1, &data_recv_len);
     166        if (rc != EOK) {
     167                return rc;
     168        }
     169        if (data_recv_len != 1) {
     170                return EEMPTY;
     171        }
     172        return (int) max_lun;
     173}
     174
    137175/**
    138176 * @}
Note: See TracChangeset for help on using the changeset viewer.