Changeset 1f131fb9 in mainline


Ignore:
Timestamp:
2011-10-16T19:38:53Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
22ceff3a, e5291e0
Parents:
98fb010 (diff), 93d2684 (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:

Minor USB changes.

Add more const qualifiers where possible.
Do not limit the number possible usbhid subdrivers.
This should not break anything. If it does feel free to revert this merge.

Location:
uspace
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkbd/main.c

    r98fb010 r1f131fb9  
    6969        int rc = usb_hid_report_init(*report);
    7070        if (rc != EOK) {
    71                 usb_hid_free_report(*report);
     71                usb_hid_report_deinit(*report);
    7272                *report = NULL;
    7373                return rc;
     
    7979            &report_desc_size);
    8080        if (rc != EOK) {
    81                 usb_hid_free_report(*report);
     81                usb_hid_report_deinit(*report);
    8282                *report = NULL;
    8383                return rc;
     
    8585       
    8686        if (report_desc_size == 0) {
    87                 usb_hid_free_report(*report);
     87                usb_hid_report_deinit(*report);
    8888                *report = NULL;
    8989                // TODO: other error code?
     
    9393        uint8_t *desc = (uint8_t *) malloc(report_desc_size);
    9494        if (desc == NULL) {
    95                 usb_hid_free_report(*report);
     95                usb_hid_report_deinit(*report);
    9696                *report = NULL;
    9797                return ENOMEM;
     
    103103            &actual_size);
    104104        if (rc != EOK) {
    105                 usb_hid_free_report(*report);
     105                usb_hid_report_deinit(*report);
    106106                *report = NULL;
    107107                free(desc);
     
    110110       
    111111        if (actual_size != report_desc_size) {
    112                 usb_hid_free_report(*report);
     112                usb_hid_report_deinit(*report);
    113113                *report = NULL;
    114114                free(desc);
  • uspace/app/usbinfo/hid.c

    r98fb010 r1f131fb9  
    167167
    168168        free(raw_report);
    169         usb_hid_free_report(&report);
     169        usb_hid_report_deinit(&report);
    170170}
    171171
  • uspace/drv/bus/usb/usbhid/generic/hiddev.c

    r98fb010 r1f131fb9  
    4848/*----------------------------------------------------------------------------*/
    4949
    50 usb_endpoint_description_t usb_hid_generic_poll_endpoint_description = {
     50const usb_endpoint_description_t usb_hid_generic_poll_endpoint_description = {
    5151        .transfer_type = USB_TRANSFER_INTERRUPT,
    5252        .direction = USB_DIRECTION_IN,
  • uspace/drv/bus/usb/usbhid/generic/hiddev.h

    r98fb010 r1f131fb9  
    4141struct usb_hid_dev;
    4242
    43 usb_endpoint_description_t usb_hid_generic_poll_endpoint_description;
     43extern const usb_endpoint_description_t
     44    usb_hid_generic_poll_endpoint_description;
    4445
    4546const char *HID_GENERIC_FUN_NAME;
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.c

    r98fb010 r1f131fb9  
    8888
    8989/** Keyboard polling endpoint description for boot protocol class. */
    90 usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description = {
     90const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description = {
    9191        .transfer_type = USB_TRANSFER_INTERRUPT,
    9292        .direction = USB_DIRECTION_IN,
     
    237237
    238238        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    239             hid_dev->report, NULL, kbd_dev->led_path,
     239            &hid_dev->report, NULL, kbd_dev->led_path,
    240240            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    241241            USB_HID_REPORT_TYPE_OUTPUT);
    242242
    243243        while (field != NULL) {
    244                
    245                 if ((field->usage == USB_HID_LED_NUM_LOCK) 
     244
     245                if ((field->usage == USB_HID_LED_NUM_LOCK)
    246246                    && (kbd_dev->mods & KM_NUM_LOCK)){
    247247                        field->value = 1;
    248248                }
    249249
    250                 if ((field->usage == USB_HID_LED_CAPS_LOCK) 
     250                if ((field->usage == USB_HID_LED_CAPS_LOCK)
    251251                    && (kbd_dev->mods & KM_CAPS_LOCK)){
    252252                        field->value = 1;
    253253                }
    254254
    255                 if ((field->usage == USB_HID_LED_SCROLL_LOCK) 
     255                if ((field->usage == USB_HID_LED_SCROLL_LOCK)
    256256                    && (kbd_dev->mods & KM_SCROLL_LOCK)){
    257257                        field->value = 1;
    258258                }
    259                
    260                 field = usb_hid_report_get_sibling(hid_dev->report, field,
    261                     kbd_dev->led_path, 
    262                 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    263                         USB_HID_REPORT_TYPE_OUTPUT);
     259
     260                field = usb_hid_report_get_sibling(
     261                    &hid_dev->report, field, kbd_dev->led_path,
     262                USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     263                    USB_HID_REPORT_TYPE_OUTPUT);
    264264        }
    265265
    266266        // TODO: what about the Report ID?
    267         int rc = usb_hid_report_output_translate(hid_dev->report, 0,
     267        int rc = usb_hid_report_output_translate(&hid_dev->report, 0,
    268268            kbd_dev->output_buffer, kbd_dev->output_size);
    269269
     
    432432static void usb_kbd_process_data(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
    433433{
    434         assert(hid_dev->report != NULL);
    435434        assert(hid_dev != NULL);
    436435        assert(kbd_dev != NULL);
     
    444443
    445444        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    446             hid_dev->report, NULL, path,
    447             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
     445            &hid_dev->report, NULL, path,
     446            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    448447            USB_HID_REPORT_TYPE_INPUT);
    449448        unsigned i = 0;
     
    454453               
    455454                assert(i < kbd_dev->key_count);
    456                
     455
    457456                // save the key usage
    458457                if (field->value != 0) {
     
    463462                }
    464463                usb_log_debug2("Saved %u. key usage %d\n", i, kbd_dev->keys[i]);
    465                
     464
    466465                ++i;
    467                 field = usb_hid_report_get_sibling(hid_dev->report, field, path,
    468                     USB_HID_PATH_COMPARE_END
    469                     | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     466                field = usb_hid_report_get_sibling(
     467                    &hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
     468                        | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    470469                    USB_HID_REPORT_TYPE_INPUT);
    471470        }
     
    616615
    617616        kbd_dev->key_count = usb_hid_report_size(
    618             hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT);
     617            &hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT);
    619618        usb_hid_report_path_free(path);
    620619
    621620        usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
    622621
    623         kbd_dev->keys = (int32_t *)calloc(kbd_dev->key_count, sizeof(int32_t));
     622        kbd_dev->keys = calloc(kbd_dev->key_count, sizeof(int32_t));
    624623
    625624        if (kbd_dev->keys == NULL) {
     
    643642         */
    644643        kbd_dev->output_size = 0;
    645         kbd_dev->output_buffer = usb_hid_report_output(hid_dev->report,
     644        kbd_dev->output_buffer = usb_hid_report_output(&hid_dev->report,
    646645            &kbd_dev->output_size, 0);
    647646        if (kbd_dev->output_buffer == NULL) {
     
    657656            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
    658657
    659         kbd_dev->led_output_size = usb_hid_report_size(hid_dev->report,
    660             0, USB_HID_REPORT_TYPE_OUTPUT);
     658        kbd_dev->led_output_size = usb_hid_report_size(
     659            &hid_dev->report, 0, USB_HID_REPORT_TYPE_OUTPUT);
    661660
    662661        usb_log_debug("Output report size (in items): %zu\n",
     
    826825int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev)
    827826{
    828         int rc = usb_hid_parse_report_descriptor(hid_dev->report,
    829             USB_KBD_BOOT_REPORT_DESCRIPTOR,
     827        int rc = usb_hid_parse_report_descriptor(
     828            &hid_dev->report, USB_KBD_BOOT_REPORT_DESCRIPTOR,
    830829            USB_KBD_BOOT_REPORT_DESCRIPTOR_SIZE);
    831830
     
    836835        }
    837836
    838         rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe, 
     837        rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe,
    839838            hid_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT);
    840839
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.h

    r98fb010 r1f131fb9  
    118118/*----------------------------------------------------------------------------*/
    119119
    120 usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description;
     120extern const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description;
    121121
    122122const char *HID_KBD_FUN_NAME;
  • uspace/drv/bus/usb/usbhid/main.c

    r98fb010 r1f131fb9  
    9292        if (rc != EOK) {
    9393                usb_log_error("Failed to initialize USB/HID device.\n");
    94                 usb_hid_destroy(hid_dev);
     94                usb_hid_deinit(hid_dev);
    9595                return rc;
    9696        }
     
    128128                usb_log_error("Failed to start polling fibril for `%s'.\n",
    129129                    dev->ddf_dev->name);
    130                 usb_hid_destroy(hid_dev);
     130                usb_hid_deinit(hid_dev);
    131131                return rc;
    132132        }
    133133        hid_dev->running = true;
    134         dev->driver_data = hid_dev;
    135134
    136135        /*
     
    204203
    205204        assert(!hid_dev->running);
    206         usb_hid_destroy(hid_dev);
     205        usb_hid_deinit(hid_dev);
    207206        usb_log_debug2("%s destruction complete.\n", dev->ddf_dev->name);
    208207        return EOK;
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    r98fb010 r1f131fb9  
    5959/*----------------------------------------------------------------------------*/
    6060
    61 usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description = {
     61const usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description = {
    6262        .transfer_type = USB_TRANSFER_INTERRUPT,
    6363        .direction = USB_DIRECTION_IN,
     
    268268
    269269        int shift_x = get_mouse_axis_move_value(hid_dev->report_id,
    270             hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_X);
     270            &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_X);
    271271        int shift_y = get_mouse_axis_move_value(hid_dev->report_id,
    272             hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_Y);
     272            &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_Y);
    273273        int wheel = get_mouse_axis_move_value(hid_dev->report_id,
    274             hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL);
     274            &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL);
    275275
    276276        if ((shift_x != 0) || (shift_y != 0)) {
    277                 async_exch_t *exch = async_exchange_begin(mouse_dev->mouse_sess);
     277                async_exch_t *exch =
     278                    async_exchange_begin(mouse_dev->mouse_sess);
    278279                async_req_2_0(exch, MOUSEEV_MOVE_EVENT, shift_x, shift_y);
    279280                async_exchange_end(exch);
     
    291292
    292293        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    293             hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
    294             | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    295             USB_HID_REPORT_TYPE_INPUT);
     294            &hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
     295            | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, USB_HID_REPORT_TYPE_INPUT);
    296296
    297297        while (field != NULL) {
     
    314314                        async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 0);
    315315                        async_exchange_end(exch);
    316                        
     316
    317317                        mouse_dev->buttons[field->usage - field->usage_minimum] =
    318318                           field->value;
    319319                }
    320                
     320
    321321                field = usb_hid_report_get_sibling(
    322                     hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
    323                     | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
     322                    &hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
     323                    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    324324                    USB_HID_REPORT_TYPE_INPUT);
    325325        }
     
    474474        // that the current solution is good enough.
    475475        /* Adding 1 because we will be accessing buttons[highest]. */
    476         mouse_dev->buttons_count = usb_mouse_get_highest_button(hid_dev->report,
    477             hid_dev->report_id) + 1;
     476        mouse_dev->buttons_count = 1 + usb_mouse_get_highest_button(
     477            &hid_dev->report, hid_dev->report_id);
    478478        mouse_dev->buttons = calloc(mouse_dev->buttons_count, sizeof(int32_t));
    479479
     
    532532int usb_mouse_set_boot_protocol(usb_hid_dev_t *hid_dev)
    533533{
    534         int rc = usb_hid_parse_report_descriptor(hid_dev->report,
    535             USB_MOUSE_BOOT_REPORT_DESCRIPTOR,
     534        int rc = usb_hid_parse_report_descriptor(
     535            &hid_dev->report, USB_MOUSE_BOOT_REPORT_DESCRIPTOR,
    536536            USB_MOUSE_BOOT_REPORT_DESCRIPTOR_SIZE);
    537537
     
    542542        }
    543543
    544         rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe, 
     544        rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe,
    545545            hid_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT);
    546546
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.h

    r98fb010 r1f131fb9  
    6363/*----------------------------------------------------------------------------*/
    6464
    65 usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description;
     65extern const usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description;
    6666
    6767const char *HID_MOUSE_FUN_NAME;
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.c

    r98fb010 r1f131fb9  
    161161/*----------------------------------------------------------------------------*/
    162162
    163 static int usb_multimedia_create_function(usb_hid_dev_t *hid_dev,
    164     usb_multimedia_t *multim_dev)
    165 {
     163int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
     164{
     165        if (hid_dev == NULL || hid_dev->usb_dev == NULL) {
     166                return EINVAL; /*! @todo Other return code? */
     167        }
     168
     169        usb_log_debug(NAME " Initializing HID/multimedia structure...\n");
     170
    166171        /* Create the exposed function. */
    167         ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
    168             NAME);
     172        ddf_fun_t *fun = ddf_fun_create(
     173            hid_dev->usb_dev->ddf_dev, fun_exposed, NAME);
    169174        if (fun == NULL) {
    170175                usb_log_error("Could not create DDF function node.\n");
     
    173178
    174179        fun->ops = &multimedia_ops;
    175         fun->driver_data = multim_dev;   // TODO: maybe change to hid_dev->data
     180
     181        usb_multimedia_t *multim_dev =
     182            ddf_fun_data_alloc(fun, sizeof(usb_multimedia_t));
     183        if (multim_dev == NULL) {
     184                ddf_fun_destroy(fun);
     185                return ENOMEM;
     186        }
     187
     188        multim_dev->console_sess = NULL;
     189        multim_dev->fun = fun;
     190
     191        //todo Autorepeat?
    176192
    177193        int rc = ddf_fun_bind(fun);
     
    194210                return rc;
    195211        }
    196         multim_dev->fun = fun;
    197 
    198         return EOK;
    199 }
    200 
    201 /*----------------------------------------------------------------------------*/
    202 
    203 int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
    204 {
    205         if (hid_dev == NULL || hid_dev->usb_dev == NULL) {
    206                 return EINVAL; /*! @todo Other return code? */
    207         }
    208 
    209         usb_log_debug(NAME " Initializing HID/multimedia structure...\n");
    210 
    211         usb_multimedia_t *multim_dev = (usb_multimedia_t *)malloc(
    212             sizeof(usb_multimedia_t));
    213         if (multim_dev == NULL) {
    214                 return ENOMEM;
    215         }
    216 
    217         multim_dev->console_sess = NULL;
    218 
    219         /*! @todo Autorepeat */
    220 
    221         // save the KBD device structure into the HID device structure
     212
     213        /* Save the KBD device structure into the HID device structure. */
    222214        *data = multim_dev;
    223215
    224         usb_log_debug(NAME " HID/multimedia device structure initialized.\n");
    225 
    226         int rc = usb_multimedia_create_function(hid_dev, multim_dev);
    227         if (rc != EOK)
    228                 return rc;
    229 
    230216        usb_log_debug(NAME " HID/multimedia structure initialized.\n");
    231 
    232217        return EOK;
    233218}
     
    272257
    273258        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    274             hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
    275             | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
     259            &hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
     260            | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    276261            USB_HID_REPORT_TYPE_INPUT);
    277262
     
    293278
    294279                field = usb_hid_report_get_sibling(
    295                     hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
     280                    &hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
    296281                    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    297282                    USB_HID_REPORT_TYPE_INPUT);
  • uspace/drv/bus/usb/usbhid/subdrivers.c

    r98fb010 r1f131fb9  
    4242#include "generic/hiddev.h"
    4343
    44 static usb_hid_subdriver_usage_t path_kbd[] = {
    45         {USB_HIDUT_PAGE_GENERIC_DESKTOP, 
    46          USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD}, 
     44static const usb_hid_subdriver_usage_t path_kbd[] = {
     45        {USB_HIDUT_PAGE_GENERIC_DESKTOP,
     46         USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD},
    4747        {0, 0}
    4848};
    4949
    50 static usb_hid_subdriver_usage_t path_mouse[] = {
     50static const usb_hid_subdriver_usage_t path_mouse[] = {
    5151        {USB_HIDUT_PAGE_GENERIC_DESKTOP, USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE},
    5252        {0, 0}
    5353};
    5454
    55 static usb_hid_subdriver_usage_t multim_key_path[] = {
     55static const usb_hid_subdriver_usage_t multim_key_path[] = {
    5656        {USB_HIDUT_PAGE_CONSUMER, USB_HIDUT_USAGE_CONSUMER_CONSUMER_CONTROL},
    5757        {0, 0}
     
    7171                        .poll_end = NULL
    7272                },
    73                
    7473        },
    7574        {
     
    102101};
    103102
     103const int USB_HID_MAX_SUBDRIVERS =
     104    sizeof(usb_hid_subdrivers) / sizeof(usb_hid_subdrivers[0]);
     105
    104106/**
    105107 * @}
  • uspace/drv/bus/usb/usbhid/subdrivers.h

    r98fb010 r1f131fb9  
    7878
    7979        /** Subdriver for controlling this device. */
    80         usb_hid_subdriver_t subdriver;
     80        const usb_hid_subdriver_t subdriver;
    8181} usb_hid_subdriver_mapping_t;
    8282
     
    8484
    8585extern const usb_hid_subdriver_mapping_t usb_hid_subdrivers[];
     86extern const int USB_HID_MAX_SUBDRIVERS;
    8687
    8788/*----------------------------------------------------------------------------*/
  • uspace/drv/bus/usb/usbhid/usbhid.c

    r98fb010 r1f131fb9  
    5454
    5555/* Array of endpoints expected on the device, NULL terminated. */
    56 usb_endpoint_description_t *usb_hid_endpoints[] = {
     56const usb_endpoint_description_t *usb_hid_endpoints[] = {
    5757        &usb_hid_kbd_poll_endpoint_description,
    5858        &usb_hid_mouse_poll_endpoint_description,
     
    6161};
    6262
    63 static const int USB_HID_MAX_SUBDRIVERS = 10;
    64 
    6563/*----------------------------------------------------------------------------*/
    6664
    6765static int usb_hid_set_boot_kbd_subdriver(usb_hid_dev_t *hid_dev)
    6866{
    69         assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
    70 
    71         hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
    72             sizeof(usb_hid_subdriver_t));
     67        assert(hid_dev != NULL);
     68        assert(hid_dev->subdriver_count == 0);
     69
     70        hid_dev->subdrivers = malloc(sizeof(usb_hid_subdriver_t));
    7371        if (hid_dev->subdrivers == NULL) {
    7472                return ENOMEM;
    7573        }
    76 
    77         assert(hid_dev->subdriver_count >= 0);
    78 
    79         // set the init callback
    80         hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_kbd_init;
    81 
    82         // set the polling callback
    83         hid_dev->subdrivers[hid_dev->subdriver_count].poll =
    84             usb_kbd_polling_callback;
    85 
    86         // set the polling ended callback
    87         hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
    88 
    89         // set the deinit callback
    90         hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_kbd_deinit;
    91 
    92         // set subdriver count
    93         ++hid_dev->subdriver_count;
     74        hid_dev->subdriver_count = 1;
     75        // TODO 0 should be keyboard, but find a better way
     76        hid_dev->subdrivers[0] = usb_hid_subdrivers[0].subdriver;
    9477
    9578        return EOK;
     
    10083static int usb_hid_set_boot_mouse_subdriver(usb_hid_dev_t *hid_dev)
    10184{
    102         assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
    103 
    104         hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
    105             sizeof(usb_hid_subdriver_t));
     85        assert(hid_dev != NULL);
     86        assert(hid_dev->subdriver_count == 0);
     87
     88        hid_dev->subdrivers = malloc(sizeof(usb_hid_subdriver_t));
    10689        if (hid_dev->subdrivers == NULL) {
    10790                return ENOMEM;
    10891        }
    109 
    110         assert(hid_dev->subdriver_count >= 0);
    111 
    112         // set the init callback
    113         hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_mouse_init;
    114 
    115         // set the polling callback
    116         hid_dev->subdrivers[hid_dev->subdriver_count].poll =
    117             usb_mouse_polling_callback;
    118 
    119         // set the polling ended callback
    120         hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
    121 
    122         // set the deinit callback
    123         hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_mouse_deinit;
    124 
    125         // set subdriver count
    126         ++hid_dev->subdriver_count;
     92        hid_dev->subdriver_count = 1;
     93        // TODO 2 should be mouse, but find a better way
     94        hid_dev->subdrivers[2] = usb_hid_subdrivers[0].subdriver;
    12795
    12896        return EOK;
     
    135103        assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
    136104
    137         hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
    138             sizeof(usb_hid_subdriver_t));
     105        hid_dev->subdrivers = malloc(sizeof(usb_hid_subdriver_t));
    139106        if (hid_dev->subdrivers == NULL) {
    140107                return ENOMEM;
    141108        }
    142 
    143         assert(hid_dev->subdriver_count >= 0);
    144 
    145         // set the init callback
    146         hid_dev->subdrivers[hid_dev->subdriver_count].init =
    147             usb_generic_hid_init;
    148 
    149         // set the polling callback
    150         hid_dev->subdrivers[hid_dev->subdriver_count].poll =
    151             usb_generic_hid_polling_callback;
    152 
    153         // set the polling ended callback
    154         hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
    155 
    156         // set the deinit callback
    157         hid_dev->subdrivers[hid_dev->subdriver_count].deinit =
    158             usb_generic_hid_deinit;
    159 
    160         // set subdriver count
    161         ++hid_dev->subdriver_count;
     109        hid_dev->subdriver_count = 1;
     110
     111        /* Set generic hid subdriver routines */
     112        hid_dev->subdrivers[0].init = usb_generic_hid_init;
     113        hid_dev->subdrivers[0].poll = usb_generic_hid_polling_callback;
     114        hid_dev->subdrivers[0].poll_end = NULL;
     115        hid_dev->subdrivers[0].deinit = usb_generic_hid_deinit;
    162116
    163117        return EOK;
     
    166120/*----------------------------------------------------------------------------*/
    167121
    168 static bool usb_hid_ids_match(usb_hid_dev_t *hid_dev,
     122static bool usb_hid_ids_match(const usb_hid_dev_t *hid_dev,
    169123    const usb_hid_subdriver_mapping_t *mapping)
    170124{
     
    172126        assert(hid_dev->usb_dev != NULL);
    173127
    174         return (hid_dev->usb_dev->descriptors.device.vendor_id 
     128        return (hid_dev->usb_dev->descriptors.device.vendor_id
    175129            == mapping->vendor_id
    176130            && hid_dev->usb_dev->descriptors.device.product_id
     
    180134/*----------------------------------------------------------------------------*/
    181135
    182 static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev, 
     136static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev,
    183137    const usb_hid_subdriver_mapping_t *mapping)
    184138{
     
    192146        }
    193147        int i = 0;
    194         while (mapping->usage_path[i].usage != 0 
     148        while (mapping->usage_path[i].usage != 0
    195149            || mapping->usage_path[i].usage_page != 0) {
    196                 if (usb_hid_report_path_append_item(usage_path, 
    197                     mapping->usage_path[i].usage_page, 
     150                if (usb_hid_report_path_append_item(usage_path,
     151                    mapping->usage_path[i].usage_page,
    198152                    mapping->usage_path[i].usage) != EOK) {
    199153                        usb_log_debug("Failed to append to usage path.\n");
     
    204158        }
    205159
    206         assert(hid_dev->report != NULL);
    207 
    208160        usb_log_debug("Compare flags: %d\n", mapping->compare);
    209161
     
    213165        do {
    214166                usb_log_debug("Trying report id %u\n", report_id);
    215                
     167
    216168                if (report_id != 0) {
    217169                        usb_hid_report_path_set_report_id(usage_path,
     
    220172
    221173                usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    222                     hid_dev->report,
    223                     NULL, usage_path, mapping->compare,
     174                    &hid_dev->report, NULL, usage_path, mapping->compare,
    224175                    USB_HID_REPORT_TYPE_INPUT);
    225                
     176
    226177                usb_log_debug("Field: %p\n", field);
    227178
     
    230181                        break;
    231182                }
    232                
     183
    233184                report_id = usb_hid_get_next_report_id(
    234                     hid_dev->report, report_id,
    235                     USB_HID_REPORT_TYPE_INPUT);
     185                    &hid_dev->report, report_id, USB_HID_REPORT_TYPE_INPUT);
    236186        } while (!matches && report_id != 0);
    237187
     
    243193/*----------------------------------------------------------------------------*/
    244194
    245 static int usb_hid_save_subdrivers(usb_hid_dev_t *hid_dev, 
     195static int usb_hid_save_subdrivers(usb_hid_dev_t *hid_dev,
    246196    const usb_hid_subdriver_t **subdrivers, int count)
    247197{
     
    254204        }
    255205
    256         // add one generic HID subdriver per device
    257 
    258         hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc((count + 1) *
    259             sizeof(usb_hid_subdriver_t));
     206        /* +1 for generic hid subdriver */
     207        hid_dev->subdrivers = calloc((count + 1), sizeof(usb_hid_subdriver_t));
    260208        if (hid_dev->subdrivers == NULL) {
    261209                return ENOMEM;
     
    269217        }
    270218
     219        /* Add one generic HID subdriver per device */
    271220        hid_dev->subdrivers[count].init = usb_generic_hid_init;
    272221        hid_dev->subdrivers[count].poll = usb_generic_hid_polling_callback;
     
    307256                        return EINVAL;
    308257                }
    309                
     258
    310259                ids_matched = false;
    311260                matched = false;
    312                
     261
    313262                if (mapping->vendor_id >= 0) {
    314263                        assert(mapping->product_id >= 0);
     
    321270                        }
    322271                }
    323                
     272
    324273                if (mapping->usage_path != NULL) {
    325274                        usb_log_debug("Comparing device against usage path.\n");
     
    332281                        matched = ids_matched;
    333282                }
    334                
     283
    335284                if (matched) {
    336285                        usb_log_debug("Subdriver matched.\n");
    337286                        subdrivers[count++] = &mapping->subdriver;
    338287                }
    339                
     288
    340289                mapping = &usb_hid_subdrivers[++i];
    341290        }
    342291
    343         // we have all subdrivers determined, save them into the hid device
     292        /* We have all subdrivers determined, save them into the hid device */
     293        // TODO Dowe really need this complicated stuff if there is
     294        // max_subdrivers limitation?
    344295        return usb_hid_save_subdrivers(hid_dev, subdrivers, count);
    345296}
     
    347298/*----------------------------------------------------------------------------*/
    348299
    349 static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, usb_device_t *dev)
    350 {
    351         assert(hid_dev != NULL && dev != NULL);
    352 
    353         int rc = EOK;
     300static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, const usb_device_t *dev)
     301{
     302        assert(hid_dev);
     303        assert(dev);
    354304
    355305        if (dev->pipes[USB_HID_KBD_POLL_EP_NO].present) {
     
    368318                usb_log_error("None of supported endpoints found - probably"
    369319                    " not a supported device.\n");
    370                 rc = ENOTSUP;
    371         }
    372 
    373         return rc;
     320                return ENOTSUP;
     321        }
     322
     323        return EOK;
    374324}
    375325
     
    378328static int usb_hid_init_report(usb_hid_dev_t *hid_dev)
    379329{
    380         assert(hid_dev != NULL && hid_dev->report != NULL);
     330        assert(hid_dev != NULL);
    381331
    382332        uint8_t report_id = 0;
    383         size_t size;
    384 
    385333        size_t max_size = 0;
    386334
    387335        do {
    388336                usb_log_debug("Getting size of the report.\n");
    389                 size = usb_hid_report_byte_size(hid_dev->report, report_id,
    390                     USB_HID_REPORT_TYPE_INPUT);
     337                const size_t size =
     338                    usb_hid_report_byte_size(&hid_dev->report, report_id,
     339                        USB_HID_REPORT_TYPE_INPUT);
    391340                usb_log_debug("Report ID: %u, size: %zu\n", report_id, size);
    392341                max_size = (size > max_size) ? size : max_size;
    393342                usb_log_debug("Getting next report ID\n");
    394                 report_id = usb_hid_get_next_report_id(hid_dev->report,
     343                report_id = usb_hid_get_next_report_id(&hid_dev->report,
    395344                    report_id, USB_HID_REPORT_TYPE_INPUT);
    396345        } while (report_id != 0);
     
    398347        usb_log_debug("Max size of input report: %zu\n", max_size);
    399348
    400         hid_dev->max_input_report_size = max_size;
    401349        assert(hid_dev->input_report == NULL);
    402350
    403         hid_dev->input_report = malloc(max_size);
     351        hid_dev->input_report = calloc(1, max_size);
    404352        if (hid_dev->input_report == NULL) {
    405353                return ENOMEM;
    406354        }
    407         memset(hid_dev->input_report, 0, max_size);
     355        hid_dev->max_input_report_size = max_size;
    408356
    409357        return EOK;
     
    430378        }
    431379
    432         hid_dev->report = (usb_hid_report_t *)(malloc(sizeof(
    433             usb_hid_report_t)));
    434         if (hid_dev->report == NULL) {
    435                 usb_log_error("No memory!\n");
    436                 return ENOMEM;
    437         }
    438         usb_hid_report_init(hid_dev->report);
     380        usb_hid_report_init(&hid_dev->report);
    439381
    440382        /* The USB device should already be initialized, save it in structure */
     
    446388                return rc;
    447389        }
    448                
     390
    449391        /* Get the report descriptor and parse it. */
    450         rc = usb_hid_process_report_descriptor(hid_dev->usb_dev, 
    451             hid_dev->report, &hid_dev->report_desc, &hid_dev->report_desc_size);
     392        rc = usb_hid_process_report_descriptor(hid_dev->usb_dev,
     393            &hid_dev->report, &hid_dev->report_desc, &hid_dev->report_desc_size);
    452394
    453395        bool fallback = false;
     
    488430                        break;
    489431                default:
    490                         assert(hid_dev->poll_pipe_index 
     432                        assert(hid_dev->poll_pipe_index
    491433                            == USB_HID_GENERIC_POLL_EP_NO);
    492                        
     434
    493435                        usb_log_info("Falling back to generic HID driver.\n");
    494436                        rc = usb_hid_set_generic_hid_subdriver(hid_dev);
     
    499441                usb_log_error("No subdriver for handling this device could be"
    500442                    " initialized: %s.\n", str_error(rc));
    501                 usb_log_debug("Subdriver count: %d\n", 
     443                usb_log_debug("Subdriver count: %d\n",
    502444                    hid_dev->subdriver_count);
    503                
    504445        } else {
    505446                bool ok = false;
    506                
    507                 usb_log_debug("Subdriver count: %d\n", 
     447
     448                usb_log_debug("Subdriver count: %d\n",
    508449                    hid_dev->subdriver_count);
    509                
     450
    510451                for (i = 0; i < hid_dev->subdriver_count; ++i) {
    511452                        if (hid_dev->subdrivers[i].init != NULL) {
     
    524465                        }
    525466                }
    526                
     467
    527468                rc = (ok) ? EOK : -1;   // what error to report
    528469        }
     
    538479        }
    539480
    540 
    541481        return rc;
    542482}
     
    544484/*----------------------------------------------------------------------------*/
    545485
    546 bool usb_hid_polling_callback(usb_device_t *dev, uint8_t *buffer, 
     486bool usb_hid_polling_callback(usb_device_t *dev, uint8_t *buffer,
    547487    size_t buffer_size, void *arg)
    548488{
    549         int i;
    550 
    551489        if (dev == NULL || arg == NULL || buffer == NULL) {
    552490                usb_log_error("Missing arguments to polling callback.\n");
    553491                return false;
    554492        }
    555 
    556         usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
     493        usb_hid_dev_t *hid_dev = arg;
    557494
    558495        assert(hid_dev->input_report != NULL);
     496
    559497        usb_log_debug("New data [%zu/%zu]: %s\n", buffer_size,
    560498            hid_dev->max_input_report_size,
     
    568506        }
    569507
    570         // parse the input report
    571 
    572         int rc = usb_hid_parse_report(hid_dev->report, buffer, buffer_size,
    573             &hid_dev->report_id);
    574 
     508        /* Parse the input report */
     509        const int rc = usb_hid_parse_report(
     510            &hid_dev->report, buffer, buffer_size, &hid_dev->report_id);
    575511        if (rc != EOK) {
    576512                usb_log_warning("Error in usb_hid_parse_report():"
    577513                    "%s\n", str_error(rc));
    578         }       
     514        }
    579515
    580516        bool cont = false;
    581 
    582         // continue if at least one of the subdrivers want to continue
    583         for (i = 0; i < hid_dev->subdriver_count; ++i) {
    584                 if (hid_dev->subdrivers[i].poll != NULL
    585                     && hid_dev->subdrivers[i].poll(hid_dev,
    586                         hid_dev->subdrivers[i].data)) {
    587                         cont = true;
     517        /* Continue if at least one of the subdrivers want to continue */
     518        for (int i = 0; i < hid_dev->subdriver_count; ++i) {
     519                if (hid_dev->subdrivers[i].poll != NULL) {
     520                        cont = cont || hid_dev->subdrivers[i].poll(
     521                            hid_dev, hid_dev->subdrivers[i].data);
    588522                }
    589523        }
     
    594528/*----------------------------------------------------------------------------*/
    595529
    596 void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason,
    597      void *arg)
    598 {
    599         int i;
    600 
    601         if (dev == NULL || arg == NULL) {
    602                 return;
    603         }
    604 
    605         usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
    606 
    607         for (i = 0; i < hid_dev->subdriver_count; ++i) {
     530void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason, void *arg)
     531{
     532        assert(dev);
     533        assert(arg);
     534
     535        usb_hid_dev_t *hid_dev = arg;
     536
     537        for (int i = 0; i < hid_dev->subdriver_count; ++i) {
    608538                if (hid_dev->subdrivers[i].poll_end != NULL) {
    609                         hid_dev->subdrivers[i].poll_end(hid_dev,
    610                             hid_dev->subdrivers[i].data, reason);
     539                        hid_dev->subdrivers[i].poll_end(
     540                            hid_dev, hid_dev->subdrivers[i].data, reason);
    611541                }
    612542        }
     
    624554/*----------------------------------------------------------------------------*/
    625555
    626 int usb_hid_report_number(usb_hid_dev_t *hid_dev)
     556int usb_hid_report_number(const usb_hid_dev_t *hid_dev)
    627557{
    628558        return hid_dev->report_nr;
     
    631561/*----------------------------------------------------------------------------*/
    632562
    633 void usb_hid_destroy(usb_hid_dev_t *hid_dev)
    634 {
    635         int i;
    636 
    637         if (hid_dev == NULL) {
    638                 return;
    639         }
     563void usb_hid_deinit(usb_hid_dev_t *hid_dev)
     564{
     565        assert(hid_dev);
     566        assert(hid_dev->subdrivers != NULL || hid_dev->subdriver_count == 0);
     567
    640568
    641569        usb_log_debug("Subdrivers: %p, subdriver count: %d\n",
    642570            hid_dev->subdrivers, hid_dev->subdriver_count);
    643571
    644         assert(hid_dev->subdrivers != NULL
    645             || hid_dev->subdriver_count == 0);
    646 
    647         for (i = 0; i < hid_dev->subdriver_count; ++i) {
     572        for (int i = 0; i < hid_dev->subdriver_count; ++i) {
    648573                if (hid_dev->subdrivers[i].deinit != NULL) {
    649574                        hid_dev->subdrivers[i].deinit(hid_dev,
     
    657582
    658583        /* Destroy the parser */
    659         if (hid_dev->report != NULL) {
    660                 usb_hid_free_report(hid_dev->report);
    661         }
     584        usb_hid_report_deinit(&hid_dev->report);
    662585
    663586}
  • uspace/drv/bus/usb/usbhid/usbhid.h

    r98fb010 r1f131fb9  
    119119
    120120        /** HID Report parser. */
    121         usb_hid_report_t *report;
     121        usb_hid_report_t report;
    122122
    123123        uint8_t report_id;
     
    141141};
    142142
    143 extern usb_endpoint_description_t *usb_hid_endpoints[];
     143extern const usb_endpoint_description_t *usb_hid_endpoints[];
    144144
    145145/*----------------------------------------------------------------------------*/
     
    147147int usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev);
    148148
    149 bool usb_hid_polling_callback(usb_device_t *dev, uint8_t *buffer,
    150     size_t buffer_size, void *arg);
     149void usb_hid_deinit(usb_hid_dev_t *hid_dev);
    151150
    152 void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason,
    153      void *arg);
     151bool usb_hid_polling_callback(usb_device_t *dev,
     152    uint8_t *buffer, size_t buffer_size, void *arg);
     153
     154void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason, void *arg);
    154155
    155156void usb_hid_new_report(usb_hid_dev_t *hid_dev);
    156157
    157 int usb_hid_report_number(usb_hid_dev_t *hid_dev);
    158 
    159 void usb_hid_destroy(usb_hid_dev_t *hid_dev);
     158int usb_hid_report_number(const usb_hid_dev_t *hid_dev);
    160159
    161160#endif /* USB_HID_USBHID_H_ */
  • uspace/drv/bus/usb/usbhub/main.c

    r98fb010 r1f131fb9  
    6767
    6868/** Hub endpoints, excluding control endpoint. */
    69 static usb_endpoint_description_t *usb_hub_endpoints[] = {
     69static const usb_endpoint_description_t *usb_hub_endpoints[] = {
    7070        &hub_status_change_endpoint_description,
    7171        NULL,
  • uspace/drv/bus/usb/usbmast/main.c

    r98fb010 r1f131fb9  
    7272};
    7373
    74 usb_endpoint_description_t *mast_endpoints[] = {
     74static const usb_endpoint_description_t *mast_endpoints[] = {
    7575        &bulk_in_ep,
    7676        &bulk_out_ep,
  • uspace/drv/bus/usb/usbmouse/init.c

    r98fb010 r1f131fb9  
    4444
    4545/** Mouse polling endpoint description for boot protocol subclass. */
    46 usb_endpoint_description_t poll_endpoint_description = {
     46const usb_endpoint_description_t poll_endpoint_description = {
    4747        .transfer_type = USB_TRANSFER_INTERRUPT,
    4848        .direction = USB_DIRECTION_IN,
  • uspace/drv/bus/usb/usbmouse/main.c

    r98fb010 r1f131fb9  
    8383};
    8484
    85 static usb_endpoint_description_t *endpoints[] = {
     85static const usb_endpoint_description_t *endpoints[] = {
    8686        &poll_endpoint_description,
    8787        NULL
  • uspace/drv/bus/usb/usbmouse/mouse.c

    r98fb010 r1f131fb9  
    124124        mouse->console_sess = NULL;
    125125       
    126         usb_device_destroy(dev);
     126        usb_device_deinit(dev);
    127127}
    128128
  • uspace/drv/bus/usb/usbmouse/mouse.h

    r98fb010 r1f131fb9  
    6161} usb_mouse_t;
    6262
    63 extern usb_endpoint_description_t poll_endpoint_description;
     63extern const usb_endpoint_description_t poll_endpoint_description;
    6464
    6565extern int usb_mouse_create(usb_device_t *);
  • uspace/lib/usbdev/include/usb/dev/driver.h

    r98fb010 r1f131fb9  
    156156\endcode
    157157         */
    158         usb_endpoint_description_t **endpoints;
     158        const usb_endpoint_description_t **endpoints;
    159159        /** Driver ops. */
    160160        const usb_driver_ops_t *ops;
     
    164164
    165165int usb_device_select_interface(usb_device_t *, uint8_t,
    166     usb_endpoint_description_t **);
     166    const usb_endpoint_description_t **);
    167167
    168168int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);
    169169int usb_device_create_pipes(const ddf_dev_t *, usb_device_connection_t *,
    170     usb_endpoint_description_t **, const uint8_t *, size_t, int, int,
     170    const usb_endpoint_description_t **, const uint8_t *, size_t, int, int,
    171171    usb_endpoint_mapping_t **, size_t *);
    172172int usb_device_destroy_pipes(const ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
    173 int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
    174 void usb_device_destroy(usb_device_t *);
     173int usb_device_create(ddf_dev_t *, const usb_endpoint_description_t **,
     174    usb_device_t **, const char **);
     175void usb_device_deinit(usb_device_t *);
    175176void * usb_device_data_alloc(usb_device_t *, size_t);
    176177
  • uspace/lib/usbdev/src/devdrv.c

    r98fb010 r1f131fb9  
    8181 * @return Number of pipes (excluding default control pipe).
    8282 */
    83 static size_t count_other_pipes(usb_endpoint_description_t **endpoints)
     83static size_t count_other_pipes(const usb_endpoint_description_t **endpoints)
    8484{
    8585        size_t count = 0;
     
    101101 * @return Error code.
    102102 */
    103 static int initialize_other_pipes(usb_endpoint_description_t **endpoints,
     103static int initialize_other_pipes(const usb_endpoint_description_t **endpoints,
    104104    usb_device_t *dev, int alternate_setting)
    105105{
     
    154154        rc = driver->ops->device_add(dev);
    155155        if (rc != EOK)
    156                 usb_device_destroy(dev);
     156                usb_device_deinit(dev);
    157157        return rc;
    158158}
     
    191191        const int ret = driver->ops->device_gone(usb_dev);
    192192        if (ret == EOK)
    193                 usb_device_destroy(usb_dev);
     193                usb_device_deinit(usb_dev);
    194194
    195195        return ret;
     
    238238 */
    239239int usb_device_select_interface(usb_device_t *dev, uint8_t alternate_setting,
    240     usb_endpoint_description_t **endpoints)
     240    const usb_endpoint_description_t **endpoints)
    241241{
    242242        if (dev->interface_no < 0) {
     
    321321 */
    322322int usb_device_create_pipes(const ddf_dev_t *dev, usb_device_connection_t *wire,
    323     usb_endpoint_description_t **endpoints,
     323    const usb_endpoint_description_t **endpoints,
    324324    const uint8_t *config_descr, size_t config_descr_size,
    325325    int interface_no, int interface_setting,
     
    526526 */
    527527int usb_device_create(ddf_dev_t *ddf_dev,
    528     usb_endpoint_description_t **endpoints,
     528    const usb_endpoint_description_t **endpoints,
    529529    usb_device_t **dev_ptr, const char **errstr_ptr)
    530530{
     
    590590/** Destroy instance of a USB device.
    591591 *
    592  * @param dev Device to be destroyed.
    593  */
    594 void usb_device_destroy(usb_device_t *dev)
     592 * @param dev Device to be de-initialized.
     593 *
     594 * Does not free/destroy supplied pointer.
     595 */
     596void usb_device_deinit(usb_device_t *dev)
    595597{
    596598        if (dev == NULL) {
  • uspace/lib/usbhid/include/usb/hid/hiddescriptor.h

    r98fb010 r1f131fb9  
    4242#include <usb/hid/hidtypes.h>
    4343
    44 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 
     44int usb_hid_parse_report_descriptor(usb_hid_report_t *report,
    4545                const uint8_t *data, size_t size);
    46 
    47 void usb_hid_free_report(usb_hid_report_t *report);
    4846
    4947void usb_hid_descriptor_print(usb_hid_report_t *report);
    5048
    5149int usb_hid_report_init(usb_hid_report_t *report);
     50
     51void usb_hid_report_deinit(usb_hid_report_t *report);
    5252
    5353int usb_hid_report_append_fields(usb_hid_report_t *report,
  • uspace/lib/usbhid/src/hiddescriptor.c

    r98fb010 r1f131fb9  
    10161016 * @return void
    10171017 */
    1018 void usb_hid_free_report(usb_hid_report_t *report)
     1018void usb_hid_report_deinit(usb_hid_report_t *report)
    10191019{
    10201020        if(report == NULL){
Note: See TracChangeset for help on using the changeset viewer.