Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 76ef94e in mainline for uspace/app/usbinfo/main.c


Ignore:
Timestamp:
2011-05-07T15:51:20Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
3ae5ca8
Parents:
d2bff2f (diff), b23e9cc (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:

Development branch changes

File:
1 edited

Legend:

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

    rd2bff2f r76ef94e  
    4545#include <usb/usbdevice.h>
    4646#include <usb/pipes.h>
     47#include <usb/host.h>
    4748#include "usbinfo.h"
     49
     50static bool try_parse_class_and_address(const char *path,
     51    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
     52{
     53        size_t class_index;
     54        size_t address;
     55        int rc;
     56        char *ptr;
     57
     58        rc = str_size_t(path, &ptr, 10, false, &class_index);
     59        if (rc != EOK) {
     60                return false;
     61        }
     62        if ((*ptr == ':') || (*ptr == '.')) {
     63                ptr++;
     64        } else {
     65                return false;
     66        }
     67        rc = str_size_t(ptr, NULL, 10, true, &address);
     68        if (rc != EOK) {
     69                return false;
     70        }
     71        rc = usb_ddf_get_hc_handle_by_class(class_index, out_hc_handle);
     72        if (rc != EOK) {
     73                return false;
     74        }
     75        if (out_device_address != NULL) {
     76                *out_device_address = (usb_address_t) address;
     77        }
     78        return true;
     79}
    4880
    4981static bool resolve_hc_handle_and_dev_addr(const char *devpath,
     
    6092        if (str_cmp(devpath, "virt") == 0) {
    6193                devpath = "/virt/usbhc/usb00_a1/usb00_a2";
     94        }
     95
     96        if (try_parse_class_and_address(devpath,
     97            out_hc_handle, out_device_address)) {
     98                return true;
    6299        }
    63100
     
    271308                }
    272309
    273                 usbinfo_device_t *dev = prepare_device(hc_handle, dev_addr);
     310                usbinfo_device_t *dev = prepare_device(devpath,
     311                    hc_handle, dev_addr);
    274312                if (dev == NULL) {
    275313                        continue;
Note: See TracChangeset for help on using the changeset viewer.