Ignore:
File:
1 edited

Legend:

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

    rdd8b6a8 r3cc55b47  
    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 
    5754static const usb_endpoint_description_t bulk_in_ep = {
    5855        .transfer_type = USB_TRANSFER_BULK,
     
    8582static int usbmast_bd_close(bd_srv_t *);
    8683static int usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
    87 static int usbmast_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);
    8884static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
    8985static int usbmast_bd_get_block_size(bd_srv_t *, size_t *);
     
    9490        .close = usbmast_bd_close,
    9591        .read_blocks = usbmast_bd_read_blocks,
    96         .sync_cache = usbmast_bd_sync_cache,
    9792        .write_blocks = usbmast_bd_write_blocks,
    9893        .get_block_size = usbmast_bd_get_block_size,
     
    112107static int usbmast_device_gone(usb_device_t *dev)
    113108{
    114         usbmast_dev_t *mdev = dev->driver_data;
     109        usbmast_dev_t *mdev = usb_device_data_get(dev);
    115110        assert(mdev);
    116111
     
    152147        unsigned i;
    153148
     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
    154158        /* Allocate softstate */
    155159        mdev = usb_device_data_alloc(dev, sizeof(usbmast_dev_t));
     
    159163        }
    160164
    161         mdev->ddf_dev = dev->ddf_dev;
    162165        mdev->usb_dev = dev;
    163166
    164         usb_log_info("Initializing mass storage `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
     167        usb_log_info("Initializing mass storage `%s'.\n",
     168            usb_device_get_name(dev));
    165169        usb_log_debug("Bulk in endpoint: %d [%zuB].\n",
    166             dev->pipes[BULK_IN_EP].pipe.endpoint_no,
    167             dev->pipes[BULK_IN_EP].pipe.max_packet_size);
     170            epm_in->pipe.endpoint_no, epm_in->pipe.max_packet_size);
    168171        usb_log_debug("Bulk out endpoint: %d [%zuB].\n",
    169             dev->pipes[BULK_OUT_EP].pipe.endpoint_no,
    170             dev->pipes[BULK_OUT_EP].pipe.max_packet_size);
     172            epm_out->pipe.endpoint_no, epm_out->pipe.max_packet_size);
    171173
    172174        usb_log_debug("Get LUN count...\n");
     
    179181        }
    180182
     183        mdev->bulk_in_pipe = &epm_in->pipe;
     184        mdev->bulk_out_pipe = &epm_out->pipe;
    181185        for (i = 0; i < mdev->lun_count; i++) {
    182186                rc = usbmast_fun_create(mdev, i);
     
    223227        }
    224228
    225         fun = ddf_fun_create(mdev->ddf_dev, fun_exposed, fun_name);
     229        fun = usb_device_ddf_fun_create(mdev->usb_dev, fun_exposed, fun_name);
    226230        if (fun == NULL) {
    227231                usb_log_error("Failed to create DDF function %s.\n", fun_name);
     
    254258        if (rc != EOK) {
    255259                usb_log_warning("Failed to inquire device `%s': %s.\n",
    256                     ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
     260                    usb_device_get_name(mdev->usb_dev), str_error(rc));
    257261                rc = EIO;
    258262                goto error;
     
    261265        usb_log_info("Mass storage `%s' LUN %u: " \
    262266            "%s by %s rev. %s is %s (%s).\n",
    263             ddf_dev_get_name(mdev->ddf_dev),
     267            usb_device_get_name(mdev->usb_dev),
    264268            lun,
    265269            inquiry.product,
     
    274278        if (rc != EOK) {
    275279                usb_log_warning("Failed to read capacity, device `%s': %s.\n",
    276                     ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
     280                    usb_device_get_name(mdev->usb_dev), str_error(rc));
    277281                rc = EIO;
    278282                goto error;
     
    340344}
    341345
    342 /** Synchronize blocks to nonvolatile storage. */
    343 static 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 
    350346/** Write blocks to the device. */
    351347static 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.