Changes in / [ab6fdad3:a13ed97] in mainline


Ignore:
Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/root_hub.c

    rab6fdad3 ra13ed97  
    198198static int process_ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
    199199
    200 static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
    201     void * change_buffer, size_t buffe_size);
    202 
    203 static bool is_zeros(void * buffer, size_t size);
     200
    204201
    205202
     
    216213        // set port power mode to no-power-switching
    217214        instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
    218         instance->unfinished_interrupt_transfer = NULL;
     215
    219216        usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
    220217        return EOK;
     
    236233                usb_log_info("Root hub got CONTROL packet\n");
    237234                opResult = process_ctrl_request(instance, request);
    238                 usb_transfer_batch_finish_error(request, opResult);
    239235        } else if (request->ep->transfer_type == USB_TRANSFER_INTERRUPT) {
    240236                usb_log_info("Root hub got INTERRUPT packet\n");
    241237                void * buffer;
    242                 size_t buffer_size;
    243238                create_interrupt_mask(instance, &buffer,
    244                         &buffer_size);
    245                 if(is_zeros(buffer,buffer_size)){
    246                         usb_log_debug("no changes..");
    247                         instance->unfinished_interrupt_transfer=
    248                             request;
    249                         //will be finished later
    250                 }else{
    251                         usb_log_debug("processing changes..");
    252                         process_interrupt(instance, request,
    253                             buffer, buffer_size);
    254                 }
    255                 free(buffer);
     239                        &(request->transfered_size));
     240                memcpy(request->data_buffer, buffer,
     241                        request->transfered_size);
    256242                opResult = EOK;
    257243        } else {
    258244                opResult = EINVAL;
    259                 usb_transfer_batch_finish_error(request, opResult);
    260         }
     245        }
     246        usb_transfer_batch_finish_error(request, opResult);
    261247        return EOK;
    262248}
     
    266252
    267253void rh_interrupt(rh_t *instance) {
    268         //usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
    269         //      "interrupts, am I?\n");
    270         if(!instance->unfinished_interrupt_transfer){
    271                 return;
    272         }
    273         size_t size;
    274         void * buffer;
    275         create_interrupt_mask(instance, &buffer,
    276                         &size);
    277         process_interrupt(instance,instance->unfinished_interrupt_transfer,
    278             buffer,size);
    279         free(buffer);
     254        usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
     255                "interrupts, am I?\n");
     256        /* TODO: implement? */
    280257}
    281258/*----------------------------------------------------------------------------*/
     
    882859        return opResult;
    883860}
    884 /*----------------------------------------------------------------------------*/
    885 
    886 /**
    887  * process hanging interrupt request
    888  *
    889  * If an interrupt transfer has been received and there was no change,
    890  * the driver stores the transfer information and waits for change to occcur.
    891  * This routine is called when that happens and it finalizes the interrupt
    892  * transfer.
    893  *
    894  * @param instance hub instance
    895  * @param request batch request to be processed
    896  * @param change_buffer chages on hub
    897  * @param buffer_size size of change buffer
    898  *
    899  * @return
    900  */
    901 static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
    902     void * change_buffer, size_t buffe_size){
    903         create_interrupt_mask(instance, &change_buffer,
    904             &(request->transfered_size));
    905         memcpy(request->data_buffer, change_buffer,request->transfered_size);
    906         instance->unfinished_interrupt_transfer = NULL;
    907         usb_transfer_batch_finish_error(request, EOK);
    908         return EOK;
    909 }
    910 
    911 /*----------------------------------------------------------------------------*/
    912 
    913 /**
    914  * return whether the buffer is full of zeros
    915  *
    916  * Convenience function.
    917  * @param buffer
    918  * @param size
    919  * @return
    920  */
    921 static bool is_zeros(void * buffer, size_t size){
    922         if(!buffer) return true;
    923         if(!size) return true;
    924         size_t i;
    925         for(i=0;i<size;++i){
    926                 if(((char*)buffer)[i])
    927                         return false;
    928         }
    929         return true;
    930 }
    931861
    932862/**
  • uspace/drv/ohci/root_hub.h

    rab6fdad3 ra13ed97  
    5454        /** hubs descriptors */
    5555        usb_device_descriptors_t descriptors;
    56         /** interrupt transfer waiting for an actual interrupt to occur */
    57         usb_transfer_batch_t * unfinished_interrupt_transfer;
    5856} rh_t;
    5957
  • uspace/drv/usbhub/usbhub.c

    rab6fdad3 ra13ed97  
    105105        }
    106106
    107         //usb_pipe_start_session(hub_info->control_pipe);
     107        usb_pipe_start_session(hub_info->control_pipe);
    108108        //set hub configuration
    109109        opResult = usb_hub_set_configuration(hub_info);
     
    122122                return opResult;
    123123        }
    124         //usb_pipe_end_session(hub_info->control_pipe);
    125 
    126 
    127         usb_log_debug("Creating 'hub' function in DDF.\n");
     124        usb_pipe_end_session(hub_info->control_pipe);
     125
     126        /// \TODO what is this?
     127        usb_log_debug("Creating `hub' function.\n");
    128128        ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
    129129            fun_exposed, "hub");
     
    153153bool hub_port_changes_callback(usb_device_t *dev,
    154154    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) {
    155         usb_log_debug("hub_port_changes_callback\n");
    156155        usb_hub_info_t *hub = (usb_hub_info_t *) arg;
    157156
     
    218217        // get hub descriptor
    219218        usb_log_debug("creating serialized descriptor\n");
    220         //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    221         uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
     219        void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    222220        usb_hub_descriptor_t * descriptor;
    223221        int opResult;
     
    237235        }
    238236        usb_log_debug2("deserializing descriptor\n");
    239         descriptor = usb_create_deserialized_hub_desriptor(
    240             serialized_descriptor);
     237        descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
    241238        if (descriptor == NULL) {
    242239                usb_log_warning("could not deserialize descriptor \n");
    243                 return ENOMEM;
     240                return opResult;
    244241        }
    245242        usb_log_debug("setting port count to %d\n", descriptor->ports_count);
    246243        hub_info->port_count = descriptor->ports_count;
    247244        /// \TODO this is not semantically correct
    248         bool is_power_switched =
    249             ((descriptor->hub_characteristics & 1) ==0);
    250         bool has_individual_port_powering =
    251             ((descriptor->hub_characteristics & 1) !=0);
    252245        hub_info->ports = malloc(
    253246            sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
     
    256249                usb_hub_port_init(&hub_info->ports[port]);
    257250        }
    258         if(is_power_switched){
    259                 usb_log_debug("is_power_switched\n");
    260                 if(has_individual_port_powering){
    261                         usb_log_debug("has_individual_port_powering\n");
    262                         for (port = 0; port < hub_info->port_count; port++) {
    263                                 opResult = usb_hub_set_port_feature(hub_info->control_pipe,
    264                                     port+1, USB_HUB_FEATURE_PORT_POWER);
    265                                 if (opResult != EOK) {
    266                                         usb_log_error("cannot power on port %d;  %d\n",
    267                                             port+1, opResult);
    268                                 }
    269                         }
    270                 }else{
    271                         usb_log_debug("!has_individual_port_powering\n");
    272                         opResult = usb_hub_set_feature(hub_info->control_pipe,
    273                             USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
    274                         if (opResult != EOK) {
    275                                 usb_log_error("cannot power hub;  %d\n",
    276                                   opResult);
    277                         }
    278                 }
    279         }else{
    280                 usb_log_debug("!is_power_switched\n");
     251        for (port = 0; port < hub_info->port_count; port++) {
     252                opResult = usb_hub_set_port_feature(hub_info->control_pipe,
     253                    port+1, USB_HUB_FEATURE_PORT_POWER);
     254                if (opResult != EOK) {
     255                        usb_log_error("cannot power on port %d;  %d\n",
     256                            port+1, opResult);
     257                }
    281258        }
    282259        usb_log_debug2("freeing data\n");
    283         //free(serialized_descriptor);
    284         //free(descriptor->devices_removable);
     260        free(serialized_descriptor);
     261        free(descriptor->devices_removable);
    285262        free(descriptor);
    286263        return EOK;
     
    344321         * auto destruction, this could work better.
    345322         */
    346         int rc = usb_hc_connection_open(&hub_info->connection);
     323        int rc = usb_pipe_start_session(hub_info->control_pipe);
    347324        if (rc != EOK) {
    348                 //usb_pipe_end_session(hub_info->control_pipe);
     325                usb_log_error("Failed to start session on control pipe: %s.\n",
     326                    str_error(rc));
     327                return rc;
     328        }
     329        rc = usb_hc_connection_open(&hub_info->connection);
     330        if (rc != EOK) {
     331                usb_pipe_end_session(hub_info->control_pipe);
    349332                usb_log_error("Failed to open connection to HC: %s.\n",
    350333                    str_error(rc));
  • uspace/drv/usbhub/usbhub_private.h

    rab6fdad3 ra13ed97  
    113113
    114114        usb_device_request_setup_packet_t clear_request = {
    115                 .request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE,
     115                .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
    116116                .request = USB_DEVREQ_SET_FEATURE,
    117117                .length = 0,
     
    166166}
    167167
     168/**
     169 * create uint8_t array with serialized descriptor
     170 *
     171 * @param descriptor
     172 * @return newly created serializd descriptor pointer
     173 */
     174void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
    168175
    169 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor);
    170 
    171 void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
    172     void * serialized_descriptor);
    173 
    174 usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
    175     void * serialized_descriptor);
    176 
    177 void usb_deserialize_hub_desriptor(void * serialized_descriptor,
    178     usb_hub_descriptor_t * descriptor);
     176/**
     177 * create deserialized desriptor structure out of serialized descriptor
     178 *
     179 * The serialized descriptor must be proper usb hub descriptor,
     180 * otherwise an eerror might occur.
     181 *
     182 * @param sdescriptor serialized descriptor
     183 * @return newly created deserialized descriptor pointer
     184 */
     185usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
    179186
    180187
  • uspace/drv/usbhub/utils.c

    rab6fdad3 ra13ed97  
    5656//hub descriptor utils
    5757
    58 /**
    59  * create uint8_t array with serialized descriptor
    60  *
    61  * @param descriptor
    62  * @return newly created serializd descriptor pointer
    63  */
    64 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor) {
     58void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor) {
    6559        //base size
    6660        size_t size = 7;
     
    7064        uint8_t * result = malloc(size);
    7165        //size
    72         if(result)
    73                 usb_serialize_hub_descriptor(descriptor,result);
     66        result[0] = size;
     67        //descriptor type
     68        result[1] = USB_DESCTYPE_HUB;
     69        result[2] = descriptor->ports_count;
     70        /// @fixme handling of endianness??
     71        result[3] = descriptor->hub_characteristics / 256;
     72        result[4] = descriptor->hub_characteristics % 256;
     73        result[5] = descriptor->pwr_on_2_good_time;
     74        result[6] = descriptor->current_requirement;
     75
     76        size_t i;
     77        for (i = 0; i < var_size; ++i) {
     78                result[7 + i] = descriptor->devices_removable[i];
     79        }
     80        for (i = 0; i < var_size; ++i) {
     81                result[7 + var_size + i] = 255;
     82        }
    7483        return result;
    7584}
    7685
    77 /**
    78  * serialize descriptor into given buffer
    79  *
    80  * The buffer size is not checked.
    81  * @param descriptor
    82  * @param serialized_descriptor
    83  */
    84 void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
    85     void * serialized_descriptor) {
    86         //base size
    87         uint8_t * sdescriptor = serialized_descriptor;
    88         size_t size = 7;
    89         //variable size according to port count
    90         size_t var_size = (descriptor->ports_count+7)/8;
    91         size += 2 * var_size;
    92         //size
    93         sdescriptor[0] = size;
    94         //descriptor type
    95         sdescriptor[1] = USB_DESCTYPE_HUB;
    96         sdescriptor[2] = descriptor->ports_count;
    97         /// @fixme handling of endianness??
    98         sdescriptor[3] = descriptor->hub_characteristics / 256;
    99         sdescriptor[4] = descriptor->hub_characteristics % 256;
    100         sdescriptor[5] = descriptor->pwr_on_2_good_time;
    101         sdescriptor[6] = descriptor->current_requirement;
    102 
    103         size_t i;
    104         for (i = 0; i < var_size; ++i) {
    105                 sdescriptor[7 + i] = descriptor->devices_removable[i];
    106         }
    107         for (i = 0; i < var_size; ++i) {
    108                 sdescriptor[7 + var_size + i] = 255;
    109         }
    110 }
    111 
    112 
    113 /**
    114  * create deserialized desriptor structure out of serialized descriptor
    115  *
    116  * The serialized descriptor must be proper usb hub descriptor,
    117  * otherwise an eerror might occur.
    118  *
    119  * @param sdescriptor serialized descriptor
    120  * @return newly created deserialized descriptor pointer
    121  */
    122 usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
     86usb_hub_descriptor_t * usb_deserialize_hub_desriptor(
    12387void * serialized_descriptor) {
    12488        uint8_t * sdescriptor = serialized_descriptor;
     
    13195
    13296        usb_hub_descriptor_t * result = malloc(sizeof(usb_hub_descriptor_t));
    133         if(result)
    134                 usb_deserialize_hub_desriptor(serialized_descriptor,result);
     97       
     98
     99        result->ports_count = sdescriptor[2];
     100        /// @fixme handling of endianness??
     101        result->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
     102        result->pwr_on_2_good_time = sdescriptor[5];
     103        result->current_requirement = sdescriptor[6];
     104        size_t var_size = (result->ports_count+7) / 8;
     105        result->devices_removable = (uint8_t*) malloc(var_size);
     106
     107        size_t i;
     108        for (i = 0; i < var_size; ++i) {
     109                result->devices_removable[i] = sdescriptor[7 + i];
     110        }
    135111        return result;
    136112}
    137113
    138 /**
    139  * deserialize descriptor into given pointer
    140  *
    141  * @param serialized_descriptor
    142  * @param descriptor
    143  * @return
    144  */
    145 void usb_deserialize_hub_desriptor(
    146 void * serialized_descriptor, usb_hub_descriptor_t * descriptor) {
    147         uint8_t * sdescriptor = serialized_descriptor;
    148         descriptor->ports_count = sdescriptor[2];
    149         /// @fixme handling of endianness??
    150         descriptor->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
    151         descriptor->pwr_on_2_good_time = sdescriptor[5];
    152         descriptor->current_requirement = sdescriptor[6];
    153         size_t var_size = (descriptor->ports_count+7) / 8;
    154         //descriptor->devices_removable = (uint8_t*) malloc(var_size);
    155114
    156         size_t i;
    157         for (i = 0; i < var_size; ++i) {
    158                 descriptor->devices_removable[i] = sdescriptor[7 + i];
    159         }
    160 }
    161115
    162116/**
  • uspace/lib/usb/include/usb/classes/hub.h

    rab6fdad3 ra13ed97  
    152152            maximum of 255 ports).
    153153     */
    154     uint8_t devices_removable[32];
     154    uint8_t * devices_removable;
    155155
    156156    /**
  • uspace/lib/usb/src/hidreport.c

    rab6fdad3 ra13ed97  
    119119        uint16_t length =  hid_desc->report_desc_info.length;
    120120        size_t actual_size = 0;
     121       
     122        /*
     123         * Start session for the control transfer.
     124         */
     125        int sess_rc = usb_pipe_start_session(&dev->ctrl_pipe);
     126        if (sess_rc != EOK) {
     127                usb_log_warning("Failed to start a session: %s.\n",
     128                    str_error(sess_rc));
     129                return sess_rc;
     130        }
    121131
    122132        /*
     
    152162                    "%u)\n", actual_size, length);
    153163                return EINVAL;
     164        }
     165       
     166        /*
     167         * End session for the control transfer.
     168         */
     169        sess_rc = usb_pipe_end_session(&dev->ctrl_pipe);
     170        if (sess_rc != EOK) {
     171                usb_log_warning("Failed to end a session: %s.\n",
     172                    str_error(sess_rc));
     173                free(*report_desc);
     174                *report_desc = NULL;
     175                return sess_rc;
    154176        }
    155177       
  • uspace/lib/usb/src/hidreq.c

    rab6fdad3 ra13ed97  
    5656 * @retval EOK if successful.
    5757 * @retval EINVAL if no HID device is given.
    58  * @return Other value inherited from function usb_control_request_set().
     58 * @return Other value inherited from one of functions
     59 *         usb_pipe_start_session(), usb_pipe_end_session(),
     60 *         usb_control_request_set().
    5961 */
    6062int usbhid_req_set_report(usb_pipe_t *ctrl_pipe, int iface_no,
     
    7779         */
    7880       
    79         int rc;
     81        int rc, sess_rc;
     82       
     83        sess_rc = usb_pipe_start_session(ctrl_pipe);
     84        if (sess_rc != EOK) {
     85                usb_log_warning("Failed to start a session: %s.\n",
     86                    str_error(sess_rc));
     87                return sess_rc;
     88        }
    8089       
    8190        uint16_t value = 0;
     
    8897            USB_HIDREQ_SET_REPORT, value, iface_no, buffer, buf_size);
    8998
    90         if (rc != EOK) {
    91                 usb_log_warning("Error sending output report to the keyboard: "
    92                     "%s.\n", str_error(rc));
    93                 return rc;
     99        sess_rc = usb_pipe_end_session(ctrl_pipe);
     100
     101        if (rc != EOK) {
     102                usb_log_warning("Error sending output report to the keyboard: "
     103                    "%s.\n", str_error(rc));
     104                return rc;
     105        }
     106
     107        if (sess_rc != EOK) {
     108                usb_log_warning("Error closing session: %s.\n",
     109                    str_error(sess_rc));
     110                return sess_rc;
    94111        }
    95112       
     
    106123 * @retval EOK if successful.
    107124 * @retval EINVAL if no HID device is given.
    108  * @return Other value inherited from function usb_control_request_set().
     125 * @return Other value inherited from one of functions
     126 *         usb_pipe_start_session(), usb_pipe_end_session(),
     127 *         usb_control_request_set().
    109128 */
    110129int usbhid_req_set_protocol(usb_pipe_t *ctrl_pipe, int iface_no,
     
    127146         */
    128147       
    129         int rc;
     148        int rc, sess_rc;
     149       
     150        sess_rc = usb_pipe_start_session(ctrl_pipe);
     151        if (sess_rc != EOK) {
     152                usb_log_warning("Failed to start a session: %s.\n",
     153                    str_error(sess_rc));
     154                return sess_rc;
     155        }
    130156
    131157        usb_log_debug("Sending Set_Protocol request to the device ("
     
    136162            USB_HIDREQ_SET_PROTOCOL, protocol, iface_no, NULL, 0);
    137163
    138         if (rc != EOK) {
    139                 usb_log_warning("Error sending output report to the keyboard: "
    140                     "%s.\n", str_error(rc));
    141                 return rc;
     164        sess_rc = usb_pipe_end_session(ctrl_pipe);
     165
     166        if (rc != EOK) {
     167                usb_log_warning("Error sending output report to the keyboard: "
     168                    "%s.\n", str_error(rc));
     169                return rc;
     170        }
     171
     172        if (sess_rc != EOK) {
     173                usb_log_warning("Error closing session: %s.\n",
     174                    str_error(sess_rc));
     175                return sess_rc;
    142176        }
    143177       
     
    155189 * @retval EOK if successful.
    156190 * @retval EINVAL if no HID device is given.
    157  * @return Other value inherited from function usb_control_request_set().
     191 * @return Other value inherited from one of functions
     192 *         usb_pipe_start_session(), usb_pipe_end_session(),
     193 *         usb_control_request_set().
    158194 */
    159195int usbhid_req_set_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t duration)
     
    175211         */
    176212       
    177         int rc;
     213        int rc, sess_rc;
     214       
     215        sess_rc = usb_pipe_start_session(ctrl_pipe);
     216        if (sess_rc != EOK) {
     217                usb_log_warning("Failed to start a session: %s.\n",
     218                    str_error(sess_rc));
     219                return sess_rc;
     220        }
    178221
    179222        usb_log_debug("Sending Set_Idle request to the device ("
     
    186229            USB_HIDREQ_SET_IDLE, value, iface_no, NULL, 0);
    187230
    188         if (rc != EOK) {
    189                 usb_log_warning("Error sending output report to the keyboard: "
    190                     "%s.\n", str_error(rc));
    191                 return rc;
     231        sess_rc = usb_pipe_end_session(ctrl_pipe);
     232
     233        if (rc != EOK) {
     234                usb_log_warning("Error sending output report to the keyboard: "
     235                    "%s.\n", str_error(rc));
     236                return rc;
     237        }
     238
     239        if (sess_rc != EOK) {
     240                usb_log_warning("Error closing session: %s.\n",
     241                    str_error(sess_rc));
     242                return sess_rc;
    192243        }
    193244       
     
    208259 * @retval EOK if successful.
    209260 * @retval EINVAL if no HID device is given.
    210  * @return Other value inherited from function usb_control_request_set().
     261 * @return Other value inherited from one of functions
     262 *         usb_pipe_start_session(), usb_pipe_end_session(),
     263 *         usb_control_request_set().
    211264 */
    212265int usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no,
     
    230283         */
    231284       
    232         int rc;
     285        int rc, sess_rc;
     286       
     287        sess_rc = usb_pipe_start_session(ctrl_pipe);
     288        if (sess_rc != EOK) {
     289                usb_log_warning("Failed to start a session: %s.\n",
     290                    str_error(sess_rc));
     291                return sess_rc;
     292        }
    233293
    234294        uint16_t value = 0;
     
    242302            actual_size);
    243303
    244         if (rc != EOK) {
    245                 usb_log_warning("Error sending output report to the keyboard: "
    246                     "%s.\n", str_error(rc));
    247                 return rc;
     304        sess_rc = usb_pipe_end_session(ctrl_pipe);
     305
     306        if (rc != EOK) {
     307                usb_log_warning("Error sending output report to the keyboard: "
     308                    "%s.\n", str_error(rc));
     309                return rc;
     310        }
     311
     312        if (sess_rc != EOK) {
     313                usb_log_warning("Error closing session: %s.\n",
     314                    str_error(sess_rc));
     315                return sess_rc;
    248316        }
    249317       
     
    260328 * @retval EOK if successful.
    261329 * @retval EINVAL if no HID device is given.
    262  * @return Other value inherited from function usb_control_request_set().
     330 * @return Other value inherited from one of functions
     331 *         usb_pipe_start_session(), usb_pipe_end_session(),
     332 *         usb_control_request_set().
    263333 */
    264334int usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no,
     
    281351         */
    282352       
    283         int rc;
     353        int rc, sess_rc;
     354       
     355        sess_rc = usb_pipe_start_session(ctrl_pipe);
     356        if (sess_rc != EOK) {
     357                usb_log_warning("Failed to start a session: %s.\n",
     358                    str_error(sess_rc));
     359                return sess_rc;
     360        }
    284361
    285362        usb_log_debug("Sending Get_Protocol request to the device ("
     
    293370            USB_HIDREQ_GET_PROTOCOL, 0, iface_no, buffer, 1, &actual_size);
    294371
    295         if (rc != EOK) {
    296                 usb_log_warning("Error sending output report to the keyboard: "
    297                     "%s.\n", str_error(rc));
    298                 return rc;
     372        sess_rc = usb_pipe_end_session(ctrl_pipe);
     373
     374        if (rc != EOK) {
     375                usb_log_warning("Error sending output report to the keyboard: "
     376                    "%s.\n", str_error(rc));
     377                return rc;
     378        }
     379
     380        if (sess_rc != EOK) {
     381                usb_log_warning("Error closing session: %s.\n",
     382                    str_error(sess_rc));
     383                return sess_rc;
    299384        }
    300385       
     
    342427         */
    343428       
    344         int rc;
     429        int rc, sess_rc;
     430       
     431        sess_rc = usb_pipe_start_session(ctrl_pipe);
     432        if (sess_rc != EOK) {
     433                usb_log_warning("Failed to start a session: %s.\n",
     434                    str_error(sess_rc));
     435                return sess_rc;
     436        }
    345437
    346438        usb_log_debug("Sending Get_Idle request to the device ("
     
    356448            &actual_size);
    357449
    358         if (rc != EOK) {
    359                 usb_log_warning("Error sending output report to the keyboard: "
    360                     "%s.\n", str_error(rc));
    361                 return rc;
     450        sess_rc = usb_pipe_end_session(ctrl_pipe);
     451
     452        if (rc != EOK) {
     453                usb_log_warning("Error sending output report to the keyboard: "
     454                    "%s.\n", str_error(rc));
     455                return rc;
     456        }
     457
     458        if (sess_rc != EOK) {
     459                usb_log_warning("Error closing session: %s.\n",
     460                    str_error(sess_rc));
     461                return sess_rc;
    362462        }
    363463       
Note: See TracChangeset for help on using the changeset viewer.