Changeset 9a884ed in mainline for uspace/app/vuhid/device.c


Ignore:
Timestamp:
2011-05-06T10:12:25Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42d47f8
Parents:
30f9f8f
Message:

Virtual HID terminates with last interface

Also it is not possible to turn on the same interface twice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/vuhid/device.c

    r30f9f8f r9a884ed  
    7777{
    7878        vuhid_interface_t *iface = arg;
     79        vuhid_data_t *hid_data = iface->vuhid_data;
    7980
    8081        if (iface->live != NULL) {
    8182                iface->live(iface);
    8283        }
     84
     85        fibril_mutex_lock(&hid_data->iface_count_mutex);
     86        hid_data->iface_died_count++;
     87        fibril_condvar_broadcast(&hid_data->iface_count_cv);
     88        fibril_mutex_unlock(&hid_data->iface_count_mutex);
    8389
    8490        return EOK;
     
    110116        if ((iface->in_data_size == 0) && (iface->out_data_size == 0)) {
    111117                return EEMPTY;
     118        }
     119
     120        // FIXME - we shall set vuhid_data to NULL in the main() rather
     121        // than to depend on individual interfaces
     122        /* Already used interface. */
     123        if (iface->vuhid_data != NULL) {
     124                return EEXISTS;
    112125        }
    113126
     
    252265
    253266        /* Launch the "life" fibril. */
     267        iface->vuhid_data = hid_data;
    254268        fid_t life_fibril = fibril_create(interface_life_fibril, iface);
    255269        if (life_fibril == 0) {
     
    310324            += total_descr_size;
    311325
     326        hid_data->iface_count++;
    312327        fibril_add_ready(life_fibril);
    313328
     
    331346}
    332347
     348void wait_for_interfaces_death(usbvirt_device_t *dev)
     349{
     350        vuhid_data_t *hid_data = dev->device_data;
     351
     352        fibril_mutex_lock(&hid_data->iface_count_mutex);
     353        while (hid_data->iface_died_count < hid_data->iface_count) {
     354                fibril_condvar_wait(&hid_data->iface_count_cv,
     355                    &hid_data->iface_count_mutex);
     356        }
     357        fibril_mutex_unlock(&hid_data->iface_count_mutex);
     358}
    333359
    334360/** @}
Note: See TracChangeset for help on using the changeset viewer.