Changeset 777e336 in mainline


Ignore:
Timestamp:
2011-04-12T15:59:44Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e7df6cd
Parents:
1cbb4b7
Message:

Minor changes in subdrivers API.

  • Changed vendor ID and product ID to uint16_t
  • Removed size of the path, ending with {0, 0}
  • Named structure initialization for usb_hid_subdrivers()
Location:
uspace/drv/usbhid
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/subdrivers.c

    r1cbb4b7 r777e336  
    3737#include "usb/classes/hidut.h"
    3838
    39 static usb_hid_subdriver_usage_t path_kbd[] = {{USB_HIDUT_PAGE_KEYBOARD, 0}};
     39static usb_hid_subdriver_usage_t path_kbd[] = {
     40        {USB_HIDUT_PAGE_KEYBOARD, 0},
     41        {0, 0}
     42};
    4043
    4144const usb_hid_subdriver_mapping_t usb_hid_subdrivers[] = {
    4245        {
    4346                path_kbd,
    44                 1,
    4547                USB_HID_PATH_COMPARE_END
    4648                | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    47                 NULL,
    48                 NULL,
     49                0,
     50                0,
    4951                {
    50                         usb_kbd_init,
    51                         usb_kbd_deinit,
    52                         usb_kbd_polling_callback,
    53                         NULL
     52                        .init = usb_kbd_init,
     53                        .deinit = usb_kbd_deinit,
     54                        .poll = usb_kbd_polling_callback,
     55                        .poll_end = NULL
    5456                },
    5557               
    5658        },
    57         {NULL, 0, 0, NULL, NULL, {NULL, NULL, NULL, NULL}}
     59        {NULL, 0, 0, 0, {NULL, NULL, NULL, NULL}}
    5860};
    5961
  • uspace/drv/usbhid/subdrivers.h

    r1cbb4b7 r777e336  
    5454typedef struct usb_hid_subdriver_mapping {
    5555        const usb_hid_subdriver_usage_t *usage_path;
    56         int path_size;
    5756        int compare;
    58         const char *vendor_id;
    59         const char *product_id;
     57        uint16_t vendor_id;
     58        uint16_t product_id;
    6059        usb_hid_subdriver_t subdriver;
    6160} usb_hid_subdriver_mapping_t;
  • uspace/drv/usbhid/usbhid.c

    r1cbb4b7 r777e336  
    164164
    165165static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev,
    166     const usb_hid_subdriver_usage_t *path, int path_size, int compare)
     166    const usb_hid_subdriver_usage_t *path, int compare)
    167167{
    168168        assert(hid_dev != NULL);
     
    174174                return false;
    175175        }
    176         int i;
    177         for (i = 0; i < path_size; ++i) {
     176        int i = 0;
     177        while (path[i].usage != 0 || path[i].usage_page != 0) {
    178178                if (usb_hid_report_path_append_item(usage_path,
    179179                    path[i].usage_page, path[i].usage) != EOK) {
     
    182182                        return false;
    183183                }
     184                ++i;
    184185        }
    185186       
     
    238239        while (count < USB_HID_MAX_SUBDRIVERS &&
    239240            (mapping->usage_path != NULL
    240             || mapping->vendor_id != NULL
    241             || mapping->product_id != NULL)) {
     241            || mapping->vendor_id != 0 || mapping->product_id != 0)) {
    242242                // check the vendor & product ID
    243                 if (mapping->vendor_id != NULL && mapping->product_id == NULL) {
    244                         usb_log_warning("Missing Product ID for Vendor ID %s\n",
     243                if (mapping->vendor_id != 0 && mapping->product_id == 0) {
     244                        usb_log_warning("Missing Product ID for Vendor ID %u\n",
    245245                            mapping->vendor_id);
    246246                        return EINVAL;
    247247                }
    248                 if (mapping->product_id != NULL && mapping->vendor_id == NULL) {
    249                         usb_log_warning("Missing Vendor ID for Product ID %s\n",
     248                if (mapping->product_id != 0 && mapping->vendor_id == 0) {
     249                        usb_log_warning("Missing Vendor ID for Product ID %u\n",
    250250                            mapping->product_id);
    251251                        return EINVAL;
    252252                }
    253253               
    254                 if (mapping->vendor_id != NULL) {
    255                         assert(mapping->product_id != NULL);
    256                         usb_log_debug("Comparing device against vendor ID %s"
    257                             " and product ID %s.\n", mapping->vendor_id,
     254                if (mapping->vendor_id != 0) {
     255                        assert(mapping->product_id != 0);
     256                        usb_log_debug("Comparing device against vendor ID %u"
     257                            " and product ID %u.\n", mapping->vendor_id,
    258258                            mapping->product_id);
    259259                        if (usb_hid_ids_match(hid_dev, mapping)) {
     
    268268                        usb_log_debug("Comparing device against usage path.\n");
    269269                        if (usb_hid_path_matches(hid_dev,
    270                             mapping->usage_path, mapping->path_size,
    271                             mapping->compare)) {
     270                            mapping->usage_path, mapping->compare)) {
    272271                                subdrivers[count++] = &mapping->subdriver;
    273272                        } else {
Note: See TracChangeset for help on using the changeset viewer.