Changeset 983e135 in mainline for uspace/drv/bus/usb/usbhub/usbhub.c


Ignore:
Timestamp:
2011-09-19T13:31:23Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5b6f8dd
Parents:
d46b13d
Message:

usbhub: Further codestyle changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/usbhub.c

    rd46b13d r983e135  
    160160 */
    161161bool hub_port_changes_callback(usb_device_t *dev,
    162     uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) {
     162    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg)
     163{
    163164        usb_log_debug("hub_port_changes_callback\n");
    164         usb_hub_info_t *hub = (usb_hub_info_t *) arg;
     165        usb_hub_info_t *hub = arg;
    165166
    166167        /* FIXME: check that we received enough bytes. */
     
    169170        }
    170171
    171         bool change;
    172         change = ((uint8_t*) change_bitmap)[0] & 1;
     172        /* Lowest bit indicates global change */
     173        const bool change = change_bitmap[0] & 1;
    173174        if (change) {
    174175                usb_hub_process_global_interrupt(hub);
    175176        }
    176177
    177         size_t port;
    178         for (port = 1; port < hub->port_count + 1; port++) {
    179                 bool change = (change_bitmap[port / 8] >> (port % 8)) % 2;
     178        /* N + 1 bit indicates change on port N */
     179        size_t port = 1;
     180        for (; port < hub->port_count + 1; port++) {
     181                const bool change = (change_bitmap[port / 8] >> (port % 8)) & 1;
    180182                if (change) {
    181183                        usb_hub_process_port_interrupt(hub, port);
     
    184186leave:
    185187        /* FIXME: proper interval. */
     188        // TODO Interval should be handled by USB HC scheduler not here
    186189        async_usleep(1000 * 250);
    187190
     
    205208static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev)
    206209{
    207         usb_hub_info_t *result = malloc(sizeof (usb_hub_info_t));
     210        assert(usb_dev);
     211        usb_hub_info_t *result = malloc(sizeof(usb_hub_info_t));
    208212        if (!result)
    209213            return NULL;
     
    215219
    216220        result->ports = NULL;
    217         result->port_count = (size_t) - 1;
     221        result->port_count = -1;
    218222        fibril_mutex_initialize(&result->port_mutex);
    219 
    220223        fibril_mutex_initialize(&result->pending_ops_mutex);
    221224        fibril_condvar_initialize(&result->pending_ops_cv);
     
    315318 * @return error code
    316319 */
    317 static int usb_hub_set_configuration(usb_hub_info_t *hub_info) {
     320static int usb_hub_set_configuration(usb_hub_info_t *hub_info)
     321{
    318322        //device descriptor
    319         usb_standard_device_descriptor_t *std_descriptor
     323        const usb_standard_device_descriptor_t *std_descriptor
    320324            = &hub_info->usb_device->descriptors.device;
    321325        usb_log_debug("Hub has %d configurations\n",
    322326            std_descriptor->configuration_count);
     327
    323328        if (std_descriptor->configuration_count < 1) {
    324329                usb_log_error("There are no configurations available\n");
Note: See TracChangeset for help on using the changeset viewer.