Ignore:
File:
1 edited

Legend:

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

    r3cc55b47 rdd8b6a8  
    5252#define NAME "usbmast"
    5353
     54#define GET_BULK_IN(dev) ((dev)->pipes[BULK_IN_EP].pipe)
     55#define GET_BULK_OUT(dev) ((dev)->pipes[BULK_OUT_EP].pipe)
     56
    5457static const usb_endpoint_description_t bulk_in_ep = {
    5558        .transfer_type = USB_TRANSFER_BULK,
     
    8285static int usbmast_bd_close(bd_srv_t *);
    8386static int usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     87static int usbmast_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);
    8488static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
    8589static int usbmast_bd_get_block_size(bd_srv_t *, size_t *);
     
    9094        .close = usbmast_bd_close,
    9195        .read_blocks = usbmast_bd_read_blocks,
     96        .sync_cache = usbmast_bd_sync_cache,
    9297        .write_blocks = usbmast_bd_write_blocks,
    9398        .get_block_size = usbmast_bd_get_block_size,
     
    107112static int usbmast_device_gone(usb_device_t *dev)
    108113{
    109         usbmast_dev_t *mdev = usb_device_data_get(dev);
     114        usbmast_dev_t *mdev = dev->driver_data;
    110115        assert(mdev);
    111116
     
    147152        unsigned i;
    148153
    149         usb_endpoint_mapping_t *epm_in =
    150             usb_device_get_mapped_ep_desc(dev, &bulk_in_ep);
    151         usb_endpoint_mapping_t *epm_out =
    152             usb_device_get_mapped_ep_desc(dev, &bulk_out_ep);
    153         if (!epm_in || !epm_out || !epm_in->present || !epm_out->present) {
    154                 usb_log_error("Required EPs were not mapped.\n");
    155                 return ENOENT;
    156         }
    157 
    158154        /* Allocate softstate */
    159155        mdev = usb_device_data_alloc(dev, sizeof(usbmast_dev_t));
     
    163159        }
    164160
     161        mdev->ddf_dev = dev->ddf_dev;
    165162        mdev->usb_dev = dev;
    166163
    167         usb_log_info("Initializing mass storage `%s'.\n",
    168             usb_device_get_name(dev));
     164        usb_log_info("Initializing mass storage `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
    169165        usb_log_debug("Bulk in endpoint: %d [%zuB].\n",
    170             epm_in->pipe.endpoint_no, epm_in->pipe.max_packet_size);
     166            dev->pipes[BULK_IN_EP].pipe.endpoint_no,
     167            dev->pipes[BULK_IN_EP].pipe.max_packet_size);
    171168        usb_log_debug("Bulk out endpoint: %d [%zuB].\n",
    172             epm_out->pipe.endpoint_no, epm_out->pipe.max_packet_size);
     169            dev->pipes[BULK_OUT_EP].pipe.endpoint_no,
     170            dev->pipes[BULK_OUT_EP].pipe.max_packet_size);
    173171
    174172        usb_log_debug("Get LUN count...\n");
     
    181179        }
    182180
    183         mdev->bulk_in_pipe = &epm_in->pipe;
    184         mdev->bulk_out_pipe = &epm_out->pipe;
    185181        for (i = 0; i < mdev->lun_count; i++) {
    186182                rc = usbmast_fun_create(mdev, i);
     
    227223        }
    228224
    229         fun = usb_device_ddf_fun_create(mdev->usb_dev, fun_exposed, fun_name);
     225        fun = ddf_fun_create(mdev->ddf_dev, fun_exposed, fun_name);
    230226        if (fun == NULL) {
    231227                usb_log_error("Failed to create DDF function %s.\n", fun_name);
     
    258254        if (rc != EOK) {
    259255                usb_log_warning("Failed to inquire device `%s': %s.\n",
    260                     usb_device_get_name(mdev->usb_dev), str_error(rc));
     256                    ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
    261257                rc = EIO;
    262258                goto error;
     
    265261        usb_log_info("Mass storage `%s' LUN %u: " \
    266262            "%s by %s rev. %s is %s (%s).\n",
    267             usb_device_get_name(mdev->usb_dev),
     263            ddf_dev_get_name(mdev->ddf_dev),
    268264            lun,
    269265            inquiry.product,
     
    278274        if (rc != EOK) {
    279275                usb_log_warning("Failed to read capacity, device `%s': %s.\n",
    280                     usb_device_get_name(mdev->usb_dev), str_error(rc));
     276                    ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
    281277                rc = EIO;
    282278                goto error;
     
    344340}
    345341
     342/** Synchronize blocks to nonvolatile storage. */
     343static int usbmast_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt)
     344{
     345        usbmast_fun_t *mfun = bd_srv_usbmast(bd);
     346
     347        return usbmast_sync_cache(mfun, ba, cnt);
     348}
     349
    346350/** Write blocks to the device. */
    347351static int usbmast_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt,
Note: See TracChangeset for help on using the changeset viewer.