Ignore:
File:
1 edited

Legend:

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

    ra12917e r6fe1ab4  
    2727 */
    2828
    29 /** @addtogroup usbinfo
     29/** @addtogroup usb
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * Dumping of generic device properties.
     34 * @brief
    3535 */
    3636#include <stdio.h>
     
    3838#include <errno.h>
    3939#include <usb/usbdrv.h>
    40 #include <usb/pipes.h>
    41 #include <usb/request.h>
    4240#include "usbinfo.h"
    4341
    44 int dump_device(devman_handle_t hc_handle, usb_address_t address)
     42int dump_device(int hc_phone, usb_address_t address)
    4543{
    46         int rc;
    47         usb_device_connection_t wire;
    48         usb_endpoint_pipe_t ctrl_pipe;
    49         ctrl_pipe.hc_phone = -1;
    50 
    51         int hc_phone = devman_device_connect(hc_handle, 0);
    52         if (hc_phone < 0) {
    53                 fprintf(stderr,
    54                     NAME ": failed to connect to host controller (%zu): %s.\n",
    55                         (size_t) hc_handle, str_error(hc_phone));
    56                 return hc_phone;
    57         }
    58 
    5944        /*
    6045         * Dump information about possible match ids.
     
    6247        match_id_list_t match_id_list;
    6348        init_match_ids(&match_id_list);
    64         rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);
     49        int rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);
    6550        if (rc != EOK) {
    6651                fprintf(stderr,
    6752                    NAME ": failed to fetch match ids of the device: %s.\n",
    6853                    str_error(rc));
    69                 goto leave;
     54                return rc;
    7055        }
    7156        dump_match_ids(&match_id_list);
    72 
    73         /*
    74          * Initialize pipes.
    75          */
    76         rc = usb_device_connection_initialize(&wire, hc_handle, address);
    77         if (rc != EOK) {
    78                 fprintf(stderr,
    79                     NAME ": failed to create connection to the device: %s.\n",
    80                     str_error(rc));
    81                 goto leave;
    82         }
    83         rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe, &wire);
    84         if (rc != EOK) {
    85                 fprintf(stderr,
    86                     NAME ": failed to create default control pipe: %s.\n",
    87                     str_error(rc));
    88                 goto leave;
    89         }
    90         rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
    91         if (rc != EOK) {
    92                 fprintf(stderr,
    93                     NAME ": failed to start session on control pipe: %s.\n",
    94                     str_error(rc));
    95                 goto leave;
    96         }
    9757
    9858        /*
     
    10060         */
    10161        usb_standard_device_descriptor_t device_descriptor;
    102         rc = usb_request_get_device_descriptor(&ctrl_pipe, &device_descriptor);
     62        usb_dprintf(NAME, 1,
     63            "usb_drv_req_get_device_descriptor(%d, %d, %p)\n",
     64            hc_phone, (int) address, &device_descriptor);
     65
     66        rc = usb_drv_req_get_device_descriptor(hc_phone, address,
     67            &device_descriptor);
    10368        if (rc != EOK) {
    10469                fprintf(stderr,
    10570                    NAME ": failed to fetch standard device descriptor: %s.\n",
    10671                    str_error(rc));
    107                 goto leave;
     72                return rc;
    10873        }
    10974        dump_usb_descriptor((uint8_t *)&device_descriptor, sizeof(device_descriptor));
     
    11479        usb_standard_configuration_descriptor_t config_descriptor;
    11580        int config_index = 0;
    116         rc = usb_request_get_bare_configuration_descriptor(&ctrl_pipe,
    117             config_index, &config_descriptor);
     81        usb_dprintf(NAME, 1,
     82            "usb_drv_req_get_bare_configuration_descriptor(%d, %d, %d, %p)\n",
     83            hc_phone, (int) address, config_index, &config_descriptor);
     84
     85        rc = usb_drv_req_get_bare_configuration_descriptor(hc_phone, address,
     86            config_index, &config_descriptor );
    11887        if (rc != EOK) {
    11988                fprintf(stderr,
    12089                    NAME ": failed to fetch standard configuration descriptor: %s.\n",
    12190                    str_error(rc));
    122                 goto leave;
     91                return rc;
    12392        }
    12493        //dump_standard_configuration_descriptor(config_index, &config_descriptor);
    12594
    12695        void *full_config_descriptor = malloc(config_descriptor.total_length);
    127         rc = usb_request_get_full_configuration_descriptor(&ctrl_pipe,
     96        usb_dprintf(NAME, 1,
     97            "usb_drv_req_get_full_configuration_descriptor(%d, %d, %d, %p, %zu)\n",
     98            hc_phone, (int) address, config_index,
     99            full_config_descriptor, config_descriptor.total_length);
     100
     101        rc = usb_drv_req_get_full_configuration_descriptor(hc_phone, address,
    128102            config_index,
    129103            full_config_descriptor, config_descriptor.total_length, NULL);
     
    132106                    NAME ": failed to fetch full configuration descriptor: %s.\n",
    133107                    str_error(rc));
    134                 goto leave;
     108                return rc;
    135109        }
    136110
     
    138112            config_descriptor.total_length);
    139113
    140         rc = EOK;
    141 leave:
    142         /* Ignoring errors here. */
    143         ipc_hangup(hc_phone);
    144         usb_endpoint_pipe_end_session(&ctrl_pipe);
    145 
    146         return rc;
     114        return EOK;
    147115}
    148116
Note: See TracChangeset for help on using the changeset viewer.