Changeset cddd151 in mainline


Ignore:
Timestamp:
2011-10-14T14:37:32Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7b54b99
Parents:
e5024111
Message:

usbhid: kbd store pointer to created function.

Make repeat mutex part of the kbd structure.

Location:
uspace/drv/bus/usb/usbhid
Files:
4 edited

Legend:

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

    re5024111 rcddd151  
    540540                usb_log_error("Could not bind DDF function: %s.\n",
    541541                    str_error(rc));
     542                fun->driver_data = NULL; /* We need this later */
    542543                ddf_fun_destroy(fun);
    543544                return rc;
     
    554555                    "Could not add DDF function to category %s: %s.\n",
    555556                    HID_KBD_CLASS_NAME, str_error(rc));
     557                fun->driver_data = NULL; /* We need this later */
    556558                ddf_fun_destroy(fun);
    557559                return rc;
    558560        }
     561        kbd_dev->fun = fun;
    559562
    560563        return EOK;
     
    687690        kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY;
    688691
    689         kbd_dev->repeat_mtx = (fibril_mutex_t *)(
    690             malloc(sizeof(fibril_mutex_t)));
    691         if (kbd_dev->repeat_mtx == NULL) {
    692                 usb_log_fatal("No memory!\n");
    693                 free(kbd_dev->keys);
    694                 usb_hid_report_output_free(kbd_dev->output_buffer);
    695                 free(kbd_dev);
    696                 return ENOMEM;
    697         }
    698 
    699         fibril_mutex_initialize(kbd_dev->repeat_mtx);
     692        fibril_mutex_initialize(&kbd_dev->repeat_mtx);
    700693
    701694        // save the KBD device structure into the HID device structure
     
    784777        async_hangup(kbd_dev->console_sess);
    785778
    786         if (kbd_dev->repeat_mtx != NULL) {
    787                 //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
    788                 // FIXME - the fibril_mutex_is_locked may not cause
    789                 // fibril scheduling
    790                 while (fibril_mutex_is_locked(kbd_dev->repeat_mtx)) {}
    791                 free(kbd_dev->repeat_mtx);
    792         }
     779        //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     780        // FIXME - the fibril_mutex_is_locked may not cause
     781        // fibril scheduling
     782        while (fibril_mutex_is_locked(&kbd_dev->repeat_mtx)) {}
    793783
    794784        // free all buffers
    795         if (kbd_dev->keys != NULL) {
    796                 free(kbd_dev->keys);
    797         }
    798         if (kbd_dev->keys_old != NULL) {
    799                 free(kbd_dev->keys_old);
    800         }
    801         if (kbd_dev->led_data != NULL) {
    802                 free(kbd_dev->led_data);
    803         }
     785        free(kbd_dev->keys);
     786        free(kbd_dev->keys_old);
     787        free(kbd_dev->led_data);
    804788        if (kbd_dev->led_path != NULL) {
    805789                usb_hid_report_path_free(kbd_dev->led_path);
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.h

    re5024111 rcddd151  
    9292
    9393        /** Mutex for accessing the information about auto-repeat. */
    94         fibril_mutex_t *repeat_mtx;
     94        fibril_mutex_t repeat_mtx;
    9595
    9696        uint8_t *output_buffer;
     
    111111         */
    112112        int initialized;
     113
     114        /** DDF function */
     115        ddf_fun_t *fun;
    113116} usb_kbd_t;
    114117
  • uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c

    re5024111 rcddd151  
    8585                }
    8686               
    87                 fibril_mutex_lock(kbd->repeat_mtx);
     87                fibril_mutex_lock(&kbd->repeat_mtx);
    8888
    8989                if (kbd->repeat.key_new > 0) {
     
    109109                        delay = CHECK_DELAY;
    110110                }
    111                 fibril_mutex_unlock(kbd->repeat_mtx);
     111                fibril_mutex_unlock(&kbd->repeat_mtx);
    112112               
    113113                async_usleep(delay);
     
    156156void usb_kbd_repeat_start(usb_kbd_t *kbd, unsigned int key)
    157157{
    158         fibril_mutex_lock(kbd->repeat_mtx);
     158        fibril_mutex_lock(&kbd->repeat_mtx);
    159159        kbd->repeat.key_new = key;
    160         fibril_mutex_unlock(kbd->repeat_mtx);
     160        fibril_mutex_unlock(&kbd->repeat_mtx);
    161161}
    162162
     
    174174void usb_kbd_repeat_stop(usb_kbd_t *kbd, unsigned int key)
    175175{
    176         fibril_mutex_lock(kbd->repeat_mtx);
     176        fibril_mutex_lock(&kbd->repeat_mtx);
    177177        if (key == kbd->repeat.key_new) {
    178178                kbd->repeat.key_new = 0;
    179179        }
    180         fibril_mutex_unlock(kbd->repeat_mtx);
     180        fibril_mutex_unlock(&kbd->repeat_mtx);
    181181}
    182182
  • uspace/drv/bus/usb/usbhid/usbhid.c

    re5024111 rcddd151  
    669669        }
    670670
    671         // free the subdrivers info
    672         if (hid_dev->subdrivers != NULL) {
    673                 free(hid_dev->subdrivers);
    674         }
    675 
    676         // destroy the parser
     671        /* Free allocated structures */
     672        free(hid_dev->subdrivers);
     673        free(hid_dev->report_desc);
     674
     675        /* Destroy the parser */
    677676        if (hid_dev->report != NULL) {
    678677                usb_hid_free_report(hid_dev->report);
    679678        }
    680679
    681         if (hid_dev->report_desc != NULL) {
    682                 free(hid_dev->report_desc);
    683         }
    684680}
    685681
Note: See TracChangeset for help on using the changeset viewer.