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