Changeset 777e336 in mainline for uspace/drv/usbhid/usbhid.c


Ignore:
Timestamp:
2011-04-12T15:59:44Z (14 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()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.