Changeset 15701921 in mainline


Ignore:
Timestamp:
2011-01-07T15:47:00Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f748215
Parents:
8324b65
Message:

Remember device attached to the port

fix port disable routine:

  • no need to change enabled_change flag
    • properly report action (enabled/disabled)

add error handling in address assignment

Location:
uspace/drv/uhci/root_hub
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/root_hub/port.c

    r8324b65 r15701921  
    3737
    3838                /* debug print */
    39                 uhci_print_info("Port(%d) status %#x:\n",
     39                uhci_print_info("Port(%d) status %#.4x:\n",
    4040                  port_instance->number, port_status.raw_value);
    4141                print_port_status( &port_status );
     
    4848                                /* TODO */
    4949                                /* remove device here */
     50                                uhci_print_error(
     51                                  "Don't know how to remove device %#x.\n",
     52                                  port_instance->attached_device);
     53                                uhci_port_set_enabled(port_instance, false);
    5054                        }
    5155                }
     
    7882        if (address <= 0) { /* address assigning went wrong */
    7983                uhci_port_set_enabled(port, false);
    80                 uhci_print_error("Failed to assign address to the device");
     84                uhci_print_error("Failed to assign address to the device.\n");
    8185                return ENOMEM;
    8286        }
    8387
    8488        /* report to devman */
    85         devman_handle_t child = 0;
    86         report_new_device(port->hc, address, port->number, &child);
     89        assert( port->attached_device == 0 );
     90        report_new_device(port->hc, address, port->number,
     91                &port->attached_device);
    8792
    8893        /* bind address */
    8994        usb_address_keeping_devman_bind(&uhci_instance->address_manager,
    90           address, child);
     95          address, port->attached_device);
    9196
    9297        return EOK;
     
    102107
    103108        /* enable port: register write */
    104         port_status.status.enabled_change = 0;
    105         port_status.status.enabled = (bool)enabled;
     109        port_status.status.enabled = enabled;
    106110        pio_write_16( port->address, port_status.raw_value );
    107111
    108         uhci_print_info( "Enabled port %d.\n", port->number );
     112        uhci_print_info( "%s port %d.\n",
     113          enabled ? "Enabled" : "Disabled", port->number );
    109114        return EOK;
    110115}
     
    216221        uhci_setup(
    217222          hc, new_device, USB_TRANSFER_CONTROL, &data, sizeof(data),
    218                 sync_out_callback, (void*)&value );
     223                sync_out_callback, (void*)&value);
    219224        uhci_print_verbose("address assignment sent, waiting to complete.\n");
    220225
    221226        sync_wait_for(&value);
    222 
    223         uhci_print_info( "Assigned address %#x.\n", usb_address );
    224 
     227        if (value.result != USB_OUTCOME_OK) {
     228                uhci_print_error(
     229                  "Failed to assign address to the connected device.\n");
     230                usb_address_keeping_release(&uhci_instance->address_manager,
     231                  usb_address);
     232                return -1;
     233        }
     234
     235        uhci_print_info("Assigned address %#x.\n", usb_address);
    225236        return usb_address;
    226237}
  • uspace/drv/uhci/root_hub/port.h

    r8324b65 r15701921  
    4747        unsigned number;
    4848        unsigned wait_period_usec;
     49        devman_handle_t attached_device;
    4950} uhci_port_t;
    5051
     
    5859        port->number = number;
    5960        port->wait_period_usec = usec;
     61        port->attached_device = 0;
    6062}
    6163
Note: See TracChangeset for help on using the changeset viewer.