Changes in uspace/drv/bus/usb/usbmast/main.c [58563585:920d0fc] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmast/main.c
r58563585 r920d0fc 35 35 * Main routines of USB mass storage driver. 36 36 */ 37 38 37 #include <as.h> 39 38 #include <async.h> … … 45 44 #include <usb/classes/massstor.h> 46 45 #include <errno.h> 47 #include <io/logctl.h>48 46 #include <str_error.h> 49 47 #include "cmdw.h" … … 53 51 54 52 #define NAME "usbmast" 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) 55 56 56 57 static const usb_endpoint_description_t bulk_in_ep = { … … 84 85 static int usbmast_bd_close(bd_srv_t *); 85 86 static int usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t); 86 static int usbmast_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);87 87 static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t); 88 88 static int usbmast_bd_get_block_size(bd_srv_t *, size_t *); … … 93 93 .close = usbmast_bd_close, 94 94 .read_blocks = usbmast_bd_read_blocks, 95 .sync_cache = usbmast_bd_sync_cache,96 95 .write_blocks = usbmast_bd_write_blocks, 97 96 .get_block_size = usbmast_bd_get_block_size, … … 111 110 static int usbmast_device_gone(usb_device_t *dev) 112 111 { 113 usbmast_dev_t *mdev = usb_device_data_get(dev);112 usbmast_dev_t *mdev = dev->driver_data; 114 113 assert(mdev); 115 114 … … 151 150 unsigned i; 152 151 153 usb_endpoint_mapping_t *epm_in =154 usb_device_get_mapped_ep_desc(dev, &bulk_in_ep);155 usb_endpoint_mapping_t *epm_out =156 usb_device_get_mapped_ep_desc(dev, &bulk_out_ep);157 if (!epm_in || !epm_out || !epm_in->present || !epm_out->present) {158 usb_log_error("Required EPs were not mapped.\n");159 return ENOENT;160 }161 162 152 /* Allocate softstate */ 163 153 mdev = usb_device_data_alloc(dev, sizeof(usbmast_dev_t)); … … 167 157 } 168 158 159 mdev->ddf_dev = dev->ddf_dev; 169 160 mdev->usb_dev = dev; 170 161 171 usb_log_info("Initializing mass storage `%s'.\n", 172 usb_device_get_name(dev)); 162 usb_log_info("Initializing mass storage `%s'.\n", ddf_dev_get_name(dev->ddf_dev)); 173 163 usb_log_debug("Bulk in endpoint: %d [%zuB].\n", 174 epm_in->pipe.endpoint_no, epm_in->pipe.max_packet_size); 164 dev->pipes[BULK_IN_EP].pipe.endpoint_no, 165 dev->pipes[BULK_IN_EP].pipe.max_packet_size); 175 166 usb_log_debug("Bulk out endpoint: %d [%zuB].\n", 176 epm_out->pipe.endpoint_no, epm_out->pipe.max_packet_size); 167 dev->pipes[BULK_OUT_EP].pipe.endpoint_no, 168 dev->pipes[BULK_OUT_EP].pipe.max_packet_size); 177 169 178 170 usb_log_debug("Get LUN count...\n"); … … 185 177 } 186 178 187 mdev->bulk_in_pipe = &epm_in->pipe;188 mdev->bulk_out_pipe = &epm_out->pipe;189 179 for (i = 0; i < mdev->lun_count; i++) { 190 180 rc = usbmast_fun_create(mdev, i); … … 231 221 } 232 222 233 fun = usb_device_ddf_fun_create(mdev->usb_dev, fun_exposed, fun_name);223 fun = ddf_fun_create(mdev->ddf_dev, fun_exposed, fun_name); 234 224 if (fun == NULL) { 235 225 usb_log_error("Failed to create DDF function %s.\n", fun_name); … … 262 252 if (rc != EOK) { 263 253 usb_log_warning("Failed to inquire device `%s': %s.\n", 264 usb_device_get_name(mdev->usb_dev), str_error(rc));254 ddf_dev_get_name(mdev->ddf_dev), str_error(rc)); 265 255 rc = EIO; 266 256 goto error; … … 269 259 usb_log_info("Mass storage `%s' LUN %u: " \ 270 260 "%s by %s rev. %s is %s (%s).\n", 271 usb_device_get_name(mdev->usb_dev),261 ddf_dev_get_name(mdev->ddf_dev), 272 262 lun, 273 263 inquiry.product, … … 282 272 if (rc != EOK) { 283 273 usb_log_warning("Failed to read capacity, device `%s': %s.\n", 284 usb_device_get_name(mdev->usb_dev), str_error(rc));274 ddf_dev_get_name(mdev->ddf_dev), str_error(rc)); 285 275 rc = EIO; 286 276 goto error; … … 299 289 goto error; 300 290 } 301 302 ddf_fun_add_to_category(fun, "disk");303 291 304 292 free(fun_name); … … 350 338 } 351 339 352 /** Synchronize blocks to nonvolatile storage. */353 static int usbmast_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt)354 {355 usbmast_fun_t *mfun = bd_srv_usbmast(bd);356 357 return usbmast_sync_cache(mfun, ba, cnt);358 }359 360 340 /** Write blocks to the device. */ 361 341 static int usbmast_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, … … 404 384 { 405 385 log_init(NAME); 406 logctl_set_log_level(NAME, LVL_NOTE); 386 407 387 return usb_driver_main(&usbmast_driver); 408 388 }
Note:
See TracChangeset
for help on using the changeset viewer.