Changeset 1f43c8f in mainline


Ignore:
Timestamp:
2010-11-28T22:14:41Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
78f01ff9, 7972b51
Parents:
ba7f671
Message:

Bugfixes and workarounds

Fixed problem when VHC died due to uninitialized list.

Another workaround for devman. Probably another deadlock. Oh, well.

Location:
uspace/lib/usb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/hcdhubd.h

    rba7f671 r1f43c8f  
    3737
    3838#include <adt/list.h>
     39#include <bool.h>
    3940#include <driver.h>
    4041#include <usb/usb.h>
     
    175176int usb_hc_async_wait_for(usb_handle_t);
    176177
    177 int usb_hc_add_child_device(device_t *, const char *, const char *);
     178int usb_hc_add_child_device(device_t *, const char *, const char *, bool);
    178179
    179180#endif
  • uspace/lib/usb/src/hcdhubd.c

    rba7f671 r1f43c8f  
    113113        }
    114114
    115         rc = usb_hc_add_child_device(dev->generic, USB_HUB_DEVICE_NAME, id);
     115        rc = usb_hc_add_child_device(dev->generic, USB_HUB_DEVICE_NAME, id, true);
    116116        if (rc != EOK) {
    117117                free(id);
     
    153153        add_match_id(&child->match_ids, match_id);
    154154
     155        printf("%s: adding child device `%s' with match \"%s\"\n",
     156            hc_driver->name, child->name, match_id->id);
    155157        rc = child_device_register(child, child_info->parent);
    156         printf("%s: adding child device with match \"%s\" (%s)\n",
    157             hc_driver->name, match_id->id, str_error(rc));
     158        printf("%s: child device `%s' registration: %s\n",
     159            hc_driver->name, child->name, str_error(rc));
     160
    158161        if (rc != EOK) {
    159162                goto failure;
     
    175178leave:
    176179        free(arg);
    177         return rc;
     180        return EOK;
    178181}
    179182
     
    182185 * driven by the same task, the child adding is done in separate fibril.
    183186 * Not optimal, but it works.
     187 * Update: not under all circumstances the new fibril is successful either.
     188 * Thus the last parameter to let the caller choose.
    184189 *
    185190 * @param parent Parent device.
    186191 * @param name Device name.
    187192 * @param match_id Match id.
     193 * @param create_fibril Whether to run the addition in new fibril.
    188194 * @return Error code.
    189195 */
    190196int usb_hc_add_child_device(device_t *parent, const char *name,
    191     const char *match_id)
    192 {
     197    const char *match_id, bool create_fibril)
     198{
     199        printf("%s: about to add child device `%s' (%s)\n", hc_driver->name,
     200            name, match_id);
     201
    193202        struct child_device_info *child_info
    194203            = malloc(sizeof(struct child_device_info));
     
    198207        child_info->match_id = match_id;
    199208
    200         fid_t fibril = fibril_create(fibril_add_child_device, child_info);
    201         if (!fibril) {
    202                 return ENOMEM;
    203         }
    204         fibril_add_ready(fibril);
     209        if (create_fibril) {
     210                fid_t fibril = fibril_create(fibril_add_child_device, child_info);
     211                if (!fibril) {
     212                        return ENOMEM;
     213                }
     214                fibril_add_ready(fibril);
     215        } else {
     216                fibril_add_child_device(child_info);
     217        }
    205218
    206219        return EOK;
  • uspace/lib/usb/src/hcdrv.c

    rba7f671 r1f43c8f  
    5454};
    5555
    56 int usb_add_hc_device(device_t *dev)
    57 {
     56static usb_hc_device_t *usb_hc_device_create(device_t *dev) {
    5857        usb_hc_device_t *hc_dev = malloc(sizeof (usb_hc_device_t));
     58
    5959        list_initialize(&hc_dev->link);
     60        list_initialize(&hc_dev->hubs);
     61        list_initialize(&hc_dev->attached_devices);
    6062        hc_dev->transfer_ops = NULL;
    6163
     
    6365        dev->ops = &usb_device_ops;
    6466        hc_dev->generic->driver_data = hc_dev;
     67
     68        return hc_dev;
     69}
     70
     71int usb_add_hc_device(device_t *dev)
     72{
     73        usb_hc_device_t *hc_dev = usb_hc_device_create(dev);
    6574
    6675        int rc = hc_driver->add_hc(hc_dev);
     
    8594         */
    8695        printf("%s: trying to add USB HID child device...\n", hc_driver->name);
    87         rc = usb_hc_add_child_device(dev, USB_KBD_DEVICE_NAME, "usb&hid");
     96        rc = usb_hc_add_child_device(dev, USB_KBD_DEVICE_NAME, "usb&hid", false);
    8897        if (rc != EOK) {
    8998                printf("%s: adding USB HID child failed...\n", hc_driver->name);
Note: See TracChangeset for help on using the changeset viewer.