Changeset e991937 in mainline


Ignore:
Timestamp:
2013-08-07T12:10:51Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2757247
Parents:
d8d100c
Message:

usb: hc function no longer represents the HC nor holds its data

Location:
uspace
Files:
6 edited

Legend:

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

    rd8d100c re991937  
    8989
    9090        /* High Speed, no bandwidth */
    91         ret = hcd_ddf_setup_device(device, NULL, USB_SPEED_HIGH, 0, NULL);     
     91        ret = hcd_ddf_setup_hc(device, USB_SPEED_HIGH, 0, NULL);       
    9292        CHECK_RET_RETURN(ret,
    9393            "Failed to init generci hcd driver: %s\n", str_error(ret));
  • uspace/drv/bus/usb/ohci/ohci.c

    rd8d100c re991937  
    131131
    132132        /* Initialize generic HCD driver */
    133         ret = hcd_ddf_setup_device(device, NULL, USB_SPEED_FULL,
     133        ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL,
    134134            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    135135        if (ret != EOK) {
  • uspace/drv/bus/usb/uhci/uhci.c

    rd8d100c re991937  
    131131        }
    132132
    133         ret = hcd_ddf_setup_device(device, NULL, USB_SPEED_FULL,
     133        ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL,
    134134            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    135135        CHECK_RET_RETURN(ret, "Failed to setup UHCI HCD.\n");
  • uspace/drv/bus/usb/vhc/main.c

    rd8d100c re991937  
    8686
    8787        /* Initialize generic structures */
    88         ret = hcd_ddf_setup_device(dev, NULL, USB_SPEED_FULL,
     88        ret = hcd_ddf_setup_hc(dev, USB_SPEED_FULL,
    8989            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    9090        if (ret != EOK) {
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    rd8d100c re991937  
    4343    usb_address_t address, usb_speed_t speed, const char *name,
    4444    const match_id_list_t *mids);
    45 int hcd_ddf_setup_device(ddf_dev_t *device, ddf_fun_t **hc_fun,
    46     usb_speed_t max_speed, size_t bw, bw_count_func_t bw_count);
     45int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed,
     46    size_t bw, bw_count_func_t bw_count);
     47void hcd_ddf_clean_hc(ddf_dev_t *device);
    4748int hcd_ddf_setup_root_hub(ddf_dev_t *device);
    4849int hcd_ddf_new_device(ddf_dev_t *device, usb_address_t *address);
  • uspace/lib/usbhost/src/ddf_helpers.c

    rd8d100c re991937  
    4747
    4848typedef struct hc_dev {
    49         ddf_fun_t *hc_fun;
     49        ddf_fun_t *ctl_fun;
    5050        list_t devices;
    5151        fibril_mutex_t guard;
     52        hcd_t hcd;
    5253} hc_dev_t;
    5354
     
    6061{
    6162        hc_dev_t *hc_dev = dev_to_hc_dev(dev);
    62         if (!hc_dev || !hc_dev->hc_fun) {
     63        if (!hc_dev) {
    6364                usb_log_error("Invalid HCD device.\n");
    6465                return NULL;
    6566        }
    66         return ddf_fun_data_get(hc_dev->hc_fun);
     67        return &hc_dev->hcd;
    6768}
    6869
     
    563564 * This function does all the ddf work for hc driver.
    564565 */
    565 int hcd_ddf_setup_device(ddf_dev_t *device, ddf_fun_t **hc_fun,
    566     usb_speed_t max_speed, size_t bw, bw_count_func_t bw_count)
    567 {
    568         if (!device)
    569                 return EBADMEM;
    570 
    571         int ret = ENOMEM;
     566int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed,
     567    size_t bw, bw_count_func_t bw_count)
     568{
     569        assert(device);
     570
    572571        hc_dev_t *instance = ddf_dev_data_alloc(device, sizeof(hc_dev_t));
    573572        if (instance == NULL) {
     
    577576        list_initialize(&instance->devices);
    578577        fibril_mutex_initialize(&instance->guard);
    579 
    580         instance->hc_fun = ddf_fun_create(device, fun_exposed, "hc");
    581         if (!instance->hc_fun) {
     578        hcd_init(&instance->hcd, max_speed, bw, bw_count);
     579
     580        int ret = ENOMEM;
     581        instance->ctl_fun = ddf_fun_create(device, fun_exposed, "ctl");
     582        if (!instance->ctl_fun) {
    582583                usb_log_error("Failed to create HCD ddf fun.\n");
    583584                goto err_destroy_fun;
    584585        }
    585586
    586         hcd_t *hcd = ddf_fun_data_alloc(instance->hc_fun, sizeof(hcd_t));
    587         if (!instance->hc_fun) {
    588                 usb_log_error("Failed to allocate HCD ddf fun data.\n");
     587        ret = ddf_fun_bind(instance->ctl_fun);
     588        if (ret != EOK) {
     589                usb_log_error("Failed to bind ctl_fun: %s.\n", str_error(ret));
    589590                goto err_destroy_fun;
    590591        }
    591592
    592         hcd_init(hcd, max_speed, bw, bw_count);
    593 
    594         ret = ddf_fun_bind(instance->hc_fun);
    595         if (ret != EOK) {
    596                 usb_log_error("Failed to bind hc_fun: %s.\n", str_error(ret));
    597                 goto err_destroy_fun;
    598         }
    599 
    600         ret = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY);
     593        ret = ddf_fun_add_to_category(instance->ctl_fun, USB_HC_CATEGORY);
    601594        if (ret != EOK) {
    602595                usb_log_error("Failed to add fun to category: %s.\n",
    603596                    str_error(ret));
    604                 ddf_fun_unbind(instance->hc_fun);
     597                ddf_fun_unbind(instance->ctl_fun);
    605598                goto err_destroy_fun;
    606599        }
    607600
    608601        /* HC should be ok at this point (except it can't do anything) */
    609         if (hc_fun)
    610                 *hc_fun = instance->hc_fun;
    611602        return EOK;
    612603
    613604err_destroy_fun:
    614         ddf_fun_destroy(instance->hc_fun);
    615         instance->hc_fun = NULL;
     605        ddf_fun_destroy(instance->ctl_fun);
     606        instance->ctl_fun = NULL;
    616607        return ret;
    617608}
    618609
     610void hcd_ddf_clean_hc(ddf_dev_t *device)
     611{
     612        assert(device);
     613        hc_dev_t *hc = dev_to_hc_dev(device);
     614        assert(hc);
     615        const int ret = ddf_fun_unbind(hc->ctl_fun);
     616        if (ret == EOK)
     617                ddf_fun_destroy(hc->ctl_fun);
     618}
    619619/**
    620620 * @}
Note: See TracChangeset for help on using the changeset viewer.