Changeset d650494 in mainline


Ignore:
Timestamp:
2011-09-27T11:21:12Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1cb170
Parents:
400f363
Message:

ushub: Handle situation when both connection and enabled change occur.

File:
1 edited

Legend:

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

    r400f363 rd650494  
    3636
    3737#include <bool.h>
     38#include <devman.h>
    3839#include <errno.h>
    3940#include <str_error.h>
     
    4243
    4344#include <usb/debug.h>
     45#include <usb/dev/hub.h>
    4446
    4547#include "port.h"
     
    5456};
    5557
    56 static void usb_hub_port_removed_device(usb_hub_port_t *port);
     58static void usb_hub_port_removed_device(usb_hub_port_t *port,
     59    usb_hub_info_t *hub);
    5760static void usb_hub_port_reset_completed(usb_hub_port_t *port,
    5861    usb_port_status_t status);
     
    148151                usb_log_debug("Connection change on port %zu: device %s.\n",
    149152                    port->port_number, connected ? "attached" : "removed");
     153
    150154                /* ACK the change */
    151155                const int opResult = usb_hub_port_clear_feature(port,
     
    165169                        }
    166170                } else {
    167                         usb_hub_port_removed_device(port);
     171                        /* If enabled change was reported leave the removal
     172                         * to that handler, it shall ACK the change too. */
     173                        if (!(status & USB_HUB_PORT_C_STATUS_ENABLED)) {
     174                                usb_hub_port_removed_device(port, hub);
     175                        }
    168176                }
    169177        }
     
    171179        /* Enable change, ports are automatically disabled on errors. */
    172180        if (status & USB_HUB_PORT_C_STATUS_ENABLED) {
    173                 usb_hub_port_removed_device(port);
     181                usb_log_info("Port %zu, disabled because of errors.\n",
     182                   port->port_number);
     183                usb_hub_port_removed_device(port, hub);
    174184                const int rc = usb_hub_port_clear_feature(port,
    175185                        USB_HUB_FEATURE_C_PORT_ENABLE);
     
    239249 * @param port port number, starting from 1
    240250 */
    241 static void usb_hub_port_removed_device(usb_hub_port_t *port)
    242 {
    243         assert(port);
    244         // TODO remove device from device manager
    245 
    246 
     251static void usb_hub_port_removed_device(usb_hub_port_t *port,
     252    usb_hub_info_t *hub)
     253{
     254        assert(port);
     255        assert(hub);
    247256        if (port->attached_device.address >= 0) {
    248 #if 0
    249                 usb_log_warning("Device unplug on `%s' (port %zu): " \
    250                     "not implemented.\n", hub->usb_device->ddf_dev->name,
    251                     (size_t) port);
    252 #endif
    253257                fibril_mutex_lock(&port->mutex);
    254258                port->attached_device.address = -1;
    255259                port->attached_device.handle = 0;
    256260                fibril_mutex_unlock(&port->mutex);
     261                usb_log_info("Removed device on port %zu.\n",
     262                    port->port_number);
    257263        } else {
    258                 usb_log_warning("Device removed before being registered.\n");
     264                usb_log_warning(
     265                    "Device on port %zu removed before being registered.\n",
     266                    port->port_number);
    259267
    260268                /*
     
    270278 * Process port reset change
    271279 *
    272  * After this change port should be enabled, unless some problem occured.
     280 * After this change port should be enabled, unless some problem occurred.
    273281 * This functions triggers second phase of enabling new device.
    274282 * @param hub
Note: See TracChangeset for help on using the changeset viewer.