Changeset 747ef72 in mainline for uspace/drv/bus/usb/ohci/hc.c


Ignore:
Timestamp:
2011-11-10T11:29:10Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
54464f6a, c2245a3, c6f189f7
Parents:
2e1b9dc (diff), 2d1ba51 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge USB changes.

Interface changes:

  • GET_ADDRESS has been renamed to GET_MY_ADDRESS and the handle parameter was dropped. Tis call no longer cascades up to the root hub, but it is answered in the first place the information is available (nearest hub)
  • Reintroduced address reservation for USB_DEFAULT_ADDRESS. The interface now enables device drivers to request specific address on initialization and either insists on that address or accept any other if the address is not available. Note that it is not possible to get the default address if the driver does not insist.
  • Any endpoint registered is removed when address is released and a warning is produced if there were any such endpoints.
  • It is no longer necessary or possible to pass device speed information when registering endpoints.

Driver fixes: memory leaks and crashes (not only) in error paths.
Fixes or removes flaky device_remove implementation in device drivers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    r2e1b9dc r747ef72  
    127127        assert(hub_fun);
    128128
    129         const usb_address_t hub_address =
    130             usb_device_manager_get_free_address(
    131                 &instance->generic.dev_manager, USB_SPEED_FULL);
    132         if (hub_address <= 0) {
     129        /* Try to get address 1 for root hub. */
     130        instance->rh.address = 1;
     131        int ret = usb_device_manager_request_address(
     132            &instance->generic.dev_manager, &instance->rh.address, false,
     133            USB_SPEED_FULL);
     134        if (ret != EOK) {
    133135                usb_log_error("Failed to get OHCI root hub address: %s\n",
    134                     str_error(hub_address));
    135                 return hub_address;
    136         }
    137         instance->rh.address = hub_address;
    138         usb_device_manager_bind(
    139             &instance->generic.dev_manager, hub_address, hub_fun->handle);
     136                    str_error(ret));
     137                return ret;
     138        }
     139        usb_device_manager_bind_address(&instance->generic.dev_manager,
     140            instance->rh.address, hub_fun->handle);
    140141
    141142#define CHECK_RET_UNREG_RETURN(ret, message...) \
     
    143144        usb_log_error(message); \
    144145        usb_endpoint_manager_remove_ep( \
    145             &instance->generic.ep_manager, hub_address, 0, USB_DIRECTION_BOTH, \
    146             NULL, NULL);\
    147         usb_device_manager_release( \
    148             &instance->generic.dev_manager, hub_address); \
     146            &instance->generic.ep_manager, instance->rh.address, 0, \
     147            USB_DIRECTION_BOTH, NULL, NULL); \
     148        usb_device_manager_release_address( \
     149            &instance->generic.dev_manager, instance->rh.address); \
    149150        return ret; \
    150151} else (void)0
    151         int ret = usb_endpoint_manager_add_ep(
    152             &instance->generic.ep_manager, hub_address, 0, USB_DIRECTION_BOTH,
    153             USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 0, NULL, NULL);
     152        ret = usb_endpoint_manager_add_ep(
     153            &instance->generic.ep_manager, instance->rh.address, 0,
     154            USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64,
     155            0, NULL, NULL);
    154156        CHECK_RET_UNREG_RETURN(ret,
    155157            "Failed to register root hub control endpoint: %s.\n",
     
    193195        list_initialize(&instance->pending_batches);
    194196
    195         hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11,
    196             bandwidth_count_usb11);
     197        hcd_init(&instance->generic, USB_SPEED_FULL,
     198            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    197199        instance->generic.private_data = instance;
    198200        instance->generic.schedule = hc_schedule;
Note: See TracChangeset for help on using the changeset viewer.