Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0fcccd9 in mainline


Ignore:
Timestamp:
2018-01-12T11:49:01Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
99a00a6
Parents:
fcdab1e
git-author:
Petr Manek <petr.manek@…> (2018-01-12 11:48:53)
git-committer:
Petr Manek <petr.manek@…> (2018-01-12 11:49:01)
Message:

usbhid: refactoring

Renamed polling synchronization primitives with the same convention as
in usbhub. Added some documentation.

Location:
uspace/drv/hid/usbhid
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/hid/usbhid/generic/hiddev.c

    rfcdab1e r0fcccd9  
    220220{
    221221        /* Continue polling until the device is about to be removed. */
    222         return !hid_dev->will_deinit;
     222        return !hid_dev->poll_stop;
    223223}
    224224
  • uspace/drv/hid/usbhid/kbd/kbddev.c

    rfcdab1e r0fcccd9  
    710710
    711711        /* Continue polling until the device is about to be removed. */
    712         return !hid_dev->will_deinit;
     712        return !hid_dev->poll_stop;
    713713}
    714714
  • uspace/drv/hid/usbhid/main.c

    rfcdab1e r0fcccd9  
    144144
    145145        /* Join polling fibril. */
    146         fibril_mutex_lock(&hid_dev->guard);
     146        fibril_mutex_lock(&hid_dev->poll_guard);
    147147        while (hid_dev->running)
    148                 fibril_condvar_wait(&hid_dev->poll_end, &hid_dev->guard);
    149         fibril_mutex_unlock(&hid_dev->guard);
     148                fibril_condvar_wait(&hid_dev->poll_cv, &hid_dev->poll_guard);
     149        fibril_mutex_unlock(&hid_dev->poll_guard);
    150150
    151151        /* Clean up. */
  • uspace/drv/hid/usbhid/mouse/mousedev.c

    rfcdab1e r0fcccd9  
    415415
    416416        /* Continue polling until the device is about to be removed. */
    417         return !hid_dev->will_deinit;
     417        return !hid_dev->poll_stop;
    418418}
    419419
  • uspace/drv/hid/usbhid/multimedia/multimedia.c

    rfcdab1e r0fcccd9  
    246246        usb_hid_report_path_t *path = usb_hid_report_path();
    247247        if (path == NULL)
    248                 return !hid_dev->will_deinit; /* This might be a temporary failure. */
     248                return !hid_dev->poll_stop; /* This might be a temporary failure. */
    249249
    250250        int ret =
     
    252252        if (ret != EOK) {
    253253                usb_hid_report_path_free(path);
    254                 return !hid_dev->will_deinit; /* This might be a temporary failure. */
     254                return !hid_dev->poll_stop; /* This might be a temporary failure. */
    255255        }
    256256
     
    284284        usb_hid_report_path_free(path);
    285285
    286         return !hid_dev->will_deinit;
     286        return !hid_dev->poll_stop;
    287287}
    288288/**
  • uspace/drv/hid/usbhid/usbhid.c

    rfcdab1e r0fcccd9  
    355355        hid_dev->poll_pipe_mapping = NULL;
    356356
    357         hid_dev->will_deinit = false;
    358         fibril_mutex_initialize(&hid_dev->guard);
    359         fibril_condvar_initialize(&hid_dev->poll_end);
     357        hid_dev->poll_stop = false;
     358        fibril_mutex_initialize(&hid_dev->poll_guard);
     359        fibril_condvar_initialize(&hid_dev->poll_cv);
    360360
    361361        int rc = usb_hid_check_pipes(hid_dev, dev);
     
    506506
    507507        /* Continue polling until the device is about to be removed. */
    508         return hid_dev->running && !hid_dev->will_deinit;
     508        return hid_dev->running && !hid_dev->poll_stop;
    509509}
    510510
     
    526526
    527527        /* Signal polling end to joining thread. */
    528         fibril_mutex_lock(&hid_dev->guard);
    529         fibril_condvar_signal(&hid_dev->poll_end);
    530         fibril_mutex_unlock(&hid_dev->guard);
     528        fibril_mutex_lock(&hid_dev->poll_guard);
     529        fibril_condvar_signal(&hid_dev->poll_cv);
     530        fibril_mutex_unlock(&hid_dev->poll_guard);
    531531}
    532532
     
    544544{
    545545        assert(hid_dev);
    546         hid_dev->will_deinit = true;
     546        hid_dev->poll_stop = true;
    547547}
    548548
  • uspace/drv/hid/usbhid/usbhid.h

    rfcdab1e r0fcccd9  
    132132        volatile bool running;
    133133
    134         volatile bool will_deinit;
    135         fibril_mutex_t guard;
    136         fibril_condvar_t poll_end;
     134        /** True if polling should stop as soon as possible */
     135        volatile bool poll_stop;
     136
     137        /** Synchronization primitives for joining polling end. */
     138        fibril_mutex_t poll_guard;
     139        fibril_condvar_t poll_cv;
    137140};
    138141
Note: See TracChangeset for help on using the changeset viewer.