Changes in uspace/drv/bus/usb/usbmast/main.c [3cc55b47:dd8b6a8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmast/main.c
r3cc55b47 rdd8b6a8 52 52 #define NAME "usbmast" 53 53 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 54 57 static const usb_endpoint_description_t bulk_in_ep = { 55 58 .transfer_type = USB_TRANSFER_BULK, … … 82 85 static int usbmast_bd_close(bd_srv_t *); 83 86 static 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); 84 88 static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t); 85 89 static int usbmast_bd_get_block_size(bd_srv_t *, size_t *); … … 90 94 .close = usbmast_bd_close, 91 95 .read_blocks = usbmast_bd_read_blocks, 96 .sync_cache = usbmast_bd_sync_cache, 92 97 .write_blocks = usbmast_bd_write_blocks, 93 98 .get_block_size = usbmast_bd_get_block_size, … … 107 112 static int usbmast_device_gone(usb_device_t *dev) 108 113 { 109 usbmast_dev_t *mdev = usb_device_data_get(dev);114 usbmast_dev_t *mdev = dev->driver_data; 110 115 assert(mdev); 111 116 … … 147 152 unsigned i; 148 153 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 158 154 /* Allocate softstate */ 159 155 mdev = usb_device_data_alloc(dev, sizeof(usbmast_dev_t)); … … 163 159 } 164 160 161 mdev->ddf_dev = dev->ddf_dev; 165 162 mdev->usb_dev = dev; 166 163 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)); 169 165 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); 171 168 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); 173 171 174 172 usb_log_debug("Get LUN count...\n"); … … 181 179 } 182 180 183 mdev->bulk_in_pipe = &epm_in->pipe;184 mdev->bulk_out_pipe = &epm_out->pipe;185 181 for (i = 0; i < mdev->lun_count; i++) { 186 182 rc = usbmast_fun_create(mdev, i); … … 227 223 } 228 224 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); 230 226 if (fun == NULL) { 231 227 usb_log_error("Failed to create DDF function %s.\n", fun_name); … … 258 254 if (rc != EOK) { 259 255 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)); 261 257 rc = EIO; 262 258 goto error; … … 265 261 usb_log_info("Mass storage `%s' LUN %u: " \ 266 262 "%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), 268 264 lun, 269 265 inquiry.product, … … 278 274 if (rc != EOK) { 279 275 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)); 281 277 rc = EIO; 282 278 goto error; … … 344 340 } 345 341 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 346 350 /** Write blocks to the device. */ 347 351 static 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.