Ignore:
Timestamp:
2010-10-25T13:23:33Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
23cb44b
Parents:
355f7c2
Message:

Code cleanup, various bugfixes

The internal functions of virtual device framework always get
device structure as parameter, thus possible enabling more devices
within single task (that is not possible because currently there
is no way to pass extra argument into callback_connection()).

Also, added some missing comments and completely removed the device
id nonsense (devices can send their descriptors and the hub is able
to enable/disable its ports).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/bus/usb/hcd/virtual/conndev.c

    r355f7c2 rca07cd3  
    4242#include "hub.h"
    4343
     44#define DEVICE_NAME_MAXLENGTH 32
     45
     46static int get_device_name(int phone, char *buffer, size_t len)
     47{
     48        ipc_call_t answer_data;
     49        ipcarg_t answer_rc;
     50        aid_t req;
     51        int rc;
     52       
     53        req = async_send_0(phone,
     54            IPC_M_USBVIRT_GET_NAME,
     55            &answer_data);
     56       
     57        rc = async_data_read_start(phone, buffer, len);
     58        if (rc != EOK) {
     59                async_wait_for(req, NULL);
     60                return EINVAL;
     61        }
     62       
     63        async_wait_for(req, &answer_rc);
     64        rc = (int)answer_rc;
     65       
     66        if (IPC_GET_ARG1(answer_data) < len) {
     67                len = IPC_GET_ARG1(answer_data);
     68        } else {
     69                len--;
     70        }
     71        buffer[len] = 0;
     72       
     73        return rc;
     74}
     75
    4476/** Connection handler for communcation with virtual device.
    4577 *
     
    5385        assert(dev != NULL);
    5486       
    55         dprintf(0, "virtual device connected through phone %#x", phone_hash);
     87        char devname[DEVICE_NAME_MAXLENGTH + 1];
     88        int rc = get_device_name(dev->phone, devname, DEVICE_NAME_MAXLENGTH);
     89       
     90        dprintf(0, "virtual device connected (phone: %#x, name: %s)",
     91            phone_hash, rc == EOK ? devname : "<unknown>");
     92       
    5693       
    5794        while (true) {
Note: See TracChangeset for help on using the changeset viewer.