Ignore:
File:
1 edited

Legend:

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

    r36f737a r4125b7d  
    158158    const usb_hid_subdriver_mapping_t *mapping)
    159159{
    160         assert(hid_dev != NULL);
    161         assert(hid_dev->usb_dev != NULL);
    162        
    163         return (hid_dev->usb_dev->descriptors.device.vendor_id
    164             == mapping->vendor_id
    165             && hid_dev->usb_dev->descriptors.device.product_id
    166             == mapping->product_id);
     160        return false;
    167161}
    168162
     
    198192        }
    199193       
    200         assert(hid_dev->report != NULL);
     194        assert(hid_dev->parser != NULL);
    201195       
    202196        usb_log_debug("Compare flags: %d\n", mapping->compare);
    203         size_t size = usb_hid_report_input_length(hid_dev->report, usage_path,
     197        size_t size = usb_hid_report_input_length(hid_dev->parser, usage_path,
    204198            mapping->compare);
    205199        usb_log_debug("Size of the input report: %zuB\n", size);
     
    257251        while (count < USB_HID_MAX_SUBDRIVERS &&
    258252            (mapping->usage_path != NULL
    259             || mapping->vendor_id >= 0 || mapping->product_id >= 0)) {
     253            || mapping->vendor_id != 0 || mapping->product_id != 0)) {
    260254                // check the vendor & product ID
    261                 if (mapping->vendor_id >= 0 && mapping->product_id < 0) {
    262                         usb_log_warning("Missing Product ID for Vendor ID %d\n",
     255                if (mapping->vendor_id != 0 && mapping->product_id == 0) {
     256                        usb_log_warning("Missing Product ID for Vendor ID %u\n",
    263257                            mapping->vendor_id);
    264258                        return EINVAL;
    265259                }
    266                 if (mapping->product_id >= 0 && mapping->vendor_id < 0) {
    267                         usb_log_warning("Missing Vendor ID for Product ID %d\n",
     260                if (mapping->product_id != 0 && mapping->vendor_id == 0) {
     261                        usb_log_warning("Missing Vendor ID for Product ID %u\n",
    268262                            mapping->product_id);
    269263                        return EINVAL;
     
    273267                matched = false;
    274268               
    275                 if (mapping->vendor_id >= 0) {
    276                         assert(mapping->product_id >= 0);
     269                if (mapping->vendor_id != 0) {
     270                        assert(mapping->product_id != 0);
    277271                        usb_log_debug("Comparing device against vendor ID %u"
    278272                            " and product ID %u.\n", mapping->vendor_id,
     
    347341        }
    348342       
    349         hid_dev->report = (usb_hid_report_t *)(malloc(sizeof(
    350             usb_hid_report_t)));
    351         if (hid_dev->report == NULL) {
     343        hid_dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof(
     344            usb_hid_report_parser_t)));
     345        if (hid_dev->parser == NULL) {
    352346                usb_log_fatal("No memory!\n");
    353347                free(hid_dev);
     
    388382                return rc;
    389383        }
    390                
     384       
     385        /* Initialize the report parser. */
     386        rc = usb_hid_parser_init(hid_dev->parser);
     387        if (rc != EOK) {
     388                usb_log_error("Failed to initialize report parser.\n");
     389                //usb_hid_free(&hid_dev);
     390                return rc;
     391        }
     392       
    391393        /* Get the report descriptor and parse it. */
    392394        rc = usb_hid_process_report_descriptor(hid_dev->usb_dev,
    393             hid_dev->report);
     395            hid_dev->parser);
    394396       
    395397        bool fallback = false;
     
    589591
    590592        // destroy the parser
    591         if ((*hid_dev)->report != NULL) {
    592                 usb_hid_free_report((*hid_dev)->report);
     593        if ((*hid_dev)->parser != NULL) {
     594                usb_hid_free_report_parser((*hid_dev)->parser);
    593595        }
    594596
Note: See TracChangeset for help on using the changeset viewer.