Ignore:
File:
1 edited

Legend:

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

    rdd8b6a8 r58563585  
    3535 * Main routines of USB mass storage driver.
    3636 */
     37
    3738#include <as.h>
    3839#include <async.h>
     
    4445#include <usb/classes/massstor.h>
    4546#include <errno.h>
     47#include <io/logctl.h>
    4648#include <str_error.h>
    4749#include "cmdw.h"
     
    5153
    5254#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)
    5655
    5756static const usb_endpoint_description_t bulk_in_ep = {
     
    112111static int usbmast_device_gone(usb_device_t *dev)
    113112{
    114         usbmast_dev_t *mdev = dev->driver_data;
     113        usbmast_dev_t *mdev = usb_device_data_get(dev);
    115114        assert(mdev);
    116115
     
    152151        unsigned i;
    153152
     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
    154162        /* Allocate softstate */
    155163        mdev = usb_device_data_alloc(dev, sizeof(usbmast_dev_t));
     
    159167        }
    160168
    161         mdev->ddf_dev = dev->ddf_dev;
    162169        mdev->usb_dev = dev;
    163170
    164         usb_log_info("Initializing mass storage `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
     171        usb_log_info("Initializing mass storage `%s'.\n",
     172            usb_device_get_name(dev));
    165173        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);
     174            epm_in->pipe.endpoint_no, epm_in->pipe.max_packet_size);
    168175        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);
     176            epm_out->pipe.endpoint_no, epm_out->pipe.max_packet_size);
    171177
    172178        usb_log_debug("Get LUN count...\n");
     
    179185        }
    180186
     187        mdev->bulk_in_pipe = &epm_in->pipe;
     188        mdev->bulk_out_pipe = &epm_out->pipe;
    181189        for (i = 0; i < mdev->lun_count; i++) {
    182190                rc = usbmast_fun_create(mdev, i);
     
    223231        }
    224232
    225         fun = ddf_fun_create(mdev->ddf_dev, fun_exposed, fun_name);
     233        fun = usb_device_ddf_fun_create(mdev->usb_dev, fun_exposed, fun_name);
    226234        if (fun == NULL) {
    227235                usb_log_error("Failed to create DDF function %s.\n", fun_name);
     
    254262        if (rc != EOK) {
    255263                usb_log_warning("Failed to inquire device `%s': %s.\n",
    256                     ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
     264                    usb_device_get_name(mdev->usb_dev), str_error(rc));
    257265                rc = EIO;
    258266                goto error;
     
    261269        usb_log_info("Mass storage `%s' LUN %u: " \
    262270            "%s by %s rev. %s is %s (%s).\n",
    263             ddf_dev_get_name(mdev->ddf_dev),
     271            usb_device_get_name(mdev->usb_dev),
    264272            lun,
    265273            inquiry.product,
     
    274282        if (rc != EOK) {
    275283                usb_log_warning("Failed to read capacity, device `%s': %s.\n",
    276                     ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
     284                    usb_device_get_name(mdev->usb_dev), str_error(rc));
    277285                rc = EIO;
    278286                goto error;
     
    291299                goto error;
    292300        }
     301
     302        ddf_fun_add_to_category(fun, "disk");
    293303
    294304        free(fun_name);
     
    394404{
    395405        log_init(NAME);
    396 
     406        logctl_set_log_level(NAME, LVL_NOTE);
    397407        return usb_driver_main(&usbmast_driver);
    398408}
Note: See TracChangeset for help on using the changeset viewer.