Ignore:
Timestamp:
2011-10-15T13:06:28Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a044f71
Parents:
3958e315 (diff), 065064e6 (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:

USB improvements.

USB unplug part2; Unplug support in all drivers (except for unused usbmouse driver).
Make descriptor paring work on const pointers.
Fixes several crashes and memory leaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c

    r3958e315 re3f7418  
    4646
    4747
    48 /** Delay between auto-repeat state checks when no key is being repeated. */
    49 static unsigned int CHECK_DELAY = 10000;
    5048
    5149/*----------------------------------------------------------------------------*/
     
    7371{
    7472        unsigned int delay = 0;
    75        
     73
    7674        usb_log_debug("Starting autorepeat loop.\n");
    7775
     
    7977                // check if the kbd structure is usable
    8078                if (!usb_kbd_is_initialized(kbd)) {
    81                         if (usb_kbd_is_ready_to_destroy(kbd)) {
    82                                 usb_kbd_destroy(kbd);
    83                         }
     79                        usb_log_warning("kbd not ready, exiting autorepeat.\n");
    8480                        return;
    8581                }
    8682               
    87                 fibril_mutex_lock(kbd->repeat_mtx);
     83                fibril_mutex_lock(&kbd->repeat_mtx);
    8884
    8985                if (kbd->repeat.key_new > 0) {
     
    109105                        delay = CHECK_DELAY;
    110106                }
    111                 fibril_mutex_unlock(kbd->repeat_mtx);
     107                fibril_mutex_unlock(&kbd->repeat_mtx);
    112108               
    113109                async_usleep(delay);
     
    130126{
    131127        usb_log_debug("Autorepeat fibril spawned.\n");
    132        
     128
    133129        if (arg == NULL) {
    134130                usb_log_error("No device!\n");
    135131                return EINVAL;
    136132        }
    137        
     133
    138134        usb_kbd_t *kbd = (usb_kbd_t *)arg;
    139        
     135
    140136        usb_kbd_repeat_loop(kbd);
    141        
     137
    142138        return EOK;
    143139}
     
    156152void usb_kbd_repeat_start(usb_kbd_t *kbd, unsigned int key)
    157153{
    158         fibril_mutex_lock(kbd->repeat_mtx);
     154        fibril_mutex_lock(&kbd->repeat_mtx);
    159155        kbd->repeat.key_new = key;
    160         fibril_mutex_unlock(kbd->repeat_mtx);
     156        fibril_mutex_unlock(&kbd->repeat_mtx);
    161157}
    162158
     
    174170void usb_kbd_repeat_stop(usb_kbd_t *kbd, unsigned int key)
    175171{
    176         fibril_mutex_lock(kbd->repeat_mtx);
     172        fibril_mutex_lock(&kbd->repeat_mtx);
    177173        if (key == kbd->repeat.key_new) {
    178174                kbd->repeat.key_new = 0;
    179175        }
    180         fibril_mutex_unlock(kbd->repeat_mtx);
     176        fibril_mutex_unlock(&kbd->repeat_mtx);
    181177}
    182178
Note: See TracChangeset for help on using the changeset viewer.