Changeset 540e2d2 in mainline


Ignore:
Timestamp:
2011-02-20T12:38:40Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3ae93a8
Parents:
745d2ad
Message:

Add creation of match ids from interface descriptor

Location:
uspace/lib/usb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/recognise.h

    r745d2ad r540e2d2  
    4141#include <ipc/devman.h>
    4242
     43int usb_device_create_match_ids_from_interface(
     44    const usb_standard_interface_descriptor_t *, match_id_list_t *);
     45
    4346int usb_device_create_match_ids(usb_endpoint_pipe_t *, match_id_list_t *);
    4447
  • uspace/lib/usb/src/recognise.c

    r745d2ad r540e2d2  
    142142}
    143143
     144/** Create device match ids based on its interface.
     145 *
     146 * @param[in] descriptor Interface descriptor.
     147 * @param[out] matches Initialized list of match ids.
     148 * @return Error code (the two mentioned are not the only ones).
     149 * @retval EINVAL Invalid input parameters (expects non NULL pointers).
     150 * @retval ENOENT Interface does not specify class.
     151 */
     152int usb_device_create_match_ids_from_interface(
     153    const usb_standard_interface_descriptor_t *descriptor,
     154    match_id_list_t *matches)
     155{
     156        if (descriptor == NULL) {
     157                return EINVAL;
     158        }
     159        if (matches == NULL) {
     160                return EINVAL;
     161        }
     162
     163        int rc;
     164
     165        if (descriptor->interface_class == USB_CLASS_USE_INTERFACE) {
     166                return ENOENT;
     167        }
     168
     169        const char *classname = usb_str_class(descriptor->interface_class);
     170        assert(classname != NULL);
     171
     172        rc = usb_add_match_id(matches, 50,
     173            "usb&interface&class=%s",
     174            classname);
     175        if (rc != EOK) {
     176                return rc;
     177        }
     178
     179        rc = usb_add_match_id(matches, 70,
     180            "usb&interface&class=%s&subclass=0x%02x",
     181            classname, descriptor->interface_subclass);
     182        if (rc != EOK) {
     183                return rc;
     184        }
     185
     186        rc = usb_add_match_id(matches, 100,
     187            "usb&interface&class=%s&subclass=0x%02x&protocol=0x%02x",
     188            classname, descriptor->interface_subclass,
     189            descriptor->interface_protocol);
     190
     191        return rc;
     192}
     193
    144194/** Create DDF match ids from USB device descriptor.
    145195 *
Note: See TracChangeset for help on using the changeset viewer.