Changeset 9e195e2c in mainline for uspace/app/usbinfo/main.c


Ignore:
Timestamp:
2011-05-12T09:03:00Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d59d0bb
Parents:
456aea3 (diff), c372e03 (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:

Merge from development

File:
1 edited

Legend:

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

    r456aea3 r9e195e2c  
    4545#include <usb/usbdevice.h>
    4646#include <usb/pipes.h>
     47#include <usb/host.h>
     48#include <usb/driver.h>
    4749#include "usbinfo.h"
     50
     51static bool try_parse_class_and_address(const char *path,
     52    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
     53{
     54        size_t class_index;
     55        size_t address;
     56        int rc;
     57        char *ptr;
     58
     59        rc = str_size_t(path, &ptr, 10, false, &class_index);
     60        if (rc != EOK) {
     61                return false;
     62        }
     63        if ((*ptr == ':') || (*ptr == '.')) {
     64                ptr++;
     65        } else {
     66                return false;
     67        }
     68        rc = str_size_t(ptr, NULL, 10, true, &address);
     69        if (rc != EOK) {
     70                return false;
     71        }
     72        rc = usb_ddf_get_hc_handle_by_class(class_index, out_hc_handle);
     73        if (rc != EOK) {
     74                return false;
     75        }
     76        if (out_device_address != NULL) {
     77                *out_device_address = (usb_address_t) address;
     78        }
     79        return true;
     80}
    4881
    4982static bool resolve_hc_handle_and_dev_addr(const char *devpath,
     
    6093        if (str_cmp(devpath, "virt") == 0) {
    6194                devpath = "/virt/usbhc/usb00_a1/usb00_a2";
     95        }
     96
     97        if (try_parse_class_and_address(devpath,
     98            out_hc_handle, out_device_address)) {
     99                return true;
    62100        }
    63101
     
    271309                }
    272310
    273                 usbinfo_device_t *dev = prepare_device(hc_handle, dev_addr);
     311                usbinfo_device_t *dev = prepare_device(devpath,
     312                    hc_handle, dev_addr);
    274313                if (dev == NULL) {
    275314                        continue;
Note: See TracChangeset for help on using the changeset viewer.